/* FleetDesk portal — light/dark, palette per the data-viz reference instance. */
:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --shadow: 0 1px 2px rgba(11,11,11,.05), 0 8px 24px rgba(11,11,11,.04);

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-text: #006300;

  --seq-100: #cde2fb; --seq-250: #86b6ef; --seq-400: #3987e5; --seq-550: #1c5cab;
  --radius: 10px;
  --sidebar-w: 226px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --plane: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --good-text: #0ca30c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  background: var(--plane);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

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

/* ---------------- layout ---------------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 10px 16px; font-weight: 650; font-size: 15px; letter-spacing: -.2px;
}
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); padding: 14px 10px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 8px; color: var(--text-secondary);
  font-weight: 500; text-decoration: none;
}
.nav a:hover { background: color-mix(in srgb, var(--text-primary) 5%, transparent); }
.nav a.active { background: color-mix(in srgb, var(--series-1) 12%, transparent);
  color: var(--series-1); font-weight: 600; }
.nav .pill { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px;
  background: color-mix(in srgb, var(--critical) 15%, transparent); color: var(--critical); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 26px;
  border-bottom: 1px solid var(--border); background: var(--surface-1);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: -.2px; }
.spacer { flex: 1; }
.content { padding: 22px 26px 60px; }

.live {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px;
  color: var(--text-secondary); padding: 4px 10px; border-radius: 99px;
  border: 1px solid var(--border);
}
.live .beacon { width: 7px; height: 7px; border-radius: 50%; background: var(--good);
  animation: pulse 2s ease-in-out infinite; }
.live.down .beacon { background: var(--critical); animation: none; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(.8); } }

/* ---------------- cards / tiles ---------------- */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--border); }
.card-head h2 { margin: 0; font-size: 13px; font-weight: 650; letter-spacing: -.1px; }
.card-head .sub { font-size: 12px; color: var(--text-muted); }
.card-body { padding: 14px 16px; }

.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); font-weight: 650; margin: 26px 0 10px; }
.section-title:first-child { margin-top: 4px; }

.tiles { display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); }
.tile {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 14px; display: block; color: inherit; text-decoration: none;
  transition: border-color .12s ease, transform .12s ease;
}
a.tile:hover { text-decoration: none; border-color: var(--axis); transform: translateY(-1px); }
.tile .label { font-size: 11.5px; color: var(--text-secondary); font-weight: 500;
  display: flex; align-items: center; gap: 6px; }
.tile .value { font-size: 27px; font-weight: 620; letter-spacing: -.6px; margin-top: 5px;
  line-height: 1.05; }
.tile .foot { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.tile.hero .value { font-size: 34px; }
.tile .swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }

.tile.good .value { color: var(--good-text); }
.tile.warn .value { color: var(--serious); }
.tile.crit .value { color: var(--critical); }

/* ---------------- badges ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px; border: 1px solid var(--border);
  color: var(--text-secondary); white-space: nowrap;
}
.badge .ico { font-size: 10px; line-height: 1; }
.badge.online { color: var(--good-text);
  background: color-mix(in srgb, var(--good) 14%, transparent);
  border-color: color-mix(in srgb, var(--good) 34%, transparent); }
.badge.active { color: var(--series-1);
  background: color-mix(in srgb, var(--series-1) 12%, transparent);
  border-color: color-mix(in srgb, var(--series-1) 30%, transparent); }
.badge.stale { color: var(--serious);
  background: color-mix(in srgb, var(--warning) 18%, transparent);
  border-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.badge.inactive, .badge.never, .badge.critical { color: var(--critical);
  background: color-mix(in srgb, var(--critical) 12%, transparent);
  border-color: color-mix(in srgb, var(--critical) 32%, transparent); }
.badge.warning { color: var(--serious);
  background: color-mix(in srgb, var(--warning) 16%, transparent);
  border-color: color-mix(in srgb, var(--warning) 38%, transparent); }
.badge.info { color: var(--series-1);
  background: color-mix(in srgb, var(--series-1) 10%, transparent); }
.badge.assigned { color: var(--series-1); }
.badge.spare { color: var(--text-secondary); }
.badge.repair { color: var(--serious); }
.badge.retired { color: var(--text-muted); }

/* ---------------- tables ---------------- */
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); font-weight: 650; padding: 9px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; background: var(--surface-1);
}
table.grid td { padding: 9px 12px; border-bottom: 1px solid var(--grid);
  vertical-align: middle; }
table.grid tbody tr:hover { background: color-mix(in srgb, var(--text-primary) 3.5%, transparent); }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-secondary); }
.host { font-weight: 600; }
.table-wrap { overflow-x: auto; }

/* ---------------- meters ---------------- */
.meter { width: 90px; height: 6px; border-radius: 3px; background: var(--grid);
  overflow: hidden; display: inline-block; vertical-align: middle; }
.meter > span { display: block; height: 100%; border-radius: 3px; background: var(--series-1); }
.meter.s-good > span { background: var(--good); }
.meter.s-warn > span { background: var(--warning); }
.meter.s-crit > span { background: var(--critical); }
.meter-row { display: flex; align-items: center; gap: 8px; }
.meter-row .val { font-variant-numeric: tabular-nums; font-size: 12px; min-width: 42px;
  color: var(--text-secondary); }

/* ---------------- bar chart (horizontal, CSS) ---------------- */
.barlist { display: flex; flex-direction: column; gap: 9px; }
.barlist .row { display: grid; grid-template-columns: 108px 1fr 42px; gap: 10px;
  align-items: center; }
.barlist .name { font-size: 12px; color: var(--text-secondary); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.barlist .track { height: 10px; background: color-mix(in srgb, var(--grid) 60%, transparent);
  border-radius: 3px; }
.barlist .fill { height: 10px; border-radius: 3px; background: var(--series-1);
  min-width: 3px; }
.barlist .n { font-size: 12px; font-variant-numeric: tabular-nums; text-align: right;
  color: var(--text-primary); font-weight: 600; }

/* stacked presence bar */
.stack { display: flex; height: 12px; border-radius: 4px; overflow: hidden; gap: 2px;
  background: transparent; }
.stack > i { display: block; height: 100%; border-radius: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 11px; font-size: 12px;
  color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

/* ---------------- forms ---------------- */
input[type=text], input[type=search], input[type=password], input[type=email], select {
  font: inherit; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-primary); min-width: 0;
}
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--series-1) 45%, transparent);
  outline-offset: 1px; }
.btn {
  font: inherit; font-weight: 600; font-size: 13px; padding: 7px 13px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: color-mix(in srgb, var(--text-primary) 5%, transparent);
  text-decoration: none; }
.btn.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }

/* ---------------- detail page ---------------- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.kv { display: grid; grid-template-columns: 128px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; color: var(--text-primary); overflow-wrap: anywhere; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 22px 0 0; }
.tabs button { font: inherit; font-weight: 600; font-size: 13px; padding: 9px 14px;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-secondary); cursor: pointer; }
.tabs button.active { color: var(--series-1); border-bottom-color: var(--series-1); }
.tabpane { display: none; } .tabpane.active { display: block; }

/* ---------------- timeline ---------------- */
.timeline { display: flex; flex-direction: column; }
.timeline .item { display: grid; grid-template-columns: 16px 1fr auto; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--grid); align-items: start; }
.timeline .item:last-child { border-bottom: none; }
.timeline .marker { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px;
  background: var(--series-1); }
.timeline .marker.warning { background: var(--warning); }
.timeline .marker.critical { background: var(--critical); }
.timeline .msg { font-size: 13px; }
.timeline .meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.timeline .when { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end;
  margin-top: 14px; font-size: 13px; color: var(--text-secondary); }
.empty { padding: 34px; text-align: center; color: var(--text-muted); }

.toast-wrap { position: fixed; right: 18px; bottom: 18px; display: flex;
  flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--surface-1); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: 9px; padding: 10px 13px; font-size: 12.5px; max-width: 330px;
  animation: slide .25s ease; }
@keyframes slide { from { opacity: 0; transform: translateY(6px); } }

.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card { width: 360px; }
.login-card .card-body { display: flex; flex-direction: column; gap: 11px; }
.login-card input { width: 100%; }
.err { color: var(--critical); font-size: 12.5px; }
.hint { font-size: 12px; color: var(--text-muted); }

@media (max-width: 980px) {
  .detail-grid { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
