/* Gestão - clean, calm, mobile first. Brand colours arrive from /api/config as --brand-* (see app.js). */
@font-face { font-family: "Bodoni Moda"; src: url("/fonts/BodoniModa.ttf") format("truetype"); font-display: swap; }

:root {
  --brand-ink: #7A4E58; --brand-blush: #EFCED2; --brand-gold: #D9BFA3; --brand-teal: #51ABAD; --brand-coral: #DD7676;
  --bg: #FAF7F6; --surface: #FFFFFF; --surface-2: #F4EEEC; --text: #2B2124; --muted: #7D6E72; --line: #EAE1DF;
  --ok: #2E8B6E; --ok-bg: #E4F3EE; --warn: #B7791F; --warn-bg: #FBF1DE; --bad: #C2475A; --bad-bg: #FBE6E9;
  --accent: var(--brand-ink); --accent-soft: var(--brand-blush); --on-accent: #FFFFFF;
  --radius: 16px; --radius-sm: 10px; --shadow: 0 1px 2px rgba(60, 30, 40, .06), 0 6px 20px rgba(60, 30, 40, .06);
  --font: "Avenir Next", "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;
  --font-title: Didot, "Bodoni Moda", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171214; --surface: #211A1D; --surface-2: #2A2125; --text: #F3ECEE; --muted: #B3A3A8; --line: #3A2F33;
    --ok-bg: #173229; --warn-bg: #33291A; --bad-bg: #3A1D23; --accent: #E7B8C0; --accent-soft: #3A262C; --on-accent: #2A161C;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* boot + login */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(180deg, var(--surface) 0%, var(--accent-soft) 100%); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 24px; box-shadow: var(--shadow); padding: 32px 26px; }
.login-card img { display: block; height: 56px; margin: 0 auto 6px; }
.login-card h1 { font: 500 26px/1.2 var(--font-title); text-align: center; margin: 4px 0 24px; color: var(--accent); }

/* layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 22px 14px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.side .logo { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 0 12px 20px; }
.side .logo img { height: 30px; }
.side .logo small { color: var(--muted); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }
.side .logo span { font: 500 18px var(--font-title); color: var(--accent); }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 0; background: none; cursor: pointer; text-align: left; color: var(--muted); font-weight: 500; }
.nav-item svg { width: 20px; height: 20px; flex: none; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.on { background: var(--accent-soft); color: var(--accent); }
.nav-item .badge { margin-left: auto; }
.side .spacer { flex: 1; }
.main { min-width: 0; padding: 26px 32px 60px; max-width: 1180px; width: 100%; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.top h1 { font: 500 28px/1.15 var(--font-title); margin: 0; }
.top .sub { color: var(--muted); margin-top: 4px; }
.bottom-nav { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 18px 16px calc(92px + env(safe-area-inset-bottom)); }
  .top h1 { font-size: 24px; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav .nav-item { flex: 1; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 11px; border-radius: 10px; justify-content: center; align-items: center; text-align: center; position: relative; }
  .bottom-nav .nav-item .badge { position: absolute; top: 2px; right: 50%; margin-right: -22px; }
}

/* building blocks */
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpis.quad { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h2 small { color: var(--muted); font-weight: 500; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .hint { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kpi.alert .value { color: var(--bad); }
.hero { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center; }
.ring { --p: 0; --c: var(--accent); width: 132px; height: 132px; border-radius: 50%; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-2) 0); display: grid; place-items: center; }
.ring > div { width: 104px; height: 104px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; }
.ring b { font-size: 26px; letter-spacing: -.02em; display: block; }
.ring span { font-size: 11.5px; color: var(--muted); }
.bar { height: 10px; border-radius: 99px; background: var(--surface-2); position: relative; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--accent); }
.bar .mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: .45; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* lists */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 10px; }
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--surface-2); }
.thumb { width: 46px; height: 46px; border-radius: 10px; background: var(--surface-2) center/cover no-repeat; flex: none; display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .t span { color: var(--muted); font-size: 12.5px; }
.check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; }
.check.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.check.diff { background: var(--warn); border-color: var(--warn); color: #fff; }
.group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 4px 4px; font-weight: 600; }
.empty { text-align: center; padding: 34px 10px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 6px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12.5px; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.neg { color: var(--bad); font-weight: 600; }
.pos { color: var(--warn); font-weight: 600; }

/* forms */
label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea { min-height: 70px; resize: vertical; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 12px; border: 0; background: var(--accent); color: var(--on-accent); font-weight: 600; cursor: pointer; transition: transform .05s, opacity .15s; text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.ok { background: var(--ok); }
.btn.bad { background: var(--bad); }
.btn.small { padding: 8px 12px; font-size: 13.5px; border-radius: 10px; }
.btn svg { width: 18px; height: 18px; }
.search { position: relative; flex: 1; }
.search input { padding-left: 40px; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.error { color: var(--bad); font-size: 13.5px; min-height: 20px; margin: 4px 0 10px; }
.seg { display: inline-flex; background: var(--surface-2); padding: 4px; border-radius: 12px; gap: 2px; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13.5px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* sheet (product / dialogs) */
.sheet-bg { position: fixed; inset: 0; background: rgba(30, 15, 20, .38); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 24px 24px 0 0; padding: 20px 20px calc(22px + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
@media (min-width: 861px) { .sheet-bg { align-items: center; } .sheet { border-radius: 24px; } }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: -6px auto 14px; }
.sheet h3 { margin: 0 0 4px; font-size: 19px; }
.product-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.product-head .thumb { width: 84px; height: 84px; border-radius: 14px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.fact { background: var(--surface-2); border-radius: 12px; padding: 10px; }
.fact span { display: block; font-size: 11.5px; color: var(--muted); }
.fact b { font-size: 16px; word-break: break-all; }
.stepper { display: grid; grid-template-columns: 64px 1fr 64px; gap: 10px; margin-bottom: 14px; }
.stepper button { border: 0; border-radius: 14px; background: var(--surface-2); font-size: 28px; font-weight: 500; cursor: pointer; }
.stepper input { text-align: center; font-size: 30px; font-weight: 650; padding: 12px; }
.result { border-radius: 14px; padding: 14px; margin-bottom: 14px; font-weight: 600; }
.result.ok { background: var(--ok-bg); color: var(--ok); }
.result.warn { background: var(--warn-bg); color: var(--warn); }

/* scanner */
.scanner { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; flex-direction: column; }
.scanner video { flex: 1; width: 100%; object-fit: cover; }
.scanner .frame { position: absolute; left: 10%; right: 10%; top: 35%; height: 22%; border: 3px solid rgba(255, 255, 255, .9); border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
.scanner .bar-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: flex; gap: 10px; }
.scanner .msg { position: absolute; top: calc(18px + env(safe-area-inset-top)); left: 16px; right: 16px; color: #fff; text-align: center; font-weight: 600; text-shadow: 0 1px 4px rgba(0, 0, 0, .6); }

#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .2s; z-index: 80; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 861px) { #toast { bottom: 28px; } }

/* spacing helpers (the CSP forbids inline style attributes) */
.mt { margin-top: 14px; }
.mt-s { margin-top: 8px; }
.mt-l { margin-top: 18px; }
.my { margin: 10px 0; }
.center { justify-content: center; }
.tiny { font-size: 12px; }
.small-text { font-size: 13px; }
.side .who { padding: 8px 12px; font-size: 13px; }
.boot.short { min-height: 40vh; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input { -moz-appearance: textfield; appearance: textfield; }

/* statistics - chart colours validated (dataviz validator): magenta series #d55181 (light+dark), blue sequential */
:root { --series-1: #d55181; --seq: #2a78d6; --chart-axis: var(--muted); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --seq: #3987e5; } }
.filters { gap: 8px; }
.filters input[type=date] { width: auto; padding: 8px 10px; }
.three { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.insights { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.insight { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; }
.ins-icon { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--surface-2); color: var(--muted); }
.insight.good .ins-icon { background: var(--ok-bg); color: var(--ok); }
.insight.warn .ins-icon { background: var(--warn-bg); color: var(--warn); }
.delta { font-weight: 700; font-size: 12px; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .mark { fill: var(--series-1); }
svg.chart .dead { fill: var(--line); }
svg.chart .hit { fill: transparent; }
svg.chart .col.hover .hit { fill: var(--surface-2); }
svg.chart .base { stroke: var(--line); stroke-width: 1; }
svg.chart .axis { fill: var(--chart-axis); font-size: 9px; text-anchor: middle; }
.inline-bar { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.inline-bar .bar { flex: 1; height: 8px; }
.inline-bar .bar i { background: var(--series-1); }
.inline-bar span { font-variant-numeric: tabular-nums; font-size: 13px; min-width: 42px; text-align: right; }
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hb { display: grid; grid-template-columns: minmax(80px, 140px) 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.hb-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-t { height: 12px; background: var(--surface-2); border-radius: 99px; position: relative; overflow: hidden; }
.hb-t i { position: absolute; inset: 0 auto 0 0; background: var(--series-1); border-radius: 0 4px 4px 0; }
.hb-v { font-variant-numeric: tabular-nums; color: var(--muted); }
.hb.hover .hb-l { font-weight: 600; }
table.heat { border-collapse: separate; border-spacing: 2px; }
table.heat th { font-size: 11px; padding: 2px 4px; text-align: center; border: 0; }
table.heat td { text-align: center; font-size: 11px; padding: 6px 2px; min-width: 28px; border-radius: 6px; border: 0; color: var(--text); font-variant-numeric: tabular-nums; }
table.heat td.hot { color: #fff; }
table.heat td.hover { outline: 2px solid var(--text); }
#tip { position: fixed; z-index: 90; pointer-events: none; background: var(--text); color: var(--bg); padding: 6px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 600; opacity: 0; transition: opacity .1s; white-space: nowrap; }
#tip.show { opacity: 1; }

.kpis.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .kpis.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 12px; }
