/* =============================================================================
   Abregel — painel administrativo
   Mesma família visual do site (marinho, cinzas frios, ciano como acento),
   com densidade de ferramenta de trabalho: tipografia menor, tabelas e
   formulários em cartões, navegação lateral fixa.

   Contraste (WCAG AA): textos sobre branco usam --ink (15.9:1) e --muted
   (7.5:1); sobre a barra lateral, --side-text (#C9D1DC / #050F24 = 12.5:1).
   ============================================================================= */

@layer tokens, base, layout, components, utilities;

@font-face {
  font-family: "Montserrat";
  src: url("../fonts/montserrat-latin-var.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-var-italic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

@layer tokens {
  :root {
    --navy-950: #050f24;
    --navy-900: #0a1f44;
    --navy-800: #122b56;
    --navy-700: #1c355e;
    --ink: #1a2230;
    --muted: #4a5568;
    --subtle: #6b7686;
    --rule: #dde3ea;
    --rule-strong: #c9d1dc;
    --field-border: #7a8699;
    --paper: #f5f7fa;
    --paper-2: #eef2f6;
    --white: #ffffff;
    --cyan: #1aa7ec;
    --cyan-soft: #7fd0f5;
    --cyan-tint: #e8f6fd;
    --success: #1f6b4a;
    --success-tint: #e7f3ed;
    --danger: #a4262c;
    --danger-tint: #fbeaea;
    --warning: #8a5a00;
    --warning-tint: #fdf3e1;
    --side-text: #c9d1dc;
    --side-muted: #8e9bb0;

    --font-heading: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --fs-xs: 0.75rem;
    --fs-sm: 0.8125rem;
    --fs: 0.9375rem;
    --fs-md: 1.0625rem;
    --fs-lg: 1.375rem;
    --fs-xl: clamp(1.5rem, 1.2rem + 1vw, 1.875rem);

    --s1: 0.25rem;
    --s2: 0.5rem;
    --s3: 0.75rem;
    --s4: 1rem;
    --s5: 1.5rem;
    --s6: 2rem;
    --s7: 3rem;

    --radius: 4px;
    --radius-lg: 6px;
    --side-w: 16rem;
    --top-h: 3.75rem;
    --shadow: 0 1px 2px rgb(5 15 36 / 0.05), 0 4px 16px -8px rgb(5 15 36 / 0.12);
    --shadow-lg: 0 24px 64px -24px rgb(5 15 36 / 0.45);
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --dur: 180ms;

    color-scheme: light;
  }
}

@layer base {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 400 var(--fs) / 1.55 var(--font-sans);
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
  }
  h1, h2, h3, h4 {
    margin: 0;
    color: var(--navy-900);
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.2;
    text-wrap: balance;
  }
  h1 { font-size: var(--fs-xl); }
  h2 { font-size: var(--fs-lg); }
  h3 { font-size: var(--fs-md); }
  h4 { font-size: var(--fs); }
  p { margin: 0; }
  p + p { margin-top: var(--s3); }
  a {
    color: var(--navy-900);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
  }
  a:hover { text-decoration-color: var(--cyan); }
  img, svg { display: block; max-width: 100%; }
  img { height: auto; }
  button, input, select, textarea { font: inherit; color: inherit; }
  table { border-collapse: collapse; width: 100%; }
  code, kbd { font-family: var(--font-mono); font-size: 0.9em; }
  :focus-visible {
    outline: 2px solid var(--navy-900);
    outline-offset: 2px;
  }
  [hidden] { display: none !important; }
  ::selection { background: var(--navy-900); color: var(--white); }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      transition-duration: 0.01ms !important;
      animation-duration: 0.01ms !important;
    }
  }
}

/* =============================================================================
   ESTRUTURA
   ========================================================================== */
@layer layout {
  .skip-link {
    position: absolute;
    left: var(--s4);
    top: -4rem;
    z-index: 100;
    padding: var(--s2) var(--s4);
    background: var(--white);
    color: var(--navy-900);
    font-weight: 600;
  }
  .skip-link:focus { top: var(--s4); }

  .shell {
    min-height: 100vh;
    min-height: 100svh;
  }
  @media (min-width: 64rem) {
    .shell {
      display: grid;
      grid-template-columns: var(--side-w) minmax(0, 1fr);
    }
  }

  /* Barra lateral */
  .side {
    background: var(--navy-950);
    color: var(--side-text);
  }
  @media (min-width: 64rem) {
    .side {
      position: sticky;
      top: 0;
      height: 100vh;
      height: 100svh;
      display: flex;
      flex-direction: column;
    }
  }
  .side__brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s3);
    height: var(--top-h);
    padding: 0 var(--s4) 0 var(--s5);
    border-bottom: 1px solid rgb(255 255 255 / 0.08);
  }
  .side__brand a {
    display: flex;
    align-items: center;
    gap: var(--s3);
    color: var(--white);
    text-decoration: none;
  }
  .side__brand img { width: 6.5rem; height: auto; }
  .side__tag {
    padding-left: var(--s3);
    border-left: 1px solid rgb(255 255 255 / 0.2);
    color: var(--side-muted);
    font-size: var(--fs-xs);
    letter-spacing: 0.06em;
  }
  .side__toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--s2);
    padding: var(--s2) var(--s3);
    border: 1px solid rgb(255 255 255 / 0.24);
    border-radius: var(--radius);
    background: none;
    color: var(--white);
    font-size: var(--fs-sm);
    cursor: pointer;
  }
  @media (min-width: 64rem) {
    .side__toggle { display: none; }
  }
  .side__nav {
    padding: var(--s4) var(--s3) var(--s6);
    overflow-y: auto;
    overscroll-behavior: contain;
    flex: 1;
  }
  @media (max-width: 63.99rem) {
    .js .side__nav:not(.is-open) { display: none; }
    .side__nav { border-bottom: 1px solid rgb(255 255 255 / 0.08); }
  }
  .side__group + .side__group { margin-top: var(--s5); }
  .side__label {
    margin: 0 0 var(--s2);
    padding: 0 var(--s3);
    color: var(--side-muted);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }
  .side__list { margin: 0; padding: 0; list-style: none; }
  .side__link {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--s3);
    padding: 0.4375rem var(--s3);
    border-radius: var(--radius);
    color: var(--side-text);
    font-size: var(--fs-sm);
    text-decoration: none;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
  }
  .side__link .icon { width: 1rem; height: 1rem; color: var(--side-muted); flex: none; }
  .side__link:hover { background: rgb(255 255 255 / 0.06); color: var(--white); }
  .side__link[aria-current="page"] {
    background: rgb(26 167 236 / 0.12);
    color: var(--white);
  }
  .side__link[aria-current="page"]::before {
    content: "";
    position: absolute;
    left: -0.75rem;
    top: 0.375rem;
    bottom: 0.375rem;
    width: 2px;
    background: var(--cyan);
  }
  .side__link[aria-current="page"] .icon { color: var(--cyan-soft); }
  .side__link:focus-visible { outline-color: var(--cyan-soft); }

  /* Área principal */
  .main {
    min-width: 0;
    display: flex;
    flex-direction: column;
  }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s4);
    min-height: var(--top-h);
    padding: 0 var(--s5);
    background: rgb(255 255 255 / 0.94);
    border-bottom: 1px solid var(--rule);
    backdrop-filter: blur(8px);
  }
  .topbar__crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s1) var(--s2);
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--fs-sm);
    color: var(--muted);
    min-width: 0;
  }
  .topbar__crumbs li + li::before {
    content: "/";
    margin-right: var(--s2);
    color: var(--rule-strong);
  }
  .topbar__crumbs a { color: var(--muted); text-decoration: none; }
  .topbar__crumbs a:hover { color: var(--navy-900); text-decoration: underline; }
  .topbar__user {
    display: flex;
    align-items: center;
    gap: var(--s3);
    flex: none;
    font-size: var(--fs-sm);
  }
  .topbar__user form { margin: 0; }
  .topbar__name {
    display: none;
    color: var(--muted);
    text-decoration: none;
  }
  @media (min-width: 48rem) {
    .topbar__name { display: inline; }
  }
  .content {
    width: 100%;
    max-width: 88rem;
    padding: var(--s5) var(--s4) var(--s7);
  }
  @media (min-width: 48rem) {
    .content { padding: var(--s6) var(--s6) var(--s7); }
  }
  .content--narrow { max-width: 64rem; }

  .page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--s4) var(--s5);
    margin-bottom: var(--s5);
  }
  .page-head__text { max-width: 48rem; }
  .page-head__eyebrow {
    margin-bottom: var(--s2);
    color: var(--muted);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }
  .page-head p.page-head__lead {
    margin-top: var(--s2);
    color: var(--muted);
  }
  .page-head__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s2);
  }

  .grid-2, .grid-3, .grid-4 {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s4);
  }
  @media (min-width: 48rem) {
    .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (min-width: 72rem) {
    .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  }
  .split {
    display: grid;
    gap: var(--s5);
    align-items: start;
  }
  @media (min-width: 72rem) {
    .split { grid-template-columns: minmax(0, 1fr) 20rem; }
    .split__aside { position: sticky; top: calc(var(--top-h) + var(--s5)); }
  }
  .stack > * + * { margin-top: var(--s5); }
  .stack-sm > * + * { margin-top: var(--s3); }

  /* Telas de acesso (login) */
  .auth {
    min-height: 100vh;
    min-height: 100svh;
    display: grid;
    background: var(--navy-950);
  }
  @media (min-width: 60rem) {
    .auth { grid-template-columns: minmax(0, 1.1fr) minmax(28rem, 0.9fr); }
  }
  .auth__aside {
    position: relative;
    display: none;
    padding: var(--s7);
    overflow: hidden;
    color: var(--side-text);
    background-image:
      linear-gradient(rgb(255 255 255 / 0.05) 1px, transparent 1px),
      linear-gradient(90deg, rgb(255 255 255 / 0.05) 1px, transparent 1px);
    background-size: 3.5rem 3.5rem;
  }
  @media (min-width: 60rem) {
    .auth__aside { display: flex; flex-direction: column; justify-content: space-between; }
  }
  .auth__aside::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(80% 70% at 20% 90%, rgb(26 167 236 / 0.18), transparent 60%);
    pointer-events: none;
  }
  .auth__aside img { width: 9rem; }
  .auth__claim {
    position: relative;
    max-width: 30rem;
    color: var(--white);
    font-family: var(--font-heading);
    font-size: clamp(1.75rem, 1.2rem + 1.4vw, 2.5rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.15;
  }
  .auth__foot { position: relative; font-size: var(--fs-sm); color: var(--side-muted); }
  .auth__panel {
    display: grid;
    align-content: center;
    padding: var(--s6) var(--s4);
    background: var(--white);
  }
  @media (min-width: 30rem) {
    .auth__panel { padding: var(--s7) var(--s6); }
  }
  .auth__box { width: 100%; max-width: 24rem; margin: 0 auto; }
  .auth__logo { width: 8rem; margin-bottom: var(--s6); }
  @media (min-width: 60rem) {
    .auth__logo { display: none; }
  }
  .auth__box h1 { font-size: var(--fs-lg); }
  .auth__box > p { margin-top: var(--s2); color: var(--muted); }
  .auth__box form { margin-top: var(--s5); }
  .auth__links { margin-top: var(--s5); font-size: var(--fs-sm); }
}

/* =============================================================================
   COMPONENTES
   ========================================================================== */
@layer components {
  .icon {
    width: 1.125rem;
    height: 1.125rem;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  /* Botões */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s2);
    min-height: 2.5rem;
    padding: 0.4375rem 1rem;
    border: 1px solid var(--navy-900);
    border-radius: var(--radius);
    background: var(--navy-900);
    color: var(--white);
    font-size: var(--fs-sm);
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
  }
  .btn:hover { background: var(--navy-700); border-color: var(--navy-700); color: var(--white); }
  .btn .icon { width: 1rem; height: 1rem; }
  .btn--secondary {
    background: var(--white);
    border-color: var(--rule-strong);
    color: var(--navy-900);
  }
  .btn--secondary:hover { background: var(--paper); border-color: var(--navy-900); color: var(--navy-900); }
  .btn--ghost {
    background: transparent;
    border-color: transparent;
    color: var(--navy-900);
  }
  .btn--ghost:hover { background: var(--paper-2); border-color: transparent; color: var(--navy-900); }
  .btn--danger {
    background: var(--white);
    border-color: #e3b7b9;
    color: var(--danger);
  }
  .btn--danger:hover { background: var(--danger); border-color: var(--danger); color: var(--white); }
  .btn--sm { min-height: 2rem; padding: 0.25rem 0.625rem; font-size: var(--fs-xs); }
  .btn--block { width: 100%; }
  .btn--icon { padding: 0; width: 2.25rem; min-height: 2.25rem; }
  .btn[aria-disabled="true"], .btn:disabled { opacity: 0.55; pointer-events: none; }
  .btn--light {
    background: transparent;
    border-color: rgb(255 255 255 / 0.28);
    color: var(--white);
  }
  .link-btn {
    padding: 0;
    border: 0;
    background: none;
    color: var(--navy-900);
    font-size: inherit;
    text-decoration: underline;
    text-underline-offset: 0.18em;
    cursor: pointer;
  }
  .link-btn--danger { color: var(--danger); }

  /* Cartões */
  .card {
    background: var(--white);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
  }
  .card__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s2) var(--s4);
    padding: var(--s4) var(--s5);
    border-bottom: 1px solid var(--rule);
  }
  .card__head h2 { font-size: var(--fs-md); }
  .card__head p { color: var(--muted); font-size: var(--fs-sm); margin-top: var(--s1); }
  .card__body { padding: var(--s5); }
  .card__body--flush { padding: 0; }
  .card__foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s3);
    padding: var(--s4) var(--s5);
    border-top: 1px solid var(--rule);
    background: var(--paper);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  }
  fieldset.card { margin: 0; padding: 0; min-width: 0; }
  .card__legend {
    float: left;
    width: 100%;
    padding: var(--s4) var(--s5) 0;
    color: var(--navy-900);
    font-family: var(--font-heading);
    font-size: var(--fs-md);
    font-weight: 600;
  }
  .card__legend + * { clear: both; }
  .card--danger { border-color: #efcfd0; }
  .card--danger .card__head { background: var(--danger-tint); }

  /* Indicadores do painel inicial */
  .stat {
    display: block;
    padding: var(--s5);
    color: inherit;
    text-decoration: none;
    transition: border-color var(--dur) var(--ease);
  }
  .stat:hover { border-color: var(--navy-900); }
  .stat__label { color: var(--muted); font-size: var(--fs-sm); }
  .stat__value {
    margin: var(--s2) 0 var(--s1);
    color: var(--navy-900);
    font-family: var(--font-heading);
    font-size: 2.25rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
  }
  .stat__detail { color: var(--subtle); font-size: var(--fs-xs); }

  .checklist { margin: 0; padding: 0; list-style: none; }
  .checklist li { border-top: 1px solid var(--rule); }
  .checklist li:first-child { border-top: 0; }
  .checklist a {
    display: flex;
    align-items: center;
    gap: var(--s3);
    padding: var(--s3) var(--s5);
    color: var(--ink);
    text-decoration: none;
  }
  .checklist a:hover { background: var(--paper); }
  .checklist .icon { color: var(--warning); }
  .checklist .is-ok .icon { color: var(--success); }
  .checklist .is-ok span { color: var(--muted); }

  /* Avisos */
  .notice {
    display: flex;
    align-items: flex-start;
    gap: var(--s3);
    padding: var(--s3) var(--s4);
    border: 1px solid var(--rule-strong);
    border-left-width: 3px;
    border-radius: var(--radius);
    background: var(--white);
    font-size: var(--fs-sm);
  }
  .notice .icon { margin-top: 0.125rem; }
  .notice--success { border-color: #b9d8c8; border-left-color: var(--success); background: var(--success-tint); }
  .notice--success .icon { color: var(--success); }
  .notice--error { border-color: #efcfd0; border-left-color: var(--danger); background: var(--danger-tint); }
  .notice--error .icon { color: var(--danger); }
  .notice--warning { border-color: #eed8b0; border-left-color: var(--warning); background: var(--warning-tint); }
  .notice--warning .icon { color: var(--warning); }
  .notice--info { border-left-color: var(--cyan); background: var(--cyan-tint); border-color: #bfe4f7; }
  .notice--info .icon { color: var(--navy-900); }
  .flash { margin-bottom: var(--s5); }
  .flash:focus { outline: none; }

  /* Selos */
  .badge {
    display: inline-flex;
    align-items: center;
    gap: var(--s1);
    padding: 0.125rem 0.5rem;
    border: 1px solid var(--rule-strong);
    border-radius: 999px;
    background: var(--white);
    color: var(--muted);
    font-size: var(--fs-xs);
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
  }
  .badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.8;
  }
  .badge--plain::before { display: none; }
  .badge--ok, .badge--publicado, .badge--confirmado, .badge--convertido, .badge--ativo, .badge--paga { border-color: #b9d8c8; background: var(--success-tint); color: var(--success); }
  .badge--novo, .badge--agendado, .badge--em_contato, .badge--em_analise { border-color: #bfe4f7; background: var(--cyan-tint); color: var(--navy-900); }
  .badge--rascunho, .badge--pendente, .badge--off, .badge--cancelada { color: var(--muted); }
  .badge--cancelado, .badge--descartado, .badge--descadastrado, .badge--danger, .badge--recusado, .badge--estornada, .badge--vencida { border-color: #efcfd0; background: var(--danger-tint); color: var(--danger); }
  .badge--warning, .badge--aguardando_pagamento, .badge--suspenso, .badge--erro { border-color: #eed8b0; background: var(--warning-tint); color: var(--warning); }

  /* Tabelas */
  /* position: rótulos visually-hidden (absolutos) ficam contidos na rolagem. */
  .table-wrap { position: relative; overflow-x: auto; }
  .table { font-size: var(--fs-sm); }
  .table th, .table td {
    padding: 0.625rem var(--s4);
    border-bottom: 1px solid var(--rule);
    text-align: left;
    vertical-align: middle;
  }
  .table th {
    color: var(--muted);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    white-space: nowrap;
    background: var(--paper);
  }
  .table tbody th {
    background: none;
    color: var(--ink);
    font-size: var(--fs-sm);
    font-weight: 500;
    letter-spacing: 0;
    white-space: normal;
  }
  .table tbody tr:last-child td, .table tbody tr:last-child th { border-bottom: 0; }
  .table tbody tr:hover { background: #fafbfd; }
  .table td.is-num, .table th.is-num { text-align: right; font-variant-numeric: tabular-nums; }
  .table td.is-actions { width: 1%; white-space: nowrap; text-align: right; }
  .table td.is-thumb { width: 3.5rem; padding-right: 0; }
  .table .cell-title { color: var(--navy-900); font-weight: 600; text-decoration: none; }
  .table .cell-title:hover { text-decoration: underline; }
  .table .cell-sub { display: block; margin-top: 0.125rem; color: var(--subtle); font-size: var(--fs-xs); }
  .table .is-dim { color: var(--subtle); }
  .thumb {
    width: 3rem;
    height: 2.25rem;
    border-radius: var(--radius);
    background: var(--paper-2);
    object-fit: cover;
  }
  .thumb--empty { display: block; }
  .yes { color: var(--success); }
  .no { color: var(--rule-strong); }

  .drag {
    display: inline-grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: var(--subtle);
    cursor: grab;
    touch-action: none;
  }
  .drag:hover { background: var(--paper-2); color: var(--navy-900); }
  .sortable-ghost { opacity: 0.4; background: var(--cyan-tint) !important; }
  .sortable-chosen { box-shadow: var(--shadow); }
  .sort-status { font-size: var(--fs-xs); color: var(--muted); min-height: 1.2em; }

  /* Barra de filtros */
  .toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--s3);
    padding: var(--s4) var(--s5);
    border-bottom: 1px solid var(--rule);
  }
  .toolbar .field { margin: 0; min-width: 10rem; }
  .toolbar .field--grow { flex: 1 1 16rem; }
  .toolbar__meta { margin-left: auto; padding-bottom: 0.625rem; color: var(--muted); font-size: var(--fs-sm); }
  .tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s1);
    margin: 0 0 var(--s4);
    padding: 0;
    list-style: none;
  }
  .tabs a {
    display: inline-flex;
    align-items: center;
    gap: var(--s2);
    padding: 0.375rem 0.75rem;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--muted);
    font-size: var(--fs-sm);
    text-decoration: none;
  }
  .tabs a:hover { background: var(--white); border-color: var(--rule); color: var(--navy-900); }
  .tabs a[aria-current="true"] { background: var(--navy-900); color: var(--white); }
  .tabs .count { font-variant-numeric: tabular-nums; opacity: 0.8; }

  .pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s3);
    padding: var(--s3) var(--s5);
    border-top: 1px solid var(--rule);
    font-size: var(--fs-sm);
    color: var(--muted);
  }
  .pagination__links { display: flex; gap: var(--s2); }

  .empty {
    padding: var(--s7) var(--s5);
    text-align: center;
    color: var(--muted);
  }
  .empty .icon { width: 2rem; height: 2rem; margin: 0 auto var(--s3); color: var(--rule-strong); }
  .empty h2 { font-size: var(--fs-md); margin-bottom: var(--s2); }
  .empty .btn { margin-top: var(--s4); }

  /* Formulários */
  .form-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--s4) var(--s4);
  }
  .form-grid > * { grid-column: 1 / -1; }
  @media (min-width: 40rem) {
    .form-grid > .w-half { grid-column: span 3; }
    .form-grid > .w-third { grid-column: span 2; }
  }
  .fieldset {
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
  }
  .fieldset + .fieldset { margin-top: var(--s5); padding-top: var(--s5); border-top: 1px solid var(--rule); }
  .fieldset > legend {
    float: left;
    width: 100%;
    margin-bottom: var(--s4);
    padding: 0;
    color: var(--navy-900);
    font-family: var(--font-heading);
    font-size: var(--fs);
    font-weight: 600;
  }
  .fieldset > legend + * { clear: both; }
  .field { min-width: 0; }
  .field__label {
    display: block;
    margin-bottom: 0.375rem;
    color: var(--ink);
    font-size: var(--fs-sm);
    font-weight: 600;
  }
  .field__req { color: var(--danger); font-weight: 600; }
  .field__hint {
    margin-top: 0.375rem;
    color: var(--muted);
    font-size: var(--fs-xs);
    line-height: 1.45;
  }
  .field__error {
    display: flex;
    align-items: center;
    gap: var(--s1);
    margin-top: 0.375rem;
    color: var(--danger);
    font-size: var(--fs-xs);
    font-weight: 600;
  }
  .field__error .icon { width: 0.875rem; height: 0.875rem; }
  .input, .select, .textarea {
    display: block;
    width: 100%;
    min-height: 2.5rem;
    padding: 0.4375rem 0.75rem;
    border: 1px solid var(--field-border);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--ink);
    font-size: var(--fs);
    line-height: 1.5;
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  }
  .textarea { min-height: 5rem; resize: vertical; }
  .textarea--code { font-family: var(--font-mono); font-size: var(--fs-sm); }
  .select {
    appearance: none;
    padding-right: 2.25rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230a1f44' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.625rem center;
    background-size: 1rem;
  }
  .input:hover, .select:hover, .textarea:hover { border-color: var(--navy-900); }
  .input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--navy-900);
    box-shadow: 0 0 0 3px rgb(26 167 236 / 0.28);
  }
  .input[readonly] { background: var(--paper); }
  .field--error .input, .field--error .select, .field--error .textarea, .field--error .editor { border-color: var(--danger); }
  .input-group { display: flex; align-items: stretch; }
  .input-group__prefix {
    display: grid;
    place-items: center;
    padding: 0 0.625rem;
    border: 1px solid var(--field-border);
    border-right: 0;
    border-radius: var(--radius) 0 0 var(--radius);
    background: var(--paper);
    color: var(--muted);
    font-size: var(--fs-sm);
    white-space: nowrap;
  }
  .input-group .input { border-radius: 0 var(--radius) var(--radius) 0; min-width: 0; }
  .counter { float: right; color: var(--subtle); font-size: var(--fs-xs); font-weight: 400; font-variant-numeric: tabular-nums; }
  .counter.is-over { color: var(--danger); font-weight: 600; }

  .check {
    display: flex;
    align-items: flex-start;
    gap: var(--s2);
    font-size: var(--fs-sm);
    cursor: pointer;
  }
  .check input {
    width: 1.125rem;
    height: 1.125rem;
    margin: 0.125rem 0 0;
    accent-color: var(--navy-900);
    flex: none;
  }
  .check strong { display: block; font-weight: 600; }
  .check span.field__hint { margin-top: 0.125rem; }
  .switch-list { display: grid; gap: var(--s3); }

  .link-field {
    display: grid;
    gap: var(--s3);
    padding: var(--s3);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--paper);
  }
  @media (min-width: 40rem) {
    .link-field { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); }
  }
  .link-field .field__label { font-weight: 500; color: var(--muted); }

  /* Lista repetível */
  .repeater__items { display: grid; gap: var(--s3); }
  .repeater__item {
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--paper);
  }
  .repeater__bar {
    display: flex;
    align-items: center;
    gap: var(--s2);
    padding: var(--s2) var(--s3);
    border-bottom: 1px solid var(--rule);
    font-size: var(--fs-sm);
    color: var(--muted);
  }
  .repeater__bar strong { color: var(--ink); font-weight: 600; }
  .repeater__bar strong { margin-right: auto; }
  .repeater__fields { padding: var(--s3); }
  .repeater__add { margin-top: var(--s3); }

  /* Campo de imagem */
  .media-field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s4);
    padding: var(--s3);
    border: 1px dashed var(--rule-strong);
    border-radius: var(--radius);
    background: var(--paper);
  }
  .media-field__preview {
    display: grid;
    place-items: center;
    width: 7rem;
    aspect-ratio: 4 / 3;
    flex: none;
    border-radius: var(--radius);
    background:
      linear-gradient(135deg, var(--paper-2) 25%, transparent 25%) 0 0 / 12px 12px,
      linear-gradient(135deg, transparent 75%, var(--paper-2) 75%) 0 0 / 12px 12px,
      var(--white);
    overflow: hidden;
    color: var(--subtle);
  }
  .media-field__preview img { width: 100%; height: 100%; object-fit: cover; }
  .media-field__info { min-width: 12rem; flex: 1; font-size: var(--fs-sm); }
  .media-field__name { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
  .media-field__alt { color: var(--muted); font-size: var(--fs-xs); margin-top: 0.125rem; }
  .media-field__actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }

  /* Editor rico */
  .editor {
    border: 1px solid var(--field-border);
    border-radius: var(--radius);
    background: var(--white);
  }
  .editor:focus-within { border-color: var(--navy-900); box-shadow: 0 0 0 3px rgb(26 167 236 / 0.28); }
  .editor__toolbar {
    position: sticky;
    top: var(--top-h);
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: var(--s1);
    border-bottom: 1px solid var(--rule);
    background: var(--paper);
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .editor__btn {
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: none;
    color: var(--navy-900);
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
  }
  .editor__btn:hover { background: var(--white); border-color: var(--rule-strong); }
  .editor__btn[aria-pressed="true"] { background: var(--navy-900); color: var(--white); }
  .editor__sep { width: 1px; margin: 0.25rem 0.25rem; background: var(--rule-strong); }
  .editor__area {
    min-height: 14rem;
    max-height: 70vh;
    overflow-y: auto;
    padding: var(--s4) var(--s5);
    font-size: 1rem;
    line-height: 1.7;
  }
  .editor__area:focus { outline: none; }
  .editor__area > * + * { margin-top: 0.75em; }
  .editor__area h2 { font-size: 1.375rem; margin-top: 1.25em; }
  .editor__area h3 { font-size: 1.125rem; margin-top: 1.1em; }
  .editor__area ul, .editor__area ol { padding-left: 1.4em; }
  .editor__area blockquote { margin-left: 0; padding-left: 1em; border-left: 3px solid var(--cyan); color: var(--muted); }
  .editor__area a { color: var(--navy-900); }
  .editor__area table { border: 1px solid var(--rule); }
  .editor__area td, .editor__area th { border: 1px solid var(--rule); padding: 0.25rem 0.5rem; }
  .editor__area:empty::before { content: attr(data-placeholder); color: var(--subtle); }
  .editor__source { border: 0; border-radius: 0 0 var(--radius) var(--radius); min-height: 14rem; }
  .editor mark.pending, mark.pending {
    background: rgb(255 196 0 / 0.2);
    color: inherit;
    outline: 1px dashed rgb(138 90 0 / 0.6);
  }

  /* Barra de ações do formulário */
  .form-actions {
    position: sticky;
    bottom: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s2) var(--s3);
    margin-top: var(--s5);
    padding: var(--s3) var(--s4);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    background: rgb(255 255 255 / 0.96);
    box-shadow: 0 -8px 24px -16px rgb(5 15 36 / 0.25);
    backdrop-filter: blur(6px);
  }
  .form-actions__meta { margin-left: auto; color: var(--muted); font-size: var(--fs-xs); }
  .dirty-flag { color: var(--warning); font-weight: 600; }

  .meta-list { margin: 0; font-size: var(--fs-sm); }
  .meta-list div { display: grid; grid-template-columns: 8rem minmax(0, 1fr); gap: var(--s3); padding: var(--s2) 0; border-top: 1px solid var(--rule); }
  .meta-list div:first-child { border-top: 0; padding-top: 0; }
  .meta-list dt { color: var(--muted); }
  .meta-list dd { margin: 0; overflow-wrap: anywhere; }

  .timeline { margin: 0; padding: 0; list-style: none; font-size: var(--fs-sm); }
  .timeline li { position: relative; padding: 0 0 var(--s3) var(--s4); border-left: 1px solid var(--rule-strong); }
  .timeline li::before {
    content: "";
    position: absolute;
    left: -4px;
    top: 0.45em;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--white);
    border: 1px solid var(--navy-900);
  }
  .timeline li:last-child { padding-bottom: 0; }
  .timeline time { display: block; color: var(--subtle); font-size: var(--fs-xs); }

  .note {
    padding: var(--s3) var(--s4);
    border-left: 2px solid var(--cyan);
    background: var(--paper);
    border-radius: 0 var(--radius) var(--radius) 0;
    white-space: pre-line;
    font-size: var(--fs-sm);
  }
  .note__meta { display: block; margin-top: var(--s2); color: var(--subtle); font-size: var(--fs-xs); white-space: normal; }
  .message {
    padding: var(--s4);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--paper);
    white-space: pre-line;
    overflow-wrap: anywhere;
  }

  /* Blocos da página */
  .blocks { margin: 0; padding: 0; list-style: none; }
  .block-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--s3);
    padding: var(--s3) var(--s4);
    border-top: 1px solid var(--rule);
    background: var(--white);
  }
  .block-row:first-child { border-top: 0; }
  .block-row.is-off .block-row__title { color: var(--subtle); }
  .block-row__type { color: var(--muted); font-size: var(--fs-xs); letter-spacing: 0.04em; }
  .block-row__title { display: block; color: var(--navy-900); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
  .block-row__title:hover { text-decoration: underline; }
  .block-row__excerpt { display: block; margin-top: 0.125rem; color: var(--subtle); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .block-row__actions { display: flex; align-items: center; gap: var(--s2); }
  @media (max-width: 40rem) {
    .block-row { grid-template-columns: auto minmax(0, 1fr); }
    .block-row__actions { grid-column: 2; }
  }
  .block-row__actions form { margin: 0; }
  .type-grid {
    display: grid;
    gap: var(--s3);
  }
  @media (min-width: 40rem) {
    .type-grid { grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
  }
  .type-card {
    display: block;
    padding: var(--s4);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    background: var(--white);
    color: inherit;
    text-decoration: none;
    transition: border-color var(--dur) var(--ease);
  }
  .type-card:hover { border-color: var(--navy-900); }
  .type-card strong { display: block; color: var(--navy-900); }
  .type-card span { display: block; margin-top: var(--s1); color: var(--muted); font-size: var(--fs-sm); }

  /* Comparativo de planos */
  .matrix { font-size: var(--fs-sm); }
  .matrix th, .matrix td { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--rule); vertical-align: top; }
  /* Sem cabeçalho fixo: dentro de .table-wrap (overflow) ele se prenderia ao contêiner. */
  .matrix thead th { background: var(--paper); text-align: left; font-size: var(--fs-xs); color: var(--muted); }
  .matrix .group-row th { background: var(--paper-2); padding: var(--s2) var(--s3); }
  .matrix .group-row .input { max-width: 24rem; font-weight: 600; }
  .matrix .group-row .input[type="number"] { width: 5.5rem; font-weight: 400; }
  .matrix td.cell { min-width: 9.5rem; }
  .matrix .cell .select { min-height: 2rem; padding-top: 0.25rem; padding-bottom: 0.25rem; font-size: var(--fs-sm); }
  .matrix .cell .input { margin-top: var(--s1); min-height: 2rem; font-size: var(--fs-sm); }
  .matrix .feature .input { min-height: 2rem; font-size: var(--fs-sm); }
  .matrix .feature .input + .input { margin-top: var(--s1); color: var(--muted); }
  .matrix .feature { min-width: 18rem; }
  .matrix tr.is-off .feature .input:first-child { text-decoration: line-through; color: var(--subtle); }

  /* Mapa */
  .uf-grid { display: grid; gap: var(--s2); }
  @media (min-width: 40rem) {
    .uf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (min-width: 80rem) {
    .uf-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  }
  .uf {
    display: grid;
    gap: var(--s2);
    padding: var(--s3);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--white);
  }
  .uf:has(input:checked) { border-color: var(--navy-900); background: var(--cyan-tint); }
  .uf .input { min-height: 2rem; font-size: var(--fs-sm); }

  /* Biblioteca de mídia */
  .media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap: var(--s3);
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .media-tile {
    position: relative;
    display: block;
    height: 100%;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--white);
    color: inherit;
    text-decoration: none;
    overflow: hidden;
    text-align: left;
    padding: 0;
    width: 100%;
    cursor: pointer;
    transition: border-color var(--dur) var(--ease);
  }
  .media-tile:hover, .media-tile[aria-pressed="true"] { border-color: var(--navy-900); }
  .media-tile[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--cyan); }
  .media-tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--paper-2); }
  .media-tile__meta { display: block; padding: var(--s2); font-size: var(--fs-xs); color: var(--muted); }
  .media-tile__meta strong { display: block; color: var(--ink); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .media-tile .badge { position: absolute; top: var(--s2); left: var(--s2); }
  .media-preview {
    border-radius: var(--radius);
    background: var(--paper-2);
    overflow: hidden;
  }
  .media-preview img { width: 100%; max-height: 32rem; object-fit: contain; }
  .focal {
    position: relative;
    cursor: crosshair;
  }
  .focal__dot {
    position: absolute;
    width: 1.25rem;
    height: 1.25rem;
    margin: -0.625rem 0 0 -0.625rem;
    border: 2px solid var(--white);
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--navy-900), 0 2px 8px rgb(0 0 0 / 0.4);
    pointer-events: none;
  }
  .dropzone {
    display: grid;
    gap: var(--s3);
    padding: var(--s4);
    border: 1px dashed var(--field-border);
    border-radius: var(--radius);
    background: var(--paper);
  }
  .dropzone.is-over { border-color: var(--navy-900); background: var(--cyan-tint); }

  /* Diálogo */
  .dialog {
    width: min(64rem, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    padding: 0;
    border: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    color: var(--ink);
  }
  .dialog--sm { width: min(28rem, calc(100vw - 2rem)); }
  .dialog::backdrop { background: rgb(5 15 36 / 0.6); }
  .dialog__head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s3);
    padding: var(--s4) var(--s5);
    border-bottom: 1px solid var(--rule);
    background: var(--white);
  }
  .dialog__body { padding: var(--s5); }
  .dialog__foot {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: flex-end;
    gap: var(--s2);
    padding: var(--s3) var(--s5);
    border-top: 1px solid var(--rule);
    background: var(--paper);
  }
  .loading { padding: var(--s6); text-align: center; color: var(--muted); }

  .qr { width: 11rem; height: 11rem; padding: var(--s2); border: 1px solid var(--rule); border-radius: var(--radius); background: var(--white); }
  .secret-state { display: flex; align-items: center; gap: var(--s2); }
  .secret-state .icon { width: 0.875rem; height: 0.875rem; }
  .secret { font-family: var(--font-mono); letter-spacing: 0.08em; overflow-wrap: anywhere; }
  .code-input { font-family: var(--font-mono); font-size: 1.25rem; letter-spacing: 0.3em; text-align: center; }

  .diff { font-size: var(--fs-sm); }
  .diff td { vertical-align: top; overflow-wrap: anywhere; }
  .diff .old { color: var(--danger); background: var(--danger-tint); }
  .diff .new { color: var(--success); background: var(--success-tint); }
  .diff pre { margin: 0; white-space: pre-wrap; font: inherit; }

  .perm-table td, .perm-table th { text-align: center; }
  .perm-table td:first-child, .perm-table th:first-child { text-align: left; }
  .perm-table input { width: 1.125rem; height: 1.125rem; accent-color: var(--navy-900); }
  .perm-table .na { color: var(--rule-strong); }

  .env-ribbon {
    position: fixed;
    right: var(--s3);
    bottom: var(--s3);
    z-index: 90;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius);
    background: var(--warning);
    color: var(--white);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    pointer-events: none;
  }
}

@layer utilities {
  .visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }
  .muted { color: var(--muted); }
  .small { font-size: var(--fs-sm); }
  .xs { font-size: var(--fs-xs); }
  .mt-2 { margin-top: var(--s2); }
  .mt-3 { margin-top: var(--s3); }
  .mt-4 { margin-top: var(--s4); }
  .mt-5 { margin-top: var(--s5); }
  .mb-4 { margin-bottom: var(--s4); }
  .nowrap { white-space: nowrap; }
  .break-all { word-break: break-all; }
  /* Texto rico exibido fora do editor (comunicados do portal). */
  .prose > * + * { margin-top: 1em; }
  .prose h2, .prose h3 { margin-top: 1.5em; }
  .prose ul, .prose ol { padding-left: 1.25em; }
  .prose a { color: var(--navy-900); text-decoration: underline; }
  .prose blockquote { margin-left: 0; padding-left: 1em; border-left: 3px solid var(--cyan); color: var(--muted); }
  .num { font-variant-numeric: tabular-nums; }
  .cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
  .inline-form { display: inline; margin: 0; }
  .text-right { text-align: right; }
}
