@font-face { font-family: "Atkinson"; src: url("vendor/fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("vendor/fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Bricolage"; src: url("vendor/fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  color-scheme: light;
  --paper: #f3f6f5;
  --surface: #ffffff;
  --sunken: #e9eeec;
  --ink: #14211c;
  --ink-2: #4b5c55;
  --ink-3: #6f7f78;
  --line: #d9e1de;
  --brand: #0f5c46;
  --brand-ink: #ffffff;
  --brand-soft: #dcefe7;
  --focus: #1f7aff;
  --urgente: #d03b3b;
  --aviso: #b97d00;
  --info: #4b5c55;
  --ok: #0a7f2e;
  --chart-surface: #ffffff;
  --radius-l: 20px;
  --radius-m: 12px;
  --radius-s: 8px;
  --head: "Bricolage", "Atkinson", system-ui, sans-serif;
  --body: "Atkinson", system-ui, -apple-system, "Segoe UI", sans-serif;
  --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #101614;
    --surface: #18201d;
    --sunken: #0c1110;
    --ink: #e7eeeb;
    --ink-2: #a9b8b1;
    --ink-3: #82938b;
    --line: #2b3632;
    --brand: #4fb892;
    --brand-ink: #06231a;
    --brand-soft: #173a2f;
    --urgente: #ec6b6b;
    --aviso: #f0b429;
    --info: #a9b8b1;
    --ok: #4cc777;
    --chart-surface: #18201d;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #101614; --surface: #18201d; --sunken: #0c1110; --ink: #e7eeeb; --ink-2: #a9b8b1; --ink-3: #82938b;
  --line: #2b3632; --brand: #4fb892; --brand-ink: #06231a; --brand-soft: #173a2f; --urgente: #ec6b6b;
  --aviso: #f0b429; --info: #a9b8b1; --ok: #4cc777; --chart-surface: #18201d;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 17px/1.5 var(--body); min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: var(--head); font-weight: 700; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 30px; font-variation-settings: "wght" 720; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
p { margin: 0 0 .6em; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.tiny { font-size: 13px; color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- estrutura ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in oklab, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-right: auto; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand b { font-family: var(--head); font-size: 18px; letter-spacing: -0.01em; }
.brand span { display: block; font-size: 12px; color: var(--ink-3); line-height: 1; }
.main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 40px; }
.main.narrow { max-width: 680px; }

.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: space-around;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; font-size: 12px; color: var(--ink-3); position: relative;
}
.nav a svg { width: 24px; height: 24px; }
.nav a[aria-current="page"] { color: var(--brand); font-weight: 700; }
.nav a[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand);
}
@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 92px; }
  .nav { top: 0; right: auto; width: 92px; height: 100dvh; flex-direction: column; justify-content: flex-start;
         padding-top: 84px; border-top: 0; border-right: 1px solid var(--line); gap: 6px; }
  .nav a { flex: none; height: 68px; }
  .nav a[aria-current="page"]::before { top: 14px; bottom: 14px; left: 0; right: auto; width: 3px; height: auto; border-radius: 0 3px 3px 0; }
  .topbar { padding-left: 24px; padding-right: 24px; }
  .main { padding: 28px 28px 60px; }
}

/* ---------- botões e campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px;
  border-radius: var(--radius-m); border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font-weight: 700; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 15px; border-radius: var(--radius-s); }
.btn.danger { color: var(--urgente); }
.btn[disabled] { opacity: .55; cursor: progress; }
.btn svg { width: 20px; height: 20px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--sunken); }
.icon-btn svg { width: 22px; height: 22px; }

.field { margin: 0 0 22px; }
.field > label, .field > .label { display: block; font-weight: 700; margin-bottom: 8px; }
.field .req { color: var(--urgente); margin-left: 2px; }
.field .help { font-size: 14px; color: var(--ink-2); margin: -4px 0 8px; }
.field .err { color: var(--urgente); font-size: 14px; margin-top: 6px; font-weight: 700; }
.input, select.input, textarea.input {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: var(--radius-m);
  border: 1.5px solid var(--line); background: var(--surface); font-size: 17px;
}
textarea.input { min-height: 110px; resize: vertical; }
.input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 25%, transparent); }
.field.has-err .input { border-color: var(--urgente); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }

/* opções grandes (rádio/checkbox) */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice span {
  display: inline-flex; align-items: center; min-height: 46px; padding: 0 16px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; user-select: none;
}
.choice input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.choice input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.stepper { display: inline-flex; align-items: stretch; border: 1.5px solid var(--line); border-radius: var(--radius-m); overflow: hidden; background: var(--surface); }
.stepper button { width: 52px; border: 0; background: var(--sunken); font-size: 24px; cursor: pointer; }
.stepper input { width: 80px; border: 0; text-align: center; font-size: 20px; font-weight: 700; background: transparent; }
.money { position: relative; max-width: 220px; }
.money .input { padding-right: 36px; }
.money::after { content: "€"; position: absolute; right: 14px; top: 13px; color: var(--ink-3); font-weight: 700; }

.ac { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 15; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: 0 10px 30px rgba(10, 30, 20, .14); overflow: hidden; }
.ac-list button { display: flex; width: 100%; justify-content: space-between; gap: 10px; padding: 12px 14px; border: 0; background: none; text-align: left; cursor: pointer; }
.ac-list button:hover, .ac-list button.on { background: var(--sunken); }

.photos { display: flex; gap: 10px; flex-wrap: wrap; }
.photos img, .photo-add { width: 92px; height: 92px; border-radius: var(--radius-m); object-fit: cover; }
.photo-add { display: grid; place-items: center; border: 1.5px dashed var(--ink-3); color: var(--ink-2); cursor: pointer; background: var(--surface); }

/* ---------- início (registar) ---------- */
.hello { margin: 6px 0 22px; }
.hello h1 { font-size: clamp(30px, 7vw, 44px); font-variation-settings: "wght" 760; max-width: 16ch; }
.loja-pick { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--ink-2); white-space: nowrap; }
.loja-pick select { min-width: 0; max-width: 100%; border: 0; background: var(--brand-soft); color: var(--ink); font-weight: 700; padding: 9px 14px; border-radius: 999px; }
.launch { display: grid; gap: 10px; }
@media (min-width: 700px) { .launch { grid-template-columns: 1fr 1fr; } }
.launch a {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 16px; text-decoration: none;
  padding: 14px 14px 14px 18px; border-radius: var(--radius-l); min-height: 84px;
  background: color-mix(in oklab, var(--c) 13%, var(--surface)); border-left: 8px solid var(--c);
  transition: transform .12s ease;
}
.launch a:active { transform: scale(.985); }
.launch .t { font-family: var(--head); font-size: 21px; font-weight: 700; line-height: 1.1; }
.launch .d { grid-column: 1; font-size: 14px; line-height: 1.35; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.launch .plus { grid-row: 1 / span 3; grid-column: 2; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  background: var(--c); color: #111; }
.launch .plus svg { width: 26px; height: 26px; }
.launch .today { font-size: 13px; font-weight: 700; color: var(--ink-2); }

.queue-banner { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-m);
  background: color-mix(in oklab, var(--aviso) 18%, var(--surface)); margin-bottom: 16px; font-weight: 700; }

/* ---------- listas de registos ---------- */
.section { margin-top: 30px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin-right: auto; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); overflow: hidden; }
.item { display: grid; grid-template-columns: 12px 1fr auto; gap: 4px 12px; align-items: center; padding: 14px 16px;
  text-decoration: none; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item:hover { background: color-mix(in oklab, var(--sunken) 60%, var(--surface)); }
.item .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); grid-row: 1 / span 2; align-self: start; margin-top: 6px; }
.item .s { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .m { grid-column: 2; font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .r { grid-column: 3; grid-row: 1 / span 2; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: var(--sunken); color: var(--ink-2); white-space: nowrap; }
.pill.open { background: color-mix(in oklab, var(--aviso) 22%, var(--surface)); color: var(--ink); }
.pill.done { background: color-mix(in oklab, var(--ok) 16%, var(--surface)); color: var(--ink); }
.empty { padding: 28px 18px; text-align: center; color: var(--ink-2); }

/* ---------- formulário ---------- */
.form-head { margin: -18px -16px 22px; padding: 22px 16px 20px; background: color-mix(in oklab, var(--c) 14%, var(--paper));
  border-bottom: 4px solid var(--c); }
@media (min-width: 900px) { .form-head { margin: -28px -28px 26px; padding: 28px; border-radius: 0 0 var(--radius-l) var(--radius-l); } }
.form-head h1 { font-size: 30px; }
.form-head p { color: var(--ink-2); margin: 6px 0 0; }
.sticky-actions { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px); display: flex; gap: 10px; margin-top: 10px; z-index: 5; }
.sticky-actions .btn { flex: 1; min-height: 56px; font-size: 18px; box-shadow: 0 8px 24px rgba(10, 30, 20, .18); }
@media (min-width: 900px) { .sticky-actions { bottom: 16px; } }
.form-errbox { padding: 12px 14px; border-radius: var(--radius-m); background: color-mix(in oklab, var(--urgente) 12%, var(--surface)); color: var(--ink); font-weight: 700; margin-bottom: 16px; }

/* ---------- backoffice ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.seg { display: inline-flex; background: var(--sunken); border-radius: 999px; padding: 3px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { white-space: nowrap; flex: none; border: 0; background: none; padding: 7px 14px; border-radius: 999px; font-weight: 700; cursor: pointer; color: var(--ink-2); font-size: 15px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.filters select.input, .filters input.input { min-height: 40px; padding: 6px 12px; width: auto; font-size: 15px; border-radius: 999px; }

.summary-ai { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 20px 20px 14px; position: relative; }
.summary-ai .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.summary-ai .md h2 { font-size: 17px; margin: 16px 0 6px; }
.summary-ai .md h2:first-child { margin-top: 0; }
.summary-ai .md { max-width: 75ch; }
.summary-ai.collapsed .md { max-height: 220px; overflow: hidden; mask-image: linear-gradient(#000 70%, transparent); }
@media (min-width: 1000px) { .summary-ai.collapsed .md { max-height: 470px; } }
.md ul { margin: 0 0 .6em; padding-left: 1.2em; }
.md li { margin: 3px 0; }

.alerts { display: grid; gap: 8px; }
.alert { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 12px 14px; border-radius: var(--radius-m);
  background: var(--surface); border: 1px solid var(--line); text-decoration: none; }
.alert .lv { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.alert .lv svg { width: 14px; height: 14px; }
.alert.urgente { border-left: 5px solid var(--urgente); }
.alert.urgente .lv { background: color-mix(in oklab, var(--urgente) 16%, var(--surface)); color: var(--urgente); }
.alert.aviso { border-left: 5px solid var(--aviso); }
.alert.aviso .lv { background: color-mix(in oklab, var(--aviso) 20%, var(--surface)); color: var(--ink); }
.alert.info { border-left: 5px solid var(--line); }
.alert.info .lv { background: var(--sunken); color: var(--ink-2); }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-l); overflow: hidden; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface); padding: 16px 16px 14px; text-decoration: none; display: block; }
.kpi .k { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); font-weight: 700; }
.kpi .k i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.kpi .v { font-family: var(--head); font-size: 34px; font-weight: 700; line-height: 1.1; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.kpi .delta { font-size: 13px; color: var(--ink-3); }

.grid-2 { display: grid; gap: 22px; }
@media (min-width: 1000px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 18px; min-width: 0; }
.panel h3 { margin-bottom: 4px; }
.panel .sub { font-size: 14px; color: var(--ink-2); margin-bottom: 14px; }
.chart-box { position: relative; height: 240px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: var(--ink-2); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; background: var(--c); }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; font-size: 15px; }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .val { font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-row .track { grid-column: 1 / -1; display: flex; gap: 2px; height: 12px; }
.bar-row .seg-bar { height: 100%; background: var(--c); border-radius: 2px; min-width: 3px; }
.bar-row .seg-bar:first-child { border-radius: 4px 2px 2px 4px; }
.bar-row .seg-bar:last-child { border-radius: 2px 4px 4px 2px; }
.bar-row .seg-bar:only-child { border-radius: 4px; }
details.table-view { margin-top: 10px; font-size: 14px; }
details.table-view summary { cursor: pointer; color: var(--ink-2); font-weight: 700; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.data th:first-child, table.data td:first-child { text-align: left; }
.scroll-x { overflow-x: auto; }

/* ---------- detalhe ---------- */
.detail-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.detail-head .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); margin-top: 9px; flex: none; }
dl.fields { margin: 0; display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); overflow: hidden; }
dl.fields dt, dl.fields dd { padding: 11px 14px; border-top: 1px solid var(--line); margin: 0; }
dl.fields dt { color: var(--ink-2); font-size: 15px; }
dl.fields dd { font-weight: 700; white-space: pre-wrap; overflow-wrap: anywhere; }
dl.fields dt:first-of-type, dl.fields dd:first-of-type { border-top: 0; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.timeline li { display: grid; grid-template-columns: 10px 1fr; gap: 12px; }
.timeline li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); margin-top: 7px; }
.workflow { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- assistente ---------- */
.chat { display: grid; gap: 14px; margin-bottom: 16px; }
.msg { max-width: 760px; }
.msg.user { justify-self: end; background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: 18px 18px 4px 18px; max-width: 85%; }
.msg.bot { background: var(--surface); border: 1px solid var(--line); padding: 16px 18px; border-radius: 18px 18px 18px 4px; }
.msg.bot .foot { font-size: 13px; color: var(--ink-3); margin-top: 8px; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.suggest button { border: 1px solid var(--line); background: var(--surface); padding: 10px 14px; border-radius: 999px; cursor: pointer; text-align: left; font-size: 15px; }
.composer { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); display: flex; gap: 8px; background: var(--paper); padding: 10px 0 12px; }
@media (min-width: 900px) { .composer { bottom: 0; padding-bottom: 18px; } }
.composer textarea { min-height: 52px; max-height: 160px; }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- definições ---------- */
.settings { display: grid; gap: 22px; }
.settings .panel h2 { font-size: 20px; margin-bottom: 4px; }
.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.toggle input { width: 22px; height: 22px; accent-color: var(--brand); }
.item.simple { grid-template-columns: minmax(0, 1fr) auto; }
.item.simple .s { grid-column: 1; }
.item.simple .m { grid-column: 1; }
.item.simple .r { grid-column: 2; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; margin-bottom: calc(-1 * var(--nav-h)); }
.login form { width: 100%; max-width: 400px; }
.login .mark { width: 64px; height: 64px; margin-bottom: 18px; }
.login h1 { font-size: 36px; margin-bottom: 6px; }
.login p.lead { color: var(--ink-2); margin-bottom: 26px; }

/* ---------- toast e folha ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 22px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 999px; font-weight: 700; z-index: 60;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: calc(100% - 32px); }
.toast.err { background: var(--urgente); color: #fff; }
.sheet-bg { position: fixed; inset: 0; background: rgba(5, 15, 10, .45); z-index: 50; display: grid; align-items: end; }
@media (min-width: 700px) { .sheet-bg { place-items: center; } }
.sheet { background: var(--paper); width: 100%; max-height: 92dvh; overflow: auto; border-radius: 22px 22px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .sheet { max-width: 560px; border-radius: 22px; } }
.sheet h2 { margin-bottom: 14px; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--sunken); padding: 10px 12px; border-radius: var(--radius-s); word-break: break-all; font-size: 15px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; padding: 60px 0; }

/* cor de cada formulário: clara/escura escolhidas e validadas para gráficos */
.fc { --c: var(--cl); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fc { --c: var(--cd); } }
:root[data-theme="dark"] .fc { --c: var(--cd); }

/* áreas (agrupam formulários no início e no painel) */
.area { margin-top: 26px; }
.area:first-of-type { margin-top: 6px; }
.area-title { display: flex; align-items: center; gap: 10px; font-size: 15px; font-family: var(--body); font-weight: 700;
  color: var(--ink-2); margin: 0 0 10px; }
.area-title i { width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
.kpi-groups { display: grid; gap: 18px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); } }
.kpi .v { font-size: 30px; }

/* produtos e linhas de produtos */
.product { display: grid; gap: 8px; }
.product .cnp { max-width: 180px; }
.stockinfo { font-size: 14px; color: var(--ink-2); margin: 0; }
.items { display: grid; gap: 12px; }
.item-line { display: grid; gap: 8px; padding: 12px; border: 1.5px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
.item-line .qty { width: 64px; min-height: 44px; text-align: center; font-weight: 700; }
.item-row { flex-wrap: nowrap; gap: 8px; }
.item-row .cnp { flex: 1 1 auto; min-width: 0; max-width: 150px; min-height: 44px; }
.item-row .btn { margin-left: auto; padding-inline: 10px; }
.ac-list button .tiny { white-space: nowrap; }

/* seguimentos */
.origin-note { background: var(--brand-soft); padding: 10px 14px; border-radius: var(--radius-m); font-weight: 700; }
.followups { display: grid; gap: 10px; justify-items: center; }
.section.followups { justify-items: stretch; }
.followups .btn { width: 100%; max-width: 420px; }
.done-mark { width: 72px; height: 72px; border-radius: 50%; background: var(--c); display: grid; place-items: center; margin: 0 auto 18px; color: #111; }
.done-mark svg { width: 34px; height: 34px; }
.item .rel { color: var(--ink-2); font-weight: 400; }
table.audit td { text-align: left; vertical-align: top; }
table.audit td:first-child { white-space: nowrap; }

/* painel: detalhe dobrável por formulário */
details.fold > summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer;
  font-family: var(--head); font-size: 20px; font-weight: 700; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary i { width: 12px; height: 12px; border-radius: 3px; background: var(--c); flex: none; }
details.fold > summary::after { content: ""; width: 9px; height: 9px; border-right: 2.5px solid var(--ink-3); border-bottom: 2.5px solid var(--ink-3);
  transform: rotate(45deg); margin: -4px 4px 0 6px; transition: transform .15s; flex: none; }
details.fold[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
details.fold[open] > summary { margin-bottom: 6px; }
details.fold > summary .tiny { font-family: var(--body); font-weight: 400; }
details.fold[open] > summary .tiny { display: none; }
.kpis > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
@media (min-width: 900px) { .kpis > .kpi:last-child:nth-child(odd) { grid-column: auto; } }
.section + .grid-2 { margin-top: 12px; }
