/* ============================================================
   Command Centre — hero dashboard
   Linear-grade UI. Dark and light themes off one token set.
   ============================================================ */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/inter-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Sora";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("fonts/sora-latin.woff2") format("woff2");
}

/* ---------- DARK (default) ---------- */
:root {
  --bg-0: #0E141A;
  --bg-1: #131B23;
  --bg-2: #17212B;
  --bg-3: #1D2A36;
  --bg-inset: #0B1015;

  --sidebar-grad: linear-gradient(180deg, #131B23, #0E141A 120%);
  --topbar-bg: rgba(14,20,26,0.72);

  --line: rgba(245, 244, 239, 0.08);
  --line-strong: rgba(245, 244, 239, 0.14);
  --line-faint: rgba(245, 244, 239, 0.05);

  --text-hi: #F5F4EF;
  --text: #C6CFD8;
  --text-mid: #93A0AD;
  --text-lo: #67757F;
  --text-faint: #4A5761;

  --accent: #5FA168;
  --accent-hi: #77BC82;
  --accent-dim: rgba(95, 161, 104, 0.14);
  --accent-line: rgba(95, 161, 104, 0.30);
  --on-accent: #08130C;

  --amber: #D9A44A;
  --amber-dim: rgba(217, 164, 74, 0.14);
  --amber-line: rgba(217, 164, 74, 0.30);
  --rose: #C7736B;
  --rose-dim: rgba(199, 115, 107, 0.14);
  --rose-line: rgba(199, 115, 107, 0.30);
  --sky: #6E93B0;

  /* chart tokens (read by JS + used in SVG attrs) */
  --chart-1: #5FA168;
  --chart-2: #6E93B0;
  --chart-bg: #0E141A;
  --grid: rgba(245,244,239,0.05);

  --aurora-1: rgba(95,161,104,0.10);
  --aurora-2: rgba(110,147,176,0.07);

  --avatar-grad: linear-gradient(135deg, #35505f, #223038);
  --shadow-card: 0 1px 0 rgba(255,255,255,0.03) inset, 0 8px 24px -12px rgba(0,0,0,0.6);
  --shadow-pop: 0 12px 40px -12px rgba(0,0,0,0.7), 0 0 0 1px var(--line);
  --btn-glow: 0 6px 18px -8px rgba(95,161,104,0.7), 0 0 0 1px rgba(255,255,255,0.08) inset;
  --scroll-track: #0E141A;

  --radius: 12px;
  --radius-sm: 9px;
  --radius-lg: 16px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --nav-w: 244px;
}

/* ---------- LIGHT ---------- */
[data-theme="light"] {
  --bg-0: #F5F4EF;          /* Bone */
  --bg-1: #FFFFFF;
  --bg-2: #FFFFFF;
  --bg-3: #EFEDE5;
  --bg-inset: #F2F0E9;

  --sidebar-grad: linear-gradient(180deg, #FFFFFF, #F7F6F1 120%);
  --topbar-bg: rgba(245,244,239,0.78);

  --line: rgba(32, 45, 57, 0.10);
  --line-strong: rgba(32, 45, 57, 0.18);
  --line-faint: rgba(32, 45, 57, 0.06);

  --text-hi: #16212B;       /* Ink */
  --text: #2E3D48;
  --text-mid: #5A6B7A;      /* Slate */
  --text-lo: #798793;
  --text-faint: #9BA6B0;

  --accent: #3F7D4E;        /* Forest */
  --accent-hi: #2F6B3E;
  --accent-dim: rgba(63, 125, 78, 0.10);
  --accent-line: rgba(63, 125, 78, 0.28);
  --on-accent: #FFFFFF;

  --amber: #9C6F1C;
  --amber-dim: rgba(156, 111, 28, 0.10);
  --amber-line: rgba(156, 111, 28, 0.26);
  --rose: #A8463D;
  --rose-dim: rgba(168, 70, 61, 0.10);
  --rose-line: rgba(168, 70, 61, 0.26);
  --sky: #44708F;

  --chart-1: #3F7D4E;
  --chart-2: #6E93B0;
  --chart-bg: #FFFFFF;
  --grid: rgba(32,45,57,0.07);

  --aurora-1: rgba(63,125,78,0.07);
  --aurora-2: rgba(68,112,143,0.05);

  --avatar-grad: linear-gradient(135deg, #4E6B7C, #2E4350);
  --shadow-card: 0 1px 2px rgba(32,45,57,0.04), 0 8px 24px -16px rgba(32,45,57,0.18);
  --shadow-pop: 0 16px 40px -16px rgba(32,45,57,0.30), 0 0 0 1px var(--line);
  --btn-glow: 0 6px 18px -8px rgba(63,125,78,0.45), 0 0 0 1px rgba(255,255,255,0.18) inset;
  --scroll-track: #F5F4EF;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.006em;
  transition: background .4s var(--ease), color .4s var(--ease);
}

::selection { background: var(--accent-dim); color: var(--text-hi); }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 600px at 78% -8%, var(--aurora-1), transparent 60%),
    radial-gradient(1100px 700px at -6% 108%, var(--aurora-2), transparent 60%);
  pointer-events: none;
  z-index: 0;
  transition: background .4s var(--ease);
}

h1, h2, h3, .display { font-family: "Sora", "Inter", sans-serif; letter-spacing: -0.02em; }
button { font-family: inherit; cursor: pointer; color: inherit; }
a { color: inherit; text-decoration: none; }
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ============================================================
   Shell
   ============================================================ */
.app {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  background: var(--sidebar-grad);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 18px 14px 14px; gap: 6px;
  transition: background .4s var(--ease), border-color .4s var(--ease);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, #5FA168, #3F7D4E);
  box-shadow: 0 6px 16px -6px rgba(63,125,78,0.55), 0 0 0 1px rgba(255,255,255,0.10) inset;
  flex: none;
}
.brand .mark svg { width: 16px; height: 16px; display: block; }
.brand .name {
  font-family: "Sora", sans-serif; font-weight: 700;
  color: var(--text-hi); font-size: 15px; letter-spacing: -0.02em;
}
.brand .sub {
  font-size: 9.5px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-lo); font-weight: 500; margin-top: 1px;
}

.nav-group { margin-top: 6px; }
.nav-label {
  font-size: 10px; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 600; padding: 10px 10px 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-mid); font-size: 13.5px; font-weight: 450;
  background: transparent; border: 1px solid transparent;
  transition: background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
  position: relative; text-align: left;
}
.nav-item svg { width: 16px; height: 16px; flex: none; opacity: .85; }
.nav-item .kbd {
  margin-left: auto; font-size: 10.5px; color: var(--text-faint);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px;
  font-variant-numeric: tabular-nums;
}
.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item.active { background: var(--bg-3); color: var(--text-hi); border-color: var(--line); }
.nav-item.active::before {
  content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 3px;
  background: linear-gradient(var(--accent), var(--accent-hi));
}
.nav-item .badge {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: var(--accent-dim); color: var(--accent-hi);
  border-radius: 20px; padding: 1px 7px; min-width: 20px; text-align: center;
}
.nav-item.active .kbd { border-color: var(--line-strong); }

.sidebar .spacer { flex: 1; }
.nav-foot { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 6px; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: var(--radius-sm);
  transition: background .18s var(--ease);
}
.user-chip:hover { background: var(--bg-3); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--avatar-grad); display: grid; place-items: center;
  font-size: 11px; font-weight: 600; color: #F5F4EF;
  box-shadow: 0 0 0 1px var(--line-strong) inset;
}
.user-chip .who { line-height: 1.25; }
.user-chip .who b { color: var(--text-hi); font-weight: 550; font-size: 12.5px; display: block; }
.user-chip .who span { color: var(--text-lo); font-size: 11px; }
.user-chip .dot { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

/* ---------- main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
  height: 56px; flex: none;
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  transition: background .4s var(--ease), border-color .4s var(--ease);
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-lo); }
.crumbs .cur { color: var(--text-hi); font-weight: 500; font-family: "Sora", sans-serif; letter-spacing: -0.01em; font-size: 14.5px; }
.crumbs svg { width: 14px; height: 14px; opacity: .5; }

.search {
  margin-left: 8px; display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px;
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 8px; color: var(--text-lo); font-size: 12.5px;
  min-width: 200px; transition: border-color .18s var(--ease), background .18s;
}
.search:hover { border-color: var(--line-strong); }
.search svg { width: 14px; height: 14px; }
.search .k { margin-left: auto; border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; font-size: 10.5px; }

.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: 8px; border: 1px solid var(--line); background: var(--bg-1);
  color: var(--text-mid); transition: all .18s var(--ease);
}
.icon-btn:hover { background: var(--bg-3); color: var(--text-hi); border-color: var(--line-strong); }
.icon-btn svg { width: 16px; height: 16px; }
.btn-primary {
  height: 32px; padding: 0 13px; border-radius: 8px;
  background: linear-gradient(180deg, var(--accent), var(--accent-hi));
  color: var(--on-accent); font-weight: 600; font-size: 12.5px; border: none;
  display: flex; align-items: center; gap: 7px;
  box-shadow: var(--btn-glow);
  transition: transform .16s var(--ease), filter .16s;
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary svg { width: 15px; height: 15px; }

/* ---------- live tour pill ---------- */
.tour {
  display: flex; align-items: center; gap: 8px;
  height: 28px; padding: 0 11px 0 9px;
  border-radius: 20px; border: 1px solid var(--accent-line);
  background: var(--accent-dim); color: var(--accent-hi);
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  transition: opacity .45s var(--ease), transform .45s var(--ease);
  overflow: hidden; position: relative;
}
.tour.hide { opacity: 0; transform: translateY(-4px) scale(.96); pointer-events: none; }
.tour .pulse {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none;
  animation: pulse 2s var(--ease) infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.8); }
}
.tour .track {
  position: absolute; left: 0; bottom: 0; height: 2px; width: 100%;
  background: var(--accent-line);
}
.tour .track i {
  display: block; height: 100%; width: 0; background: var(--accent);
}
.tour.running .track i { animation: tourfill var(--dwell, 5000ms) linear forwards; }
@keyframes tourfill { from { width: 0; } to { width: 100%; } }

/* ---------- canvas ---------- */
.canvas {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 26px 26px 60px;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.canvas::-webkit-scrollbar { width: 10px; }
.canvas::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 3px solid var(--scroll-track); }
.canvas::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

.view { display: none; }
.view.active { display: block; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.view.active [data-rise] {
  opacity: 0;
  animation: rise .6s var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 55ms);
}
@media (prefers-reduced-motion: reduce) {
  .view.active [data-rise] { animation: none; opacity: 1; transform: none; }
  .tour.running .track i { animation: none; }
}

.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.page-head .h { font-size: 22px; color: var(--text-hi); font-weight: 700; }
.page-head .sub { color: var(--text-lo); font-size: 13px; margin-top: 3px; }
.page-head .head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.seg {
  display: inline-flex; background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 9px; padding: 3px; gap: 2px;
}
.seg button {
  padding: 5px 12px; border-radius: 6px; font-size: 12.5px; color: var(--text-mid);
  background: transparent; border: none; font-weight: 500;
  transition: all .16s var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--bg-3); color: var(--text-hi); box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset; }
[data-theme="light"] .seg button.on { background: var(--bg-0); box-shadow: 0 1px 2px rgba(32,45,57,0.06); }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  transition: background .4s var(--ease), border-color .4s var(--ease), box-shadow .4s var(--ease);
}
:root .card { background: linear-gradient(180deg, var(--bg-2), var(--bg-1)); }
[data-theme="light"] .card { background: var(--bg-1); }

.grid { display: grid; gap: 16px; }

.stats { grid-template-columns: repeat(4, 1fr); margin-bottom: 16px; }
.stat {
  padding: 16px 16px 12px; position: relative; overflow: hidden;
  transition: transform .22s var(--ease), border-color .22s var(--ease), background .4s var(--ease), box-shadow .22s;
}
.stat:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: var(--shadow-pop); }
.stat .top { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.stat .ico {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--bg-inset); border: 1px solid var(--line); color: var(--text-mid);
}
.stat .ico svg { width: 15px; height: 15px; }
.stat .lbl { font-size: 12px; color: var(--text-lo); font-weight: 500; letter-spacing: .01em; }
.stat .val {
  font-family: "Sora", sans-serif; font-weight: 700; color: var(--text-hi);
  font-size: 27px; letter-spacing: -0.03em; line-height: 1;
}
.stat .val .cur { color: var(--text-mid); font-weight: 500; font-size: 18px; }
.stat .row2 { display: flex; align-items: center; gap: 8px; margin-top: 9px; height: 18px; position: relative; z-index: 1; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--accent-hi); }
.delta.down { color: var(--rose); }
.delta svg { width: 12px; height: 12px; }
.stat .vs { font-size: 11.5px; color: var(--text-faint); }
.spark { position: absolute; right: 14px; bottom: 12px; width: 92px; height: 34px; opacity: .95; }

.panel { padding: 0; overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.panel-head .t { font-family: "Sora", sans-serif; font-weight: 600; color: var(--text-hi); font-size: 14.5px; letter-spacing: -0.01em; }
.panel-head .meta { color: var(--text-lo); font-size: 12px; }
.panel-head .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 18px; }

.ghost-btn {
  height: 28px; padding: 0 10px; border-radius: 7px; font-size: 12px; font-weight: 500;
  background: var(--bg-1); border: 1px solid var(--line); color: var(--text-mid);
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .16s var(--ease);
}
.ghost-btn:hover { background: var(--bg-3); color: var(--text-hi); border-color: var(--line-strong); }
.ghost-btn svg { width: 14px; height: 14px; }

/* ---------- overview grids ---------- */
.ov-grid { grid-template-columns: 1.6fr 1fr; align-items: start; }

.chart-wrap { position: relative; }
.chart-legend { display: flex; gap: 16px; align-items: center; }
.leg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-mid); }
.leg .sw { width: 9px; height: 9px; border-radius: 3px; }
.chart-svg { width: 100%; display: block; overflow: visible; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--bg-3); border: 1px solid var(--line-strong);
  border-radius: 9px; padding: 8px 11px; box-shadow: var(--shadow-pop);
  font-size: 12px; opacity: 0; transform: translateY(4px);
  transition: opacity .14s, transform .14s; white-space: nowrap;
}
[data-theme="light"] .chart-tip { background: var(--bg-1); }
.chart-tip.show { opacity: 1; transform: translateY(0); }
.chart-tip .tt-l { color: var(--text-lo); font-size: 11px; margin-bottom: 3px; }
.chart-tip .tt-row { display: flex; align-items: center; gap: 7px; color: var(--text-hi); font-weight: 600; }
.chart-tip .tt-row .sw { width: 8px; height: 8px; border-radius: 2px; }
.hover-guide { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; transition: opacity .12s; }
.hover-guide.show { opacity: 1; }
.hover-dot { opacity: 0; transition: opacity .12s; }
.hover-dot.show { opacity: 1; }

/* ---------- rows ---------- */
.rows { display: flex; flex-direction: column; }
.rowi {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--line-faint);
  transition: background .15s var(--ease);
}
.rowi:last-child { border-bottom: none; }
.rowi:hover { background: var(--bg-3); }
.rowi .lead {
  width: 30px; height: 30px; border-radius: 8px; flex: none; display: grid; place-items: center;
  background: var(--bg-inset); border: 1px solid var(--line); color: var(--text-mid);
}
.rowi .lead svg { width: 15px; height: 15px; }
.rowi .lead.g { color: var(--accent-hi); background: var(--accent-dim); border-color: var(--accent-line); }
.rowi .lead.a { color: var(--amber); background: var(--amber-dim); border-color: var(--amber-line); }
.rowi .lead.r { color: var(--rose); background: var(--rose-dim); border-color: var(--rose-line); }
.rowi .body { min-width: 0; flex: 1; }
.rowi .body b { color: var(--text-hi); font-weight: 550; font-size: 13px; }
.rowi .body p { color: var(--text-lo); font-size: 12px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowi .when { color: var(--text-faint); font-size: 11.5px; flex: none; }
.rowi .chev { color: var(--text-faint); flex: none; opacity: 0; transition: opacity .15s, transform .15s; }
.rowi:hover .chev { opacity: 1; transform: translateX(2px); }
.rowi .chev svg { width: 15px; height: 15px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px;
  border: 1px solid var(--line);
}
.pill .d { width: 6px; height: 6px; border-radius: 50%; }
.pill.g { color: var(--accent-hi); background: var(--accent-dim); border-color: var(--accent-line); }
.pill.g .d { background: var(--accent); }
.pill.a { color: var(--amber); background: var(--amber-dim); border-color: var(--amber-line); }
.pill.a .d { background: var(--amber); }
.pill.r { color: var(--rose); background: var(--rose-dim); border-color: var(--rose-line); }
.pill.r .d { background: var(--rose); }
.pill.n { color: var(--text-mid); }
.pill.n .d { background: var(--text-lo); }

.bar { height: 6px; border-radius: 6px; background: var(--bg-inset); overflow: hidden; border: 1px solid var(--line-faint); }
.bar > span { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--accent-hi)); }

/* ============================================================
   Kanban
   ============================================================ */
.kanban { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.kcol {
  background: var(--bg-1);
  border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 420px;
  transition: border-color .18s var(--ease), background .18s;
}
:root .kcol { background: linear-gradient(180deg, var(--bg-1), var(--bg-0)); }
[data-theme="light"] .kcol { background: var(--bg-0); }
.kcol.drop { border-color: var(--accent-line); }
[data-theme="light"] .kcol.drop { background: #EDEBE3; }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 12px 13px 10px; }
.kcol-head .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.kcol-head .t { font-size: 12.5px; font-weight: 600; color: var(--text); letter-spacing: .01em; }
.kcol-head .n { margin-left: auto; font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.kcol-sum { padding: 0 13px 10px; font-size: 11px; color: var(--text-lo); font-variant-numeric: tabular-nums; }
.kcards { padding: 4px 10px 12px; display: flex; flex-direction: column; gap: 9px; flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

.deal {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 12px; cursor: grab; user-select: none;
  transition: transform .16s var(--ease), border-color .16s, box-shadow .16s, background .16s;
}
.deal:hover { border-color: var(--line-strong); background: var(--bg-3); transform: translateY(-1px); box-shadow: var(--shadow-card); }
[data-theme="light"] .deal:hover { background: var(--bg-1); }
.deal.dragging { opacity: .45; cursor: grabbing; }
.deal .co { font-size: 13px; color: var(--text-hi); font-weight: 550; margin-bottom: 2px; }
.deal .meta { font-size: 11.5px; color: var(--text-lo); }
.deal .foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.deal .amt { font-size: 13px; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.deal .amt-tbd { font-size: 12px; color: var(--text-faint); font-weight: 500; }
.deal .who2 {
  margin-left: auto; width: 22px; height: 22px; border-radius: 50%;
  background: var(--avatar-grad); display: grid; place-items: center;
  font-size: 9.5px; font-weight: 600; color: #F5F4EF; box-shadow: 0 0 0 1px var(--line) inset;
}
.deal .tags { display: flex; gap: 5px; margin-top: 9px; flex-wrap: wrap; }
.tag { font-size: 10.5px; color: var(--text-mid); background: var(--bg-inset); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }

/* ============================================================
   Table
   ============================================================ */
.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-faint); padding: 11px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg-1); z-index: 2;
}
.tbl thead th.num, .tbl tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line-faint); font-size: 13px; color: var(--text); }
.tbl tbody tr { transition: background .14s var(--ease); }
.tbl tbody tr:hover { background: var(--bg-3); }
.tbl tbody tr:last-child td { border-bottom: none; }
.client-cell { display: flex; align-items: center; gap: 11px; }
.client-cell .logo {
  width: 30px; height: 30px; border-radius: 8px; flex: none; display: grid; place-items: center;
  font-family: "Sora", sans-serif; font-weight: 700; font-size: 12px; color: #F5F4EF;
  box-shadow: 0 0 0 1px var(--line) inset;
}
.client-cell b { color: var(--text-hi); font-weight: 550; }
.client-cell span { color: var(--text-lo); font-size: 11.5px; }
.health { display: flex; align-items: center; gap: 9px; }
.health .track { width: 64px; }
.owner-cell { display: flex; align-items: center; gap: 8px; }
.owner-cell .av { width: 24px; height: 24px; border-radius: 50%; background: var(--avatar-grad); display: grid; place-items: center; font-size: 10px; font-weight: 600; color: #F5F4EF; flex: none; box-shadow: 0 0 0 1px var(--line) inset; }

/* ============================================================
   Financials
   ============================================================ */
.fin-grid { grid-template-columns: 1.5fr 1fr; align-items: start; }
.breakdown { display: flex; flex-direction: column; gap: 14px; }
.brow .top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.brow .top .n { font-size: 12.5px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brow .top .n .sw { width: 9px; height: 9px; border-radius: 3px; }
.brow .top .a { font-size: 12.5px; color: var(--text-hi); font-weight: 600; font-variant-numeric: tabular-nums; }

.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bars .b .col {
  width: 100%; max-width: 30px; border-radius: 6px 6px 3px 3px;
  background: var(--bg-inset); border: 1px solid var(--line);
  transition: height .5s var(--ease-out), filter .2s;
}
.bars .b .col.on { background: linear-gradient(180deg, var(--accent-hi), var(--accent)); border-color: transparent; }
.bars .b:hover .col { filter: brightness(1.12); }
.bars .b .cap { font-size: 10.5px; color: var(--text-faint); }

/* ============================================================
   Today
   ============================================================ */
.att-grid { grid-template-columns: 1fr 1fr; align-items: start; }
.task {
  display: flex; align-items: flex-start; gap: 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--line-faint); transition: background .15s var(--ease);
  cursor: pointer;
}
.task:last-child { border-bottom: none; }
.task:hover { background: var(--bg-3); }
.check {
  width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--line-strong);
  flex: none; margin-top: 1px; display: grid; place-items: center;
  transition: all .16s var(--ease); background: var(--bg-inset);
}
.check svg { width: 12px; height: 12px; opacity: 0; transform: scale(.6); transition: all .16s var(--ease); color: var(--on-accent); }
.task.done .check { background: var(--accent); border-color: var(--accent); }
.task.done .check svg { opacity: 1; transform: scale(1); }
.task.done .ttl { color: var(--text-faint); text-decoration: line-through; }
.task .tmain { flex: 1; min-width: 0; }
.task .ttl { color: var(--text-hi); font-size: 13px; font-weight: 500; transition: color .16s; }
.task .tsub { color: var(--text-lo); font-size: 12px; margin-top: 2px; }
.task .tmeta { display: flex; align-items: center; gap: 8px; margin-top: 8px; }

.focus {
  background: var(--bg-2);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-lg); padding: 22px 24px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 22px;
  transition: background .4s var(--ease);
}
:root .focus {
  background:
    radial-gradient(600px 200px at 90% -40%, rgba(95,161,104,0.16), transparent 70%),
    linear-gradient(180deg, var(--bg-2), var(--bg-1));
}
[data-theme="light"] .focus {
  background:
    radial-gradient(600px 200px at 90% -40%, rgba(63,125,78,0.10), transparent 70%),
    var(--bg-1);
}
.focus .ring { flex: none; }
.focus .ftxt h3 { font-size: 17px; color: var(--text-hi); font-weight: 700; }
.focus .ftxt p { color: var(--text-mid); font-size: 13px; margin-top: 4px; max-width: 560px; }
.focus .ftxt .meta { margin-top: 10px; display: flex; gap: 14px; }
.focus .ftxt .meta b { color: var(--text-hi); }
.focus .ftxt .meta span { color: var(--text-lo); font-size: 12px; }

/* responsive */
@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .ov-grid, .fin-grid, .att-grid { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .search { display: none; }
}

/* ============================================================
   Mobile / tablet portrait: the desktop grid does not fit a phone,
   so the shell reflows to a single column with a horizontal top
   nav strip, larger touch targets, and one card per row. The auto
   tour still runs (it only stops on a real tap inside the frame),
   so the embedded demo still comes alive on a phone.
   ============================================================ */
@media (max-width: 820px) {
  html, body { font-size: 14.5px; }

  /* Shell becomes a vertical stack, natural height so the parent page
     controls scroll instead of a nested 100vh scroller.
     minmax(0,1fr) and the min-width:0 below matter: a grid item defaults to
     min-width:auto, so the horizontally scrolling tab bar would otherwise
     stretch the shell to its content width (~733px) and push the topbar
     controls off a 375px screen instead of scrolling. */
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    height: auto;
    min-height: 100%;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }
  .sidebar, .main, .topbar, .canvas { min-width: 0; max-width: 100%; }

  /* The sidebar becomes two stacked rows at the top: the brand, then a
     full width tab bar. Giving the tabs their own row means each one gets a
     real, thumb sized target instead of competing with the brand for space. */
  .sidebar {
    flex-direction: column;
    align-items: stretch;
    gap: 9px;
    padding: 11px 0 0;
    border-right: none;
    border-bottom: 1px solid var(--line);
    overflow: visible;
    position: sticky; top: 0; z-index: 20;
  }
  .brand { padding: 0 14px; }
  .brand .sub { display: none; }
  .sidebar .nav-label,
  .sidebar .spacer,
  .sidebar .nav-foot { display: none; }
  /* Show only the primary workspace group; the secondary "Views" group is
     redundant on a phone and would push the real tabs off screen. */
  .sidebar .nav-group + .nav-group { display: none; }

  /* The tab bar itself scrolls, not the whole sidebar, so the brand stays put. */
  .nav-group {
    margin-top: 0;
    display: flex;
    gap: 8px;
    padding: 0 14px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
  }
  .nav-group::-webkit-scrollbar { display: none; }

  .nav-item {
    width: auto;
    flex: none;
    gap: 9px;
    min-height: 46px;
    padding: 11px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 11px;
    border: 1px solid var(--line);
    background: var(--bg-1);
    color: var(--text);
    white-space: nowrap;
    scroll-snap-align: start;
  }
  .nav-item .kbd { display: none; }
  .nav-item.active::before { display: none; }
  .nav-item svg { width: 18px; height: 18px; opacity: .9; }

  /* Unmistakable active state: accent fill, accent border, accent text. */
  .nav-item.active {
    background: var(--accent-dim);
    border-color: var(--accent-line);
    color: var(--accent-hi);
    font-weight: 650;
  }
  .nav-item.active svg { opacity: 1; }
  .nav-item.active .badge { background: var(--accent); color: var(--on-accent); }
  .nav-item:active { transform: scale(0.97); }

  /* The auto tour does not run on a phone, so the pill takes no space. */
  .tour { display: none; }

  /* Topbar: drop the crumbs, keep the tour pill + theme + primary action,
     bigger tap targets. */
  .topbar { height: 52px; padding: 0 14px; gap: 10px; }
  .crumbs { display: none; }
  .top-right { gap: 8px; }
  .icon-btn { width: 38px; height: 38px; }
  .btn-primary { height: 38px; padding: 0 14px; }
  .tour { height: 32px; }

  .canvas { padding: 16px 14px 40px; }

  /* Page heads stack, actions wrap under the title. */
  .page-head { flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
  .page-head .head-actions { margin-left: 0; flex-wrap: wrap; }
  .page-head .h { font-size: 20px; }
  .seg { flex-wrap: wrap; }
  .seg button { padding: 8px 13px; min-height: 36px; }

  /* Stats: two per row on tablet portrait. */
  .stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  /* Kanban reflows to a single column of stages, each a natural-height
     card, so nothing is squished and it reads as a real mobile board. */
  .kanban { grid-template-columns: 1fr; gap: 12px; }
  .kcol { min-height: 0; }
  .kcards { max-height: none; }

  /* Jobs table: let it scroll horizontally inside its own card rather
     than pushing the whole page wide. */
  .view#view-jobs .card.panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl { min-width: 620px; }

  /* Today focus block stacks the ring above the copy. */
  .focus { flex-direction: column; align-items: flex-start; gap: 16px; padding: 20px; }
  .focus .ftxt .meta { flex-direction: column; gap: 6px; }
}

/* Phone portrait (<=430px, covers 375 and 414). */
@media (max-width: 480px) {
  html, body { font-size: 14px; }
  .canvas { padding: 14px 12px 36px; }

  /* One stat per row, but keep them compact and premium. */
  .stats { grid-template-columns: 1fr; gap: 10px; }
  .stat { padding: 14px 15px 12px; }
  .stat .val { font-size: 25px; }
  .spark { width: 78px; }

  .page-head .h { font-size: 19px; }

  /* Topbar: hide the label on the New action, keep the icon, so the row
     never overflows on a narrow phone. */
  .btn-primary { padding: 0 12px; font-size: 0; gap: 0; }
  .btn-primary svg { width: 18px; height: 18px; }

  .panel-head { padding: 13px 15px; flex-wrap: wrap; }
  .panel-body { padding: 15px; }
  .rowi { padding: 12px 15px; }
  .rowi .when { display: none; }

  .brand .name { font-size: 14.5px; }
  /* Keep full size tap targets on the smallest phones; only the side padding
     tightens so more of the next tab peeks in and invites a swipe. */
  .nav-item { padding: 11px 14px; font-size: 13.5px; min-height: 46px; }
  .nav-group { gap: 7px; padding: 0 12px 10px; }
}
