/* ==========================================================================
   Portal do Cliente — base visual
   As cores da marca chegam de /theme.css (--brand, --brand-2, --accent, --on-*).
   Todo o resto da paleta é derivado aqui com color-mix(), então trocar 3 cores
   no painel admin recolore o portal inteiro.
   ========================================================================== */

@font-face {
  font-family: "Bricolage";
  font-style: normal; font-display: swap;
  font-weight: 200 800; font-stretch: 75% 100%;
  src: url(/fonts/bricolage-grotesque-latin-ext-standard-normal.woff2) format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Bricolage";
  font-style: normal; font-display: swap;
  font-weight: 200 800; font-stretch: 75% 100%;
  src: url(/fonts/bricolage-grotesque-latin-standard-normal.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Figtree";
  font-style: normal; font-display: swap; font-weight: 300 900;
  src: url(/fonts/figtree-latin-ext-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Figtree";
  font-style: normal; font-display: swap; font-weight: 300 900;
  src: url(/fonts/figtree-latin-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Tokens ---------- */
:root {
  /* fallback caso /theme.css não carregue */
  --brand: #0F6E5A; --brand-2: #14324A; --accent: #F2B705;
  --on-brand: #fff; --on-brand-2: #fff; --on-accent: #0E1116;

  --font-display: "Bricolage", "Segoe UI", system-ui, sans-serif;
  --font-body: "Figtree", "Segoe UI", system-ui, sans-serif;

  --fs-xs: .8125rem; --fs-sm: .9375rem; --fs-md: 1rem; --fs-lg: 1.25rem;
  --fs-xl: 1.5625rem; --fs-2xl: 1.953rem; --fs-3xl: 2.441rem; --fs-4xl: 3.052rem; --fs-5xl: 3.815rem;

  --r-sheet: 22px; --r-card: 14px; --r-field: 12px; --r-pill: 999px;
  --gap: 1rem;
  --ease: cubic-bezier(.2, .8, .2, 1);

  color-scheme: light;
  --bg: #EEF1F4;
  --surface: #FFFFFF;
  --raised: #F7F9FB;
  --ink: #141A21;
  --muted: #5A6572;
  --line: #DCE1E7;
  --danger: #C2361F;
  --warn: #A15C00;
  --ok: #17803D;

  --brand-ink: color-mix(in oklab, var(--brand) 88%, black);
  --brand-soft: color-mix(in oklab, var(--brand) 11%, var(--surface));
  --brand-line: color-mix(in oklab, var(--brand) 32%, var(--line));
  --accent-soft: color-mix(in oklab, var(--accent) 22%, var(--surface));
  --shadow-1: 0 1px 2px color-mix(in oklab, var(--brand-2) 14%, transparent);
  --shadow-2: 0 12px 32px -12px color-mix(in oklab, var(--brand-2) 35%, transparent);
  --focus: 0 0 0 3px var(--surface), 0 0 0 5px var(--brand);
}

/* Tema escuro: o JS aplica .dark-now quando o usuário escolhe "escuro" ou "auto" com o sistema escuro */
:root.dark-now {
  color-scheme: dark;
  --bg: #0E1318;
  --surface: #161D24;
  --raised: #1C252E;
  --ink: #E7ECF1;
  --muted: #95A2B0;
  --line: #2A3540;
  --danger: #FF7A63;
  --warn: #F3B13F;
  --ok: #5FD38A;
  --brand-ink: color-mix(in oklab, var(--brand) 55%, white);
  --brand-soft: color-mix(in oklab, var(--brand) 20%, var(--surface));
  --brand-line: color-mix(in oklab, var(--brand) 45%, var(--line));
  --accent-soft: color-mix(in oklab, var(--accent) 18%, var(--surface));
  --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-2: 0 18px 40px -16px rgb(0 0 0 / .7);
}

/* Alto contraste: fundo branco, tinta preta, bordas fortes */
:root[data-theme="contraste"] {
  --bg: #FFFFFF; --surface: #FFFFFF; --raised: #FFFFFF;
  --ink: #000000; --muted: #1F1F1F; --line: #000000;
  --brand-ink: color-mix(in oklab, var(--brand) 60%, black);
  --brand-soft: #FFFFFF; --brand-line: #000000; --accent-soft: #FFFFFF;
  --shadow-1: none; --shadow-2: none;
  --focus: 0 0 0 3px #fff, 0 0 0 6px #000;
}
:root[data-theme="contraste"] .card,
:root[data-theme="contraste"] .field input,
:root[data-theme="contraste"] .btn { border-width: 2px !important; }

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  background: var(--bg); color: var(--ink);
  font: 400 var(--fs-md)/1.55 var(--font-body);
  font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s var(--ease), color .25s var(--ease);
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-ink); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.1; margin: 0; letter-spacing: -0.01em; }

/* ---------- Botões ---------- */
.btn {
  --btn-bg: var(--brand); --btn-fg: var(--on-brand);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 48px; padding: 0 1.25rem;
  border: 1px solid transparent; border-radius: var(--r-field);
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 650; font-size: var(--fs-md); cursor: pointer;
  transition: transform .12s var(--ease), filter .2s, background-color .2s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; cursor: not-allowed; filter: none; transform: none; }
.btn.secondary { --btn-bg: var(--surface); --btn-fg: var(--ink); border-color: var(--line); }
.btn.ghost { --btn-bg: transparent; --btn-fg: var(--brand-ink); }
.btn.accent { --btn-bg: var(--accent); --btn-fg: var(--on-accent); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 0 .85rem; font-size: var(--fs-sm); border-radius: 10px; }
.btn .spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--ink);
}
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Campos ---------- */
.field { display: grid; gap: .35rem; }
.field label { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 50px; padding: .7rem .9rem;
  border: 1px solid var(--line); border-radius: var(--r-field);
  background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 22%, transparent); }
.field .hint { font-size: var(--fs-xs); color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

/* ---------- Mensagens ---------- */
.alert { padding: .75rem 1rem; border-radius: var(--r-field); font-size: var(--fs-sm); border: 1px solid; }
.alert.err { color: var(--danger); border-color: color-mix(in oklab, var(--danger) 40%, transparent); background: color-mix(in oklab, var(--danger) 8%, var(--surface)); }
.alert.info { color: var(--ink); border-color: var(--brand-line); background: var(--brand-soft); }

.toast-wrap { position: fixed; inset: auto 0 1rem 0; display: grid; justify-items: center; gap: .5rem; z-index: 90; pointer-events: none; padding: 0 1rem; }
.toast {
  pointer-events: auto; max-width: 30rem; padding: .8rem 1.1rem; border-radius: var(--r-field);
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow-2); font-size: var(--fs-sm);
  animation: toast-in .3s var(--ease);
}
.toast.err { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 650; background: var(--raised); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.chip.late { color: var(--danger); border-color: color-mix(in oklab, var(--danger) 35%, transparent); background: color-mix(in oklab, var(--danger) 9%, var(--surface)); }
.chip.soon { color: var(--warn); border-color: color-mix(in oklab, var(--warn) 35%, transparent); background: color-mix(in oklab, var(--warn) 10%, var(--surface)); }
.chip.proc { color: var(--brand-ink); border-color: var(--brand-line); background: var(--brand-soft); }
.chip.ok { color: var(--ok); border-color: color-mix(in oklab, var(--ok) 35%, transparent); background: color-mix(in oklab, var(--ok) 9%, var(--surface)); }

.skeleton { border-radius: var(--r-card); background: linear-gradient(90deg, var(--raised), color-mix(in oklab, var(--line) 60%, var(--raised)), var(--raised)); background-size: 300% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { to { background-position: -150% 0; } }

/* ---------- Menu de tema ---------- */
.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 220px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--shadow-2); padding: .4rem; display: grid; gap: 2px;
  animation: pop .18s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-pop button {
  display: flex; align-items: center; gap: .65rem; width: 100%; padding: .6rem .7rem; border: 0; background: none;
  border-radius: 10px; cursor: pointer; text-align: left; font-size: var(--fs-sm);
}
.menu-pop button:hover { background: var(--raised); }
.menu-pop button[aria-checked="true"] { background: var(--brand-soft); color: var(--brand-ink); font-weight: 650; }
.menu-pop .swatch { width: 22px; height: 22px; border-radius: 7px; border: 1px solid var(--line); flex: none; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: .3rem .2rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

.swatch-auto { background: linear-gradient(135deg, #fff 50%, #161D24 50%); }
.swatch-claro { background: #fff; }
.swatch-escuro { background: #161D24; }
.swatch-contraste { background: linear-gradient(135deg, #000 50%, #fff 50%); border-color: #000 !important; }

.logo { max-height: 40px; width: auto; }
.logo-text { font-family: var(--font-display); font-weight: 800; font-size: var(--fs-lg); letter-spacing: -0.02em; font-stretch: 85%; }
