/* JARVIS Command Center v3 — Design System
   Bloomberg-density + Linear-clarity
   ======================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ─── Variables ──────────────────────────────────────── */
:root, [data-theme="light"] {
  /* Background layers */
  --bg:         #F5F2EC;
  --bg-elev:    #FFFFFF;
  --bg-sunken:  #EDECE6;

  /* Borders */
  --border:      #D0CEC8;
  --border-soft: #E8E5DF;

  /* Text */
  --fg:       #1C1C20;
  --fg-mid:   #5A5A62;
  --fg-soft:  #8A8A92;
  --fg-mute:  #C4C4CC;

  /* Ticker (always-dark bar) */
  --ticker-bg:     #070B13;
  --ticker-border: #1A1A28;
  --fg-invert-mid:  #9A9AB2;
  --fg-invert-soft: #6A6A82;

  /* Semantic colours */
  --green:    oklch(0.55 0.14 145);
  --green-bg: oklch(0.94 0.04 145);
  --red:      oklch(0.55 0.18 25);
  --red-bg:   oklch(0.96 0.04 25);
  --amber:    oklch(0.62 0.14 75);
  --amber-bg: oklch(0.96 0.04 75);
  --blue:     oklch(0.55 0.14 245);
  --blue-bg:  oklch(0.95 0.04 245);
  --violet:   oklch(0.55 0.14 295);

  /* Typography */
  --font-sans: 'Inter', 'SF Pro Text', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'JetBrains Mono', monospace;

  /* Layout */
  --ticker-h:           44px;
  --sidebar-w:          204px;
  --sidebar-w-collapsed: 52px;
  --radius:    8px;
  --radius-sm: 5px;

  /* Legacy (kept for live-data-fetch compatibility) */
  --ink:   #0A0A09;
  --ink-2: #4A4A45;
  --ink-3: #8A8A85;
  --ink-4: #BFBFB8;
  --surface:   #FFFFFF;
  --surface-2: #F5F5F0;
}

[data-theme="dark"] {
  --bg:         #0E0E12;
  --bg-elev:    #16161C;
  --bg-sunken:  #1C1C24;
  --border:      #2C2C38;
  --border-soft: #202030;
  --fg:       #F0F0F8;
  --fg-mid:   #A0A0B8;
  --fg-soft:  #6A6A82;
  --fg-mute:  #3A3A50;
  --fg-invert-mid:  #6A6A82;
  --fg-invert-soft: #4A4A62;
  --ink:   #F0F0F8;
  --ink-2: #A0A0B8;
  --ink-3: #6A6A82;
  --ink-4: #3A3A50;
  --surface:   #16161C;
  --surface-2: #1C1C24;
}

/* ─── Reset ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  overflow: hidden;
}
button { cursor: pointer; font-family: var(--font-sans); background: none; border: none; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; }

/* ─── App shell ──────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ─── Ticker bar ─────────────────────────────────────── */
.ticker {
  height: var(--ticker-h);
  background: var(--ticker-bg);
  border-bottom: 1px solid var(--ticker-border);
  display: flex;
  align-items: center;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}

.ticker-now {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
  border-right: 1px solid var(--ticker-border);
  height: 100%;
  color: rgba(255,255,255,0.7);
}

.ticker-now .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
  flex-shrink: 0;
}

.ticker-now .live {
  color: var(--green);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  font-weight: 600;
}

.ticker-marquee {
  flex: 1;
  overflow: hidden;
  height: 100%;
  display: flex;
  align-items: center;
}

.ticker-track {
  display: inline-flex;
  animation: ticker-scroll 80s linear infinite;
  white-space: nowrap;
  will-change: transform;
}

.ticker-track:hover { animation-play-state: paused; }

@keyframes ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

@keyframes sync-spin {
  to { transform: rotate(360deg); }
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 16px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: rgba(255,255,255,0.85);
  border-right: 1px solid var(--ticker-border);
}

.ticker-item .lbl {
  color: var(--fg-invert-soft);
  font-size: 9.5px;
  letter-spacing: 0.08em;
}

.ticker-item .val          { font-weight: 500; }
.ticker-item .val.pos      { color: oklch(0.72 0.14 145); }
.ticker-item .val.neg      { color: oklch(0.70 0.18 25); }
.ticker-item .val.warn     { color: oklch(0.75 0.14 75); }

/* ─── Sidebar ────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.2s ease;
  position: relative;
}

.app-body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-brand .logo {
  width: 28px; height: 28px;
  background: var(--fg);
  color: var(--bg-elev);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.sidebar-brand .name {
  font-size: 13px; font-weight: 700;
  letter-spacing: -0.01em; white-space: nowrap;
}

.sidebar-brand .sub {
  font-size: 10px; color: var(--fg-soft);
  font-family: var(--font-mono); white-space: nowrap;
}

.app-body.sidebar-collapsed .sidebar-brand .name,
.app-body.sidebar-collapsed .sidebar-brand .sub { display: none; }

.sidebar-section { padding: 8px 0; }

.sidebar-label {
  padding: 4px 12px 2px;
  font-size: 9.5px; font-family: var(--font-mono);
  letter-spacing: 0.1em; color: var(--fg-mute);
  text-transform: uppercase;
}

.app-body.sidebar-collapsed .sidebar-label { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px;
  background: transparent; color: var(--fg-mid);
  font-size: 12.5px; font-weight: 450;
  cursor: pointer; width: 100%; text-align: left;
  transition: background 0.1s, color 0.1s;
  overflow: hidden; border: none;
}

.nav-item:hover     { background: var(--bg-sunken); color: var(--fg); }
.nav-item.active    { background: var(--bg-sunken); color: var(--fg); font-weight: 500; }

.nav-item .icon {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
}

.nav-item.active .icon { background: var(--fg); color: var(--bg-elev); }

.nav-item .label {
  flex: 1; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.app-body.sidebar-collapsed .nav-item .label { display: none; }

.nav-item .kbd {
  font-size: 10px; font-family: var(--font-mono);
  color: var(--fg-mute);
  background: var(--bg-sunken);
  border: 1px solid var(--border-soft);
  border-radius: 3px; padding: 1px 4px; white-space: nowrap;
}

.app-body.sidebar-collapsed .nav-item .kbd    { display: none; }
.app-body.sidebar-collapsed .nav-item .badge  { display: none; }

.nav-item .badge {
  font-size: 10px; font-family: var(--font-mono);
  background: var(--red); color: white;
  border-radius: 10px; padding: 1px 6px; font-weight: 600;
}

.nav-item .badge.good { background: var(--green); }

.sidebar-foot {
  margin-top: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--border-soft);
  overflow: hidden; flex-shrink: 0;
}

.sidebar-foot .avatar {
  width: 28px; height: 28px;
  background: var(--fg); color: var(--bg-elev);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}

.sidebar-collapse-btn {
  position: absolute;
  top: 56px;
  left: var(--sidebar-w);
  transform: translateX(-50%);
  transition: left 0.2s ease;
  width: 20px; height: 32px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 20; color: var(--fg-soft);
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover { color: var(--fg); background: var(--bg-sunken); }

.app-body.sidebar-collapsed .sidebar-collapse-btn {
  left: var(--sidebar-w-collapsed);
}

/* ─── Mobile navigation ─────────────────────────────── */
.mobile-bottom-nav,
.mobile-menu-sheet,
.mobile-menu-backdrop {
  display: none;
}

/* ─── Main content ───────────────────────────────────── */
.main {
  flex: 1; overflow-y: auto; overflow-x: hidden; min-width: 0;
  background: var(--bg);
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}

.main::-webkit-scrollbar { width: 6px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.main-inner {
  max-width: 1360px;
  padding: 24px;
  margin: 0 auto;
}

/* ─── Page head ──────────────────────────────────────── */
.page-head {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}

.page-head h1 {
  font-size: 22px; font-weight: 700;
  letter-spacing: -0.02em; margin-top: 2px;
}

.page-head .actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

.eyebrow {
  font-size: 10.5px; font-family: var(--font-mono);
  letter-spacing: 0.1em; color: var(--fg-soft);
  text-transform: uppercase;
}

/* ─── Cards ──────────────────────────────────────────── */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-h {
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 12px; padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
}

.card-h .left  { flex: 1; min-width: 0; }
.card-h .right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.card-h .title {
  font-size: 13px; font-weight: 600;
  letter-spacing: -0.01em; margin-top: 2px;
}

.card-b        { padding: 14px; }
.card-b.flush  { padding: 0; }

/* ─── KPI strip ──────────────────────────────────────── */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin-bottom: 14px;
}

.kpi {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
  min-width: 0;
}

.kpi.tiny {
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.kpi .lbl {
  font-size: 10.5px; font-family: var(--font-mono);
  letter-spacing: 0.06em; color: var(--fg-soft);
  text-transform: uppercase;
}

.kpi .val {
  font-size: 20px; font-weight: 700;
  letter-spacing: -0.02em; margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.kpi.tiny .val { font-size: 17px; }

.kpi .sub {
  font-size: 10.5px; color: var(--fg-soft);
  font-family: var(--font-mono); margin-top: 2px;
}

/* Colour utilities */
.neg,       .kpi .val.neg { color: var(--red); }
.pos,       .kpi .val.pos { color: var(--green); }
.kpi .sub.neg              { color: var(--red); }
.kpi .sub.pos              { color: var(--green); }
.warn                      { color: var(--amber); }

/* ─── Tables ─────────────────────────────────────────── */
.tbl { width: 100%; font-size: 12.5px; }

.tbl thead tr { border-bottom: 1px solid var(--border-soft); }

.tbl th {
  padding: 8px 14px;
  font-size: 10px; font-family: var(--font-mono);
  letter-spacing: 0.08em; color: var(--fg-soft);
  text-transform: uppercase; font-weight: 500; text-align: left;
}

.tbl td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td      { background: rgba(0,0,0,0.012); }
.tbl .num             { text-align: right; font-family: var(--font-mono); font-size: 12px; }
.tbl .sub             { color: var(--fg-soft); font-size: 11.5px; }

/* ─── Pills ──────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 10px;
  font-size: 10px; font-family: var(--font-mono);
  font-weight: 600; letter-spacing: 0.06em;
  border: 1px solid var(--border-soft);
  background: var(--bg-sunken); color: var(--fg-mid);
  white-space: nowrap;
}

.pill.green  { background: var(--green-bg);  border-color: var(--green);  color: var(--green); }
.pill.red    { background: var(--red-bg);    border-color: var(--red);    color: var(--red); }
.pill.amber  { background: var(--amber-bg);  border-color: var(--amber);  color: var(--amber); }
.pill.blue   { background: var(--blue-bg);   border-color: var(--blue);   color: var(--blue); }

/* ─── Status dots ────────────────────────────────────── */
.dot {
  display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--fg-mute); flex-shrink: 0;
}

.dot.red    { background: var(--red); }
.dot.green  { background: var(--green); }
.dot.amber  { background: var(--amber); }
.dot.blue   { background: var(--blue); }

/* ─── Bento grid ─────────────────────────────────────── */
.bento {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin-bottom: 14px;
}

.bento-cell {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 200px;
}

.bento-cell .head {
  display: flex; align-items: center;
  justify-content: space-between; gap: 8px;
}

.bento-cell .head .lbl {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-family: var(--font-mono);
  letter-spacing: 0.08em; color: var(--fg-soft);
  text-transform: uppercase; font-weight: 500;
}

.metric-row {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}

.big-num {
  font-size: 28px; font-weight: 700;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1;
}
.big-num.neg { color: var(--red); }

.big-sub {
  font-size: 11px; color: var(--fg-soft); font-family: var(--font-mono);
}

/* ─── Briefing ───────────────────────────────────────── */
.briefing {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  margin-bottom: 14px; overflow: hidden;
}

.briefing-h {
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 8px; padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
}

.briefing-h .lbl {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; font-family: var(--font-mono);
  letter-spacing: 0.06em; color: var(--fg-soft);
  text-transform: uppercase; flex-wrap: wrap;
}

.briefing-h .count {
  background: var(--fg); color: var(--bg-elev);
  border-radius: 8px; padding: 0 5px;
  font-size: 9.5px; font-weight: 700;
}

.briefing-h .x {
  border: none; background: transparent;
  color: var(--fg-soft); font-size: 16px;
  padding: 0 4px; line-height: 1; border-radius: 4px;
}
.briefing-h .x:hover { background: var(--bg-sunken); color: var(--fg); }

.briefing-list {
  display: grid; grid-template-columns: repeat(4, 1fr);
}

.briefing-row {
  padding: 12px 14px;
  border-right: 1px solid var(--border-soft);
}
.briefing-row:last-child { border-right: none; }

.briefing-row .top {
  display: flex; align-items: center; gap: 7px; margin-bottom: 5px;
}

.briefing-row .age {
  font-size: 10px; font-family: var(--font-mono);
  color: var(--fg-soft); margin-left: auto;
}

.briefing-row .ttl {
  font-size: 12.5px; font-weight: 600;
  line-height: 1.3; margin-bottom: 4px;
}

.briefing-row .ctx { font-size: 11px; color: var(--fg-soft); line-height: 1.4; }

.brief-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--bg-elev); border: 1px solid var(--border-soft);
  border-radius: 20px; cursor: pointer;
  font-size: 11px; font-family: var(--font-mono);
}

.brief-pill .pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}

.brief-pill .lbl { font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg); }

.brief-pill .count {
  background: var(--fg); color: var(--bg-elev);
  border-radius: 8px; padding: 0 5px; font-size: 9.5px; font-weight: 700;
}

/* ─── Sync button ────────────────────────────────────── */
.sync-btn-wrap { position: relative; }

.sync-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: var(--bg-elev); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 11.5px; color: var(--fg-mid);
  transition: border-color 0.15s, color 0.15s; cursor: pointer;
}

.sync-btn:hover   { border-color: var(--border); color: var(--fg); }
.sync-btn.synced  { border-color: var(--green); color: var(--green); }

.sync-label  { font-weight: 500; }

.sync-time {
  font-size: 10.5px; font-family: var(--font-mono); color: var(--fg-soft);
}

.sync-menu {
  position: absolute; top: calc(100% + 4px); right: 0;
  background: var(--bg-elev); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 6px;
  min-width: 240px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08); z-index: 100;
}

.sync-menu-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 6px 8px;
  border-bottom: 1px solid var(--border-soft); margin-bottom: 4px;
}

.sync-all {
  border: 1px solid var(--border-soft); background: transparent;
  border-radius: 4px; padding: 3px 8px; font-size: 11px; color: var(--fg-mid);
  cursor: pointer;
}

.sync-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; background: transparent; border: none;
  border-radius: 4px; width: 100%; text-align: left; cursor: pointer;
}
.sync-item:hover { background: var(--bg-sunken); }

.sync-item-body { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.sync-item-lbl  { font-size: 12px; font-weight: 500; }
.sync-item-time { font-size: 10.5px; font-family: var(--font-mono); color: var(--fg-soft); }

/* ─── Segmented control ──────────────────────────────── */
.seg {
  display: inline-flex;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden; background: var(--bg-sunken);
}

.seg button {
  padding: 5px 12px;
  border: none; background: transparent;
  font-size: 12px; color: var(--fg-mid);
  border-right: 1px solid var(--border-soft);
  cursor: pointer;
}
.seg button:last-child { border-right: none; }
.seg button:hover  { background: var(--bg-elev); color: var(--fg); }
.seg button.active { background: var(--bg-elev); color: var(--fg); font-weight: 500; }

/* ─── Section header ─────────────────────────────────── */
.section-h {
  display: flex; align-items: baseline; gap: 12px;
  margin: 16px 0 12px;
}
.section-h h2 { font-size: 14px; font-weight: 600; }
.section-h .meta { font-size: 11px; color: var(--fg-soft); font-family: var(--font-mono); }

/* ─── Today row ──────────────────────────────────────── */
.today-row {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-top: 10px;
}

/* ─── Activity ───────────────────────────────────────── */
.act-row {
  display: grid; grid-template-columns: 70px 1fr auto;
  gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  align-items: center;
}
.act-row:last-child { border-bottom: none; }

.act-row .time { font-size: 11px; font-family: var(--font-mono); color: var(--fg-soft); }
.act-row .body { font-size: 12.5px; }
.act-row .amt  { font-size: 12px; font-family: var(--font-mono); font-weight: 500; white-space: nowrap; }
.act-row .amt.pos { color: var(--green); }
.act-row .amt.neg { color: var(--red); }

/* ─── Schedule ───────────────────────────────────────── */
.sched-row {
  display: grid; grid-template-columns: 90px 1fr;
  gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft); align-items: start;
}
.sched-row:last-child { border-bottom: none; }

.sched-row .time {
  font-size: 11.5px; font-family: var(--font-mono); color: var(--fg-mid);
  font-weight: 500; white-space: nowrap;
}
.sched-row .time .d {
  display: block; font-size: 10px; color: var(--fg-soft); font-weight: 400; margin-top: 2px;
}
.sched-row .ttl { font-size: 13px; font-weight: 500; }
.sched-row .ctx { font-size: 11px; color: var(--fg-soft); margin-top: 2px; }

/* ─── Tasks ──────────────────────────────────────────── */
.task {
  display: grid; grid-template-columns: 24px 1fr auto;
  gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  align-items: start; cursor: pointer;
}
.task:last-child { border-bottom: none; }
.task:hover      { background: rgba(0,0,0,0.012); }
.task.done       { opacity: 0.45; }
.task.done .ttl  { text-decoration: line-through; }

.task .check {
  display: block; width: 14px; height: 14px;
  border: 1.5px solid var(--border); border-radius: 3px; margin-top: 1px; flex-shrink: 0;
}
.task.done .check { background: var(--green); border-color: var(--green); }

.task .body .ttl  { font-size: 12.5px; font-weight: 500; line-height: 1.3; }
.task .body .meta {
  font-size: 10px; font-family: var(--font-mono); color: var(--fg-soft);
  letter-spacing: 0.04em; margin-top: 2px;
  display: flex; gap: 4px;
}
.task .due        { font-size: 11px; font-family: var(--font-mono); color: var(--fg-soft); white-space: nowrap; margin-top: 2px; }
.task .due.red    { color: var(--red); font-weight: 600; }
.task .due.amber  { color: var(--amber); font-weight: 500; }

/* ─── Module grid (Overview V1) ──────────────────────── */
.module-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-bottom: 14px;
}

.module {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 14px;
  cursor: pointer; transition: border-color 0.15s;
}
.module:hover { border-color: var(--border); }

.module-head {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 10px;
}
.module-head .lbl {
  display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-family: var(--font-mono);
  letter-spacing: 0.08em; color: var(--fg-soft); text-transform: uppercase;
}
.module-head .arrow { font-size: 12px; color: var(--fg-mute); }

.module-metric { margin-bottom: 8px; }
.module-metric .big { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.module-metric .big.neg { color: var(--red); }
.module-metric .delta { font-size: 11.5px; font-family: var(--font-mono); margin-top: 3px; }
.module-metric .delta.neg { color: var(--red); }
.module-metric .delta.pos { color: var(--green); }

.module-spark { margin: 8px -2px; }
.module-list  { margin-top: 8px; display: flex; flex-direction: column; }

.module-li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0; font-size: 11.5px;
  border-top: 1px dashed var(--border-soft);
}
.module-li .lhs { color: var(--fg-mid); }
.module-li .rhs { font-family: var(--font-mono); font-size: 11px; color: var(--fg-mid); }

/* ─── Progress bar ───────────────────────────────────── */
.bar-track {
  height: 4px; background: var(--bg-sunken);
  border-radius: 2px; overflow: hidden; flex: 1;
}
.bar-fill {
  height: 100%; border-radius: 2px;
  background: var(--fg); transition: width 0.3s ease;
}

/* ─── Ring wrap ──────────────────────────────────────── */
.ring-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.ring-wrap .val { font-size: 14px; font-family: var(--font-mono); font-weight: 600; }
.ring-wrap .lbl { font-size: 10px; font-family: var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-soft); text-align: center; }
.ring-wrap .sub { font-size: 10px; font-family: var(--font-mono); color: var(--fg-soft); text-align: center; }

/* ─── Chat ───────────────────────────────────────────── */
.chat-msg { padding: 12px 16px; border-bottom: 1px solid var(--border-soft); }
.chat-msg .who { font-size: 10.5px; font-family: var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-soft); margin-bottom: 5px; }
.chat-msg.user { background: var(--bg-sunken); }
.chat-msg.user .who { color: var(--blue); }
.chat-msg .body { font-size: 13px; line-height: 1.5; }

/* ─── Divider ─────────────────────────────────────────── */
.div { border-top: 1px solid var(--border-soft); margin: 12px 0; }

/* ─── Icon button ────────────────────────────────────── */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  background: var(--bg-elev); color: var(--fg-soft); cursor: pointer;
  position: relative;
}
.icon-btn:hover { color: var(--fg); border-color: var(--border); }

.badge-dot {
  position: absolute; top: 5px; right: 5px;
  width: 6px; height: 6px;
  background: var(--red); border-radius: 50%;
  border: 1.5px solid var(--bg-elev);
}

/* ─── Mono utility ───────────────────────────────────── */
.mono { font-family: var(--font-mono); }
.spark { display: block; }

/* ─── Skeleton loading ───────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
.skeleton-line {
  background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--bg-elev) 50%, var(--bg-sunken) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
  height: 14px; margin: 6px 0;
}
.skeleton-line.title { height: 20px; width: 60%; }
.skeleton-line.lg    { width: 80%; }
.skeleton-line.md    { width: 60%; }
.skeleton-line.sm    { width: 40%; }

.skeleton-grid { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.skeleton-card { background: var(--bg-elev); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 16px; }

/* ─── Dark mode fixes ────────────────────────────────── */
[data-theme="dark"] {
  .card, .bento-cell, .kpi, .module, .briefing,
  .sync-btn, .sync-menu, .brief-pill { background: var(--bg-elev); }
}

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 1100px) {
  .bento { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .today-row { grid-template-columns: 1fr; }
  .module-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .briefing-list { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .main-inner {
    padding: 14px 14px calc(108px + env(safe-area-inset-bottom, 0px));
  }
  .module-grid { grid-template-columns: 1fr; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .sidebar { display: none; }
  .sidebar-brand .name, .sidebar-brand .sub,
  .sidebar-label, .nav-item .label, .nav-item .kbd,
  .nav-item .badge { display: none; }
  .briefing-list { grid-template-columns: 1fr; }
  .today-row { grid-template-columns: 1fr; }

  /* Hide collapse toggle — sidebar auto-collapses via CSS on mobile */
  .sidebar-collapse-btn { display: none; }

  .ticker {
    --mobile-status-space: max(env(safe-area-inset-top, 0px), 20px);
    height: calc(96px + var(--mobile-status-space));
    flex-direction: column;
    align-items: stretch;
    border-bottom-color: #263040;
  }

  .ticker-now {
    width: 100%;
    height: calc(56px + var(--mobile-status-space));
    justify-content: flex-start;
    gap: 10px;
    padding: calc(var(--mobile-status-space) + 15px) 16px 0;
    border-right: none;
    border-bottom: 1px solid #263040;
    font-size: 13px;
    line-height: 1;
    color: #f8fafc;
  }

  .ticker-now .dot {
    width: 8px;
    height: 8px;
    box-shadow: 0 0 0 10px rgba(45, 164, 78, 0.1);
  }

  .ticker-now .live {
    font-size: 13px;
    letter-spacing: 0.13em;
  }

  .ticker-now span:nth-child(3),
  .ticker-now span:nth-child(4) {
    font-size: 13px;
    font-weight: 650;
    letter-spacing: 0.08em;
  }

  .ticker-marquee {
    height: 40px;
    flex: 0 0 40px;
    background: #080d15;
  }

  .ticker-track {
    height: 100%;
    align-items: center;
  }

  .ticker-item {
    height: 100%;
    gap: 8px;
    padding: 0 16px;
    border-right: none;
    font-size: 13.5px;
    font-weight: 650;
  }

  .ticker-item .lbl {
    font-size: 12px;
    font-weight: 650;
    letter-spacing: 0.15em;
    color: #727987;
  }

  .finance-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .finance-overview-grid,
  .finance-secondary-grid {
    grid-template-columns: 1fr !important;
  }

  /* Allow bento grid to stack */
  .bento { grid-template-columns: 1fr; }

  .mobile-bottom-nav {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    z-index: 80;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: center;
    min-height: 66px;
    padding: 7px 8px;
    background: var(--bg-elev);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(20, 20, 24, 0.16), 0 2px 8px rgba(20, 20, 24, 0.08);
    backdrop-filter: blur(16px);
  }

  .mobile-tab-btn {
    min-width: 0;
    height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--fg-soft);
    font-size: 10px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0;
    border-radius: 8px;
    transition: color 0.12s ease, background 0.12s ease;
  }

  .mobile-tab-btn.active {
    color: var(--fg);
    background: var(--bg-sunken);
  }

  .mobile-tab-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-tab-icon svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.9;
  }

  .mobile-tab-menu-icon {
    flex-direction: column;
    gap: 4px;
  }

  .mobile-tab-menu-icon span {
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
  }

  .mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: block;
    background: rgba(20, 20, 24, 0.14);
  }

  .mobile-menu-sheet {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    z-index: 81;
    display: block;
    padding: 12px;
    background: var(--bg-elev);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(20, 20, 24, 0.2);
    transform: translateY(10px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.14s ease, transform 0.14s ease;
  }

  .mobile-menu-sheet.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-menu-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 9px 10px;
    color: var(--fg-mid);
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
  }

  .mobile-menu-item.active {
    color: var(--fg);
    background: var(--bg-sunken);
    border-color: var(--border);
  }

  .mobile-menu-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .mobile-menu-icon svg {
    width: 18px;
    height: 18px;
  }
}

@media (orientation: landscape) and (max-height: 520px) and (pointer: coarse) {
  .sidebar,
  .sidebar-collapse-btn {
    display: none;
  }

  .main-inner {
    max-width: none;
    padding: 28px max(24px, env(safe-area-inset-right, 0px)) 42px max(24px, env(safe-area-inset-left, 0px));
  }

  .ticker {
    height: 52px;
    flex-direction: row;
    align-items: center;
  }

  .ticker-now {
    width: auto;
    height: 100%;
    gap: 8px;
    padding: 0 16px 0 max(16px, env(safe-area-inset-left, 0px));
    border-right: 1px solid var(--ticker-border);
    border-bottom: none;
    font-size: 11px;
  }

  .ticker-now .dot {
    width: 6px;
    height: 6px;
    box-shadow: none;
  }

  .ticker-now .live {
    font-size: 9.5px;
    letter-spacing: 0.12em;
  }

  .ticker-now span:nth-child(3),
  .ticker-now span:nth-child(4) {
    font-size: 11px;
    letter-spacing: 0.06em;
  }

  .ticker-marquee {
    height: 100%;
    flex: 1;
  }

  .ticker-track {
    height: 100%;
    align-items: center;
  }

  .ticker-item {
    height: 100%;
    gap: 5px;
    padding: 0 16px;
    border-right: 1px solid var(--ticker-border);
    font-size: 10.5px;
  }

  .ticker-item .lbl {
    font-size: 9.5px;
    letter-spacing: 0.08em;
  }

  .mobile-bottom-nav,
  .mobile-menu-sheet,
  .mobile-menu-backdrop {
    display: none;
  }
}
