/* acordo. design system — forest/cream/crimson, Instrument Serif + IBM Plex.
   Tokens and components extracted from the design prototypes (see
   design/EXTRACTED-SPEC.md). One accent, borders over shadows. */

:root {
  --paper: #EFEBE0;
  --card: #FFFFFF;
  --warm: #F6F3EC;
  --forest: #1F4A3B;
  --forest-ink: #EFEBE0;
  --ink: #0F1922;
  --muted: #6D7580;
  --crimson: #A62A3A;
  --sage: #7FB069;
  --border: rgba(15, 25, 34, .14);
  --border-strong: rgba(15, 25, 34, .30);
  --hover: rgba(15, 25, 34, .05);
  --success: #1F7A4D;
  --success-bg: rgba(31, 122, 77, .12);
  --danger: #B4372E;
  --danger-bg: rgba(180, 55, 46, .10);
  --warning: #B8791F;
  --warning-bg: rgba(184, 121, 31, .12);
  --accent: var(--forest);
  --accent-tint: rgba(31, 74, 59, .10);
  --focus: var(--crimson);

  --f-serif: 'Instrument Serif', Georgia, serif;
  --f-sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', monospace;

  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-pill: 999px;
  --shadow-card: 0 1px 2px rgba(15, 25, 34, .04);
  --shadow-pop: 0 14px 34px rgba(15, 25, 34, .16);
  --shadow-drawer: -16px 0 40px rgba(10, 12, 16, .14);
}

:root[data-theme="dark"] {
  --paper: #0F1922;
  --card: #132029;
  --warm: #16242e;
  --forest: #1a3a2e;
  --ink: #EFEBE0;
  --muted: #9AA6A2;
  --sage: #7FB069;
  --border: rgba(239, 235, 224, .16);
  --border-strong: rgba(239, 235, 224, .34);
  --hover: rgba(239, 235, 224, .06);
  --success: #4CBF8B;
  --success-bg: rgba(76, 191, 139, .14);
  --danger: #E5766D;
  --accent: var(--sage);
  --accent-tint: rgba(127, 176, 105, .14);
  --focus: #C4515F;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--f-sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3, h4 { font-family: var(--f-serif); font-weight: 400; letter-spacing: -.01em; margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* --- logo ---------------------------------------------------------- */
.logo { font-family: var(--f-serif); font-weight: 400; display: inline-flex; align-items: baseline; gap: 1px; text-decoration: none; }
.logo .dot { color: var(--crimson); font-weight: 500; }

/* --- overline / mono labels --------------------------------------- */
.overline { font-family: var(--f-mono); text-transform: uppercase; letter-spacing: .12em; font-size: 11px; color: var(--muted); }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* --- buttons ------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--r-md);
  font-family: var(--f-sans); font-size: 14px; font-weight: 500; line-height: 1;
  border: 1px solid var(--border-strong); background: transparent; color: var(--ink);
  cursor: pointer; text-decoration: none; transition: background .15s ease-out, border-color .15s ease-out, opacity .15s ease-out;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--forest-ink); }
:root[data-theme="dark"] .btn-primary { color: #0F1922; }
.btn-primary:hover { opacity: .92; background: var(--accent); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

/* --- cards --------------------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-title { font-family: var(--f-serif); font-size: 18px; }
.card-hd { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

/* --- forms --------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.input, textarea.input, select.input {
  width: 100%; min-height: 42px; padding: 9px 12px; font-family: var(--f-sans); font-size: 14px;
  color: var(--ink); background: var(--card); border: 1px solid var(--border-strong); border-radius: var(--r-md);
}
.input.mono { font-family: var(--f-mono); }
textarea.input { min-height: auto; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: -1px; }
.help { font-size: 12px; color: var(--muted); margin-top: 6px; }
.error { font-size: 12px; color: var(--danger); margin-top: 6px; }
.errorlist { color: var(--danger); font-size: 12px; list-style: none; padding: 0; margin: 6px 0 0; }

/* --- switch (form toggle) ----------------------------------------- */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; border-radius: var(--r-pill); background: transparent; border: 1px solid var(--border-strong); transition: background .2s ease-out, border-color .2s; }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: left .2s ease-out; }
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track + .knob { left: 22px; }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }

/* --- pills / badges ------------------------------------------------ */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: var(--r-pill); }
.pill-success { background: var(--success-bg); color: var(--success); }
.pill-muted { background: var(--hover); color: var(--muted); }
.pill-accent { background: var(--accent-tint); color: var(--accent); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-warning { background: var(--warning-bg); color: var(--warning); }

/* --- consent glyph ------------------------------------------------- */
.glyph { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 2.5px; width: 18px; height: 18px; flex: none; vertical-align: middle; }
.glyph .cell { border-radius: 2px; border: 1.5px solid var(--accent); }
.glyph .cell.on { background: var(--accent); }
.glyph.lg { width: 26px; height: 26px; gap: 4px; }
.glyph.sm { width: 14px; height: 14px; gap: 2px; }

/* --- consent log table -------------------------------------------- */
.logtable { width: 100%; }
.logtable .th, .logtable .tr { display: grid; grid-template-columns: 230px 1fr 96px 120px 110px; gap: 12px; align-items: center; padding: 11px 16px; }
.logtable .th { font-family: var(--f-mono); text-transform: uppercase; letter-spacing: .05em; font-size: 11.5px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); }
.logtable .tr { width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: inherit; cursor: pointer; font: inherit; }
.logtable .tr:hover { background: var(--hover); }
.logtable .tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.logtable .id { font-family: var(--f-mono); font-size: 12.5px; }
.logtable .ts { font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--muted); }

/* --- KPI ----------------------------------------------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.kpi .label { font-size: 12px; font-weight: 500; color: var(--muted); }
.kpi .value { font-family: var(--f-serif); font-size: 30px; line-height: 1.05; }
.kpi .delta { font-size: 12px; color: var(--muted); }
.kpi .delta.up { color: var(--success); }

/* --- breakdown bars ------------------------------------------------ */
.bar-row { display: grid; grid-template-columns: 1fr 90px 44px; gap: 10px; align-items: center; padding: 6px 0; font-size: 13px; }
.bar-track { height: 8px; background: var(--hover); border-radius: var(--r-pill); overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: var(--r-pill); }
.bar-pct { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--muted); }

/* --- utilities ----------------------------------------------------- */
.stack > * + * { margin-top: var(--gap, 16px); }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.right { margin-left: auto; }
.page-title { font-size: 26px; margin-bottom: 4px; }
.page-sub { color: var(--muted); margin: 0 0 20px; }
.section-gap { margin-top: 24px; }
.text-sm { font-size: 13px; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* --- app shell (painel) ------------------------------------------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 216px; flex: none; background: var(--forest); color: var(--forest-ink); display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { display: flex; align-items: center; gap: 8px; padding: 6px 8px 18px; color: var(--forest-ink); font-size: 20px; }
.sidebar .brand .glyph .cell { border-color: var(--sage); }
.sidebar .brand .glyph .cell.on { background: var(--sage); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-md); color: rgba(239, 235, 224, .78); text-decoration: none; font-size: 13.5px; border: 0; background: transparent; cursor: pointer; font-family: var(--f-sans); text-align: left; }
.nav-item:hover { background: rgba(255, 255, 255, .07); color: var(--forest-ink); }
.nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; flex: none; }
.nav-item.active { background: rgba(255, 255, 255, .10); color: var(--forest-ink); }
.nav-item.active .dot { background: var(--sage); }
.nav-badge { margin-left: auto; background: var(--crimson); color: #fff; font-size: 11px; font-family: var(--f-mono); border-radius: var(--r-pill); padding: 1px 6px; min-width: 18px; text-align: center; }
.nav-sep { border: 0; border-top: 1px solid rgba(255, 255, 255, .12); margin: 12px 6px; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 8px 4px; font-size: 12px; color: rgba(239, 235, 224, .7); }
.main { flex: 1; padding: 28px 32px; max-width: 1200px; width: 100%; }
.main-narrow { max-width: 860px; }
.site-switch { margin: 0 6px 12px; }
.site-switch select { width: 100%; background: rgba(255,255,255,.08); color: var(--forest-ink); border: 1px solid rgba(255,255,255,.18); border-radius: var(--r-md); padding: 7px 9px; font-size: 13px; font-family: var(--f-sans); }

/* theme toggle in sidebar */
.theme-toggle { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: inherit; cursor: pointer; font-size: 12px; font-family: var(--f-sans); }

/* messages */
.msg { padding: 10px 14px; border-radius: var(--r-md); font-size: 13px; margin-bottom: 12px; border: 1px solid var(--border); }
.msg.success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.msg.error, .msg.danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.msg.warning { background: var(--warning-bg); color: var(--warning); border-color: transparent; }

/* progress steps (wizard) */
.steps { display: flex; gap: 8px; margin-bottom: 24px; }
.step { flex: 1; }
.step .bar { height: 4px; border-radius: var(--r-pill); background: var(--border); }
.step.active .bar, .step.done .bar { background: var(--accent); }
.step .lbl { font-family: var(--f-mono); text-transform: uppercase; letter-spacing: .08em; font-size: 10.5px; color: var(--muted); margin-top: 6px; }
.step.active .lbl { color: var(--accent); }

/* snippet block */
.snippet { background: #12151B; color: #e6e9ef; font-family: var(--f-mono); font-size: 12.5px; padding: 14px 16px; border-radius: var(--r-md); overflow-x: auto; white-space: pre; line-height: 1.6; }
.snippet .tag { color: #7FB069; }
.snippet .attr { color: #C99a6b; }

/* verify states */
.verify { text-align: center; padding: 20px 0; }
.verify .glyph { width: 40px; height: 40px; gap: 5px; margin: 0 auto 14px; }
.verify.ok .glyph .cell { border-color: var(--success); }
.verify.ok .glyph .cell.on { background: var(--success); }
.verify.fail .glyph .cell { border-color: var(--danger); }

/* --- portal de preferências --------------------------------------- */
.portal { max-width: 640px; margin: 0 auto; padding: 40px 20px 80px; }
.portal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.portal-head img { max-height: 40px; max-width: 160px; }
.portal .lead { color: var(--muted); margin: 0 0 24px; }
.portal .card { background: var(--card); }
.cat-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border); }
.cat-row:first-child { border-top: 0; }
.cat-name { font-weight: 600; font-size: 14px; }
.cat-desc { color: var(--muted); font-size: 13px; margin: 2px 0 0; }

/* htmx / alpine helpers */
[x-cloak] { display: none !important; }
.htmx-indicator { opacity: 0; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: .7; }

/* --- customizer --------------------------------------------------- */
.cz-grid { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.cz-rail { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; }
.cz-sec { border-top: 1px solid var(--border); padding: 14px 0; }
.cz-sec:first-child { border-top: 0; padding-top: 0; }
.cz-sec > .lbl { font-family: var(--f-mono); text-transform: uppercase; letter-spacing: .08em; font-size: 10.5px; color: var(--muted); margin-bottom: 10px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { flex: 1; min-width: 72px; text-align: center; padding: 8px 6px; border: 1px solid var(--border-strong); border-radius: var(--r-md); font-size: 12.5px; cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg input:checked + span, .seg label:has(input:checked) { }
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); color: var(--accent); }
.swatches { display: flex; gap: 10px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; }
.swatch.on { outline: 2px solid var(--focus); outline-offset: 2px; }
.range { width: 100%; accent-color: var(--accent); }
.checks label { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; }
.lang-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.lang-tabs button { border: 1px solid var(--border-strong); background: transparent; border-radius: var(--r-md); padding: 5px 10px; font-size: 12px; cursor: pointer; color: var(--ink); font-family: var(--f-sans); }
.lang-tabs button.on { background: var(--accent); border-color: var(--accent); color: var(--forest-ink); }
.cz-preview { position: sticky; top: 20px; }
.cz-preview iframe { width: 100%; height: 520px; border: 1px solid var(--border); border-radius: var(--r-lg); background: #dcd7cb; }
.publish-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.ver-list .ver { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.ver-list .ver:first-child { border-top: 0; }

/* receipt drawer */
.drawer-back { position: fixed; inset: 0; background: rgba(8,10,14,.4); z-index: 900; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(420px, 92vw); background: var(--card); border-left: 1px solid var(--border); box-shadow: var(--shadow-drawer); z-index: 901; padding: 24px; overflow-y: auto; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--border); font-size: 13px; }
.kv .k { color: var(--muted); }
.kv .v { font-family: var(--f-mono); text-align: right; word-break: break-all; }

/* auth */
.auth { max-width: 380px; margin: 8vh auto; padding: 0 20px; }
.auth .card { padding: 28px; }

@media (max-width: 860px) { .cz-grid { grid-template-columns: 1fr; } .cz-preview { position: static; } }

@media (max-width: 720px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin: 0 0 0 auto; }
  .main { padding: 20px 16px; }
  .logtable .th, .logtable .tr { grid-template-columns: 1fr 90px; }
  .logtable .th span:nth-child(2), .logtable .tr .ts, .logtable .col-hide { display: none; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
