/* ==========================================================
   EXATO — Design System
   ========================================================== */
:root {
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Manrope', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --ink-950: #070B16;
  --ink-900: #0C1222;
  --ink-800: #141C30;
  --ink-700: #1E2840;

  --bg: #F3F5F9;
  --bg-2: #EBEEF4;
  --surface: #FFFFFF;
  --surface-2: #F8F9FC;
  --line: #E3E7EF;
  --line-2: #D5DBE6;
  --text: #0E1525;
  --text-2: #3A4458;
  --muted: #6B7489;

  --brand: #1D4ED8;
  --brand-600: #1E40AF;
  --brand-50: #EEF3FF;
  --brand-100: #DCE6FF;
  --teal: #0D9488;
  --gold: #B8913F;
  --gold-50: #FBF6EA;

  --pos: #0B8A4F;
  --pos-50: #E8F6EE;
  --neg: #C62828;
  --neg-50: #FDECEC;
  --warn: #B45309;
  --warn-50: #FEF5E7;
  --info: #1D4ED8;
  --info-50: #EEF3FF;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --sh-1: 0 1px 2px rgba(14, 21, 37, .06), 0 1px 1px rgba(14, 21, 37, .04);
  --sh-2: 0 4px 14px -4px rgba(14, 21, 37, .10), 0 2px 4px rgba(14, 21, 37, .04);
  --sh-3: 0 24px 48px -16px rgba(14, 21, 37, .22), 0 6px 14px -6px rgba(14, 21, 37, .10);
  --ring: 0 0 0 4px rgba(29, 78, 216, .16);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0A0F1C;
  --bg-2: #0F1627;
  --surface: #121A2C;
  --surface-2: #172036;
  --line: #222D45;
  --line-2: #2C3953;
  --text: #EEF2FA;
  --text-2: #C3CAD9;
  --muted: #8B95AB;
  --brand: #5B8CFF;
  --brand-600: #7AA2FF;
  --brand-50: #16224A;
  --brand-100: #1C2C5C;
  --teal: #2DD4BF;
  --gold: #E0BC6A;
  --gold-50: #2A2414;
  --pos: #34D399;
  --pos-50: #0F2A20;
  --neg: #FF7A7A;
  --neg-50: #341719;
  --warn: #FBBF24;
  --warn-50: #2E2410;
  --info: #7AA2FF;
  --info-50: #16224A;
  --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-2: 0 6px 18px -6px rgba(0, 0, 0, .55);
  --sh-3: 0 24px 48px -16px rgba(0, 0, 0, .7);
  --ring: 0 0 0 4px rgba(91, 140, 255, .22);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font-ui); font-size: 14.5px; line-height: 1.5; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01';
}
h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -.02em; margin: 0; color: var(--text); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
.num, .money-out { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
::selection { background: var(--brand-100); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

/* ---------- Botões ---------- */
.btn {
  --b-bg: var(--surface); --b-fg: var(--text); --b-bd: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--b-bd); background: var(--b-bg); color: var(--b-fg);
  font: 600 13.5px/1 var(--font-ui); letter-spacing: .005em; cursor: pointer; white-space: nowrap; user-select: none;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s, border-color .18s, color .18s;
  position: relative; overflow: hidden; text-decoration: none !important;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--sh-2); }
.btn:active { transform: translateY(0) scale(.98); box-shadow: none; }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn-primary { --b-bg: linear-gradient(180deg, #2A5CF0 0%, #1D4ED8 100%); --b-fg: #fff; --b-bd: transparent; background: var(--b-bg); box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 6px 16px -6px rgba(29, 78, 216, .55); }
.btn-primary:hover { box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 12px 24px -8px rgba(29, 78, 216, .6); }
.btn-gold { background: linear-gradient(180deg, #D3AE5C 0%, #B8913F 100%); color: #1B1406; border-color: transparent; box-shadow: 0 6px 16px -6px rgba(184, 145, 63, .6); }
.btn-dark { --b-bg: var(--ink-900); --b-fg: #fff; --b-bd: var(--ink-700); }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-2); box-shadow: none; }
.btn-danger { --b-fg: var(--neg); --b-bd: color-mix(in srgb, var(--neg) 30%, transparent); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; padding: 0; }
.btn[disabled], .btn.loading { opacity: .65; pointer-events: none; }
.btn.loading::after { content: ''; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.ripple { position: absolute; border-radius: 50%; transform: scale(0); background: currentColor; opacity: .18; animation: ripple .55s var(--ease); pointer-events: none; }
@keyframes ripple { to { transform: scale(2.6); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formulários ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .lbl { font-size: 12.5px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.field .hint { font-size: 11.5px; color: var(--muted); }
.input, .select, textarea.input {
  width: 100%; height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--text); font: 500 14px/1.2 var(--font-ui);
  transition: border-color .15s, box-shadow .15s, background .15s; appearance: none; -webkit-appearance: none;
}
textarea.input { height: auto; padding: 10px 12px; line-height: 1.5; resize: vertical; }
.input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); font-weight: 400; }
.input:hover, .select:hover { border-color: color-mix(in srgb, var(--brand) 35%, var(--line-2)); }
.input:focus, .select:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.select { padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7489' stroke-width='2.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 12px center; cursor: pointer; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .prefix { position: absolute; left: 12px; font-size: 13px; font-weight: 600; color: var(--muted); pointer-events: none; }
.input-group .input.has-prefix { padding-left: 38px; }
.input-group .suffix { position: absolute; right: 12px; font-size: 12px; color: var(--muted); pointer-events: none; }
.input.money, .input.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.input.invalid { border-color: var(--neg); box-shadow: 0 0 0 4px color-mix(in srgb, var(--neg) 14%, transparent); }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 13px; font-weight: 500; color: var(--text-2); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 38px; height: 22px; border-radius: 99px; background: var(--line-2); position: relative; transition: background .2s var(--ease); flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .22s var(--ease); }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }

/* Segmented */
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--bg-2); border: 1px solid var(--line); gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; height: 32px; padding: 0 12px; border-radius: 8px; font: 600 12.5px var(--font-ui); color: var(--muted); cursor: pointer; transition: all .18s var(--ease); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }

/* ---------- Cartões ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.card-head .ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); flex: none; }
.card-head .ico svg { width: 16px; height: 16px; }

/* ---------- Etiquetas ---------- */
.tag { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--bg-2); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap; }
.tag.pos { background: var(--pos-50); color: var(--pos); border-color: transparent; }
.tag.neg { background: var(--neg-50); color: var(--neg); border-color: transparent; }
.tag.warn { background: var(--warn-50); color: var(--warn); border-color: transparent; }
.tag.info { background: var(--info-50); color: var(--info); border-color: transparent; }
.tag.gold { background: var(--gold-50); color: var(--gold); border-color: transparent; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent); }
.dot.live { animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ---------- Alertas ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: 11px; font-size: 12.8px; line-height: 1.45; border: 1px solid transparent; }
.alert svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.alert.info { background: var(--info-50); color: color-mix(in srgb, var(--info) 75%, var(--text)); }
.alert.alerta { background: var(--warn-50); color: color-mix(in srgb, var(--warn) 80%, var(--text)); }
.alert.prazo { background: var(--gold-50); color: color-mix(in srgb, var(--gold) 70%, var(--text)); border-color: color-mix(in srgb, var(--gold) 25%, transparent); }
.alert.erro { background: var(--neg-50); color: var(--neg); }
.alert.ok { background: var(--pos-50); color: var(--pos); }

/* ---------- Tabelas ---------- */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.2px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.num, .table td.r { white-space: nowrap; }
.table .cod { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }

/* ---------- Toast e modal ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; }
.toast { min-width: 260px; max-width: 380px; padding: 12px 14px; border-radius: 12px; background: var(--ink-900); color: #fff; box-shadow: var(--sh-3); font-size: 13.2px; display: flex; gap: 10px; align-items: center; animation: toastIn .35s var(--ease); }
.toast.ok { background: linear-gradient(180deg, #0F9D58, #0B8A4F); }
.toast.erro { background: linear-gradient(180deg, #D93025, #B71C1C); }
.toast.saindo { animation: toastOut .25s var(--ease) forwards; }
@keyframes toastIn { from { transform: translateY(14px) scale(.97); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(8px); opacity: 0; } }
.modal-bg { position: fixed; inset: 0; background: rgba(7, 11, 22, .55); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 9000; padding: 20px; animation: fade .2s; }
.modal { width: min(560px, 100%); max-height: 90vh; overflow: auto; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-3); border: 1px solid var(--line); animation: pop .28s var(--ease); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }

/* ---------- Utilidades ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.xs { font-size: 11.5px; }
.b { font-weight: 700; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.hide { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.skeleton { background: linear-gradient(90deg, var(--bg-2) 25%, var(--line) 37%, var(--bg-2) 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: 6px; }
@keyframes sk { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
.fade-in { animation: fadeUp .45s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 900px) {
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }
