:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #eef1f4;
  --border: #e1e6eb;
  --border-strong: #c9d1da;
  --ink: #101720;
  --ink-2: #3a4553;
  --muted: #6b7686;
  --muted-2: #98a2b0;
  --accent: #1f4e8c;
  --accent-ink: #ffffff;
  --accent-soft: #e8f0fa;
  --accent-line: #b9cfe9;
  --positive: #1b7f5a;
  --positive-soft: #e4f4ec;
  --warning: #b7791f;
  --warning-soft: #fbf1dc;
  --danger: #b93838;
  --danger-soft: #fae6e6;
  --info: #2d6cb5;
  --info-soft: #e6effa;
  --neutral-soft: #eceff3;
  --shadow: 0 1px 2px rgba(16, 23, 32, 0.04);
  --radius: 6px;
  --radius-sm: 4px;
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --font-ui: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-data: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --chart-1: #1f4e8c;
  --chart-2: #9aa9bb;
  --chart-3: #1b7f5a;
  --chart-4: #b7791f;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1419;
  --surface: #161c24;
  --surface-2: #1b222c;
  --surface-3: #212a35;
  --border: #262f3b;
  --border-strong: #37424f;
  --ink: #e8ecf1;
  --ink-2: #c3cbd5;
  --muted: #8c98a8;
  --muted-2: #66717f;
  --accent: #6fa4e8;
  --accent-ink: #0f1419;
  --accent-soft: #1b2b40;
  --accent-line: #2d4c73;
  --positive: #4cc38a;
  --positive-soft: #143126;
  --warning: #e0a94a;
  --warning-soft: #3a2c13;
  --danger: #e36c6c;
  --danger-soft: #3d1c1c;
  --info: #6fa4e8;
  --info-soft: #1b2b40;
  --neutral-soft: #232c37;
  --shadow: none;
  --chart-1: #6fa4e8;
  --chart-2: #4b5a6c;
  --chart-3: #4cc38a;
  --chart-4: #e0a94a;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 0.9375rem; }
p { margin: 0 0 0.75rem; }
p:last-child { margin-bottom: 0; }

code, .mono, .num { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.num { font-size: 0.9375rem; }
.unit { font-size: 0.75em; color: var(--muted); margin-left: 2px; font-family: var(--font-ui); font-weight: 500; }
.na { color: var(--muted-2); font-family: var(--font-ui); font-size: 0.85em; }
.muted { color: var(--muted); }
.small { font-size: 0.8125rem; }
.tiny { font-size: 0.75rem; }
.strong { font-weight: 600; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; } .gap-1 { gap: 0.5rem; } .gap-2 { gap: 1rem; } .wrap { flex-wrap: wrap; }
.hidden { display: none !important; }
.w-full { width: 100%; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Icons */
svg.icon { width: 16px; height: 16px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
svg.icon.small { width: 14px; height: 14px; }
.dropdown-item svg.icon { width: 15px; height: 15px; color: var(--muted); }
.notice svg.icon, .msg-attach svg.icon { margin-right: 2px; }

/* Layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
  transition: transform 0.2s ease;
}

.sidebar-brand {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-data); font-weight: 600; font-size: 0.8125rem;
}
img.brand-mark { object-fit: cover; flex: none; }
.brand-logo { height: 40px; width: auto; display: block; }
.brand-name { font-weight: 600; letter-spacing: -0.01em; }
.brand-scope { display: block; font-size: 0.6875rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; }

.sidebar-nav { padding: 0.75rem 0.75rem; flex: 1; overflow-y: auto; }
.nav-group-label { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-2); font-weight: 600; padding: 0.875rem 0.625rem 0.375rem; }
.nav-link {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.5rem 0.625rem; margin-bottom: 1px;
  border-radius: var(--radius-sm);
  color: var(--ink-2); font-size: 0.875rem; font-weight: 500;
  position: relative;
}
.nav-link:hover { background: var(--surface-3); text-decoration: none; color: var(--ink); }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent); }
.nav-link.is-active::before { content: ""; position: absolute; left: -0.75rem; top: 6px; bottom: 6px; width: 3px; background: var(--accent); border-radius: 0 2px 2px 0; }
.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
.nav-count { margin-left: auto; font-family: var(--font-data); font-size: 0.6875rem; padding: 1px 6px; border-radius: 10px; background: var(--surface-3); color: var(--muted); }
.nav-link.is-active .nav-count { background: var(--accent); color: var(--accent-ink); }

.sidebar-footer { padding: 0.875rem 1.25rem; border-top: 1px solid var(--border); font-size: 0.75rem; color: var(--muted); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0 1.5rem;
  position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-size: 0.9375rem; font-weight: 600; }
.topbar-spacer { flex: 1; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .dot { position: absolute; top: 7px; right: 7px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 0.625rem; font-family: var(--font-data); display: flex; align-items: center; justify-content: center; }
.menu-toggle { display: none; }

.user-chip { display: flex; align-items: center; gap: 0.625rem; padding: 0.25rem 0.375rem 0.25rem 0.25rem; border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--ink); font-family: inherit; }
.user-chip:hover { background: var(--surface-3); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em; }
.user-chip-name { font-size: 0.8125rem; font-weight: 500; line-height: 1.2; text-align: left; }
.user-chip-role { display: block; font-size: 0.6875rem; color: var(--muted); font-weight: 400; }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(16, 23, 32, 0.08); padding: 0.375rem; z-index: 50;
}
:root[data-theme="dark"] .dropdown-menu { box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.dropdown-item { display: flex; align-items: center; gap: 0.5rem; width: 100%; padding: 0.5rem 0.625rem; border-radius: var(--radius-sm); color: var(--ink-2); font-size: 0.8125rem; background: none; border: 0; text-align: left; cursor: pointer; font-family: inherit; }
.dropdown-item:hover { background: var(--surface-3); text-decoration: none; color: var(--ink); }
.dropdown-divider { height: 1px; background: var(--border); margin: 0.375rem 0; }
.dropdown-menu.wide { min-width: 340px; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item { padding: 0.5rem 0.625rem; border-radius: var(--radius-sm); display: block; color: inherit; }
.notif-item:hover { background: var(--surface-3); text-decoration: none; }
.notif-item.unread { border-left: 2px solid var(--accent); }
.notif-title { font-size: 0.8125rem; font-weight: 500; }
.notif-meta { font-size: 0.6875rem; color: var(--muted); }

.content { padding: 1.5rem; max-width: 1440px; width: 100%; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-header .eyebrow { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; margin-bottom: 0.25rem; }
.page-header p { color: var(--muted); font-size: 0.875rem; margin-top: 0.25rem; }
.page-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* 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: 1rem; padding: 0.875rem 1.125rem; border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3 { font-size: 0.9375rem; }
.card-header .sub { font-size: 0.75rem; color: var(--muted); font-weight: 400; margin-left: 0.5rem; }
.card-body { padding: 1.125rem; }
.card-footer { padding: 0.75rem 1.125rem; border-top: 1px solid var(--border); font-size: 0.8125rem; color: var(--muted); }
.card + .card { margin-top: 1rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid > .card { margin-top: 0; }

/* Stat strip: hairline-ruled figures */
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
/* Period metrics: four per row, so eight tiles sit in two rows and long amounts keep their room. */
.stat-strip-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 0.875rem 1.125rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); min-width: 0; }
.stat-label { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; margin-bottom: 0.375rem; display: flex; justify-content: space-between; gap: 0.5rem; }
.stat-value { font-family: var(--font-data); font-variant-numeric: tabular-nums; font-size: 1.375rem; font-weight: 500; letter-spacing: -0.01em; line-height: 1.15; overflow-wrap: anywhere; }
.stat-value .unit { font-size: 0.6875rem; }
.stat-value .na { font-size: 0.875rem; }
.stat-foot { margin-top: 0.375rem; font-size: 0.75rem; color: var(--muted); display: flex; gap: 0.5rem; align-items: center; }
.stat-value.tone-positive { color: var(--positive); }
.stat-value.tone-warning { color: var(--warning); }
.stat-value.tone-accent { color: var(--accent); }

.delta { font-family: var(--font-data); font-size: 0.6875rem; padding: 1px 5px; border-radius: 3px; font-weight: 500; }
.delta-up { color: var(--positive); background: var(--positive-soft); }
.delta-down { color: var(--danger); background: var(--danger-soft); }
.delta-flat, .delta-na { color: var(--muted); background: var(--neutral-soft); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 3px; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; line-height: 1.5; white-space: nowrap; }
.badge-success { background: var(--positive-soft); color: var(--positive); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-neutral { background: var(--neutral-soft); color: var(--muted); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem; padding: 0.5rem 0.875rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); font-family: inherit; font-size: 0.8125rem; font-weight: 500; cursor: pointer; line-height: 1.3; white-space: nowrap; transition: background 0.12s ease, border-color 0.12s ease; }
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
:root[data-theme="dark"] .btn-primary:hover { background: color-mix(in srgb, var(--accent) 85%, white); }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger-soft) 80%, var(--danger)); }
.btn-success { background: var(--positive-soft); border-color: transparent; color: var(--positive); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { padding: 0.3125rem 0.625rem; font-size: 0.75rem; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; gap: 0.375rem; flex-wrap: wrap; }

/* Forms */
.form-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 0.3125rem; }
.field label, .label { font-size: 0.8125rem; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: 0.75rem; color: var(--muted); }
.field .error { font-size: 0.75rem; color: var(--danger); }
.input, .select, .textarea { width: 100%; padding: 0.5rem 0.625rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-family: inherit; font-size: 0.875rem; line-height: 1.4; transition: border-color 0.12s ease; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.input.mono { font-family: var(--font-data); font-size: 0.8125rem; }
.textarea { min-height: 120px; resize: vertical; }
.select { appearance: none; 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='%236b7686' stroke-width='2' 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 0.625rem center; padding-right: 2rem; }
.input-sm, .select-sm { padding: 0.375rem 0.5rem; font-size: 0.8125rem; }
.check { display: flex; align-items: flex-start; gap: 0.5rem; font-size: 0.8125rem; color: var(--ink-2); cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.input-group { display: flex; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: 0; }
.form-actions { display: flex; gap: 0.5rem; align-items: center; justify-content: flex-end; margin-top: 1.25rem; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 0.625rem; cursor: pointer; font-size: 0.8125rem; }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 10px; background: var(--border-strong); position: relative; cursor: pointer; transition: background 0.15s; flex-shrink: 0; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(14px); }

/* Filter bar */
.filter-bar { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.filter-bar .field { min-width: 140px; }
.filter-bar .field label { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.segmented a, .segmented button { padding: 0.375rem 0.75rem; font-size: 0.8125rem; color: var(--ink-2); border: 0; background: transparent; cursor: pointer; font-family: inherit; border-right: 1px solid var(--border); font-weight: 500; }
.segmented a:last-child, .segmented button:last-child { border-right: 0; }
.segmented a:hover { background: var(--surface-3); text-decoration: none; }
.segmented .is-active { background: var(--accent); color: var(--accent-ink); }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 0.8438rem; }
.table th { text-align: left; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; padding: 0.625rem 0.875rem; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 0.6875rem 0.875rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num, .table td.num, .table th.num { text-align: right; font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.table th.num { font-family: var(--font-ui); }
.table tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--border-strong); }
.table .row-link { color: inherit; font-weight: 500; }
.table .row-link:hover { color: var(--accent); }
.table-compact td, .table-compact th { padding: 0.5rem 0.75rem; }
.tip { border-bottom: 1px dotted currentColor; cursor: help; }
.table th.is-sortable { cursor: pointer; user-select: none; }
.table th.is-sortable:hover { color: var(--ink); }
.table th.is-sortable::after { content: '↕'; opacity: 0.35; margin-left: 4px; font-size: 0.75em; }
.table th.is-sortable[aria-sort="ascending"] { color: var(--accent); }
.table th.is-sortable[aria-sort="descending"] { color: var(--accent); }
.table th.is-sortable[aria-sort="ascending"]::after { content: '↑'; opacity: 1; }
.table th.is-sortable[aria-sort="descending"]::after { content: '↓'; opacity: 1; }
.sort-link { color: inherit; display: inline-flex; gap: 3px; }
.sort-link:hover { text-decoration: none; color: var(--ink); }
.sort-link.is-active { color: var(--accent); }
.cell-primary { font-weight: 500; color: var(--ink); }
.cell-secondary { font-size: 0.75rem; color: var(--muted); display: block; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 1.125rem; border-top: 1px solid var(--border); font-size: 0.8125rem; color: var(--muted); flex-wrap: wrap; }
.pager { display: flex; gap: 0.25rem; }
.pager a, .pager span { min-width: 30px; height: 30px; padding: 0 0.5rem; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); border: 1px solid var(--border); color: var(--ink-2); font-size: 0.8125rem; font-family: var(--font-data); }
.pager a:hover { background: var(--surface-3); text-decoration: none; }
.pager .is-active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pager .disabled { opacity: 0.4; }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); border: 1px solid; font-size: 0.875rem; display: flex; gap: 0.625rem; align-items: flex-start; margin-bottom: 1rem; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.alert-success { background: var(--positive-soft); border-color: transparent; color: var(--positive); }
.alert-error { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.alert-warning { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.alert-info { background: var(--info-soft); border-color: transparent; color: var(--info); }
.alert ul { margin: 0.25rem 0 0; padding-left: 1.125rem; }
.alert .close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; font-size: 1rem; line-height: 1; opacity: 0.7; }

/* Notice blocks */
.notice { padding: 0.875rem 1rem; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); font-size: 0.8438rem; color: var(--ink-2); }
.notice strong { color: var(--ink); }
.notice-warning { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.notice-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }

/* Empty state */
.empty { padding: 3rem 1.5rem; text-align: center; color: var(--muted); }
.empty svg { width: 36px; height: 36px; stroke: var(--muted-2); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 0.75rem; }
.empty h3 { color: var(--ink-2); font-size: 0.9375rem; margin-bottom: 0.25rem; }
.empty p { font-size: 0.8438rem; max-width: 380px; margin: 0 auto 1rem; }

/* Tabs */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs a { padding: 0.625rem 0.875rem; font-size: 0.8438rem; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .count { font-family: var(--font-data); font-size: 0.6875rem; background: var(--surface-3); padding: 1px 6px; border-radius: 10px; margin-left: 4px; color: var(--muted); }

/* Definition list */
.dl { display: grid; grid-template-columns: 160px 1fr; gap: 0.5rem 1rem; font-size: 0.8438rem; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; color: var(--ink); word-break: break-word; }
.dl-compact { grid-template-columns: 130px 1fr; }

/* Charts */
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }
.chart-box.short { height: 200px; }
.chart-box canvas { width: 100% !important; height: 100% !important; }
.chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 0.8438rem; }
.chart-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.75rem; color: var(--muted); }
.chart-legend span::before { content: ""; display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; background: var(--chart-1); }
.chart-legend span.prev::before { background: var(--chart-2); }
.metric-picker { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.metric-picker button { padding: 0.25rem 0.625rem; font-size: 0.75rem; border-radius: 3px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); cursor: pointer; font-family: inherit; }
.metric-picker button.is-active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }

/* Timeline / audit */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 130px 1fr; gap: 1rem; padding: 0.625rem 0; border-bottom: 1px solid var(--border); font-size: 0.8125rem; }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--muted); font-family: var(--font-data); font-size: 0.75rem; }
.timeline .diff { font-family: var(--font-data); font-size: 0.6875rem; color: var(--muted); margin-top: 3px; word-break: break-all; }

/* Ticket conversation */
.thread { display: flex; flex-direction: column; gap: 0.875rem; }
.msg { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.msg-head { display: flex; align-items: center; gap: 0.625rem; padding: 0.625rem 0.875rem; border-bottom: 1px solid var(--border); font-size: 0.8125rem; background: var(--surface-2); }
.msg-head time { margin-left: auto; color: var(--muted); font-size: 0.75rem; font-family: var(--font-data); }
.msg-body { padding: 0.875rem; font-size: 0.875rem; white-space: pre-wrap; word-break: break-word; }
.msg-admin { border-left: 3px solid var(--accent); }
.msg-affiliate { border-left: 3px solid var(--border-strong); }
.msg-internal { border-left: 3px solid var(--warning); background: var(--warning-soft); }
.msg-internal .msg-head { background: transparent; }
.msg-attach { padding: 0.5rem 0.875rem; border-top: 1px solid var(--border); font-size: 0.75rem; }

/* Copy field */
.copy-field { display: flex; align-items: center; gap: 0.5rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.375rem 0.375rem 0.375rem 0.625rem; }
.copy-field code { font-size: 0.8125rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.auth-side { background: var(--ink); color: #dfe5ec; padding: 2.5rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
:root[data-theme="dark"] .auth-side { background: #0b0f14; }
.auth-side .brand-mark { background: #fff; color: var(--ink); }
.auth-side h1 { color: #fff; font-size: 1.75rem; margin-top: 3rem; font-weight: 600; max-width: 420px; letter-spacing: -0.02em; }
.auth-side p { color: #98a4b3; max-width: 400px; font-size: 0.9375rem; }
.auth-ledger { font-family: var(--font-data); font-size: 0.75rem; color: #6f7c8c; border-top: 1px solid #232c37; padding-top: 1rem; display: grid; grid-template-columns: 1fr auto; gap: 0.25rem 1rem; max-width: 380px; }
.auth-ledger b { color: #c9d2dc; font-weight: 500; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card.wide { max-width: 720px; }
.auth-card h2 { font-size: 1.375rem; margin-bottom: 0.25rem; letter-spacing: -0.02em; }
.auth-card .lead { color: var(--muted); font-size: 0.875rem; margin-bottom: 1.5rem; }
.auth-foot { margin-top: 1.5rem; font-size: 0.8125rem; color: var(--muted); text-align: center; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; }
.fieldset legend { padding: 0 0.375rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }

/* Theme toggle */
.theme-toggle .sun, .theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root:not([data-theme="dark"]) .theme-toggle .moon { display: block; }

/* Progress */
.bar { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }

/* Toast */
.toast { position: fixed; bottom: 1.25rem; right: 1.25rem; background: var(--ink); color: var(--bg); padding: 0.625rem 0.875rem; border-radius: var(--radius-sm); font-size: 0.8125rem; z-index: 100; opacity: 0; transform: translateY(6px); transition: opacity 0.15s, transform 0.15s; pointer-events: none; }
.toast.show { opacity: 1; transform: none; }

.overlay { display: none; position: fixed; inset: 0; background: rgba(16, 23, 32, 0.45); z-index: 35; }

/* Error pages */
.error-page { min-height: 70vh; display: flex; align-items: center; justify-content: center; text-align: center; padding: 2rem; }
.error-page .code { font-family: var(--font-data); font-size: 0.75rem; letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }
.error-page h1 { margin: 0.5rem 0; }
.error-page p { color: var(--muted); max-width: 420px; margin: 0 auto 1.25rem; }

/* Responsive */
@media (max-width: 1280px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-strip-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 1.25rem; }
}

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.is-open { transform: none; }
  .overlay.is-open { display: block; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .grid-main { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}

@media (max-width: 720px) {
  html { font-size: 14px; }
  .content { padding: 1rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .dl { grid-template-columns: 1fr; gap: 0.125rem 0; }
  .dl dt { margin-top: 0.5rem; }
  .timeline li { grid-template-columns: 1fr; gap: 0.125rem; }
  .user-chip-name { display: none; }
  .topbar { padding: 0 1rem; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-header { align-items: flex-start; flex-direction: column; }
  .table th, .table td { padding: 0.5625rem 0.625rem; }
  .filter-bar .field { min-width: 0; flex: 1 1 45%; }
  .dropdown-menu.wide { min-width: 280px; right: -40px; }
}

@media print {
  .sidebar, .topbar, .page-actions, .filter-bar, .pagination { display: none !important; }
  .main { margin: 0; }
}
[x-cloak] { display: none !important; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.locale-switch .select { width: auto; padding-right: 1.75rem; font-size: 0.75rem; }
.auth-topbar { position: absolute; top: 1rem; right: 1.25rem; display: flex; gap: 0.5rem; align-items: center; }
.auth-main { position: relative; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(16, 23, 32, 0.45); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 1rem; overflow-y: auto; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-width: 480px; box-shadow: 0 16px 48px rgba(16, 23, 32, 0.18); }
.modal.wide { max-width: 640px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 0.875rem 1.125rem; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 0.9375rem; }
.modal-body { padding: 1.125rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.75rem 1.125rem; border-top: 1px solid var(--border); }
