/* Lily HQ — private work console.
   Self-hosted only: system fonts, no external assets, no inline styles (CSP style-src 'self').
   Sections: 1 tokens · 2 base · 3 shell · 4 severity language · 5 components · 6 page-specific · 7 responsive · 8 accessibility */

/* ---------- 1. Design tokens ---------- */
:root {
  color-scheme: light dark;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* type scale */
  --fs-xs: .75rem;
  --fs-sm: .8125rem;
  --fs-md: .9375rem;
  --fs-lg: 1.0625rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.625rem;

  /* spacing (4px grid) */
  --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem; --s5: 1.25rem;
  --s6: 1.5rem; --s8: 2rem; --s10: 2.5rem;

  /* radius */
  --r1: .375rem; --r2: .625rem; --r3: .875rem; --pill: 999px;

  /* neutrals */
  --bg: #f2f5f3;
  --surface: #ffffff;
  --surface-2: #f7f9f8;
  --surface-3: #ebeff0;
  --line: #d9e0dd;
  --line-strong: #b6c2bc;
  --text: #15211d;
  --text-2: #3d4b45;
  --text-3: #54625c;

  /* brand */
  --accent: #166a4c;
  --accent-hover: #0f5a3f;
  --accent-soft: #e1f0e8;
  --on-accent: #ffffff;
  --focus: #0b63c5;

  /* sidebar (dark chrome in both themes) */
  --side-bg: #10241f;
  --side-text: #cbdad4;
  --side-strong: #ffffff;
  --side-muted: #93aba2;
  --side-line: #263f37;
  --side-hover: #19332c;
  --side-active: #214238;
  --side-focus: #8cc4ff;
  --mark-fg: #10241f;
  --brand: #45b98b;
  --alert: #c62828;
  --wait: #1868b0;

  /* elevation */
  --shadow-1: 0 1px 2px rgba(16, 36, 31, .06), 0 1px 1px rgba(16, 36, 31, .04);
  --shadow-2: 0 4px 14px rgba(16, 36, 31, .10), 0 1px 3px rgba(16, 36, 31, .08);

  /* severity language: fg on bg is >= 4.5:1; solid carries white text >= 4.5:1 */
  --erro-fg: #9b1c1c;       --erro-bg: #fdecec;       --erro-bd: #efb4b4;       --erro-solid: #c62828;
  --aviso-fg: #7a4700;      --aviso-bg: #fff2d2;      --aviso-bd: #e8c879;      --aviso-solid: #b76e00;
  --ok-fg: #11603a;         --ok-bg: #e2f4ea;         --ok-bd: #a3d6b9;         --ok-solid: #1a7f4b;
  --sem-dados-fg: #54625c;  --sem-dados-bg: #eef1f0;  --sem-dados-bd: #b7c2bd;  --sem-dados-solid: #6f7d77;
  --bloqueado-fg: #5a2a9c;  --bloqueado-bg: #efe8fb;  --bloqueado-bd: #cdbbee;  --bloqueado-solid: #6c3fbd;
  --pendente-fg: #0b5794;   --pendente-bg: #e3effb;   --pendente-bd: #a6c8ec;   --pendente-solid: #1868b0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1412;
    --surface: #151e1b;
    --surface-2: #1a2420;
    --surface-3: #202b27;
    --line: #2a3632;
    --line-strong: #41504a;
    --text: #e7eeea;
    --text-2: #bac8c2;
    --text-3: #98a8a1;

    --accent: #4cbb8c;
    --accent-hover: #6fd0a5;
    --accent-soft: #163328;
    --on-accent: #06251a;
    --focus: #7db8ff;

    --side-bg: #0a100e;
    --side-text: #b9c9c2;
    --side-hover: #141f1b;
    --side-active: #1c2e27;
    --side-line: #1f2d28;
    --mark-fg: #0a100e;

    --shadow-1: 0 0 0 1px rgba(255, 255, 255, .02);
    --shadow-2: 0 6px 20px rgba(0, 0, 0, .45);

    --erro-fg: #ffb4b4;      --erro-bg: #3a1618;      --erro-bd: #70292c;      --erro-solid: #e5484d;
    --aviso-fg: #f5cf7f;     --aviso-bg: #352810;     --aviso-bd: #6b5220;     --aviso-solid: #e0a030;
    --ok-fg: #8fdcb0;        --ok-bg: #11301f;        --ok-bd: #2a6546;        --ok-solid: #3fbf7a;
    --sem-dados-fg: #a9b7b1; --sem-dados-bg: #1d2723; --sem-dados-bd: #3b4843; --sem-dados-solid: #86958f;
    --bloqueado-fg: #cdb6f5; --bloqueado-bg: #2a1d45; --bloqueado-bd: #523a85; --bloqueado-solid: #9a73e0;
    --pendente-fg: #9ccbf5;  --pendente-bg: #11283f;  --pendente-bd: #2c5a88;  --pendente-solid: #4a9be0;
  }
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: var(--fs-md)/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.005em; }
h1 { font-size: var(--fs-2xl); font-weight: 700; }
h2 { font-size: var(--fs-lg); font-weight: 650; }
h3 { font-size: var(--fs-md); font-weight: 650; }
h4 { font-size: var(--fs-sm); font-weight: 650; }
p { margin: 0 0 var(--s3); }
p:last-child { margin-bottom: 0; }
a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--text-3); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.label { color: var(--text-3); font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: var(--s3); top: -4rem; z-index: 100; background: var(--surface); color: var(--text);
  padding: var(--s2) var(--s4); border-radius: var(--r1); box-shadow: var(--shadow-2); }
.skip:focus { top: var(--s3); }

/* ---------- 3. Shell: sidebar on desktop, compact top bar on phones ---------- */
.shell { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--s2);
  padding: var(--s5) var(--s3) var(--s4);
  background: var(--side-bg); color: var(--side-text);
}
.brand { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s2) var(--s4); color: var(--side-strong); }
.brand .mark { width: 2rem; height: 2rem; flex: none; color: var(--brand); }
.mark text { fill: var(--mark-fg); font-family: var(--font); }
.brand-name { font-weight: 700; font-size: var(--fs-lg); letter-spacing: .01em; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  margin: var(--s4) 0 var(--s1); padding: 0 var(--s3);
  font-size: var(--fs-xs); font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--side-muted);
}
.nav-link {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  padding: .5rem var(--s3); border-radius: var(--r1);
  color: var(--side-text); text-decoration: none; font-weight: 500; line-height: 1.3;
  border-left: 3px solid transparent;
}
.nav-link:hover { background: var(--side-hover); color: var(--side-strong); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--side-active); color: var(--side-strong); border-left-color: var(--accent); font-weight: 650; }
.side :focus-visible { outline-color: var(--side-focus); }
/* the owner's queue: always the most prominent entry */
.nav-link[href^="/pendencias"] { margin-bottom: var(--s1); font-weight: 650; color: var(--side-strong); background: var(--side-hover); }
.nav-link[href^="/pendencias"][aria-current="page"] { background: var(--side-active); }
.nav-link .badge, .pending-pill .badge {
  min-width: 1.75rem; justify-content: center; font-size: var(--fs-sm); font-weight: 700; padding: .1rem .55rem;
  background: transparent; color: var(--side-text); border-color: var(--side-line);
}
/* open items: blue (waiting on you); when something is overdue or due soon: red with a ring */
[data-open]:not([data-open="0"]) .badge { background: var(--wait); border-color: var(--wait); color: #fff; }
[data-open][data-urgent]:not([data-urgent="0"]) .badge { background: var(--alert); border-color: var(--alert); box-shadow: 0 0 0 3px rgba(198, 40, 40, .3); }
.pending-pill { display: none; }
#logout-form { margin: auto 0 0; padding-top: var(--s4); border-top: 1px solid var(--side-line); }
.lang-switch { display: flex; align-items: center; gap: .3rem; font-size: var(--fs-sm); }
.side .lang-switch { margin-top: var(--s3); color: var(--side-text); }
.lang-switch button { min-width: 2.4rem; min-height: 2.4rem; padding: .25rem .35rem;
  border: 0; border-radius: var(--r-sm); background: transparent; color: inherit; cursor: pointer; }
.lang-switch button[aria-pressed="true"] { font-weight: 750; text-decoration: underline; text-underline-offset: .25rem; }
.side .lang-switch button:hover { background: var(--side-hover); }
.auth-card .lang-switch { justify-content: center; }
.auth-card .lang-switch button { width: auto; }
#logout-form button {
  width: 100%; background: transparent; color: var(--side-text);
  border: 1px solid var(--side-line); padding: .45rem var(--s3); font-weight: 500;
}
#logout-form button:hover { background: var(--side-hover); color: var(--side-strong); }

main { min-width: 0; padding: var(--s8) var(--s8) var(--s10); max-width: 82rem; width: 100%; }
main > * + * { margin-top: var(--s5); }
.page-head { display: flex; flex-direction: column; gap: var(--s2); padding-bottom: var(--s2); }
.page-title { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s3); }
.lead { color: var(--text-2); max-width: 62ch; font-size: var(--fs-md); margin: 0; }
.stats { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }
.stat {
  display: inline-flex; align-items: baseline; gap: .35rem; padding: .3rem .75rem;
  border-radius: var(--pill); border: 1px solid var(--line); background: var(--surface);
  font-size: var(--fs-sm); color: var(--text-2); box-shadow: var(--shadow-1);
}
.stat b { font-size: var(--fs-md); font-variant-numeric: tabular-nums; color: var(--text); }
.stat.zero, .stat.zero b { color: var(--text-3); font-weight: 500; }
.stat.zero { background: transparent; box-shadow: none; }

/* ---------- 4. Severity language (used identically on every page) ----------
   erro · aviso · ok · sem-dados · bloqueado · pendente.  Every state has a colour AND a shape AND a word. */
.erro, .aviso, .ok, .sem-dados, .bloqueado, .pendente {
  --c-fg: var(--text); --c-bg: var(--surface-2); --c-bd: var(--line); --c-solid: var(--text-3);
}
.erro      { --c-fg: var(--erro-fg);      --c-bg: var(--erro-bg);      --c-bd: var(--erro-bd);      --c-solid: var(--erro-solid); }
.aviso     { --c-fg: var(--aviso-fg);     --c-bg: var(--aviso-bg);     --c-bd: var(--aviso-bd);     --c-solid: var(--aviso-solid); }
.ok        { --c-fg: var(--ok-fg);        --c-bg: var(--ok-bg);        --c-bd: var(--ok-bd);        --c-solid: var(--ok-solid); }
.sem-dados { --c-fg: var(--sem-dados-fg); --c-bg: var(--sem-dados-bg); --c-bd: var(--sem-dados-bd); --c-solid: var(--sem-dados-solid); }
.bloqueado { --c-fg: var(--bloqueado-fg); --c-bg: var(--bloqueado-bg); --c-bd: var(--bloqueado-bd); --c-solid: var(--bloqueado-solid); }
.pendente  { --c-fg: var(--pendente-fg);  --c-bg: var(--pendente-bg);  --c-bd: var(--pendente-bd);  --c-solid: var(--pendente-solid); }

.badge {
  display: inline-flex; align-items: center; gap: .4rem; vertical-align: middle;
  padding: .12rem .55rem; border-radius: var(--pill);
  border: 1px solid var(--line-strong); background: var(--surface-3); color: var(--text-2);
  font-size: var(--fs-xs); font-weight: 650; line-height: 1.35; white-space: nowrap;
}
.badge.erro, .badge.aviso, .badge.ok, .badge.sem-dados, .badge.bloqueado, .badge.pendente {
  background: var(--c-bg); border-color: var(--c-bd); color: var(--c-fg);
}
.badge.sem-dados { border-style: dashed; }
/* shape marker: circle ok · triangle aviso · diamond erro · hollow sem dados · square bloqueado · half pendente */
.badge.erro::before, .badge.aviso::before, .badge.ok::before, .badge.sem-dados::before,
.badge.bloqueado::before, .badge.pendente::before, .tag::before {
  content: ""; width: .55rem; height: .55rem; flex: none; background: var(--c-solid);
}
.badge.ok::before { border-radius: 50%; }
.badge.aviso::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.badge.erro::before { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); width: .65rem; height: .65rem; }
.badge.sem-dados::before { border-radius: 50%; background: transparent; border: 2px solid var(--c-solid); }
.badge.bloqueado::before { border-radius: 2px; }
.badge.pendente::before { border-radius: 50%; background: linear-gradient(90deg, var(--c-solid) 50%, transparent 50%); border: 1.5px solid var(--c-solid); }
.badge.ro { background: transparent; border-color: var(--line); color: var(--text-3); font-weight: 550; }
.badge.kind { background: var(--surface-3); color: var(--text-2); }
.badge.info { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.badge.normal { background: var(--surface-3); }

/* severity-coloured count in summary tables: zero is muted */
.count {
  display: inline-block; min-width: 2rem; padding: .05rem .55rem; text-align: center;
  border-radius: var(--pill); font-variant-numeric: tabular-nums; font-weight: 700;
  background: var(--c-bg, transparent); color: var(--c-fg, var(--text)); border: 1px solid var(--c-bd, transparent);
}
.count.zero { color: var(--text-3); font-weight: 400; background: transparent; border-color: transparent; }

/* a small status dot for one-line health text (text always follows the dot) */
p.health { display: inline-flex; align-items: center; gap: .4rem; margin: 0 var(--s3) var(--s1) 0; color: var(--text-2); font-size: var(--fs-sm); }
p.health.up { color: var(--ok-fg); }
p.health.down { color: var(--erro-fg); font-weight: 600; }
p.health.unknown { color: var(--text-3); }

.notice {
  display: block; padding: var(--s3) var(--s4); border-radius: var(--r2);
  border: 1px solid var(--c-bd, var(--line)); border-left-width: 4px;
  background: var(--c-bg, var(--surface-2)); color: var(--c-fg, var(--text-2));
}
.notice strong { color: inherit; }
.notice p + p { margin-top: var(--s1); }
.empty { padding: var(--s8) var(--s4); text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--r3); background: var(--surface-2); }
.empty-title { font-weight: 650; color: var(--text-2); }
.empty-hint { color: var(--text-3); font-size: var(--fs-sm); }

/* ---------- 5. Components ---------- */
/* cards: <section> and <article> are cards */
section, article {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3);
  box-shadow: var(--shadow-1); padding: var(--s5);
}
section > h2, article > h2, section > header h2 { font-size: var(--fs-lg); }
section > h2 + *, article > h2 + * { margin-top: var(--s3); }
section article, article section { box-shadow: none; background: var(--surface-2); padding: var(--s4); border-radius: var(--r2); }
section > * + *, article > * + * { margin-top: var(--s3); }
h3 { margin-top: var(--s5); }
h3 + * { margin-top: var(--s2); }

/* buttons */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  font: inherit; font-weight: 600; font-size: var(--fs-sm); line-height: 1.2;
  padding: .55rem var(--s4); min-height: 2.25rem; border-radius: var(--r1);
  border: 1px solid transparent; background: var(--accent); color: var(--on-accent);
  cursor: pointer; text-decoration: none;
  transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease;
}
button:hover, .btn:hover { background: var(--accent-hover); color: var(--on-accent); text-decoration: none; }
.btn-quiet, button.quiet { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn-quiet:hover, button.quiet:hover { background: var(--surface-3); color: var(--text); }
.btn-small { padding: .3rem .65rem; min-height: 1.85rem; font-size: var(--fs-xs); }
button[disabled] { opacity: .55; cursor: not-allowed; }
input {
  font: inherit; padding: .55rem var(--s3); min-height: 2.5rem; border-radius: var(--r1);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
}
label { display: block; font-weight: 600; font-size: var(--fs-sm); }
label input { display: block; margin-top: var(--s1); width: 100%; }

/* chips: links to other pages */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 1.85rem;
  padding: .2rem .7rem; border-radius: var(--pill); border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text); font-size: var(--fs-sm); text-decoration: none; line-height: 1.3;
}
a.chip:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); text-decoration: none; }
.chip .k { color: var(--text-3); font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }

/* key/value lists */
dl { margin: 0; }
dl.kv { display: grid; grid-template-columns: minmax(7rem, 13rem) minmax(0, 1fr); gap: var(--s1) var(--s4); }
dl.kv dt { color: var(--text-3); font-size: var(--fs-sm); font-weight: 500; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
dl.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr)); gap: var(--s3) var(--s4); }
dl.facts > div { min-width: 0; }
dl.facts dt { color: var(--text-3); font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
dl.facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
/* legacy record lists */
section > dl:not([class]) { display: grid; grid-template-columns: minmax(7rem, 13rem) minmax(0, 1fr); gap: var(--s1) var(--s4);
  padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface-2); }
section > dl:not([class]) dt { color: var(--text-3); font-size: var(--fs-sm); font-weight: 500; }
section > dl:not([class]) dd { margin: 0; overflow-wrap: anywhere; }

/* tables: wide tables scroll inside their own container */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r3); background: var(--surface); box-shadow: var(--shadow-1); max-width: 100%; }
.table-wrap table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.table-wrap th, .table-wrap td { padding: .65rem var(--s4); text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.table-wrap thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-3);
  font-size: var(--fs-xs); font-weight: 650; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
}
.table-wrap tbody tr:last-child > * { border-bottom: 0; }
.table-wrap tbody tr:hover > td, .table-wrap tbody tr:hover > th { background-color: var(--surface-2); }
.table-wrap td.num, .table-wrap th.num { text-align: right; }
.table-wrap tbody th { font-weight: 600; color: var(--text); }
.card-tables .table-wrap { box-shadow: none; }
.table-wrap:focus-visible { outline-offset: 0; }
/* matrices: sticky first column and header */
.matrix { max-height: min(76vh, 46rem); }
.matrix thead th:first-child { left: 0; z-index: 4; }
.matrix tbody th { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 12rem; box-shadow: 1px 0 0 var(--line); }
.matrix td { min-width: 9.5rem; }
.matrix tbody tr:hover > th { background: var(--surface-2); }

/* details / summary */
details { border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface-2); }
summary {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2) var(--s3); padding: .7rem var(--s4);
  cursor: pointer; list-style: none; font-weight: 600; border-radius: var(--r2);
}
summary::-webkit-details-marker { display: none; }
summary::before {
  content: ""; width: .5rem; height: .5rem; flex: none; margin-right: var(--s1);
  border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(-45deg); transition: transform .12s ease;
}
details[open] > summary::before { transform: rotate(45deg); }
summary:hover { background: var(--surface-3); }
details[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom: 1px solid var(--line); }
details > :not(summary) { margin: var(--s4); }
details > summary + * { margin-top: var(--s4); }
summary h2, summary h3 { display: inline; font-size: var(--fs-lg); }
/* inside table first cells: a quiet link-like toggle */
th details { border: 0; background: transparent; margin-top: var(--s1); }
th summary { padding: .1rem 0; font-size: var(--fs-xs); font-weight: 600; color: var(--accent); background: none; }
th summary:hover { background: none; text-decoration: underline; }
th details[open] > summary { border: 0; }
th details > :not(summary) { margin: var(--s2) 0 0; }
th details dl.kv { grid-template-columns: 1fr; gap: 0; font-weight: 400; font-size: var(--fs-xs); }
th details dl.kv dt { margin-top: var(--s2); }
.table-wrap details { background: transparent; }

/* ---------- 6. Page-specific ---------- */
/* Aguardando Rafael: action cards */
.group-title { margin: var(--s6) 0 var(--s3); font-size: var(--fs-sm); font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); }
.group-title:first-child { margin-top: 0; }
article.action { border-left: 4px solid var(--line-strong); padding: var(--s5); scroll-margin-top: var(--s5); }
article.action.erro { border-left-color: var(--erro-solid); background: linear-gradient(90deg, var(--erro-bg), var(--surface) 28%); }
article.action.aviso { border-left-color: var(--aviso-solid); }
article.action:target { box-shadow: 0 0 0 2px var(--focus), var(--shadow-2); }
.action-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
.action-id { font-family: var(--mono); font-weight: 700; font-size: var(--fs-sm); padding: .1rem .45rem; border-radius: var(--r1); background: var(--surface-3); color: var(--text-2); }
article.action > h2 { font-size: var(--fs-xl); line-height: 1.3; margin-top: var(--s2); }
.meta { color: var(--text-3); font-size: var(--fs-sm); display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); }
.meta strong { color: var(--text-2); font-weight: 600; }
.blocks { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.reco { padding: var(--s3) var(--s4); border-radius: var(--r2); background: var(--surface-2); border: 1px solid var(--line); }
.answer { border-radius: var(--r2); background: var(--surface-3); border: 1px solid var(--line-strong); padding: var(--s3) var(--s4); }
.answer-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--s3); margin-top: var(--s2); }
.phrase {
  flex: 1 1 18rem; min-width: 0; margin: 0; padding: var(--s2) var(--s3); border-radius: var(--r1);
  background: var(--surface); border: 1px solid var(--line-strong);
  font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.5; user-select: all; overflow-wrap: anywhere; white-space: pre-wrap;
}

/* Clientes / Configuração: collapsible client cards */
section > details { border: 0; background: none; }
section.client { padding: 0; }
section.client > details > summary { padding: var(--s4) var(--s5); border-radius: var(--r3); }
section.client > details[open] > summary { border-bottom-color: var(--line); }
section.client > details > :not(summary) { margin: var(--s5); }
section.client > details > summary + * { margin-top: var(--s5); }
.card-meta { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); color: var(--text-2); font-size: var(--fs-sm); }
.card-meta p { margin: 0; }
.signals { display: flex; flex-wrap: wrap; }
.subhead { display: flex; align-items: baseline; gap: var(--s2); margin: var(--s5) 0 var(--s2); }
.subhead h3 { margin: 0; font-size: var(--fs-md); }
.subhead .muted { font-size: var(--fs-sm); }
tr.fleet-divergent > * { background: var(--erro-bg) !important; }
tr.fleet-divergent > :first-child { box-shadow: inset 4px 0 0 var(--erro-solid); }
.reason { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s2); align-items: baseline; }
td code, th code { overflow-wrap: anywhere; }

/* Componentes: status matrix */
.legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); align-items: center; font-size: var(--fs-sm); color: var(--text-3); }
.legend .badge { margin-right: var(--s1); }
td.st { color: var(--text); }
td.st.bloqueado { background: var(--c-bg); color: var(--c-fg); }
td.st.sem-dados { color: var(--text-3); }
td.st.ok .st-label { color: var(--ok-fg); }
td.st .badge { background: var(--surface); }
td.st.bloqueado a { color: inherit; font-weight: 700; }
td.st-none { color: var(--text-3); }
.st-label { display: block; font-weight: 600; line-height: 1.4; }
.st-label::before { content: ""; display: inline-block; width: .6rem; height: .6rem; margin-right: .45rem; background: var(--c-solid); }
td.ok .st-label::before, td.pendente .st-label::before, td.rel-ok .st-label::before { border-radius: 50%; }
td.aviso .st-label::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
td.erro .st-label::before { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); width: .7rem; height: .7rem; }
td.bloqueado .st-label::before { border-radius: 2px; }
td.sem-dados .st-label::before { border-radius: 50%; background: transparent; border: 2px solid var(--c-solid); }
td.pendente .st-label::before { background: linear-gradient(90deg, var(--c-solid) 50%, transparent 50%); border: 1.5px solid var(--c-solid); }
td.sem-dados .st-label { font-weight: 500; }
td.st .cell-extra { margin-top: var(--s2); font-size: var(--fs-xs); color: var(--text-2); }
td.st .cell-extra dl { margin: 0; }
td.st .cell-extra dt { display: inline; font-weight: 600; margin-right: var(--s1); }
td.st .cell-extra dd { display: inline; margin: 0; }
.kind { color: var(--text-3); font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; display: block; }

/* Plataforma: tools as rows */
.tool { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s3) var(--s5); align-items: start; }
.tool > * { margin-top: 0; }
.tool-main { min-width: 0; }
.tool-main > * + * { margin-top: var(--s3); }
.tool h3 { margin: 0; font-size: var(--fs-lg); }
.tool .purpose { color: var(--text-2); margin-top: var(--s1); }
.tool-badges { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.tool-badges p.health { margin: 0; padding: .12rem .6rem; border: 1px solid var(--line-strong); border-radius: var(--pill); background: var(--surface-3); font-size: var(--fs-xs); font-weight: 600; }
.tool-badges p.health.up { background: var(--ok-bg); border-color: var(--ok-bd); }
.tool-badges p.health.down { background: var(--erro-bg); border-color: var(--erro-bd); }
.tool-side { display: flex; align-items: flex-start; }
.gates { display: flex; flex-direction: column; gap: var(--s2); }
.gate { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); align-items: baseline; padding: var(--s2) var(--s3); border-radius: var(--r1);
  border: 1px solid var(--c-bd); background: var(--c-bg); color: var(--c-fg); font-size: var(--fs-sm); }
.gate a { color: inherit; font-weight: 600; }
.gate .label { color: inherit; }
.secrets { font-size: var(--fs-sm); color: var(--text-2); }
.secrets code { color: var(--text); }
.group-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2) var(--s4); margin-bottom: var(--s3); }
.group-head h2 { font-size: var(--fs-xl); }
section.group { background: transparent; border: 0; box-shadow: none; padding: 0; }
section.group > .tools { display: flex; flex-direction: column; gap: var(--s3); margin-top: 0; }
p.warnings { display: contents; }
section.group article { background: var(--surface); box-shadow: var(--shadow-1); padding: var(--s5); border-radius: var(--r3); }

/* Lançamentos: release train */
td.rel { white-space: nowrap; }
td.rel .badge { font-weight: 650; }
td.rel small { display: block; margin-top: 2px; color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; }
td.rel-atual { background: var(--accent-soft); box-shadow: inset 0 3px 0 var(--accent); }
td.rel-none { color: var(--text-3); text-align: center; }
.rel-cur { font-weight: 700; }
section.release { padding: 0; }
section.release > details { border: 0; background: none; }
section.release > details > summary { padding: var(--s4) var(--s5); border-radius: var(--r3); }
section.release > details > :not(summary) { margin: var(--s5); }
.change { display: block; }
.change h4 { font-family: var(--mono); }
.change p { font-size: var(--fs-sm); color: var(--text-2); margin-top: var(--s1); }

/* Alertas / Canais legacy record cards */
.alert-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s3); }
.alert-actions button { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.alert-actions button:hover { background: var(--surface-3); }
.push-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.push-actions button { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.push-actions button:hover { background: var(--surface-3); }
.source-meta { padding-bottom: var(--s3); border-bottom: 1px solid var(--line); gap: var(--s2) var(--s4); grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); }
.source-meta dt { font-size: .6875rem; }
.source-meta dd { font-size: var(--fs-xs); color: var(--text-3); }
dl.record { padding: var(--s3) var(--s4); border: 1px solid var(--line); border-left: 4px solid var(--c-solid, var(--line-strong)); border-radius: var(--r2); background: var(--surface-2); grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
.alert-card { border: 1px solid var(--line); border-left: 4px solid var(--c-solid, var(--line-strong)); border-radius: var(--r2); background: var(--surface-2); padding: var(--s3) var(--s4); }
.alert-card dl.record { border: 0; padding: 0; background: none; }
.alert-card + .alert-card { margin-top: var(--s3); }

/* Auth pages */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--s5); }
.auth-card { width: 100%; max-width: 26rem; padding: var(--s8); box-shadow: var(--shadow-2); }
.auth-card .brand { color: var(--text); padding: 0 0 var(--s4); }
.auth-card .brand .mark { color: var(--accent); }
.auth-card .mark text { fill: var(--on-accent); }
.auth-card h1 { font-size: var(--fs-xl); margin-top: var(--s2); }
.auth-card > * + * { margin-top: var(--s4); }
.auth-card button { width: 100%; padding: .7rem var(--s4); min-height: 2.75rem; }
#message { min-height: 1.5em; color: var(--erro-fg); font-size: var(--fs-sm); }

/* ---------- 7. Responsive ---------- */
@media (max-width: 62rem) {
  main { padding: var(--s6) var(--s5) var(--s8); }
}
@media (max-width: 52rem) {
  .shell { display: block; }
  .side {
    position: sticky; top: 0; z-index: 50; height: auto; overflow: visible;
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "brand pill lang out" "nav nav nav nav";
    align-items: center; gap: var(--s1) var(--s3); padding: var(--s2) var(--s3) 0;
  }
  .brand { grid-area: brand; padding: 0; }
  .brand .mark { width: 1.75rem; height: 1.75rem; }
  .pending-pill {
    grid-area: pill; justify-self: end; display: inline-flex; align-items: center; gap: var(--s2);
    padding: .3rem .4rem .3rem .8rem; border-radius: var(--pill); min-height: 2.25rem;
    background: var(--side-hover); color: var(--side-strong); text-decoration: none; font-weight: 650; font-size: var(--fs-sm);
    border: 1px solid var(--side-line); white-space: nowrap;
  }
  .pending-pill:hover { color: var(--side-strong); text-decoration: none; background: var(--side-active); }
  #logout-form { grid-area: out; margin: 0; padding: 0; border: 0; }
  .side .lang-switch { grid-area: lang; margin: 0; }
  #logout-form button { width: auto; min-height: 2.25rem; padding: .3rem .8rem; }
  .side nav {
    grid-area: nav; flex-direction: row; gap: var(--s1); overflow-x: auto; overscroll-behavior-x: contain;
    margin: 0 calc(var(--s3) * -1); padding: var(--s1) var(--s3) var(--s2); scrollbar-width: none;
  }
  .side nav::-webkit-scrollbar { display: none; }
  .nav-label { display: none; }
  .nav-link { flex: none; min-height: 2.5rem; border-left: 0; border-bottom: 3px solid transparent; border-radius: var(--r1) var(--r1) 0 0; white-space: nowrap; padding: .4rem var(--s3); }
  .nav-link[aria-current="page"] { border-bottom-color: var(--accent); }
  .nav-link[href^="/pendencias"] { display: none; }
  main { padding: var(--s5) var(--s4) var(--s8); }
  h1 { font-size: var(--fs-xl); }
  .stats { gap: var(--s1) var(--s2); }
  .stat { padding: .2rem .6rem; font-size: var(--fs-xs); }
  .stat b { font-size: var(--fs-sm); }
  section, article { padding: var(--s4); }
  section.client, section.release, section.group { padding: 0; }
  .tool { grid-template-columns: minmax(0, 1fr); }
  dl.kv, section > dl:not([class]) { grid-template-columns: minmax(0, 1fr); gap: 0; }
  dl.kv dt, section > dl:not([class]) dt { margin-top: var(--s2); }
  dl.facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-wrap th, .table-wrap td { padding: .55rem var(--s3); }
  .matrix tbody th { min-width: 9.5rem; }
  .matrix td { min-width: 8.5rem; }
  .matrix { max-height: 70vh; }
  section.client > details > summary, section.release > details > summary { padding: var(--s3) var(--s4); }
  section.client > details > :not(summary), section.release > details > :not(summary) { margin: var(--s4); }
  .auth-card { padding: var(--s5); }
}
@media (max-width: 26rem) {
  .brand-name { display: none; }
  dl.facts { grid-template-columns: minmax(0, 1fr); }
  dl.facts.source-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2) var(--s3); }
}
@media (pointer: coarse) {
  .chip, .btn-small { min-height: 2.75rem; }
  button, .btn { min-height: 2.75rem; }
  summary { min-height: 2.75rem; }
}

/* ---------- 8. Accessibility ---------- */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
::selection { background: var(--accent-soft); color: var(--text); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print {
  .side, #logout-form, .btn, button { display: none !important; }
  .shell { display: block; }
  body { background: #fff; color: #000; }
}
