/* ==========================================================================
   Imperium Weekly — layout & components
   ========================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-deep);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* Ambient neon field behind everything. Purely decorative, low contrast so it
   never competes with a chart mark. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1035px 598px at 12% -8%, rgba(0, 162, 216, 0.16), transparent 62%),
    radial-gradient(874px 552px at 88% 4%, rgba(120, 0, 220, 0.14), transparent 60%),
    radial-gradient(1265px 713px at 50% 108%, rgba(0, 180, 0, 0.09), transparent 66%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image:
    linear-gradient(rgba(130, 175, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(130, 175, 255, 0.045) 1px, transparent 1px);
  background-size: 64.4px 64.4px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, #000 20%, transparent 78%);
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
  border-radius: 4.6px;
}

/* Screen-reader-only, but focusable (skip link). */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip-link:focus {
  position: fixed; top: 13.8px; left: 13.8px;
  width: auto; height: auto; clip: auto;
  z-index: 200;
  padding: 11.5px 18.4px;
  background: var(--surface-2);
  border: 1px solid var(--stroke-strong);
  border-radius: var(--radius-sm);
}

/* ── Shell ──────────────────────────────────────────────────────────────── */

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  transition: grid-template-columns 0.26s var(--ease);
}
.app[data-sidebar="collapsed"] { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ── Sidebar ────────────────────────────────────────────────────────────── */

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, rgba(14, 22, 56, 0.94), rgba(7, 12, 34, 0.94));
  border-right: 1px solid var(--stroke);
  backdrop-filter: blur(13.8px);
}
.sidebar::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: var(--sidebar-w);
  width: 1px;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, var(--accent-glow) 22%, rgba(171, 0, 255, 0.4) 68%, transparent);
  opacity: 0.55;
  transition: left 0.26s var(--ease);
}
.app[data-sidebar="collapsed"] .sidebar::after { left: var(--sidebar-w-collapsed); }

.brand {
  display: flex;
  align-items: center;
  gap: 13.8px;
  height: var(--topbar-h);
  padding: 0 18.4px;
  border-bottom: 1px solid var(--stroke);
  flex-shrink: 0;
}
.brand-mark {
  flex-shrink: 0;
  width: 39.1px; height: 39.1px;
  display: grid; place-items: center;
  border-radius: 11.5px;
  background: linear-gradient(140deg, var(--accent), #6d28d9);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14) inset, 0 0 25.3px -4px var(--accent-glow);
  font-weight: 800; font-size: 17.2px; letter-spacing: 0.02em;
  color: #fff;
}
.brand-text { min-width: 0; }
.brand-name {
  font-size: 14.9px; font-weight: 700; letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}
.brand-sub {
  font-size: 12.6px; color: var(--text-muted);
  white-space: nowrap;
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16.1px 11.5px;
}
.nav-heading {
  padding: 16.1px 11.5px 6.9px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13.8px;
  width: 100%;
  padding: 10.3px 11.5px;
  border-radius: 11.5px;
  color: var(--text-secondary);
  font-size: 15.5px;
  text-align: left;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.nav-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.nav-item[aria-current="true"] {
  background: linear-gradient(90deg, rgba(0, 162, 216, 0.2), rgba(0, 162, 216, 0.02));
  color: var(--text-primary);
  font-weight: 600;
}
.nav-item[aria-current="true"]::before {
  content: "";
  position: absolute;
  left: 0; top: 9.2px; bottom: 9.2px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent-bright);
  box-shadow: 0 0 11.5px 1px var(--accent-glow);
}
.nav-icon { flex-shrink: 0; width: 20.7px; height: 20.7px; opacity: 0.85; }
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-count {
  margin-left: auto;
  font-size: 12.6px;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
}

.app[data-sidebar="collapsed"] .brand-text,
.app[data-sidebar="collapsed"] .nav-label,
.app[data-sidebar="collapsed"] .nav-count,
.app[data-sidebar="collapsed"] .nav-heading,
.app[data-sidebar="collapsed"] .sidebar-footer-full { display: none; }
.app[data-sidebar="collapsed"] .nav-item { justify-content: center; padding: 11.5px; }

.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--stroke);
  padding: 13.8px 11.5px;
}
.who {
  display: flex; align-items: center; gap: 11.5px;
  width: 100%;
  padding: 9.2px;
  border-radius: 11.5px;
  text-align: left;
  transition: background 0.16s var(--ease);
}
.who:hover { background: var(--surface-hover); }
.avatar {
  flex-shrink: 0;
  width: 34.5px; height: 34.5px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 13.8px; font-weight: 700;
  color: #04121c;
  background: linear-gradient(140deg, var(--accent-bright), var(--accent-2-bright));
}
.who-meta { min-width: 0; }
.who-name {
  font-size: 14.4px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.who-role { font-size: 12.6px; color: var(--text-muted); text-transform: capitalize; }

.sidebar-actions { display: flex; gap: 6.9px; margin-top: 9.2px; }
.ghost-btn {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9.2px 11.5px;
  border-radius: 10.3px;
  border: 1px solid var(--stroke);
  color: var(--text-secondary);
  font-size: 13.8px;
  transition: border-color 0.16s var(--ease), color 0.16s var(--ease), background 0.16s var(--ease);
}
.ghost-btn:hover {
  border-color: var(--stroke-strong);
  color: var(--text-primary);
  background: var(--surface-hover);
}
.ghost-btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* ── Main column ────────────────────────────────────────────────────────── */

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 18.4px;
  height: var(--topbar-h);
  padding: 0 25.3px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(7, 12, 34, 0.72);
  backdrop-filter: blur(16.1px);
}
.icon-btn {
  flex-shrink: 0;
  display: grid; place-items: center;
  width: 39.1px; height: 39.1px;
  border-radius: 10.3px;
  border: 1px solid var(--stroke);
  color: var(--text-secondary);
  transition: border-color 0.16s var(--ease), color 0.16s var(--ease), background 0.16s var(--ease);
}
.icon-btn:hover { border-color: var(--stroke-strong); color: var(--text-primary); background: var(--surface-hover); }

.topbar > div { min-width: 0; }
.page-title {
  font-size: 18.4px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0;
  white-space: nowrap;
}
.page-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* The grain switch sits beside the title — it changes what the whole page is
   about, so it reads as a peer of the title rather than as another filter. */
.segmented.grain { margin-left: 6.9px; }
.segmented.grain button { padding: 6.9px 16.1px; font-size: 14.4px; font-weight: 550; }
.page-sub { font-size: 13.8px; color: var(--text-muted); margin: 2px 0 0; }
.topbar-spacer { flex: 1; }

.live-dot {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5.8px 12.6px 5.8px 10.3px;
  border-radius: 1148.8px;
  border: 1px solid var(--stroke);
  font-size: 12.6px; color: var(--text-secondary);
  white-space: nowrap;
}
.live-dot i {
  width: 6.9px; height: 6.9px; border-radius: 50%;
  background: var(--accent-2-bright);
  box-shadow: 0 0 9.2px 1px rgba(78, 240, 122, 0.8);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ── Filter bar (one row, scopes everything below it) ───────────────────── */

.filterbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16.1px;
  flex-wrap: wrap;
  padding: 13.8px 25.3px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(7, 12, 34, 0.5);
}
.filter-group { display: flex; align-items: center; gap: 9.2px; }
.filter-label {
  font-size: 12.1px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-faint);
}
.segmented {
  display: flex;
  padding: 3.4px;
  border-radius: 11.5px;
  border: 1px solid var(--stroke);
  background: rgba(5, 9, 25, 0.6);
}
.segmented button {
  padding: 5.8px 12.6px;
  border-radius: 8px;
  font-size: 13.8px;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color 0.16s var(--ease), background 0.16s var(--ease);
}
.segmented button:hover { color: var(--text-primary); }
.segmented button[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(0, 162, 216, 0.34), rgba(0, 162, 216, 0.16));
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(0, 208, 255, 0.3), 0 0 16.1px -4px var(--accent-glow);
}
.select {
  padding: 6.9px 11.5px;
  border-radius: 10.3px;
  border: 1px solid var(--stroke);
  background: rgba(5, 9, 25, 0.6);
  color: var(--text-primary);
  font-size: 14.4px;
  font-variant-numeric: tabular-nums;
}
.select:hover { border-color: var(--stroke-strong); }

/* ── Content ────────────────────────────────────────────────────────────── */

.content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 25.3px 25.3px 92px;
  scroll-behavior: smooth;
}
.content[data-stale="true"] .section-body { opacity: 0.45; transition: opacity 0.2s var(--ease); }

.section { margin-bottom: 39.1px; scroll-margin-top: 18.4px; }
.section-head {
  display: flex;
  align-items: baseline;
  gap: 13.8px;
  margin-bottom: 16.1px;
  padding-bottom: 11.5px;
  border-bottom: 1px solid var(--stroke);
}
.section-head h2 {
  margin: 0;
  font-size: 13.8px; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-primary);
}
.section-head h2::before {
  content: "";
  display: inline-block;
  width: 3.4px; height: 13.8px;
  margin-right: 11.5px;
  vertical-align: -1px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent-bright), var(--accent-2-bright));
  box-shadow: 0 0 11.5px 0 var(--accent-glow);
}
.section-note { font-size: 13.2px; color: var(--text-muted); margin-left: auto; }
.ghost-btn.compact { flex: 0 0 auto; padding: 5.8px 12.6px; font-size: 13.2px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280.6px, 1fr));
  gap: 16.1px;
}
.grid.hero { grid-template-columns: repeat(auto-fit, minmax(340.4px, 1fr)); }
.grid .span-2 { grid-column: span 2; }
@media (max-width: 874px) { .grid .span-2 { grid-column: span 1; } }

.group-label {
  grid-column: 1 / -1;
  margin: 9.2px 0 -4px;
  font-size: 12.6px; font-weight: 650;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Metric card ────────────────────────────────────────────────────────── */

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 16.1px 17.2px 11.5px;
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  background: linear-gradient(165deg, rgba(19, 29, 71, 0.86), rgba(10, 16, 44, 0.86));
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.card:hover { border-color: var(--stroke-strong); transform: translateY(-1px); }
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg, transparent, rgba(0, 208, 255, 0.5), transparent);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.card:hover::before { opacity: 1; }

.card[data-metric] { cursor: pointer; }
.card[data-metric]:hover { border-color: var(--stroke-strong); }

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 9.2px;
  margin-bottom: 10.3px;
  min-height: 20.7px;
}
/* Expand affordance — visible on hover, always reachable by keyboard. */
.card-expand {
  margin-left: auto;
  flex-shrink: 0;
  display: grid; place-items: center;
  width: 25.3px; height: 25.3px;
  margin: -3px -3px 0 auto;
  border-radius: 8px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.16s var(--ease), color 0.16s var(--ease), background 0.16s var(--ease);
}
.card-expand svg { width: 14.9px; height: 14.9px; }
.card:hover .card-expand,
.card-expand:focus-visible { opacity: 1; }
.card-expand:hover { color: var(--text-primary); background: var(--surface-hover); }
.card-title {
  font-size: 13.2px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-secondary);
  line-height: 1.35;
}
.card-help {
  display: inline-grid; place-items: center;
  width: 16.1px; height: 16.1px; flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--stroke-strong);
  font-size: 10.3px; color: var(--text-muted);
  cursor: help;
}

.card-value-row {
  display: flex;
  align-items: baseline;
  gap: 11.5px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}
.card-value {
  font-size: 29.9px;
  font-weight: 660;
  letter-spacing: -0.022em;
  line-height: 1.1;
  color: var(--text-primary);
  text-shadow: 0 0 29.9px rgba(0, 208, 255, 0.22);
}
.card.hero-card .card-value { font-size: 39.1px; }
.card-value.is-empty { color: var(--text-faint); font-size: 23px; font-weight: 500; }

.delta {
  display: inline-flex; align-items: center; gap: 3.4px;
  font-size: 13.8px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  white-space: nowrap;
}
.delta[data-tone="good"] { color: var(--status-good-ink); }
.delta[data-tone="bad"] { color: var(--status-critical-ink); }
.delta svg { width: 12.6px; height: 12.6px; }

.card-meta {
  display: flex;
  align-items: center;
  gap: 9.2px;
  flex-wrap: wrap;
  margin-top: 9.2px;
  padding-top: 9.2px;
  border-top: 1px solid var(--stroke);
  font-size: 12.6px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Status chip — always icon + label, never colour alone. */
.badge {
  display: inline-flex; align-items: center; gap: 5.8px;
  padding: 3.4px 9.2px 3.4px 6.9px;
  border-radius: 1148.8px;
  font-size: 12.1px; font-weight: 650;
  letter-spacing: 0.04em;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.badge svg { width: 12.6px; height: 12.6px; flex-shrink: 0; }
.badge[data-status="good"] { color: var(--status-good-ink); background: rgba(12, 163, 12, 0.13); }
.badge[data-status="warning"] { color: var(--status-warning); background: rgba(250, 178, 25, 0.12); }
.badge[data-status="critical"] { color: var(--status-critical-ink); background: rgba(208, 59, 59, 0.14); }
.badge[data-status="neutral"] { color: var(--status-neutral); background: rgba(111, 126, 169, 0.12); }

/* ── Chart ──────────────────────────────────────────────────────────────── */

.chart {
  position: relative;
  margin-top: 11.5px;
  width: 100%;
}
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-empty {
  display: grid; place-items: center;
  height: 73.6px;
  font-size: 13.2px;
  color: var(--text-faint);
  border: 1px dashed var(--stroke);
  border-radius: var(--radius-sm);
}

.grid-line { stroke: var(--grid); stroke-width: 1; }
.axis-line { stroke: var(--axis); stroke-width: 1; }
.axis-text {
  fill: var(--text-faint);
  font-size: 10.9px;
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
}
.target-line { stroke: var(--status-warning); stroke-width: 1; opacity: 0.65; }
/* The halo lets the label sit over a mark without either becoming unreadable. */
.target-text {
  fill: var(--status-warning);
  font-size: 10.3px;
  font-family: var(--font-sans);
  stroke: var(--surface-1);
  stroke-width: 3;
  paint-order: stroke fill;
}

.series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series-bar { rx: 2; }
.end-dot { stroke: var(--surface-1); stroke-width: 2; }

.crosshair { stroke: var(--stroke-strong); stroke-width: 1; }
.hover-dot { stroke: var(--surface-1); stroke-width: 2; }

.chart-tip {
  position: absolute;
  z-index: 40;
  min-width: 147.2px;
  padding: 9.2px 11.5px;
  border-radius: 11.5px;
  border: 1px solid var(--stroke-strong);
  background: rgba(10, 16, 44, 0.97);
  box-shadow: var(--shadow-pop);
  font-size: 13.2px;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 13.8px));
  opacity: 0;
  transition: opacity 0.12s var(--ease);
}
.chart-tip[data-open="true"] { opacity: 1; }
.chart-tip .tip-date {
  color: var(--text-muted);
  font-size: 12.1px;
  margin-bottom: 5.8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tip-row { display: flex; align-items: center; gap: 8px; margin-top: 3.4px; }
.tip-swatch { width: 9.2px; height: 9.2px; border-radius: 2px; flex-shrink: 0; }
.tip-name { color: var(--text-secondary); }
.tip-value { margin-left: auto; font-weight: 650; font-variant-numeric: tabular-nums; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6.9px 16.1px;
  margin-top: 10.3px;
  font-size: 12.6px;
  color: var(--text-secondary);
}
.legend span { display: inline-flex; align-items: center; gap: 6.9px; }
.legend i { width: 10.3px; height: 10.3px; border-radius: 2px; flex-shrink: 0; }

/* ── Table view (the WCAG-clean twin of every chart) ────────────────────── */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: rgba(10, 16, 44, 0.7);
}
table.data { border-collapse: collapse; width: 100%; font-size: 13.8px; }
table.data th, table.data td {
  padding: 9.2px 13.8px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--stroke);
  font-variant-numeric: tabular-nums;
}
table.data th {
  position: sticky; top: 0;
  background: rgba(14, 22, 56, 0.98);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12.6px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: right;
  z-index: 1;
}
table.data th:first-child, table.data td:first-child {
  text-align: left;
  position: sticky; left: 0;
  background: rgba(14, 22, 56, 0.98);
  z-index: 2;
}
table.data th:first-child { z-index: 3; }
table.data tbody tr:hover td { background: rgba(0, 162, 216, 0.07); }
table.data td.null { color: var(--text-faint); }

/* Editable cells. The input fills the cell so the table still reads as a
   table — no visible field until you land on one. */
table.data.editable td.cell-edit { padding: 0; }
.cell-input {
  width: 100%;
  padding: 9.2px 13.8px;
  border: 1px solid transparent;
  border-radius: 6.9px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: right;
  transition: border-color 0.14s var(--ease), background 0.14s var(--ease);
}
.cell-input:hover { border-color: var(--stroke-strong); background: rgba(0, 162, 216, 0.06); }
.cell-input:focus {
  border-color: var(--accent-bright);
  background: rgba(5, 9, 25, 0.85);
  box-shadow: 0 0 0 3.4px rgba(0, 208, 255, 0.14);
  outline: none;
  text-align: right;
}
.cell-input.saved { border-color: var(--status-good-ink); background: rgba(12, 163, 12, 0.12); }
/* Spinners would halve the usable width of every cell. */
.cell-input::-webkit-outer-spin-button,
.cell-input::-webkit-inner-spin-button { appearance: none; margin: 0; }
.cell-input[type="number"] { appearance: textfield; -moz-appearance: textfield; }

/* ── Modal (user management) ────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 27.6px;
  background: rgba(3, 6, 18, 0.7);
  backdrop-filter: blur(6.9px);
}
.modal-backdrop[hidden] { display: none; }

/* The sidebar and topbar each carry their own backdrop-filter. While a popup is
   open the fixed backdrop paints above them, and those filter layers re-sample
   the composited result — which lightens the strips and, on some GPUs, ghosts a
   displaced copy of the popup clipped to the sidebar's width. Suspending the two
   filters for as long as a popup is open removes it; both surfaces are opaque
   enough under the dimmed backdrop that nothing else changes. */
:root[data-modal-open] .sidebar,
:root[data-modal-open] .topbar { backdrop-filter: none; }
.modal {
  width: min(828px, 100%);
  max-height: min(84vh, 828px);
  display: flex; flex-direction: column;
  border-radius: var(--radius-lg);
  border: 1px solid var(--stroke-strong);
  background: linear-gradient(165deg, rgba(19, 29, 71, 0.98), rgba(8, 13, 36, 0.98));
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; gap: 13.8px;
  padding: 18.4px 23px;
  border-bottom: 1px solid var(--stroke);
}
.modal-head h2 { margin: 0; font-size: 17.2px; font-weight: 650; }
.modal-head p { margin: 2px 0 0; font-size: 13.8px; color: var(--text-muted); }
.modal-body { padding: 18.4px 23px; overflow-y: auto; }
.modal-foot {
  display: flex; gap: 9.2px; justify-content: flex-end;
  padding: 16.1px 23px;
  border-top: 1px solid var(--stroke);
}

/* ── Metric detail popup ────────────────────────────────────────────────── */

.modal.detail { width: min(1219px, 96vw); max-height: min(92vh, 1242px); }
.modal.detail .modal-head { flex-wrap: wrap; row-gap: 11.5px; }
.modal.detail .modal-head > div { flex: 1 1 276px; }
.detail-headline {
  display: flex;
  align-items: baseline;
  gap: 16.1px;
  flex-wrap: wrap;
  margin-bottom: 4.6px;
}
.detail-value {
  font-size: 46px;
  font-weight: 660;
  letter-spacing: -0.024em;
  line-height: 1.05;
  text-shadow: 0 0 34.5px rgba(0, 208, 255, 0.24);
}
.detail-value.is-empty { color: var(--text-faint); font-size: 29.9px; font-weight: 500; }
.detail-sub { font-size: 14.4px; color: var(--text-muted); margin: 0 0 18.4px; }

.detail-chart {
  padding: 16.1px 16.1px 6.9px;
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  background: rgba(5, 9, 25, 0.45);
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(147.2px, 1fr));
  gap: 1px;
  margin-top: 18.4px;
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  background: var(--stroke);
  overflow: hidden;
}
.stat {
  padding: 12.6px 14.9px;
  background: rgba(10, 16, 44, 0.94);
}
.stat dt {
  font-size: 11.5px; font-weight: 700;
  letter-spacing: 0.11em; text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 5.8px;
}
.stat dd {
  margin: 0;
  font-size: 18.4px; font-weight: 620;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.stat dd small {
  display: block;
  margin-top: 2px;
  font-size: 12.1px; font-weight: 500;
  color: var(--text-muted);
}

/* Two columns shouldn't be stretched across a 1150px popup. */
.modal.detail .table-wrap { display: inline-block; max-width: 100%; }
.modal.detail table.data { width: auto; min-width: 391px; }
.modal.detail table.data th:not(:first-child),
.modal.detail table.data td:not(:first-child) { min-width: 172.5px; }

.detail-section-title {
  margin: 20.7px 0 10.3px;
  font-size: 12.1px; font-weight: 700;
  letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--text-faint);
}

/* ── Targets manager ────────────────────────────────────────────────────── */

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 18.4px;
  flex-wrap: wrap;
  margin-bottom: 20.7px;
  padding-bottom: 16.1px;
  border-bottom: 1px solid var(--stroke);
}
.page-head h2 { margin: 0; font-size: 19.5px; font-weight: 650; letter-spacing: -0.01em; }
.page-head p { margin: 4.6px 0 0; font-size: 14.4px; color: var(--text-muted); max-width: 62ch; line-height: 1.55; }
.page-head .field { margin-left: auto; min-width: 276px; }

table.targets { table-layout: fixed; }
table.targets th.col-metric { width: 27%; }
table.targets .col-type { width: 11%; }
table.targets .col-latest { width: 15%; }
table.targets .col-target { width: 16%; min-width: 126.5px; }
table.targets .col-status { width: 19%; }
table.targets .col-actions { width: 12%; }
/* Fixed layout would clip the longer sales-team labels, so this column wraps. */
table.targets tbody th[scope="row"] {
  font-weight: 600;
  font-size: 14.4px;
  white-space: normal;
  line-height: 1.35;
}
table.targets .row-section {
  display: block;
  margin-top: 2px;
  font-size: 12.1px; font-weight: 500;
  color: var(--text-faint);
  letter-spacing: 0.05em; text-transform: uppercase;
}
.target-input {
  width: 100%;
  padding: 6.9px 10.3px;
  border-radius: 9.2px;
  border: 1px solid var(--stroke);
  background: rgba(5, 9, 25, 0.75);
  color: var(--text-primary);
  font-size: 14.4px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.target-input:hover:not([disabled]) { border-color: var(--stroke-strong); }
.target-input:focus {
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3.4px rgba(0, 208, 255, 0.14);
  outline: none;
}
.target-input[disabled] { opacity: 0.45; cursor: not-allowed; }
.target-input.saved {
  border-color: var(--status-good-ink);
  box-shadow: 0 0 0 3.4px rgba(12, 163, 12, 0.16);
}
.goal-tag {
  font-size: 12.1px; font-weight: 650;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted);
}
.targets-empty {
  padding: 39.1px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14.9px;
}

.user-row {
  display: grid;
  grid-template-columns: 39.1px 1fr auto auto;
  align-items: center;
  gap: 13.8px;
  padding: 11.5px 0;
  border-bottom: 1px solid var(--stroke);
}
.user-row:last-of-type { border-bottom: none; }
.user-name { font-size: 15.5px; font-weight: 600; }
.user-email { font-size: 13.2px; color: var(--text-muted); }

.field { display: flex; flex-direction: column; gap: 5.8px; }
.field label {
  font-size: 12.1px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-faint);
}
.field input, .field select {
  padding: 10.3px 12.6px;
  border-radius: 10.3px;
  border: 1px solid var(--stroke);
  background: rgba(5, 9, 25, 0.7);
  color: var(--text-primary);
  font-size: 14.9px;
}
.field input:hover, .field select:hover { border-color: var(--stroke-strong); }
.invite-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 172.5px auto;
  gap: 11.5px;
  align-items: end;
  padding: 16.1px;
  margin-top: 16.1px;
  border-radius: var(--radius);
  border: 1px dashed var(--stroke-strong);
  background: rgba(0, 162, 216, 0.05);
}
@media (max-width: 713px) { .invite-grid { grid-template-columns: 1fr; } }

.primary-btn {
  padding: 10.3px 18.4px;
  border-radius: 10.3px;
  font-size: 14.9px; font-weight: 600;
  color: #03121a;
  background: linear-gradient(140deg, var(--accent-bright), var(--accent-2-bright));
  box-shadow: 0 0 27.6px -6px var(--accent-glow);
  transition: filter 0.16s var(--ease);
}
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn[disabled] { opacity: 0.45; cursor: not-allowed; filter: none; }

.role-pill {
  display: inline-flex; align-items: center; gap: 5.8px;
  padding: 4.6px 11.5px;
  border-radius: 1148.8px;
  font-size: 12.6px; font-weight: 650;
  border: 1px solid currentColor;
  text-transform: capitalize;
}
.role-pill[data-role="admin"] { color: var(--series-3); background: rgba(171, 0, 255, 0.13); }
.role-pill[data-role="editor"] { color: var(--accent-bright); background: rgba(0, 162, 216, 0.13); }
.role-pill[data-role="viewer"] { color: var(--text-muted); background: rgba(111, 126, 169, 0.12); }

.role-select {
  padding: 6.9px 10.3px;
  border-radius: 9.2px;
  border: 1px solid var(--stroke);
  background: rgba(5, 9, 25, 0.7);
  font-size: 13.8px;
}
.link-btn {
  font-size: 13.8px;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3.4px;
}
.link-btn:hover { color: var(--status-critical-ink); }

.notice {
  padding: 11.5px 13.8px;
  border-radius: 11.5px;
  border: 1px solid var(--stroke);
  background: rgba(0, 162, 216, 0.07);
  font-size: 13.8px;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ── Login ──────────────────────────────────────────────────────────────── */

.login-veil {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 27.6px;
  background: var(--bg-deep);
}
/* Same ambient neon field as the app behind it. */
.login-veil::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1035px 598px at 18% 2%, rgba(0, 162, 216, 0.18), transparent 62%),
    radial-gradient(874px 552px at 85% 90%, rgba(120, 0, 220, 0.15), transparent 60%);
}
.login-card {
  position: relative;
  width: min(420px, 100%);
  padding: 32.2px 29.9px 27.6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--stroke-strong);
  background: linear-gradient(165deg, rgba(19, 29, 71, 0.97), rgba(8, 13, 36, 0.97));
  box-shadow: var(--shadow-pop);
}
.login-card .brand-mark { width: 46px; height: 46px; font-size: 20.7px; }
.login-head {
  display: flex;
  align-items: center;
  gap: 13.8px;
  margin-bottom: 23px;
}
.login-head h1 { margin: 0; font-size: 18.4px; font-weight: 650; letter-spacing: -0.01em; }
.login-head p { margin: 2.3px 0 0; font-size: 12.6px; color: var(--text-muted); }
.login-card .field { margin-bottom: 13.8px; }
.login-error {
  display: none;
  margin: 0 0 13.8px;
  padding: 9.2px 11.5px;
  border-radius: 9.2px;
  border: 1px solid var(--status-critical);
  background: rgba(208, 59, 59, 0.12);
  color: var(--status-critical-ink);
  font-size: 12.6px;
  line-height: 1.5;
}
.login-error[data-show="true"] { display: block; }
.login-card .primary-btn { width: 100%; padding: 11.5px; font-size: 14.9px; }
.login-foot {
  margin: 16.1px 0 0;
  font-size: 11.5px;
  color: var(--text-faint);
  text-align: center;
  line-height: 1.6;
}

/* ── Import page ────────────────────────────────────────────────────────── */

.import-zone {
  display: grid;
  place-items: center;
  min-height: 172.5px;
  padding: 27.6px;
  border: 2px dashed var(--stroke-strong);
  border-radius: var(--radius-lg);
  background: rgba(0, 162, 216, 0.04);
  cursor: pointer;
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease);
}
.import-zone:hover,
.import-zone[data-drag="true"] {
  border-color: var(--accent-bright);
  background: rgba(0, 162, 216, 0.09);
}
.import-zone-inner {
  display: grid;
  justify-items: center;
  gap: 6.9px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14.9px;
}
.import-zone-inner span { font-size: 12.6px; color: var(--text-muted); max-width: 52ch; line-height: 1.6; }
.import-icon { width: 32.2px; height: 32.2px; color: var(--accent-bright); }
#import-error { margin-top: 16.1px; }
.import-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 13.8px;
  margin-top: 18.4px;
}
.import-actions span { font-size: 12.6px; color: var(--status-critical-ink); }

/* ── Loading / empty ────────────────────────────────────────────────────── */

.boot {
  display: grid; place-items: center;
  height: 60vh;
  gap: 16.1px;
  color: var(--text-muted);
  font-size: 14.9px;
}
.boot-bar {
  width: 207px; height: 3.4px;
  border-radius: 2px;
  background: rgba(130, 175, 255, 0.12);
  overflow: hidden;
}
.boot-bar i {
  display: block; height: 100%; width: 40%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent-bright), var(--accent-2-bright));
  animation: sweep 1.1s var(--ease) infinite;
}
@keyframes sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}

@media (max-width: 1035px) {
  .app { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
  .app[data-sidebar="expanded"] { grid-template-columns: var(--sidebar-w) 1fr; }
}
