/* ==========================================================================
   Samson demo-dashboard chassis — design system
   One shared system; each demo re-themes via the :root variables below
   (override in a <style> block in its index.html). Light UI only.
   ========================================================================== */

:root {
  /* Brand (override per demo) */
  --accent:        #224685;   /* primary actions, active nav, links */
  --accent-ink:    #ffffff;   /* text on accent */
  --accent-soft:   #e8eef8;   /* tinted chips/washes of the accent */
  --sidebar-bg:    #16213a;   /* sidebar surface */
  --sidebar-ink:   #c7d2e4;   /* sidebar resting text */
  --sidebar-ink-2: #8496b8;   /* sidebar muted text */
  --sidebar-active:#ffffff;

  /* Neutrals */
  --page:    #f4f6fa;
  --surface: #ffffff;
  --line:    #e5e9f0;
  --ink:     #101828;
  --ink-2:   #475467;
  --ink-3:   #98a2b3;

  /* Status (fixed; icon + label always accompany colour) */
  --good:     #0ca30c;
  --good-bg:  #e9f7e9;
  --warn:     #b45309;
  --warn-bg:  #fdf3e0;
  --serious:  #c2410c;
  --serious-bg:#fdeee5;
  --crit:     #d03b3b;
  --crit-bg:  #fcebeb;
  --info-bg:  #eef4fd;

  /* Charts (validated categorical order — do not re-order) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --grid: #e7eaf0;
  --axis: #cbd3df;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16,24,40,.05);
  --shadow-lg: 0 12px 32px -8px rgba(16,24,40,.18);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sidebar-w: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%;
  font-family: var(--font); font-size: 14px; line-height: 1.45;
  color: var(--ink); background: var(--page);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; padding: 0; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
::placeholder { color: var(--ink-3); }
canvas { max-width: 100%; }

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

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-ink);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  scrollbar-width: thin; z-index: 40;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px;
  color: #fff; font-weight: 800; font-size: 16px; letter-spacing: -0.01em;
}
.sidebar-brand .logo {
  width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 15px; font-weight: 800; flex-shrink: 0;
}
.sidebar-brand small { display: block; font-size: 10.5px; font-weight: 600; color: var(--sidebar-ink-2); margin-top: 1px; }
.nav-group { padding: 10px 12px 2px; }
.nav-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-ink-2); padding: 8px 8px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: 8px; color: var(--sidebar-ink);
  font-weight: 600; font-size: 13.5px; margin-bottom: 1px; text-align: left;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .8; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--accent); color: var(--accent-ink); }
.nav-item.active svg { opacity: 1; }
.nav-item .count {
  margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 7px;
  border-radius: 99px; background: rgba(255,255,255,.12); color: #fff;
}
.sidebar-foot { margin-top: auto; padding: 14px 18px; font-size: 11.5px; color: var(--sidebar-ink-2); }

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

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 10px 20px; min-height: 58px;
}
.topbar .page-title { font-size: 16px; font-weight: 700; }
.topbar .crumb { color: var(--ink-3); font-weight: 600; font-size: 12.5px; }
.top-search {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  background: var(--page); border: 1px solid var(--line); border-radius: 99px;
  padding: 7px 14px; width: 300px; max-width: 32vw; color: var(--ink-3); font-weight: 500;
}
.top-search kbd {
  margin-left: auto; font: 600 10.5px var(--font); background: var(--surface);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; color: var(--ink-3);
}
.icon-btn {
  position: relative; width: 36px; height: 36px; border-radius: 99px;
  display: grid; place-items: center; color: var(--ink-2); flex-shrink: 0;
}
.icon-btn:hover { background: var(--page); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot {
  position: absolute; top: 7px; right: 8px; width: 8px; height: 8px;
  border-radius: 99px; background: var(--crit); border: 2px solid var(--surface);
}
.avatar {
  width: 34px; height: 34px; border-radius: 99px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700; flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }

/* Live pulse — the chassis signature: one quiet heartbeat that says "this is live" */
.live-pill {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700;
  color: var(--ink-2); background: var(--page); border: 1px solid var(--line);
  padding: 5px 12px; border-radius: 99px; white-space: nowrap;
}
.live-pill .pulse { width: 8px; height: 8px; border-radius: 99px; background: var(--good); position: relative; }
.live-pill .pulse::after {
  content: ''; position: absolute; inset: -4px; border-radius: 99px;
  border: 2px solid var(--good); opacity: 0; animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse { 0% { transform: scale(.4); opacity: .8; } 70%, 100% { transform: scale(1.15); opacity: 0; } }

/* ---------- Page area ---------- */
.pages { flex: 1; }
.page { display: none; padding: 22px 20px 48px; max-width: 1560px; }
.page.current { display: block; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; }
.page-head .sub { color: var(--ink-2); margin-top: 3px; font-size: 13.5px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Grid + cards ---------- */
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.span-2 { grid-column: span 2; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2 { font-size: 14.5px; }
.card-head .link { font-size: 12.5px; font-weight: 700; }
.card.pad-0 { padding: 0; }
.card.pad-0 .card-head { padding: 14px 16px 0; }

/* KPI tiles */
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .label { font-size: 12px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.kpi .delta { font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.kpi .delta.up { color: #006300; }
.kpi .delta.down { color: var(--crit); }
.kpi .delta .vs { color: var(--ink-3); font-weight: 500; }
.kpi canvas.spark { margin-top: 6px; width: 100%; height: 34px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-3); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: var(--page); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .strong { font-weight: 700; }
table.data .muted { color: var(--ink-2); }
.row-main { display: flex; align-items: center; gap: 10px; }
.row-main .t { font-weight: 700; }
.row-main .s { font-size: 12px; color: var(--ink-2); }

/* ---------- Chips, badges, status ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700;
  padding: 3px 9px; border-radius: 99px; white-space: nowrap;
}
.chip svg { width: 12px; height: 12px; }
.chip.good    { background: var(--good-bg);    color: #067306; }
.chip.warn    { background: var(--warn-bg);    color: var(--warn); }
.chip.serious { background: var(--serious-bg); color: var(--serious); }
.chip.crit    { background: var(--crit-bg);    color: var(--crit); }
.chip.info    { background: var(--info-bg);    color: #1c5cab; }
.chip.neutral { background: var(--page); color: var(--ink-2); border: 1px solid var(--line); }
.chip.accent  { background: var(--accent-soft); color: var(--accent); }

/* Integration badges */
.integrations { display: flex; flex-wrap: wrap; gap: 8px; }
.integration {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 99px;
  font-size: 12.5px; font-weight: 700;
}
.integration .sync { font-size: 11px; color: var(--ink-3); font-weight: 600; }
.integration .ok { width: 7px; height: 7px; border-radius: 99px; background: var(--good); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-weight: 700; font-size: 13px; padding: 9px 16px; border-radius: 99px;
  background: var(--accent); color: var(--accent-ink);
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.btn svg { width: 15px; height: 15px; }
.btn.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.sm { padding: 6px 12px; font-size: 12px; }
.btn.danger { background: var(--crit); color: #fff; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.kanban-col { background: var(--page); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-width: 0; }
.kanban-col h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); display: flex; justify-content: space-between; padding: 2px 4px 8px; }
.kanban-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.kanban-card:hover { border-color: var(--accent); }
.kanban-card .t { font-weight: 700; font-size: 13px; }
.kanban-card .s { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.kanban-card .foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }

/* ---------- Feed / timeline ---------- */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 11px; padding: 9px 2px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.feed-item:last-child { border-bottom: 0; }
.feed-icon {
  width: 30px; height: 30px; border-radius: 99px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
}
.feed-icon svg { width: 15px; height: 15px; }
.feed-body { min-width: 0; }
.feed-body .t { font-size: 13px; font-weight: 600; }
.feed-body .t b { font-weight: 800; }
.feed-body .time { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); border-radius: 2px; }
.timeline-item { position: relative; padding: 7px 0; }
.timeline-item::before {
  content: ''; position: absolute; left: -20px; top: 13px; width: 10px; height: 10px;
  border-radius: 99px; background: var(--surface); border: 2.5px solid var(--accent);
}
.timeline-item.auto::before { border-color: var(--s3); }

/* ---------- Progress ---------- */
.bar { height: 7px; background: var(--page); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); gap: 1px; }
.cal .dow { background: var(--page); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding: 8px; text-align: center; }
.cal .day { background: var(--surface); min-height: 92px; padding: 6px; font-size: 12px; }
.cal .day .d { font-weight: 700; color: var(--ink-2); }
.cal .day.dim { background: var(--page); }
.cal .day.today .d { color: var(--accent); }
.cal .evt { margin-top: 4px; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 2px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--accent-soft); color: var(--accent); }

/* ---------- Drawer (detail slide-over) ---------- */
.drawer-veil { position: fixed; inset: 0; background: rgba(16,24,40,.44); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .22s ease; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 94vw; z-index: 61;
  background: var(--surface); box-shadow: -18px 0 48px rgba(16,24,40,.22);
  transform: translateX(102%); transition: transform .26s cubic-bezier(.32,.72,.28,1);
  display: flex; flex-direction: column;
}
.drawer-open .drawer { transform: none; }
.drawer-open .drawer-veil { opacity: 1; pointer-events: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 15.5px; }
.drawer-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 7px 12px; font-size: 13px; }
.kv dt { color: var(--ink-2); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; gap: 10px; align-items: flex-start; width: 320px; max-width: 88vw;
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 11px 13px;
}
.toast .t { font-size: 13px; font-weight: 700; }
.toast .s { font-size: 12px; color: var(--ink-2); margin-top: 1px; }
.toast .feed-icon { width: 26px; height: 26px; }

/* ---------- Command palette ---------- */
.cmdk-veil { position: fixed; inset: 0; background: rgba(16,24,40,.5); z-index: 70; display: none; }
.cmdk-veil.open { display: block; }
.cmdk {
  width: 560px; max-width: 92vw; margin: 12vh auto 0; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden;
}
.cmdk input { width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 14px 16px; font-size: 15px; }
.cmdk-list { max-height: 320px; overflow-y: auto; padding: 6px; }
.cmdk-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; font-weight: 600; font-size: 13.5px; width: 100%; text-align: left; }
.cmdk-item .where { margin-left: auto; font-size: 11px; color: var(--ink-3); font-weight: 600; }
.cmdk-item:hover, .cmdk-item.sel { background: var(--page); }

/* ---------- AI assistant ---------- */
.ai-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 55;
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 17px; border-radius: 99px;
  background: var(--ink); color: #fff; font-weight: 700; font-size: 13px; box-shadow: var(--shadow-lg);
}
.ai-fab svg { width: 16px; height: 16px; }
.ai-msg { display: flex; gap: 9px; margin-bottom: 12px; }
.ai-msg .bubble { background: var(--page); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; font-size: 13px; max-width: 85%; }
.ai-msg.me { justify-content: flex-end; }
.ai-msg.me .bubble { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ai-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ai-suggest button { font-size: 12px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 99px; padding: 5px 11px; }

/* ---------- Demo ribbon ---------- */
.demo-ribbon {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 600;
  padding: 8px 10px 8px 16px; border-radius: 12px 12px 0 0; box-shadow: var(--shadow-lg);
  white-space: nowrap;
}
.demo-ribbon a {
  background: #fff; color: var(--ink); font-weight: 800; padding: 5px 12px; border-radius: 99px; font-size: 12px;
}

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 34px 16px; color: var(--ink-2); }
.empty .big { font-size: 15px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.chart-box.short { height: 200px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-top: 10px; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .key i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Mobile ---------- */
.menu-btn { display: none; }
@media (max-width: 1100px) {
  .cols-4 { grid-template-columns: repeat(2, 1fr); }
  .cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 780px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-104%);
    transition: transform .25s ease; box-shadow: var(--shadow-lg); height: 100dvh;
  }
  .nav-open .sidebar { transform: none; }
  .nav-veil { position: fixed; inset: 0; background: rgba(16,24,40,.44); z-index: 39; display: none; }
  .nav-open .nav-veil { display: block; }
  .menu-btn { display: grid; }
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .top-search { display: none; }
  .page { padding: 16px 12px 88px; }
  .kanban { grid-auto-columns: 82vw; }
  .demo-ribbon { width: 100%; border-radius: 0; justify-content: space-between; left: 0; transform: none; }
  .kv { grid-template-columns: 110px 1fr; }
}

/* Reduced motion: kill the pulse + transitions */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
