/* ContaFácil design system — tokens → base → componentes.
   Referências: Linear (densidade calma), Stripe/Ramp (tabelas financeiras), Vercel (economia de cor), Radix (escalas acessíveis). */
@font-face { font-family: "Inter"; src: url("/fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("/fonts/instrument-serif.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("/fonts/instrument-serif-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  color-scheme: light;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;

  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #f8f9fc; --border: #e3e7ef; --border-strong: #cdd3e0;
  --text: #0b1220; --muted: #596380; --faint: #8a93ab;
  --primary: #2447d8; --primary-hover: #1a38b3; --primary-contrast: #ffffff; --primary-soft: #e8edfe; --primary-ring: rgb(36 71 216 / .28);
  --ok: #067647; --ok-bg: #e3f6ec; --ok-solid: #12b76a;
  --warn: #9a4a05; --warn-bg: #fef0c7; --warn-solid: #f79009;
  --err: #b42318; --err-bg: #fee4e2; --err-solid: #f04438;
  --side: #0a1330; --side-text: #b9c3dd; --side-hover: rgb(255 255 255 / .07); --side-active: rgb(255 255 255 / .12);

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px;
  --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem; --s5: 1.5rem; --s6: 2rem; --s7: 3rem; --s8: 5rem;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / .05), 0 1px 3px rgb(16 24 40 / .06);
  --shadow-md: 0 10px 30px -12px rgb(16 24 40 / .22), 0 2px 6px rgb(16 24 40 / .05);
  --shadow-lg: 0 30px 60px -24px rgb(11 27 77 / .35), 0 8px 20px -8px rgb(16 24 40 / .12);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #090e1d; --surface: #101733; --surface-2: #0c1229; --border: #222b4a; --border-strong: #333f66;
  --text: #eef1f9; --muted: #9ea9c6; --faint: #6f7a99;
  --primary: #7b9bff; --primary-hover: #9db4ff; --primary-contrast: #0a1030; --primary-soft: #1a2552; --primary-ring: rgb(123 155 255 / .35);
  --ok: #5fd99a; --ok-bg: #0f2e22; --ok-solid: #32d583;
  --warn: #f5c35c; --warn-bg: #33270b; --warn-solid: #fdb022;
  --err: #ff9a90; --err-bg: #3a1613; --err-solid: #f97066;
  --side: #060a18; --side-text: #9ea9c6;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-md: 0 10px 30px -12px rgb(0 0 0 / .6);
  --shadow-lg: 0 30px 60px -24px rgb(0 0 0 / .7);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 15px/1.55 var(--font); font-feature-settings: "cv11", "ss03"; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0 0 var(--s3); line-height: 1.2; letter-spacing: -.02em; font-weight: 650; }
p { margin: 0 0 var(--s3); }
a { color: var(--primary); }
img { max-width: 100%; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--primary-ring); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--primary-soft); }
.num { font-variant-numeric: tabular-nums; }
.serif { font-family: var(--serif); font-weight: 400; font-style: italic; letter-spacing: 0; }
.skip { position: absolute; left: -999px; top: 0; } .skip:focus { left: var(--s4); top: var(--s4); background: var(--surface); padding: var(--s3) var(--s4); z-index: 100; border-radius: var(--r-sm); box-shadow: var(--shadow-md); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ícones */
.i { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i.lg { width: 1.5em; height: 1.5em; }

/* botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 42px; padding: 0 var(--s4); border: 1px solid var(--primary);
  border-radius: var(--r-sm); background: var(--primary); color: var(--primary-contrast); font-weight: 600; font-size: .9375rem; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; box-shadow: var(--shadow-sm); white-space: nowrap; }
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--surface-2); border-color: var(--faint); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.btn.ghost:hover { background: var(--primary-soft); color: var(--primary); }
.btn.danger { background: var(--err-bg); border-color: transparent; color: var(--err); box-shadow: none; }
.btn.danger:hover { background: var(--err-solid); color: #fff; }
.btn.sm { min-height: 34px; padding: 0 var(--s3); font-size: .8125rem; }
.btn.icon { width: 34px; min-height: 34px; padding: 0; }
.btn.lg { min-height: 50px; padding: 0 var(--s5); font-size: 1rem; border-radius: var(--r-md); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: progress; }

/* formulários */
label { display: block; font-weight: 600; font-size: .8125rem; margin-bottom: var(--s1); }
input, select { width: 100%; min-height: 42px; padding: 0 var(--s3); border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s; }
input::placeholder { color: var(--faint); }
input:hover, select:hover { border-color: var(--faint); }
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
input[aria-invalid="true"] { border-color: var(--err-solid); }
.field { margin-bottom: var(--s4); }
.hint { color: var(--muted); font-size: .8125rem; margin-top: var(--s1); }
.input-wrap { position: relative; } .input-wrap input { padding-right: 46px; }
.input-wrap .btn { position: absolute; right: 4px; top: 4px; }
.input-icon { position: relative; } .input-icon > .i { position: absolute; left: 12px; top: 50%; translate: 0 -50%; color: var(--faint); pointer-events: none; } .input-icon input { padding-left: 38px; }

/* superfícies */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s5); box-shadow: var(--shadow-sm); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.card-head h3 { margin: 0; font-size: 1rem; }

/* badges & status (nunca só cor: ponto + texto) */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.erro { background: var(--err-bg); color: var(--err); } .badge.aviso { background: var(--warn-bg); color: var(--warn); }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.info, .badge.neutral { background: var(--primary-soft); color: var(--primary); }

.msg { display: flex; gap: var(--s2); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-sm); margin-bottom: var(--s4); font-size: .875rem; }
.msg.erro { background: var(--err-bg); color: var(--err); } .msg.aviso { background: var(--warn-bg); color: var(--warn); } .msg.ok { background: var(--ok-bg); color: var(--ok); }
.toasts { position: fixed; right: var(--s4); bottom: var(--s4); display: grid; gap: var(--s2); z-index: 60; max-width: min(420px, calc(100vw - 2rem)); }
.toast { box-shadow: var(--shadow-md); margin: 0; border: 1px solid var(--border); animation: rise .25s ease; background: var(--surface) !important; color: var(--text) !important; }
.toast.erro { border-color: var(--err-solid); } .toast.ok { border-color: var(--ok-solid); } .toast.aviso { border-color: var(--warn-solid); }
.toast .i { margin-top: 2px; } .toast.erro .i { color: var(--err-solid); } .toast.ok .i { color: var(--ok-solid); } .toast.aviso .i { color: var(--warn-solid); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* tabelas */
.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; padding: var(--s3) var(--s5); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: var(--s3) var(--s5); border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; } tbody tr:hover { background: var(--surface-2); }
td.right, th.right { text-align: right; font-variant-numeric: tabular-nums; }
.cell-actions { display: flex; gap: 2px; justify-content: flex-end; }

.avatar { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: .8125rem; color: #fff; flex: none; }
.who { display: flex; align-items: center; gap: var(--s3); } .who strong { display: block; font-weight: 600; } .who small { color: var(--muted); }

.meter { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; min-width: 90px; }
.meter > span { display: block; height: 100%; width: calc(var(--v, 0) * 1%); border-radius: inherit; background: var(--ok-solid); transition: width .5s ease; }
.meter.warn > span { background: var(--warn-solid); } .meter.erro > span { background: var(--err-solid); }

.empty { text-align: center; padding: var(--s7) var(--s5); color: var(--muted); }
.empty .art { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto var(--s4); display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.empty .art .i { width: 28px; height: 28px; }
.empty h3 { color: var(--text); font-size: 1.05rem; margin-bottom: var(--s1); }
.skeleton { display: block; height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--border), var(--surface-2), var(--border)); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }

dialog { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--text); padding: 0; width: min(560px, calc(100vw - 2rem)); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgb(6 10 24 / .55); backdrop-filter: blur(3px); }
dialog form { padding: var(--s5); } dialog h3 { font-size: 1.15rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s4); }

.theme-btn .sun { display: none; } :root[data-theme="dark"] .theme-btn .sun { display: block; } :root[data-theme="dark"] .theme-btn .moon { display: none; }

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