/* Design tokens + shell (sidebar/topbar) shared across all pages. */
:root {
  --surface-0: #f4f6f9;
  --surface-1: #ffffff;
  --surface-2: #eef1f6;
  --border: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #52596b;
  --text-muted: #8a91a3;

  --sidebar-bg: #0b1220;
  --sidebar-text: #cbd5e1;
  --sidebar-text-active: #ffffff;
  --sidebar-active-bg: #1c2a45;

  --series-1: #2a78d6; /* dataviz reference palette: blue */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--surface-0);
  color: var(--text-primary);
}

a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }

#app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 18px;
  font-weight: 700;
  color: #fff;
  font-size: 1.02rem;
}
.sidebar .brand .dot { color: var(--series-1); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 0.88rem;
  text-decoration: none;
}
.sidebar nav a:hover { background: #131c30; text-decoration: none; }
.sidebar nav a.active { background: var(--sidebar-active-bg); color: var(--sidebar-text-active); font-weight: 600; }
.sidebar nav a .icon { font-size: 1rem; width: 18px; text-align: center; }
.sidebar .tip-card {
  margin-top: auto;
  background: linear-gradient(160deg, #16233f, #0b1220);
  border: 1px solid #1c2a45;
  border-radius: 10px;
  padding: 14px;
  font-size: 0.78rem;
  color: #cbd5e1;
}
.sidebar .tip-card .tip-title { font-weight: 700; color: #fff; margin-bottom: 4px; }
.sidebar .tip-card a { color: #7fb2f0; font-weight: 600; font-size: 0.76rem; }
.sidebar .foot {
  font-size: 0.68rem;
  color: #64748b;
  padding: 10px 10px 0;
  border-top: 1px solid #1c2a45;
  margin-top: 10px;
}

/* ---- Topbar ---- */
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; }
.topbar {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar .greeting { flex: 0 0 auto; }
.topbar .greeting h1 { margin: 0; font-size: 1.05rem; }
.topbar .greeting p { margin: 2px 0 0; font-size: 0.78rem; color: var(--text-muted); }
.topbar .search {
  flex: 1;
  max-width: 420px;
  margin-left: 12px;
}
.topbar .search input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--text-primary);
}
.topbar .search { position: relative; }
.topbar .search input { padding-right: 46px; }
.topbar .search .kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 0.68rem; color: var(--text-muted);
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px;
}
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.topbar .date { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }
.topbar .bell { position: relative; font-size: 1.15rem; color: var(--text-secondary); cursor: default; }
.topbar .bell .dot {
  position: absolute; top: -2px; right: -2px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--status-critical); border: 2px solid var(--surface-1);
}
.topbar .dealer { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; cursor: default; }
.topbar .dealer .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--series-1); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.78rem;
}
.topbar .dealer .name { font-weight: 600; }
.topbar .dealer .sub { color: var(--text-muted); font-size: 0.72rem; }
.topbar .dealer .chevron { color: var(--text-muted); font-size: 0.65rem; margin-left: 2px; }

main.content {
  padding: 20px 24px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* ---- Shared components ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.stat-card .icon-chip {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.chip-blue { background: #dbeafe; }
.chip-green { background: #dcfce7; }
.chip-purple { background: #ede9fe; }
.chip-indigo { background: #e0e7ff; }
.chip-cyan { background: #cffafe; }
.chip-navy { background: #dbeafe; }
.stat-card .label { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 4px; }
.stat-card .value { font-size: 1.4rem; font-weight: 700; line-height: 1.1; }
.stat-card .sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.panel h2 { margin: 0 0 2px; font-size: 0.95rem; display: flex; align-items: center; gap: 8px; }
.panel h2 .icon-chip { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 7px; font-size: 0.85rem; }
.panel .panel-sub { margin: 0 0 12px; font-size: 0.78rem; color: var(--text-muted); }

.avatar-color-0 { background: #2a78d6; }
.avatar-color-1 { background: #1baf7a; }
.avatar-color-2 { background: #4a3aa7; }
.avatar-color-3 { background: #eb6834; }
.avatar-color-4 { background: #e87ba4; }
.avatar-color-5 { background: #0891b2; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
}
.badge.good { background: rgba(12,163,12,0.12); color: var(--status-good); }
.badge.warning { background: rgba(250,178,25,0.18); color: #a3690a; }
.badge.serious { background: rgba(236,131,90,0.16); color: #b1461f; }
.badge.critical { background: rgba(208,59,59,0.12); color: var(--status-critical); }
.badge.neutral { background: var(--surface-2); color: var(--text-secondary); }
.badge.info { background: rgba(42,120,214,0.12); color: var(--series-1); }

.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 90px; }
.bar-chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-chart .bar {
  width: 100%;
  max-width: 26px;
  background: var(--series-1);
  border-radius: 4px 4px 2px 2px;
  min-height: 3px;
}
.bar-chart .bar-label { font-size: 0.65rem; color: var(--text-muted); margin-top: 4px; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.data-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
table.data-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table img.thumb { width: 48px; height: 36px; object-fit: cover; border-radius: 6px; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .topbar .search { display: none; }
}
