/* ============================================================
   iRoadTech Asset Portal — Kimi-themed dark SaaS shell
   ============================================================ */

:root {
  --bg-primary: #08080d;
  --bg-secondary: #0f0f17;
  --bg-tertiary: #14141d;
  --bg-card: #16161f;
  --bg-card-hover: #1c1c28;
  --bg-input: #0c0c13;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.10);
  --border-hover: rgba(255, 255, 255, 0.18);
  --border-strong: rgba(255, 255, 255, 0.24);

  --text-primary: #f0f0f4;
  --text-secondary: #a3a3b3;
  --text-muted: #6c6c80;
  --text-inverse: #0a0a10;

  --accent: #00b8f0;
  --accent-glow: rgba(0, 184, 240, 0.18);
  --accent-soft: rgba(0, 184, 240, 0.10);
  --accent-secondary: #7b5cff;
  --accent-secondary-soft: rgba(123, 92, 255, 0.12);
  --accent-warm: #ff6b4a;
  --accent-warm-soft: rgba(255, 107, 74, 0.12);
  --accent-mint: #00f0a0;
  --accent-mint-soft: rgba(0, 240, 160, 0.12);
  --accent-amber: #ffb547;
  --accent-amber-soft: rgba(255, 181, 71, 0.12);

  --font-heading: 'Outfit', -apple-system, sans-serif;
  --font-body: 'DM Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Consolas', monospace;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.2), 0 4px 14px rgba(0, 0, 0, 0.25);
  --shadow-pop: 0 8px 32px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--border);
  --shadow-glow: 0 0 30px var(--accent-glow);

  --topbar-height: 56px;
  --rail-width: 232px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast: 120ms var(--ease);
  --t-mid: 200ms var(--ease);
  --t-slow: 320ms var(--ease);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text-primary);
  background: var(--bg-primary);
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); color: var(--text-primary); }

kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-secondary);
}

/* ============================================================
   SHELL LAYOUT
   ============================================================ */

#shell {
  display: grid;
  grid-template-columns: var(--rail-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "topbar topbar"
    "rail   view";
  height: 100%;
  background:
    radial-gradient(ellipse 1200px 600px at 30% -20%, rgba(0, 184, 240, 0.06), transparent 60%),
    radial-gradient(ellipse 800px 400px at 100% 100%, rgba(123, 92, 255, 0.04), transparent 60%),
    var(--bg-primary);
}

/* ============================================================
   TOP BAR
   ============================================================ */

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(8, 8, 13, 0.7);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  z-index: 50;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast);
}
.topbar__brand:hover { background: var(--bg-card); }

.topbar__brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topbar__brand-text {
  display: flex;
  flex-direction: column;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  line-height: 1;
}
.topbar__brand-sub {
  font-weight: 500;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 3px;
  letter-spacing: 0.02em;
}

.topbar__module {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-size: 13px;
}
.topbar__module-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-mint);
  box-shadow: 0 0 8px var(--accent-mint);
  animation: pulse 2s ease-in-out infinite;
}
.topbar__module-name {
  font-weight: 600;
  color: var(--text-primary);
}
.topbar__module-meta {
  color: var(--text-secondary);
}
.topbar__module-status {
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-mint);
  padding: 2px 8px;
  background: var(--accent-mint-soft);
  border-radius: 4px;
}

.topbar__search {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  max-width: 380px;
  margin-left: auto;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  transition: var(--t-fast);
  text-align: left;
}
.topbar__search:hover {
  border-color: var(--border-hover);
  color: var(--text-secondary);
}
.topbar__search span { flex: 1; }

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar__icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--t-fast);
}
.topbar__icon-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.topbar__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-secondary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 12px;
  color: white;
  margin-left: 6px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.9); }
}

/* ============================================================
   LEFT RAIL
   ============================================================ */

.rail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
}

.rail__nav {
  flex: 1;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.rail__group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rail__group-label {
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 12px 6px;
}

.rail__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  position: relative;
  transition: var(--t-fast);
}
.rail__item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}
.rail__item.is-active {
  background: var(--accent-soft);
  color: var(--text-primary);
}
.rail__item.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
.rail__item.is-active .rail__icon { color: var(--accent); }

.rail__item--soon {
  color: var(--text-muted);
  cursor: default;
}
.rail__item--soon:hover {
  background: transparent;
  color: var(--text-muted);
}

.rail__icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color var(--t-fast);
  flex-shrink: 0;
}
.rail__item:hover .rail__icon { color: var(--text-secondary); }

.rail__label { flex: 1; }

.rail__chip {
  font-family: var(--font-heading);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 2px 6px;
  border-radius: 4px;
}

.rail__footer {
  border-top: 1px solid var(--border-subtle);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rail__footer-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}
.rail__footer-label {
  color: var(--text-muted);
  font-family: var(--font-heading);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 600;
}
.rail__footer-value {
  color: var(--text-secondary);
  font-weight: 500;
}

/* ============================================================
   MAIN VIEW
   ============================================================ */

.view {
  grid-area: view;
  position: relative;
  overflow: hidden;
}

.page {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* Respect HTML hidden attribute for layered portal surfaces.
   Some components intentionally override [hidden] (e.g. asset panel). */
.page[hidden],
.page-loading[hidden],
.page-error[hidden],
.map-empty[hidden] {
  display: none !important;
}

.page--map {
  display: grid;
  grid-template-columns: 320px 1fr;
  overflow: hidden;
}

.page__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 32px 32px 0;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page__eyebrow {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.page__title {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.page__subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.page__header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  transition: var(--t-fast);
  border: 1px solid transparent;
}

.btn--primary {
  background: var(--accent);
  color: var(--text-inverse);
  font-weight: 600;
}
.btn--primary:hover {
  background: #33ccff;
  box-shadow: var(--shadow-glow);
}

.btn--ghost {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
.btn--ghost:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}
.btn--ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--danger {
  color: var(--accent-warm);
}

/* ============================================================
   CARDS / GENERIC
   ============================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  margin-bottom: 18px;
  margin-left: 32px;
  margin-right: 32px;
}

.card--flush { padding: 0; overflow: hidden; }

.card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.card__title {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.005em;
}

.card__hint {
  font-size: 12px;
  color: var(--text-muted);
}

.card__action {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent);
  transition: var(--t-fast);
}
.card__action:hover { color: #33ccff; }

.row--2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.row--2col .card { margin-left: 0; margin-right: 0; }
.row {
  margin: 0 32px 18px;
}

@media (max-width: 1100px) {
  .row--2col { grid-template-columns: 1fr; }
}

/* ============================================================
   OVERVIEW
   ============================================================ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 0 32px;
  margin-bottom: 18px;
}

@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px)  { .kpi-grid { grid-template-columns: 1fr; } }

.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: var(--t-fast);
}
.kpi:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.kpi__label {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.kpi__value {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1;
}
.kpi__suffix {
  font-size: 18px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-left: 4px;
}

.kpi__delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 500;
}
.kpi__delta--up { color: var(--accent-mint); }
.kpi__delta--flat { color: var(--text-muted); }

.kpi__sparkline {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 60%;
  height: 50%;
  pointer-events: none;
  opacity: 0.7;
}

/* Donut */
.donut-wrap {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 24px;
  align-items: center;
}
.donut-wrap svg { width: 160px; height: 160px; }
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.donut-legend__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.donut-legend__label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}
.donut-legend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.donut-legend__value {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Bars */
.bars-wrap {
  height: 160px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 12px 0 0;
}
.bars-wrap__bar {
  flex: 1;
  background: linear-gradient(180deg, var(--accent), var(--accent-secondary));
  border-radius: 3px 3px 0 0;
  min-height: 6px;
  transition: opacity var(--t-fast);
  position: relative;
}
.bars-wrap__bar:hover { opacity: 0.85; }
.bars-wrap__bar::after {
  content: attr(data-label);
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Map preview */
.card--map-preview { padding-bottom: 0; overflow: hidden; }
.card--map-preview .card__header { padding-bottom: 0; }
.map-preview {
  height: 260px;
  margin: 0 -24px -22px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-tertiary);
}

/* Streets list */
.streets-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.streets-list__row {
  display: grid;
  grid-template-columns: 24px 1fr 60px;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border-subtle);
}
.streets-list__row:last-child { border-bottom: none; }
.streets-list__rank {
  font-family: var(--font-heading);
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}
.streets-list__name { color: var(--text-primary); font-weight: 500; }
.streets-list__bar-wrap {
  position: relative;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  margin-top: 4px;
}
.streets-list__bar {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
  border-radius: 2px;
}
.streets-list__count {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Activity feed */
.activity-feed {
  list-style: none;
  display: flex;
  flex-direction: column;
}
.activity-feed__item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
  align-items: flex-start;
}
.activity-feed__item:last-child { border-bottom: none; }
.activity-feed__icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.activity-feed__title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.activity-feed__meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.activity-feed__time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Compliance strip */
.compliance-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px 32px 32px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--font-heading);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}
.compliance-strip__item { color: var(--text-secondary); }
.compliance-strip__sep { color: var(--text-muted); }

/* ============================================================
   FILTERS PANEL
   ============================================================ */

.filters {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.filters__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.filters__eyebrow {
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.filters__title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.filters__reset {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: 6px;
  transition: var(--t-fast);
}
.filters__reset:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.filters__group {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.filters__group--grow {
  flex: 1;
  overflow-y: auto;
  border-bottom: none;
}

.filters__label {
  font-family: var(--font-heading);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filters__search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: var(--t-fast);
}
.filters__search:focus-within {
  border-color: var(--accent);
  background: var(--bg-card);
}
.filters__search svg { color: var(--text-muted); flex-shrink: 0; }
.filters__search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--text-primary);
}
.filters__search input::placeholder { color: var(--text-muted); }

.filters__search--inline {
  flex: none;
  width: 280px;
}

.filters__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--t-fast);
  user-select: none;
}
.chip:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}
.chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text-primary);
}
.chip__swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.chip__count {
  font-size: 10.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.chip.is-active .chip__count { color: var(--text-secondary); }

.filters__streets {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 100%;
  overflow-y: auto;
}
.filters__street-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--t-fast);
  user-select: none;
}
.filters__street-row:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}
.filters__street-row.is-active {
  background: var(--accent-soft);
  color: var(--text-primary);
}
.filters__street-check {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--t-fast);
}
.filters__street-row.is-active .filters__street-check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inverse);
}
.filters__street-name { flex: 1; }
.filters__street-count {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.filters__footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch__slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  transition: var(--t-fast);
}
.switch__slider::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 14px;
  height: 14px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: var(--t-fast);
}
.switch input:checked + .switch__slider {
  background: var(--accent);
  border-color: var(--accent);
}
.switch input:checked + .switch__slider::before {
  background: var(--text-inverse);
  transform: translateX(16px);
}

/* ============================================================
   MAP AREA
   ============================================================ */

.map-area {
  position: relative;
  overflow: hidden;
  background: var(--bg-tertiary);
}

.map-canvas {
  position: absolute;
  inset: 0;
  background: var(--bg-tertiary);
}

.map-overlay {
  position: absolute;
  z-index: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.map-overlay > * { pointer-events: auto; }

.map-overlay--top {
  top: 14px;
  right: 14px;
}
.map-overlay--bottom-left {
  bottom: 16px;
  left: 16px;
}
.map-overlay--bottom-right {
  bottom: 16px;
  right: 14px;
}

.basemap-switch {
  display: flex;
  background: rgba(15, 15, 23, 0.85);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.basemap-switch__btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 6px;
  transition: var(--t-fast);
}
.basemap-switch__btn:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}
.basemap-switch__btn.is-active {
  background: var(--accent);
  color: var(--text-inverse);
  font-weight: 600;
}

.map-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(15, 15, 23, 0.85);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--t-fast);
}
.map-icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.map-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: rgba(15, 15, 23, 0.85);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
}
.map-badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-mint);
  box-shadow: 0 0 6px var(--accent-mint);
}
.map-badge span:last-child { color: var(--text-primary); }

.legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: rgba(15, 15, 23, 0.85);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 11.5px;
}
.legend__item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}
.legend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.06);
}

/* Empty state inside map */
.map-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 700;
  background: rgba(8, 8, 13, 0.55);
  backdrop-filter: blur(2px);
}
.map-empty__inner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 28px 32px;
  max-width: 360px;
  text-align: center;
  box-shadow: var(--shadow-pop);
}
.map-empty__inner h3 {
  font-family: var(--font-heading);
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.map-empty__inner p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ============================================================
   ASSET PANEL
   ============================================================ */

.asset-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 440px;
  max-width: 100%;
  height: 100%;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 800;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform var(--t-mid);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.35);
}
.asset-panel[hidden] {
  display: flex;
  transform: translateX(100%);
  pointer-events: none;
}

.asset-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.asset-panel__eyebrow {
  font-family: var(--font-heading);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.asset-panel__title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.asset-panel__close {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: var(--t-fast);
}
.asset-panel__close:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.asset-panel__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 20px 0;
}
.asset-panel__chips .chip { cursor: default; }
.asset-panel__chips .chip:hover { background: var(--bg-card); }

.asset-panel__image {
  margin: 16px 20px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  overflow: hidden;
}
.asset-panel__image img {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  display: block;
  background: var(--bg-tertiary);
}
.asset-panel__image figcaption {
  padding: 8px 14px;
  font-size: 11.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
}

.asset-panel__tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 20px;
}
.asset-panel__tab {
  position: relative;
  padding: 10px 0;
  margin-right: 18px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: var(--t-fast);
}
.asset-panel__tab:hover { color: var(--text-primary); }
.asset-panel__tab.is-active { color: var(--text-primary); }
.asset-panel__tab.is-active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.asset-panel__tabpanel {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 8px;
}

.asset-panel__lead {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.asset-panel__code {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow-y: auto;
}

.asset-panel__minimap {
  height: 200px;
  margin-top: 14px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  background: var(--bg-tertiary);
}

.asset-panel__footer {
  border-top: 1px solid var(--border-subtle);
  padding: 12px 20px 16px;
}

.asset-panel__actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.asset-panel__actions .btn { padding: 6px 10px; font-size: 12px; }

.asset-panel__compliance {
  font-family: var(--font-heading);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
  font-weight: 500;
}

/* Key/value display */
.asset-kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  row-gap: 12px;
  column-gap: 14px;
  font-size: 13px;
}
.asset-kv dt {
  font-family: var(--font-heading);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-top: 2px;
}
.asset-kv dd {
  color: var(--text-primary);
  word-break: break-word;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.asset-kv .copy-btn {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: var(--t-fast);
}
.asset-kv .copy-btn:hover {
  background: var(--bg-card-hover);
  color: var(--accent);
}

.asset-kv__mono {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

/* ============================================================
   SIGNS LIST TABLE
   ============================================================ */

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  text-align: left;
  font-family: var(--font-heading);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.table th.is-sortable {
  cursor: pointer;
  user-select: none;
}
.table th.is-sortable:hover { color: var(--text-primary); }
.table th.is-sortable[data-direction="asc"]::after { content: ' ↑'; color: var(--accent); }
.table th.is-sortable[data-direction="desc"]::after { content: ' ↓'; color: var(--accent); }

.table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--t-fast);
  cursor: pointer;
}
.table tbody tr:hover { background: var(--bg-card-hover); }

.table tbody td {
  padding: 12px 16px;
  color: var(--text-secondary);
  vertical-align: middle;
}
.table tbody td:first-child {
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
}

.table .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.table .pill__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.table .conf {
  display: flex;
  align-items: center;
  gap: 8px;
}
.table .conf__bar {
  width: 50px;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}
.table .conf__bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
}
.table-footer__hint { color: var(--text-muted); }

/* ============================================================
   EMPTY (cosmetic) PAGES
   ============================================================ */

.page--empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
}
.empty-card {
  max-width: 480px;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 40px 36px;
}
.empty-card__icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.empty-card__title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.empty-card__desc {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 18px;
}
.empty-card__chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-secondary-soft);
  color: var(--accent-secondary);
  font-family: var(--font-heading);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
}
.empty-card__roadmap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 22px;
  text-align: left;
}
.empty-card__roadmap-item {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

/* ============================================================
   GLOBAL LOADING / ERROR
   ============================================================ */

.page-loading,
.page-error {
  position: absolute;
  inset: 0;
  background: var(--bg-primary);
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.page-loading p {
  color: var(--text-secondary);
  font-size: 13px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page-error__inner {
  text-align: center;
  max-width: 420px;
  padding: 30px;
}
.page-error__inner h2 {
  font-family: var(--font-heading);
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.page-error__inner p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 18px;
  line-height: 1.5;
}

/* ============================================================
   TOAST
   ============================================================ */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 12px);
  padding: 10px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow-pop);
  z-index: 9000;
  opacity: 0;
  pointer-events: none;
  transition: var(--t-mid);
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ============================================================
   ⌘K COMMAND PALETTE
   ============================================================ */

.cmdk {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14vh;
}
.cmdk[hidden] { display: none; }

.cmdk__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 13, 0.55);
  backdrop-filter: blur(4px);
}

.cmdk__panel {
  position: relative;
  width: 100%;
  max-width: 560px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

.cmdk__input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}
.cmdk__input-wrap svg { color: var(--text-muted); flex-shrink: 0; }
.cmdk__input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 15px;
  color: var(--text-primary);
}
.cmdk__input-wrap input::placeholder { color: var(--text-muted); }

.cmdk__results {
  max-height: 360px;
  overflow-y: auto;
}
.cmdk__group {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.cmdk__group:last-child { border-bottom: none; }
.cmdk__group-label {
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 18px 6px;
}
.cmdk__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 18px;
  font-size: 13.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--t-fast);
}
.cmdk__item-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.cmdk__item-text { flex: 1; }
.cmdk__item-meta { font-size: 11.5px; color: var(--text-muted); }
.cmdk__item:hover,
.cmdk__item.is-active {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}
.cmdk__item:hover .cmdk__item-icon,
.cmdk__item.is-active .cmdk__item-icon { color: var(--accent); }

.cmdk__empty {
  padding: 36px 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.cmdk__footer {
  display: flex;
  gap: 18px;
  padding: 8px 18px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-muted);
}
.cmdk__footer kbd { margin-right: 4px; }

/* ============================================================
   LEAFLET OVERRIDES
   ============================================================ */

.leaflet-container {
  background: var(--bg-tertiary) !important;
  font-family: var(--font-body) !important;
}

.leaflet-control-zoom {
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--radius-sm) !important;
  background: rgba(15, 15, 23, 0.85) !important;
  backdrop-filter: blur(12px) saturate(1.4) !important;
  box-shadow: none !important;
  overflow: hidden;
}
.leaflet-control-zoom a {
  background: transparent !important;
  color: var(--text-secondary) !important;
  border-bottom: 1px solid var(--border-subtle) !important;
  font-weight: 500 !important;
  font-size: 16px !important;
  width: 30px !important;
  height: 30px !important;
  line-height: 30px !important;
}
.leaflet-control-zoom a:hover {
  color: var(--text-primary) !important;
  background: var(--bg-card) !important;
}
.leaflet-control-zoom a:last-child {
  border-bottom: none !important;
}

.leaflet-control-attribution {
  background: rgba(15, 15, 23, 0.7) !important;
  color: var(--text-muted) !important;
  font-size: 10px !important;
  padding: 2px 8px !important;
  border-radius: 4px;
}
.leaflet-control-attribution a {
  color: var(--text-secondary) !important;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-pop) !important;
  border-radius: var(--radius-sm) !important;
}
.leaflet-popup-content-wrapper {
  padding: 4px 0;
}
.leaflet-popup-content {
  margin: 8px 14px !important;
  font-size: 12.5px !important;
  line-height: 1.5 !important;
}

.leaflet-tooltip {
  background: rgba(15, 15, 23, 0.92) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-primary) !important;
  font-size: 12px !important;
  padding: 5px 9px !important;
  border-radius: 6px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35) !important;
  font-weight: 500;
}
.leaflet-tooltip-top:before { border-top-color: rgba(15, 15, 23, 0.92) !important; }
.leaflet-tooltip-bottom:before { border-bottom-color: rgba(15, 15, 23, 0.92) !important; }

/* Custom marker (color-coded) */
.asset-marker {
  border-radius: 50%;
  border: 2px solid rgba(8, 8, 13, 0.65);
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.10), 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: var(--t-fast);
  cursor: pointer;
}
.asset-marker:hover {
  transform: scale(1.2);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18), 0 4px 14px rgba(0, 0, 0, 0.5);
}
.asset-marker--selected {
  transform: scale(1.4);
  box-shadow: 0 0 0 4px var(--accent-soft), 0 0 22px var(--accent), 0 4px 14px rgba(0, 0, 0, 0.5);
  z-index: 1000 !important;
}

/* Cluster styling */
.marker-cluster {
  background: rgba(0, 184, 240, 0.18) !important;
}
.marker-cluster div {
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary)) !important;
  color: white !important;
  font-family: var(--font-heading) !important;
  font-weight: 700 !important;
  font-size: 13px !important;
  border: 2px solid rgba(8, 8, 13, 0.6) !important;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 960px) {
  #shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-height) auto 1fr;
    grid-template-areas:
      "topbar"
      "rail"
      "view";
  }
  .rail {
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    height: auto;
  }
  .rail__nav { flex-direction: row; padding: 8px 12px; gap: 12px; }
  .rail__group { flex-direction: row; gap: 6px; }
  .rail__group-label { display: none; }
  .rail__item { padding: 6px 12px; font-size: 12.5px; white-space: nowrap; }
  .rail__footer { display: none; }
  .topbar__search { display: none; }
  .topbar__module-meta { display: none; }
  .page--map { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .filters { max-height: 240px; border-right: none; border-bottom: 1px solid var(--border-subtle); }
  .asset-panel { width: 100%; max-width: 100%; }
  .page__header { padding: 18px 18px 0; }
  .card, .row { margin-left: 18px; margin-right: 18px; }
  .kpi-grid { padding: 0 18px; }
}
