/* ============================================================
   X3 COMPASS — DEV PREVIEW (Manus Compliance Command Center)
   Self-contained CSS for the /dev/ multi-page mockup.
   Black + cyan aesthetic. Pixel-faithful to Manus design.
============================================================ */

* { box-sizing: border-box; }

:root {
  --bg:           #000000;
  --bg-2:         #000000;
  --surface:      #0F1620;
  --surface-2:    #141C28;
  --border:       #1F2937;
  --border-hover: #2D3B4F;
  --fg:           #FFFFFF;
  --fg-muted:     #B8C5D6;
  --fg-faint:     #6B7A90;
  --accent:       #16C7FF;
  --accent-2:     #00B7FF;
  --accent-dim:   rgba(22, 199, 255, 0.18);
  --success:      #22C55E;
  --warning:      #FBBF24;
  --danger:       #EF4444;
  --grid-line:    rgba(255, 255, 255, 0.05);
}

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* ============== SHELL ============== */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* ============== TOPBAR ============== */
.topbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 64px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-logo {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-right: 1px solid var(--border);
  height: 100%;
}
.topbar-logo .x3-mark {
  font-weight: 900;
  font-size: 28px;
  letter-spacing: -1px;
  color: var(--accent);
  line-height: 1;
}
.topbar-title {
  padding: 0 28px;
  font-size: 20px;
  font-weight: 600;
  color: var(--fg);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 24px;
}
.topbar-bell {
  position: relative;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  cursor: pointer;
  color: var(--accent);
  font-size: 18px;
}
.topbar-bell:hover { background: var(--surface); }
.topbar-bell .dot {
  position: absolute;
  top: 8px; right: 10px;
  width: 8px; height: 8px;
  background: var(--accent);
  border: 2px solid var(--bg);
  border-radius: 50%;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.topbar-user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FBBF24, #F59E0B);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #1F2937;
  font-size: 13px;
}
.topbar-user-text { line-height: 1.2; }
.topbar-user-name { font-weight: 600; font-size: 14px; }
.topbar-user-role { font-size: 11px; color: var(--fg-faint); }

/* ============== SIDEBAR v2 (FleetRabbit-style) ============== */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 0;
  height: calc(100vh - 64px);
  overflow-y: auto;
  position: sticky;
  top: 64px;
  display: flex;
  flex-direction: column;
}

/* Brand strip at the top of the sidebar */
.sb2-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sb2-x3 {
  width: 32px; height: 32px;
  border-radius: 7px;
  background: linear-gradient(135deg, #22D3EE, #06B6D4);
  color: #0A1929;
  display: grid; place-items: center;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: -0.5px;
}
.sb2-brand-text { line-height: 1.1; min-width: 0; }
.sb2-brand-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: 0.02em;
}
.sb2-brand-tag {
  font-size: 9px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 2px;
  font-weight: 700;
}

/* Nav body */
.sb2-nav {
  padding: 8px 6px;
  flex: 1;
}

/* Flat leaf items (Dashboard, Ask Compass, Hazmat, Bulk Import) */
.sb2-leaf {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg-faint);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.12s;
}
.sb2-leaf:hover {
  color: var(--fg);
  background: var(--surface);
}
.sb2-leaf.active {
  background: var(--accent-dim);
  color: var(--fg);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}

/* Group headers (Driver Brain, Vehicle Brain, etc.) */
.sb2-group {
  margin: 1px 0;
}
.sb2-group-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg-faint);
  cursor: pointer;
  list-style: none;
  transition: all 0.12s;
}
.sb2-group-head::-webkit-details-marker { display: none; }
.sb2-group-head:hover {
  color: var(--fg);
  background: var(--surface);
}

.sb2-ico {
  width: 20px;
  text-align: center;
  font-size: 15px;
  opacity: 0.9;
  flex-shrink: 0;
}
.sb2-label { flex: 1; min-width: 0; }
.sb2-chev {
  color: var(--fg-faint);
  font-size: 11px;
  transition: transform 0.15s ease;
}
.sb2-group[open] > .sb2-group-head .sb2-chev {
  transform: rotate(180deg);
}

/* Group body (sub-items revealed when expanded) */
.sb2-group-body {
  padding: 2px 0 4px 12px;
}

/* Sub-items inside a group */
.sb2-subitem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 5px;
  font-size: 12.5px;
  color: var(--fg-muted);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.12s;
}
.sb2-subitem:hover {
  color: var(--fg);
  background: var(--surface);
}
.sb2-subitem.active {
  background: var(--accent-dim);
  color: var(--fg);
  font-weight: 600;
}

/* Colored dots (categorical color system) */
.sb2-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sb2-dot.dot-emerald { background: #34D399; }
.sb2-dot.dot-cyan    { background: #22D3EE; }
.sb2-dot.dot-amber   { background: #FBBF24; }
.sb2-dot.dot-rose    { background: #FB7185; }
.sb2-dot.dot-violet  { background: #A78BFA; }
.sb2-dot.dot-slate   { background: #94A3B8; }

/* Counter pills on group titles + leaf items */
.sb2-pill {
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* "What's new" footer card */
.sb2-newcard {
  margin: 10px 8px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.sb2-newicon {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, #22D3EE, #06B6D4);
  color: #0A1929;
  display: grid; place-items: center;
  font-size: 15px;
  flex-shrink: 0;
}
.sb2-newtitle {
  font-size: 12px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.2;
}
.sb2-newsub {
  font-size: 10.5px;
  color: var(--fg-faint);
  margin-top: 2px;
}

/* ============== MAIN AREA ============== */
.main {
  padding: 24px;
  background: var(--bg);
  min-width: 0;
}

/* ============== CARDS ============== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--border-hover); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--fg-faint);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-info {
  font-size: 12px;
  color: var(--fg-faint);
  cursor: help;
}
.card-link {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

/* ============== KPI HERO ROW ============== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.kpi-card { padding: 22px; min-height: 150px; }
.kpi-card-body {
  display: flex;
  align-items: center;
  gap: 16px;
}
.kpi-donut {
  position: relative;
  width: 110px;
  height: 110px;
  flex-shrink: 0;
}
.kpi-donut svg { transform: rotate(-90deg); }
.kpi-donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  line-height: 1.1;
}
.kpi-donut-number {
  font-size: 28px;
  font-weight: 800;
  color: var(--fg);
}
.kpi-donut-label {
  font-size: 11px;
  color: var(--success);
  font-weight: 600;
  margin-top: 2px;
}
.kpi-donut-label.warning { color: var(--warning); }
.kpi-meta { flex: 1; min-width: 0; }
.kpi-meta-delta {
  font-size: 13px;
  color: var(--success);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}
.kpi-meta-sub {
  font-size: 12px;
  color: var(--fg-faint);
  margin-top: 2px;
}
.kpi-spark {
  margin-top: 12px;
  height: 36px;
}

/* "Active Drivers" big number card */
.kpi-card-big {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}
.kpi-big-number {
  font-size: 56px;
  font-weight: 800;
  color: var(--fg);
  line-height: 1;
}
.kpi-big-icon {
  font-size: 56px;
  color: var(--fg-faint);
  opacity: 0.35;
}
.kpi-big-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--success);
  font-weight: 600;
}
.kpi-big-sub {
  font-size: 12px;
  color: var(--fg-faint);
  margin-top: 4px;
}

/* "Open Alerts" alerts breakdown */
.alerts-breakdown {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}
.alerts-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.alerts-num { font-weight: 700; min-width: 22px; text-align: right; }
.alerts-label { color: var(--fg-muted); }
.alerts-line.urgent .alerts-num { color: var(--danger); }
.alerts-line.urgent .alerts-label { color: var(--danger); }
.alerts-line.warning .alerts-num { color: var(--warning); }
.alerts-line.warning .alerts-label { color: var(--warning); }
.alerts-line.info .alerts-num { color: var(--accent); }
.alerts-line.info .alerts-label { color: var(--accent); }
.alerts-icon-large {
  width: 110px; height: 110px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 36px;
  background: conic-gradient(var(--danger) 0deg 130deg, var(--warning) 130deg 360deg);
  position: relative;
}
.alerts-icon-large::before {
  content: '';
  position: absolute;
  inset: 14px;
  background: var(--surface);
  border-radius: 50%;
}
.alerts-icon-large span { position: relative; color: var(--danger); }

/* ============== MIDDLE ROW (3 panels) ============== */
.middle-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* Compliance overview progress bars */
.compliance-row {
  display: grid;
  grid-template-columns: 24px 1fr 60px 14px;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.compliance-row:last-of-type { border-bottom: none; }
.compliance-icon {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  background: var(--accent-dim);
  border-radius: 5px;
  color: var(--accent);
  font-size: 13px;
}
.compliance-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.compliance-bar-label {
  font-size: 13px;
  color: var(--fg);
  font-weight: 500;
}
.compliance-bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.compliance-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 3px;
}
.compliance-pct {
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
  text-align: right;
}
.compliance-chev { color: var(--fg-faint); font-size: 16px; }
.compliance-cta {
  margin-top: 16px;
  padding: 10px;
  text-align: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
}
.compliance-cta:hover { background: var(--surface-2); border-color: var(--accent); }

/* Action items */
.action-item {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.action-item:last-of-type { border-bottom: none; }
.action-icon { font-size: 16px; padding-top: 1px; }
.action-icon.urgent { color: var(--danger); }
.action-icon.warning { color: var(--warning); }
.action-icon.success { color: var(--success); }
.action-text { font-size: 13px; color: var(--fg); line-height: 1.4; }
.action-text strong { font-weight: 700; }
.action-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}
.action-badge-pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 4px;
}
.action-badge-pill.urgent {
  background: rgba(239, 68, 68, 0.18);
  color: var(--danger);
}
.action-badge-pill.warning {
  background: rgba(251, 191, 36, 0.18);
  color: var(--warning);
}
.action-badge-pill.good {
  background: rgba(34, 197, 94, 0.18);
  color: var(--success);
}
.action-badge-sub {
  font-size: 10px;
  color: var(--fg-faint);
  margin-top: 3px;
}

/* CSA BASICS */
.csa-row {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.csa-row:last-of-type { border-bottom: none; }
.csa-letter {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: transparent;
  border: 2px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  font-weight: 800;
  font-size: 14px;
}
.csa-name { display: flex; flex-direction: column; }
.csa-name-main { font-size: 13px; color: var(--fg); font-weight: 600; }
.csa-name-sub { font-size: 11px; color: var(--fg-faint); }
.csa-score { font-size: 18px; font-weight: 800; color: var(--fg); }
.csa-rating {
  font-size: 12px;
  font-weight: 600;
  min-width: 50px;
  text-align: right;
}
.csa-rating.good { color: var(--success); }
.csa-rating.fair { color: var(--warning); }
.csa-rating.poor { color: var(--danger); }
.csa-subtitle {
  font-size: 11px;
  color: var(--fg-faint);
  margin-bottom: 8px;
}

/* ============== BOTTOM ROW (3 charts) ============== */
.bottom-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1.4fr;
  gap: 16px;
  margin-bottom: 16px;
}
.chart-wrap { height: 220px; position: relative; }

/* Open alerts donut & legend */
.donut-flex {
  display: flex;
  align-items: center;
  gap: 18px;
}
.donut-large {
  width: 160px; height: 160px;
  position: relative;
  flex-shrink: 0;
}
.donut-center-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  line-height: 1.1;
}
.donut-center-num { font-size: 30px; font-weight: 800; color: var(--fg); }
.donut-center-sub { font-size: 11px; color: var(--fg-faint); }
.donut-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.donut-legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.donut-legend-dot { width: 10px; height: 10px; border-radius: 50%; }
.donut-legend-dot.urgent { background: var(--danger); }
.donut-legend-dot.warning { background: var(--warning); }
.donut-legend-dot.info { background: var(--accent); }
.donut-legend-label { color: var(--fg-muted); flex: 1; }
.donut-legend-val { font-weight: 700; color: var(--fg); }
.donut-legend-pct { color: var(--fg-faint); font-size: 11px; margin-left: 4px; }

/* ============== FOOTER ============== */
.app-footer {
  grid-column: 2 / -1;
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  font-size: 12px;
  color: var(--fg-faint);
  display: flex;
  justify-content: space-between;
}
.app-footer a { color: var(--accent); }

/* ============== STUB PAGES ============== */
.stub-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 24px;
}
.stub-hero-icon {
  font-size: 56px;
  margin-bottom: 16px;
  color: var(--accent);
}
.stub-hero h1 {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 700;
  color: var(--fg);
}
.stub-hero p {
  margin: 0;
  font-size: 15px;
  color: var(--fg-muted);
  max-width: 560px;
}
.stub-hero .stub-back {
  margin-top: 24px;
  padding: 10px 20px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  display: inline-block;
}

/* Page title above content */
.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-title { font-size: 24px; font-weight: 700; color: var(--fg); margin: 0; }

/* Responsive — collapse columns on narrow screens */
@media (max-width: 1200px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .middle-row { grid-template-columns: 1fr; }
  .bottom-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .topbar { grid-template-columns: 1fr auto; }
  .topbar-title { display: none; }
  .sidebar { display: none; }
  .app-footer { grid-column: 1 / -1; }
  .kpi-row { grid-template-columns: 1fr; }
}


/* === Centered topbar title (X3 logo lives in sidebar only) === */
.topbar-title {
  grid-column: 2;
  text-align: center;
  justify-self: center;
  padding: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.01em;
}
.topbar-right {
  grid-column: 3;
  justify-self: end;
}


/* === Unified brand box + body grid layout (top-left corner) === */
body {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 88px 1fr;
  grid-template-areas:
    "brand topbar"
    "sidebar main";
  min-height: 100vh;
}
.brand-box {
  grid-area: brand;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #000000;
  border-right: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  transition: background 0.12s;
}
.brand-box:hover { background: var(--surface); }
.brand-box .brand-x3 {
  height: 44px;
  width: auto;
  display: block;
  filter: drop-shadow(0 0 14px rgba(22, 199, 255, 0.35));
}
.brand-box .brand-word {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  margin-top: 4px;
  line-height: 1;
}

/* Topbar: row 1, col 2 only (no longer full-width); height matches brand-box (88px) */
.topbar {
  grid-area: topbar !important;
  grid-column: auto !important;
  height: 88px !important;
  grid-template-columns: 1fr auto 1fr !important;
  position: relative !important;
  top: 0 !important;
  border-bottom: 1px solid var(--border);
}

/* App-shell becomes invisible wrapper so its children promote into body grid */
.app-shell {
  display: contents !important;
}

/* Sidebar: row 2, col 1; height now = viewport minus topbar (88px) */
.sidebar {
  grid-area: sidebar !important;
  height: calc(100vh - 88px) !important;
  top: 88px !important;
  border-top: 0;
}

/* Hide legacy in-sidebar brand block (replaced by .brand-box up top) */
.sb2-brand {
  display: none !important;
}

/* Main fills row 2 col 2 */
.main { grid-area: main !important; }

/* AI Safety Director — BIG centered title */
.topbar-title {
  grid-column: 2;
  text-align: center;
  justify-self: center;
  padding: 0;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.015em;
  background: linear-gradient(180deg, #FFFFFF 30%, #16C7FF 130%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--fg); /* fallback */
  line-height: 1;
}

@media (max-width: 768px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: 64px 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .brand-box, .sidebar { display: none; }
  .topbar { height: 64px !important; }
  .topbar-title { font-size: 22px; }
}


/* === Sidebar text WHITE, icons CYAN, line-style upgrade === */
.sb2-leaf,
.sb2-group-head,
.sb2-subitem {
  color: #FFFFFF !important;
}
.sb2-leaf:hover,
.sb2-group-head:hover,
.sb2-subitem:hover {
  background: rgba(22, 199, 255, 0.10) !important;
  color: #FFFFFF !important;
}
.sb2-leaf.active,
.sb2-subitem.active {
  background: rgba(22, 199, 255, 0.18) !important;
  color: #FFFFFF !important;
}
/* Icon color CYAN */
.sb2-ico {
  color: var(--accent) !important;
  opacity: 1 !important;
}
.sb2-ico svg {
  width: 18px;
  height: 18px;
  stroke: var(--accent);
  stroke-width: 2;
  fill: none;
  display: block;
}
.sb2-group-head .sb2-chev {
  color: rgba(255,255,255,0.5);
}


/* === Sticky shell: brand box + topbar + sidebar stay in place; only .main scrolls === */
html, body { height: 100%; overflow: hidden; }
.main {
  overflow-y: auto !important;
  overflow-x: hidden;
  height: calc(100vh - 88px);
}
.sidebar {
  overflow-y: auto !important;
}
