/* SONAFE · Controle Financeiro — design system */

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f7;
  --text: #0f1b2d;
  --muted: #5b6b82;
  --subtle: #8a97ab;
  --border: #e3e8f0;
  --border-strong: #cfd7e3;
  --primary: #1d4ed8;
  --primary-600: #1e40af;
  --primary-soft: #e8efff;
  --primary-contrast: #ffffff;
  --navy: #0b2545;
  --navy-2: #13315c;
  --in: #067647;
  --in-bg: #e7f8ef;
  --out: #b42318;
  --out-bg: #fdeceb;
  --warn: #9a4a07;
  --warn-bg: #fff4e0;
  --info: #175cd3;
  --info-bg: #eaf2ff;
  --focus: #2e6bff;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --bottom-nav-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1220;
    --surface: #101a2c;
    --surface-2: #142039;
    --surface-3: #1a2945;
    --text: #e7ecf5;
    --muted: #9fadc4;
    --subtle: #73839e;
    --border: #22314d;
    --border-strong: #2e4166;
    --primary: #6b9dff;
    --primary-600: #8cb3ff;
    --primary-soft: #18294d;
    --primary-contrast: #07152e;
    --navy: #07101f;
    --navy-2: #0f1c33;
    --in: #4cd38f;
    --in-bg: #0f2f22;
    --out: #ff8a7a;
    --out-bg: #3a1714;
    --warn: #f5b04c;
    --warn-bg: #3a2a0d;
    --info: #84b4ff;
    --info-bg: #142a4d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.45rem; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sprite { display: none; }
[hidden] { display: none !important; }

.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 26px; height: 26px; }

/* ------------------------------------------------------------- utilities */
.muted { color: var(--muted); }
.subtle { color: var(--subtle); }
.small { font-size: .85rem; }
.xsmall { font-size: .76rem; }
.strong { font-weight: 650; }
.num, .amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.center { text-align: center; }
.right { text-align: right; }
.amount-in { color: var(--in); }
.amount-out { color: var(--out); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.grid > *, .grid-2 > *, .grid-3 > *, .grid-4 > * { min-width: 0; }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.divider { height: 1px; background: var(--border); margin: 4px 0; border: 0; }
.kbd { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85em; background: var(--surface-3); padding: 1px 6px; border-radius: 6px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .02em; }
@media (max-width: 1023px) { .hide-mobile { display: none !important; } }
@media (min-width: 1024px) { .hide-desktop { display: none !important; } }
.print-only { display: none; }

/* ------------------------------------------------------------------ boot */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #2f6bff, #0b2545); color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15);
}
.brand-mark-lg { width: 56px; height: 56px; font-size: 26px; border-radius: 16px; }

/* ---------------------------------------------------------------- layout */
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 30;
  background: var(--navy); color: #d7e1f5; display: flex; flex-direction: column; padding: 18px 14px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brand-name { font-weight: 750; color: #fff; letter-spacing: .01em; }
.brand-sub { font-size: .78rem; color: #9fb3d9; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: #c5d3ee; font-weight: 550; text-decoration: none; border: 0; background: transparent; width: 100%;
  cursor: pointer; text-align: left;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(84, 132, 255, .22); color: #fff; }
.nav-section { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .1); padding-top: 12px; }
.user-box { display: flex; align-items: center; gap: 10px; padding: 8px 10px 12px; }
.user-box .name { color: #fff; font-weight: 600; font-size: .9rem; }
.user-box .role { color: #9fb3d9; font-size: .76rem; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: #2b4c86; color: #fff; font-weight: 700; font-size: .85rem;
}

.main { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 700; font-size: 1.05rem; }
.topbar .brand-mark { width: 30px; height: 30px; font-size: 15px; border-radius: 9px; }
.page { padding: 18px 16px calc(var(--bottom-nav-h) + 28px + env(safe-area-inset-bottom)); max-width: 1320px; margin: 0 auto; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-header .subtitle { color: var(--muted); margin-top: 2px; font-size: .92rem; }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.section { margin-top: 22px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }

@media (min-width: 1024px) {
  .main { margin-left: var(--sidebar-w); }
  .topbar { padding: 0 28px; }
  .page { padding: 24px 28px 40px; }
}
@media (max-width: 1023px) {
  .sidebar { display: none; }
}

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  box-shadow: 0 -4px 16px rgba(16, 24, 40, .06);
}
.bottom-nav a, .bottom-nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 100%; color: var(--muted); font-size: .7rem; font-weight: 600; text-decoration: none;
  border: 0; background: transparent; cursor: pointer;
}
.bottom-nav .active { color: var(--primary); }
.bottom-nav .nav-add { position: relative; }
.bottom-nav .nav-add span.add-circle {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; margin-top: -26px;
  background: var(--primary); color: var(--primary-contrast); box-shadow: 0 6px 18px rgba(29, 78, 216, .4);
  border: 4px solid var(--surface);
}
.bottom-nav .nav-add .icon { width: 24px; height: 24px; stroke-width: 2.4; }
@media (min-width: 1024px) { .bottom-nav { display: none; } }

/* ------------------------------------------------------------------ cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 6px 10px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card-title { font-weight: 650; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 16px; }
.card-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.card-link { display: block; color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
.card-link:hover { border-color: var(--border-strong); text-decoration: none; transform: translateY(-1px); }

.kpi { padding: 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi-label { color: var(--muted); font-size: .82rem; font-weight: 600; display: flex; align-items: center; gap: 6px; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.45rem; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.01em; overflow-wrap: anywhere; }
.kpi-sub { color: var(--muted); font-size: .82rem; }
.kpi-in .kpi-value { color: var(--in); }
.kpi-out .kpi-value { color: var(--out); }
.kpi-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; }
.kpi-in .kpi-icon { background: var(--in-bg); color: var(--in); }
.kpi-out .kpi-icon { background: var(--out-bg); color: var(--out); }
.kpi-neutral .kpi-icon { background: var(--primary-soft); color: var(--primary); }
.kpi-icon.kpi-in { background: var(--in-bg); color: var(--in); }
.kpi-icon.kpi-out { background: var(--out-bg); color: var(--out); }
.kpi-icon.kpi-neutral { background: var(--primary-soft); color: var(--primary); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: .94rem; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-600); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: var(--out); color: #fff; }
.btn-danger:hover { filter: brightness(.95); }
.btn-danger-ghost { background: transparent; color: var(--out); }
.btn-danger-ghost:hover { background: var(--out-bg); }
.btn-success { background: var(--in); color: #fff; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .86rem; border-radius: 8px; }
.btn-lg { min-height: 50px; padding: 0 22px; font-size: 1rem; }
.btn-icon { width: 42px; padding: 0; }
.btn-icon.btn-sm { width: 34px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: .6; cursor: not-allowed; pointer-events: none; }
.btn.is-loading::after {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: .74rem; font-weight: 650; line-height: 1.5; white-space: nowrap; background: var(--surface-3); color: var(--muted);
}
.badge-in { background: var(--in-bg); color: var(--in); }
.badge-out { background: var(--out-bg); color: var(--out); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--surface-3); color: var(--muted); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: .86rem; font-weight: 550;
  cursor: pointer; white-space: nowrap;
}
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chip .icon { width: 14px; height: 14px; }

/* ------------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-weight: 600; font-size: .88rem; }
.field .hint { color: var(--muted); font-size: .8rem; }
.field .error, .form-error { color: var(--out); font-size: .84rem; font-weight: 550; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--out); }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; font-size: 16px;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.input-money { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; font-size: 1.1rem; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-left: 40px; }
.input-group .icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.input-group .input-suffix { position: absolute; right: 6px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.span-2 { grid-column: 1 / -1; }
.checkbox { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: .92rem; }
.checkbox input { width: 20px; height: 20px; accent-color: var(--primary); }

.segmented { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
@media (min-width: 560px) { .segmented { grid-template-columns: repeat(4, 1fr); } }
.segmented button {
  min-height: 44px; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); font-weight: 600; font-size: .84rem; cursor: pointer; line-height: 1.2;
}
.segmented button.active[data-nature="entrada"] { background: var(--in-bg); border-color: var(--in); color: var(--in); }
.segmented button.active[data-nature="saida"] { background: var(--out-bg); border-color: var(--out); color: var(--out); }
.segmented button.active:not([data-nature]) { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 999px; background: var(--border-strong); position: relative; flex: none; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: var(--shadow); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(18px); }

/* ----------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; white-space: nowrap; z-index: 1; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr.clickable { cursor: pointer; }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 700; background: var(--surface-2); }
.table .sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 2; }
.table th.sticky-col { background: var(--surface-2); z-index: 3; }
.table tbody tr:hover td.sticky-col { background: var(--surface-2); }
.table td.zero { color: var(--subtle); }

/* ------------------------------------------------------------------ lists */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; min-height: 60px; }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-2); text-decoration: none; }
button.list-item { width: 100%; background: transparent; border: 0; border-bottom: 1px solid var(--border); text-align: left; cursor: pointer; font: inherit; }
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item-sub { color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item-side { text-align: right; flex: none; }

/* ------------------------------------------------------------ empty/skel */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 36px 16px; color: var(--muted); }
.empty-state .icon { width: 40px; height: 40px; color: var(--subtle); stroke-width: 1.6; }
.empty-state .title { font-weight: 650; color: var(--text); }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px; min-height: 14px; }
.skeleton-row { height: 52px; margin: 8px 16px; }
.skeleton-kpi { height: 96px; border-radius: var(--radius); }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ------------------------------------------------------------------- tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; margin-bottom: 16px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 10px 14px; border: 0; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ----------------------------------------------------------------- modals */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(8, 15, 30, .55);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease;
}
.modal {
  background: var(--surface); width: 100%; max-height: 92vh; display: flex; flex-direction: column;
  border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg); animation: slide-up .2s ease;
  padding-bottom: env(safe-area-inset-bottom);
}
.modal-header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-title { font-weight: 700; font-size: 1.05rem; flex: 1; min-width: 0; }
.modal-body { padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; }
.modal-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal-footer .btn { flex: 1 1 auto; }
@media (min-width: 720px) {
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { max-width: 560px; border-radius: 16px; max-height: 88vh; animation: pop .16s ease; }
  .modal-lg { max-width: 860px; }
  .modal-xl { max-width: 1100px; }
  .modal-footer .btn { flex: 0 0 auto; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(24px); opacity: .6; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }

/* ----------------------------------------------------------------- toasts */
.toast-container {
  position: fixed; z-index: 200; left: 12px; right: 12px; bottom: calc(var(--bottom-nav-h) + 14px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
@media (min-width: 1024px) { .toast-container { left: auto; right: 24px; bottom: 24px; align-items: flex-end; } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 460px; width: 100%;
  padding: 12px 14px; border-radius: 12px; background: #142039; color: #fff; box-shadow: var(--shadow-lg);
  animation: slide-up .2s ease; font-size: .92rem;
}
.toast-success { background: #05603a; }
.toast-error { background: #912018; }
.toast .toast-msg { flex: 1; }
.toast button { background: rgba(255, 255, 255, .16); color: #fff; border: 0; border-radius: 8px; padding: 6px 10px; font-weight: 650; cursor: pointer; }

/* ------------------------------------------------------------ misc parts */
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--primary); animation: spin .8s linear infinite; }
.spinner-lg { width: 40px; height: 40px; border-width: 4px; }
.progress { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); width: 0; transition: width .2s; }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; font-size: .9rem; align-items: flex-start; }
.callout .icon { margin-top: 1px; }
.callout-info { background: var(--info-bg); color: var(--info); }
.callout-warn { background: var(--warn-bg); color: var(--warn); }
.callout-error { background: var(--out-bg); color: var(--out); }
.callout-success { background: var(--in-bg); color: var(--in); }
.callout a { color: inherit; text-decoration: underline; font-weight: 650; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); }
.dropzone.dragover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.chart-box { position: relative; height: 280px; }
.chart-box-sm { position: relative; height: 220px; }
.bar-list { display: flex; flex-direction: column; gap: 12px; }
.bar-item .row-between { font-size: .9rem; }
.bar-track { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--primary); }
.bar-fill.in { background: var(--in); }
.bar-fill.out { background: var(--out); }
.uf-badge {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--primary-soft); color: var(--primary); font-weight: 800; letter-spacing: .03em;
}
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: .92rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ----------------------------------------------------------------- print */
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --border: #bbb; }
  body { font-size: 11pt; }
  .sidebar, .topbar, .bottom-nav, .toast-container, .no-print, .page-header .actions { display: none !important; }
  .main { margin: 0 !important; }
  .page { padding: 0 !important; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  .table-wrap { overflow: visible; }
  .table th { position: static; }
  .print-only { display: block; }
  a { color: inherit; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
