/* Lose Eat Admin — styles. Plain CSS, no build. Brand tokens match frontend/site/style.css.
   Sections: fonts · tokens · base · login · shell · sidebar · topbar · page · cards · kpi
   · buttons · forms · tables · badges · menu · dialog · toast · charts · states · responsive */

/* ---------- fonts (Plus Jakarta Sans; OFL, see fonts/OFL.txt) ---------- */
@font-face { font-family: "Plus Jakarta Sans"; font-weight: 400 500; font-display: swap; src: url(fonts/jakarta-Medium.woff2) format("woff2"); }
@font-face { font-family: "Plus Jakarta Sans"; font-weight: 600 700; font-display: swap; src: url(fonts/jakarta-SemiBold.woff2) format("woff2"); }
@font-face { font-family: "Plus Jakarta Sans"; font-weight: 800; font-display: swap; src: url(fonts/jakarta-ExtraBold.woff2) format("woff2"); }

/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #fff;
  --surface-2: #fafbf9;
  --sunken: #f1f4f1;
  --line: #e4ebe6;
  --line-strong: #d0dcd3;
  --ink: #14211a;
  --ink-2: #33473b;
  --muted: #5b6e62;
  --faint: #8a9a90;

  --brand: #16a34a;          /* fills, bars, focus */
  --brand-strong: #15803d;   /* text + primary buttons (>= 4.5:1 on white) */
  --brand-ink: #fff;
  --brand-soft: #e7f5ec;
  --brand-line: #c8e3d0;

  --ok: #15803d;      --ok-soft: #e7f5ec;
  --warn: #a16207;    --warn-soft: #fdf3d0;
  --danger: #b42318;  --danger-soft: #fdecea;  --danger-line: #f5c2bc;
  --info: #0369a1;    --info-soft: #e4f4fc;
  --neutral-soft: #eef1ee;

  --sidebar: #10201a;
  --sidebar-ink: #c9d6ce;
  --sidebar-muted: #7f9488;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --sidebar-active: rgba(74, 222, 128, .12);
  --sidebar-active-ink: #fff;

  --r-xs: 6px;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 33, 26, .05);
  --shadow: 0 1px 2px rgba(20, 33, 26, .04), 0 8px 24px -12px rgba(20, 33, 26, .14);
  --shadow-lg: 0 24px 48px -16px rgba(20, 33, 26, .28);
  --ease: cubic-bezier(.22, .8, .3, 1);
  --sidebar-w: 248px;
  --topbar-h: 64px;
}

/* Dark: its own steps, not an inversion. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b120e; --surface: #121b16; --surface-2: #151f19; --sunken: #0f1712;
    --line: #223029; --line-strong: #2e3e35;
    --ink: #e6eee9; --ink-2: #c3d1c8; --muted: #93a69a; --faint: #6c7f73;
    --brand: #22c55e; --brand-strong: #4ade80; --brand-ink: #06210f; --brand-soft: #12301f; --brand-line: #1f4a31;
    --ok: #4ade80; --ok-soft: #12301f;
    --warn: #facc15; --warn-soft: #2e2810;
    --danger: #f87171; --danger-soft: #341716; --danger-line: #5a2522;
    --info: #38bdf8; --info-soft: #0f2a38;
    --neutral-soft: #1b2620;
    --sidebar: #08100c; --sidebar-hover: rgba(255, 255, 255, .05);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, .7);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b120e; --surface: #121b16; --surface-2: #151f19; --sunken: #0f1712;
  --line: #223029; --line-strong: #2e3e35;
  --ink: #e6eee9; --ink-2: #c3d1c8; --muted: #93a69a; --faint: #6c7f73;
  --brand: #22c55e; --brand-strong: #4ade80; --brand-ink: #06210f; --brand-soft: #12301f; --brand-line: #1f4a31;
  --ok: #4ade80; --ok-soft: #12301f;
  --warn: #facc15; --warn-soft: #2e2810;
  --danger: #f87171; --danger-soft: #341716; --danger-line: #5a2522;
  --info: #38bdf8; --info-soft: #0f2a38;
  --neutral-soft: #1b2620;
  --sidebar: #08100c; --sidebar-hover: rgba(255, 255, 255, .05);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, .7);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--ink);
  font: 500 .9375rem/1.55 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; color: var(--ink); }
p { margin: 0; }
a { color: var(--brand-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--r-xs); }
.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; }
.muted { color: var(--muted); }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 15px; height: 15px; }

/* ---------- login ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--brand-soft), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, var(--brand-soft), transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; padding: 36px 32px 28px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-brand img { width: 40px; height: 40px; border-radius: 10px; }
.login-brand b { display: block; font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; }
.login-brand span { display: block; font-size: .8125rem; color: var(--muted); }
.login h1 { font-size: 1.5rem; }
.login .lead { margin: 6px 0 24px; color: var(--muted); }
.login form { display: grid; gap: 16px; }
.login .btn { width: 100%; height: 44px; margin-top: 4px; }
.login-foot { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); font-size: .8125rem; color: var(--faint); display: flex; align-items: center; gap: 8px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.main { display: flex; flex-direction: column; min-width: 0; }

/* ---------- sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--sidebar); color: var(--sidebar-ink); padding: 18px 14px;
}
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 22px; color: #fff; }
.sb-brand img { width: 32px; height: 32px; border-radius: 8px; }
.sb-brand b { font-weight: 800; letter-spacing: -.01em; }
.sb-brand small { display: block; font-size: .6875rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--sidebar-muted); }
.sb-label { padding: 0 12px 8px; font-size: .6875rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--sidebar-muted); }
.sb-nav { display: grid; gap: 2px; }
.sb-nav a {
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: var(--r-sm);
  color: var(--sidebar-ink); font-weight: 600; text-decoration: none; transition: background .15s, color .15s;
}
.sb-nav a:hover { background: var(--sidebar-hover); color: #fff; }
.sb-nav a[aria-current="page"] { background: var(--sidebar-active); color: var(--sidebar-active-ink); box-shadow: inset 3px 0 0 #4ade80; }
.sb-nav a[aria-current="page"] .i { color: #4ade80; }
.sb-foot { margin-top: auto; display: grid; gap: 4px; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, .08); }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; min-width: 0; }
.avatar {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: #1f3a2c; color: #bbf7d0; font-weight: 800; font-size: .8125rem; text-transform: uppercase;
}
.sb-user div { min-width: 0; }
.sb-user b { display: block; font-size: .8125rem; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user span { display: block; font-size: .75rem; color: var(--sidebar-muted); }
.sb-btn {
  display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 12px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--sidebar-ink); font-weight: 600; cursor: pointer; text-align: left; width: 100%;
}
.sb-btn:hover { background: var(--sidebar-hover); color: #fff; }
.scrim { display: none; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h); padding: 0 32px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: .8125rem; color: var(--muted); min-width: 0; }
.crumbs b { color: var(--ink); font-weight: 700; }
.topbar .spacer { flex: 1; }
.menu-toggle { display: none; }
.env-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: .75rem; font-weight: 700; color: var(--muted);
}
.env-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---------- page ---------- */
.page { width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px 32px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { font-size: 1.625rem; }
.page-head p { margin-top: 4px; color: var(--muted); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack { display: grid; gap: 20px; }
.section-title { margin-bottom: 12px; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.grid-2 { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 1rem; letter-spacing: -.01em; }
.card-head p { font-size: .8125rem; color: var(--muted); margin-top: 2px; }
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r) var(--r); }

/* ---------- kpi ---------- */
.kpis { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.kpi { padding: 18px 20px; display: grid; gap: 10px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: .8125rem; font-weight: 700; color: var(--muted); }
.kpi-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--brand-soft); color: var(--brand-strong); }
.kpi-icon.info { background: var(--info-soft); color: var(--info); }
.kpi-icon.warn { background: var(--warn-soft); color: var(--warn); }
.kpi-value { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .8125rem; color: var(--muted); }
.kpi-sub b { color: var(--ink-2); font-weight: 700; }
a.kpi { color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s var(--ease); }
a.kpi:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-1px); }

.shortcuts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.shortcut { display: flex; align-items: center; gap: 14px; padding: 16px 18px; color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.shortcut:hover { border-color: var(--line-strong); box-shadow: var(--shadow); text-decoration: none; }
.shortcut b { display: block; font-weight: 700; }
.shortcut span { display: block; font-size: .8125rem; color: var(--muted); }
.shortcut .go { margin-left: auto; color: var(--faint); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink);
  font-weight: 700; font-size: .875rem; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, box-shadow .15s, color .15s;
}
.btn:hover { background: var(--sunken); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--brand-ink); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: color-mix(in srgb, var(--brand-strong) 88%, #000); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, #000); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--sunken); }
.btn-text-danger { color: var(--danger); }
.btn-sm { height: 30px; padding: 0 10px; font-size: .8125rem; }
.btn-icon { width: 34px; padding: 0; }
.btn .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r-sm); }
.seg button { height: 30px; padding: 0 12px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-weight: 700; font-size: .8125rem; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: .8125rem; font-weight: 700; color: var(--ink-2); }
.hint { font-size: .8125rem; color: var(--muted); }
.input {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; font: inherit; }
.input::placeholder { color: var(--faint); }
.input:hover { border-color: color-mix(in srgb, var(--line-strong) 60%, var(--muted)); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input-wrap { position: relative; }
.input-wrap > .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-wrap > .input { padding-left: 38px; }
.input-wrap > .reveal { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.input-wrap.has-reveal > .input { padding-right: 44px; }
select.input { appearance: none; padding-right: 36px; 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='%235b6e62' 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; }
.form-grid { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }

.choice-group { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice { position: relative; display: flex; gap: 12px; padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: var(--r); cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s; }
.choice:hover { border-color: color-mix(in srgb, var(--line-strong) 50%, var(--muted)); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .dot { width: 18px; height: 18px; flex: none; margin-top: 2px; border: 2px solid var(--line-strong); border-radius: 50%; transition: border .15s; }
.choice b { display: block; font-weight: 700; }
.choice span { display: block; font-size: .8125rem; color: var(--muted); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand) inset; }
.choice:has(input:checked) .dot { border: 5px solid var(--brand); }
.choice:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }

.key-row { display: grid; gap: 10px; padding: 16px 0; border-top: 1px solid var(--line); }
.key-row:first-child { border-top: 0; padding-top: 0; }
.key-row:last-child { padding-bottom: 0; }
.key-row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.key-row-head b { font-weight: 700; }
.key-line { display: flex; gap: 8px; }
.key-line .input-wrap { flex: 1; }

.savebar {
  position: sticky; bottom: 16px; z-index: 15; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 12px 18px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); box-shadow: var(--shadow-lg);
}
.savebar p { font-size: .875rem; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.savebar.dirty p { color: var(--ink); font-weight: 700; }
.savebar.dirty p::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }

/* ---------- tables ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar .input-wrap { flex: 1; min-width: 200px; max-width: 380px; }
.toolbar .count { margin-left: auto; font-size: .8125rem; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .875rem; }
.table th {
  position: sticky; top: 0; padding: 10px 16px; text-align: left; white-space: nowrap;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .r { text-align: right; }
.table .actions { width: 1%; text-align: right; }
.cell-user { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-user .avatar { width: 32px; height: 32px; background: var(--brand-soft); color: var(--brand-strong); }
.cell-user b { display: block; font-weight: 700; color: var(--ink); }
.cell-user span { display: block; font-size: .75rem; color: var(--muted); }
.sub { display: block; font-size: .75rem; color: var(--muted); }
.meter { display: flex; align-items: center; gap: 8px; }
.meter-track { width: 64px; height: 6px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; background: var(--brand); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: .75rem; font-weight: 700; white-space: nowrap; background: var(--neutral-soft); color: var(--ink-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand-strong); }
.badges { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; border: 1px solid var(--line-strong); font-size: .6875rem; font-weight: 700; color: var(--muted); }

/* ---------- menu ---------- */
.menu {
  position: fixed; z-index: 60; min-width: 210px; padding: 6px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); box-shadow: var(--shadow-lg); animation: pop .14s var(--ease);
}
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: 0; border-radius: var(--r-xs);
  background: none; font-weight: 600; font-size: .875rem; cursor: pointer; text-align: left; color: var(--ink);
}
.menu button:hover, .menu button:focus-visible { background: var(--sunken); outline: none; }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover, .menu button.danger:focus-visible { background: var(--danger-soft); }
.menu hr { margin: 6px 0; border: 0; border-top: 1px solid var(--line); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ---------- dialog ---------- */
dialog.dialog {
  width: min(460px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
}
dialog.dialog[open] { animation: pop .18s var(--ease); }
dialog.dialog::backdrop { background: rgba(8, 16, 12, .5); backdrop-filter: blur(2px); }
.dlg-body { display: flex; gap: 16px; padding: 24px 24px 8px; }
.dlg-icon { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--brand-soft); color: var(--brand-strong); }
.dlg-icon.danger { background: var(--danger-soft); color: var(--danger); }
.dlg-icon.warn { background: var(--warn-soft); color: var(--warn); }
.dlg-main { flex: 1; min-width: 0; display: grid; gap: 8px; }
.dlg-main h2 { font-size: 1.0625rem; }
.dlg-main p { color: var(--muted); }
.dlg-main strong { color: var(--ink); }
.dlg-extra { display: grid; gap: 12px; margin-top: 8px; }
.dlg-err { color: var(--danger); font-size: .875rem; font-weight: 600; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 30px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); font-weight: 700; font-size: .8125rem; cursor: pointer; }
.chip:hover { background: var(--sunken); }
.chip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); }

/* ---------- toast ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: grid; gap: 8px; width: min(380px, calc(100vw - 40px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); box-shadow: var(--shadow-lg); font-weight: 600; font-size: .875rem; animation: pop .18s var(--ease);
}
.toast .i { margin-top: 1px; color: var(--ok); }
.toast.error .i { color: var(--danger); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }

/* ---------- alerts ---------- */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--r-sm); font-size: .875rem; font-weight: 600; }
.alert.error { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-line); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert .i { margin-top: 1px; }

/* ---------- charts ---------- */
.chart-card .card-head { align-items: flex-start; border-bottom: 0; padding-bottom: 4px; }
.chart-card .card-head p:first-child { font-size: .875rem; font-weight: 700; color: var(--ink-2); margin: 0 0 4px; }
.chart-total { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.chart { position: relative; padding: 4px 16px 12px; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .grid.base { stroke: var(--line-strong); }
.chart .tick { fill: var(--faint); font-size: 11px; font-family: inherit; font-weight: 600; }
.chart .bar { fill: var(--brand); transition: fill .12s; }
.chart .hit { fill: transparent; cursor: default; }
.chart g:hover .bar, .chart g:focus .bar { fill: var(--brand-strong); }
.chart g:hover .hit, .chart g:focus .hit { fill: var(--sunken); }
.chart g:focus { outline: none; }
.chart .table-wrap { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
.tip {
  position: absolute; z-index: 5; pointer-events: none; padding: 8px 10px; border-radius: var(--r-sm);
  background: var(--ink); color: var(--bg); font-size: .75rem; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow);
}
.tip b { display: block; font-size: .875rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.link-btn { border: 0; background: none; padding: 0; color: var(--brand-strong); font-weight: 700; font-size: .8125rem; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ---------- states ---------- */
.empty { display: grid; justify-items: center; gap: 8px; padding: 48px 24px; text-align: center; color: var(--muted); }
.empty .empty-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: var(--sunken); color: var(--faint); margin-bottom: 4px; }
.empty b { color: var(--ink); font-weight: 700; }
.skel { border-radius: var(--r-xs); background: linear-gradient(90deg, var(--sunken), var(--line), var(--sunken)); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-kpi { height: 124px; border-radius: var(--r); }
.skel-block { height: 260px; border-radius: var(--r); }
.page-error { display: grid; justify-items: center; gap: 12px; padding: 64px 24px; text-align: center; }
.page-error .empty-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: var(--danger-soft); color: var(--danger); }
.page-error b { font-size: 1.0625rem; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(280px, 84vw);
    transform: translateX(-100%); transition: transform .22s var(--ease);
  }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(8, 16, 12, .45); }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .page { padding: 20px 16px 48px; }
  .env-pill { display: none; }
}
@media (max-width: 640px) {
  .form-grid, .choice-group { grid-template-columns: minmax(0, 1fr); }
  .page-head h1 { font-size: 1.375rem; }
  .kpi-value { font-size: 1.75rem; }
  .login-card { padding: 28px 20px 22px; }
  .savebar { flex-direction: column; align-items: stretch; }
  .savebar .page-actions { justify-content: flex-end; }
  .key-line { flex-wrap: wrap; }
  .toolbar .count { margin-left: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
