/* Brain's look: the house style of Sergio's decks (src/outputs/deck.js),
   dark navy surfaces, a bright-blue accent, Bitter for headings and Inter
   for everything else, extended to an application. Mobile first where it
   matters: below 900px the sidebar becomes a drawer behind a top bar,
   tables stack into cards (js/app.js labels their cells) and tabs scroll. */

@font-face { font-family: 'Inter'; src: url('/fonts/inter.woff2') format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Bitter'; src: url('/fonts/bitter.woff2') format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Bitter'; src: url('/fonts/bitter-italic.woff2') format('woff2'); font-weight: 100 900; font-style: italic; font-display: swap; }

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  color-scheme: dark;
  /* Deck tokens */
  --navy: #0A1A33; --band: #071226; --surface: #10254A; --surface-2: #0D2041; --deep: #163A6B; --strong: #1B4F9C;
  --line: #1F3B68; --line-2: #3A64A8; --accent: #5B8FE0; --bright: #8DB4F0; --tint: #DCE8FA;
  --ink: #F1F5FC; --body: #C7D3E8; --sub: #A9B8D3; --soft: #7F93B3;
  --blue: #2F6FD1; --blue-hover: #3A7BE0;
  --red: #F08A75; --green: #5FD3A2; --amber: #F2C46D; --violet: #B9A4F5;
  --serif: 'Bitter', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Fira Code', Menlo, monospace;
  /* The names the pages already use, mapped onto the new palette. */
  --bg: var(--navy);
  --border: var(--line);
  --text: var(--body);
  --text-muted: var(--soft);
  --muted: var(--soft);
  --primary: var(--blue);
  --primary-hover: var(--blue-hover);
  --success: var(--green);
  --danger: var(--red);
  --warning: var(--amber);
  --radius: 8px;
  --sidebar-w: 232px;
  --topbar-h: 56px;
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  background: var(--navy);
  background-image: radial-gradient(ellipse 70% 40% at 60% 0%, rgba(47,111,209,.12), transparent 70%);
  background-attachment: fixed;
  color: var(--body);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--bright); text-decoration: none; }
a:hover { color: var(--tint); text-decoration: underline; text-underline-offset: 2px; }
strong, b { color: var(--ink); font-weight: 600; }
h1 { font: 300 30px/1.15 var(--serif); letter-spacing: -.015em; color: #fff; }
h2 { font: 600 20px/1.25 var(--serif); color: var(--ink); }
h3 { font: 600 15px/1.35 var(--sans); color: var(--ink); }
h4 { font: 600 14px/1.35 var(--sans); color: var(--ink); }
hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
::selection { background: rgba(91,143,224,.4); color: #fff; }
:focus-visible { outline: 2px solid var(--bright); outline-offset: 2px; border-radius: 4px; }
code { font-family: var(--mono); font-size: .92em; }
img, svg, video, iframe { max-width: 100%; }

/* ---- Layout ---- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--band);
  border-right: 1px solid var(--line);
  color: var(--body);
  padding: 18px 0 12px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 60;
}
.sidebar h2 { padding: 0 18px 18px; margin-bottom: 10px; border-bottom: 1px solid var(--line); font: 600 16px/1 var(--sans); color: var(--ink); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { flex: none; border-radius: 7px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; margin-bottom: 14px; }
.sidebar .nav-group { font: 500 10.5px/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--soft); padding: 8px 12px 8px; }
.sidebar .nav-spacer { flex: 1; }
.sidebar .brand-link { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.sidebar .brand-link:hover { text-decoration: none; color: #fff; }
.nav-ico { flex: none; opacity: .85; }
.sidebar a.active .nav-ico { opacity: 1; color: var(--bright); }
.sidebar a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  color: var(--sub);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 7px;
  position: relative;
}
.sidebar a:hover { color: var(--ink); background: rgba(91,143,224,.10); text-decoration: none; }
.sidebar a.active { color: #fff; background: var(--deep); }
.sidebar a.active::before { content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--bright); }
.sidebar a .badge { margin-left: auto; }
.sidebar form { padding: 12px 16px 4px !important; }
.sidebar form .btn { width: 100%; color: var(--sub) !important; border-color: var(--line) !important; }
.sidebar form .btn:hover { color: var(--ink) !important; border-color: var(--line-2) !important; }
.main { margin-left: var(--sidebar-w); padding: 28px 32px 48px; flex: 1; min-width: 0; max-width: 100%; }
.main > h1, .page-head h1 { margin-bottom: 18px; }
.main > h1::before, .page-head h1::before {
  content: ''; display: block; width: 22px; height: 2px; background: var(--bright); margin-bottom: 12px;
}

/* Shell pieces built by js/app.js */
.topbar, .tabbar { display: none; }
.nav-backdrop { display: none; }
.utilbar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin: -8px 0 18px; }
.search-trigger { display: inline-flex; align-items: center; gap: 10px; min-width: 260px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--soft); font: 400 13px/1.2 var(--sans); cursor: pointer; margin-right: auto; }
.search-trigger:hover { border-color: var(--line-2); color: var(--sub); }
.search-trigger kbd { margin-left: auto; font: 500 11px/1 var(--sans); color: var(--soft); border: 1px solid var(--line); border-radius: 5px; padding: 3px 5px; }
.tool-btn { position: relative; width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); cursor: pointer; }
.tool-btn:hover { border-color: var(--accent); background: rgba(91,143,224,.12); }
.tool-btn .dot { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #2a0b05; font: 700 10.5px/18px var(--sans); text-align: center; }

/* Sheets: search, quick add, notifications */
body.sheet-open { overflow: hidden; }
.sheet { position: fixed; inset: 0; z-index: 900; background: rgba(3,9,20,.6); backdrop-filter: blur(3px); display: flex; justify-content: center; align-items: flex-start; padding: 10vh 16px 16px; }
.sheet-panel { width: 100%; max-width: 620px; max-height: 78vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: 0 30px 80px rgba(0,0,0,.5); padding: 16px 18px; }
.sheet-bell { justify-content: flex-end; align-items: stretch; padding: 0; }
.sheet-bell .sheet-panel { max-width: 420px; max-height: none; height: 100%; border-radius: 0; border-width: 0 0 0 1px; }
.sheet-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sheet-title h3 { margin: 0; font: 600 18px/1.2 var(--serif); }
.search-head { display: flex; align-items: center; gap: 10px; color: var(--soft); border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 8px; }
.search-head input { flex: 1; border: none !important; background: transparent !important; box-shadow: none !important; font-size: 16px !important; padding: 6px 0 !important; }
.search-results h4 { font: 500 10.5px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--bright); margin: 14px 0 4px; }
.search-results .row-list > li { padding: 8px 0; align-items: center; }
.seg { display: flex; gap: 4px; padding: 4px; background: var(--band); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; overflow-x: auto; }
.seg button { flex: 1; white-space: nowrap; background: none; border: none; color: var(--sub); padding: 8px 10px; border-radius: 7px; font: 500 13px/1 var(--sans); cursor: pointer; }
.seg button.on { background: var(--deep); color: #fff; }
.notif.unread { background: linear-gradient(90deg, rgba(91,143,224,.10), transparent 60%); }
.notif .notif-body { white-space: pre-wrap; margin-top: 4px; }
.badge-tier-now { background: rgba(240,138,117,.15); color: var(--red); border-color: rgba(240,138,117,.4); }
.badge-tier-today { background: rgba(91,143,224,.16); color: var(--bright); border-color: rgba(91,143,224,.35); }
.badge-tier-week { background: rgba(127,147,179,.15); color: var(--sub); }

/* ---- Login ---- */
.login-container {
  max-width: 380px;
  margin: 14vh auto 40px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 36px 32px 32px;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
  position: relative;
  overflow: hidden;
}
.login-container::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, #3A7BE0, #8DB4F0);
}
.login-container h1 { font: 300 32px/1 var(--serif); margin-bottom: 8px; color: #fff; }
.login-container h1 img { width: 34px; height: 34px; }
.login-container .login-sub { color: var(--sub); margin-bottom: 26px; font-size: 14px; }
.login-container input {
  width: 100%;
  margin-bottom: 12px;
}
.login-container .btn { padding: 11px 16px; font-size: 14.5px; }
.login-container .error { color: var(--red); font-size: 13px; margin-bottom: 12px; }
.login-shell { min-height: 100vh; padding: 0 16px; background: radial-gradient(ellipse 80% 70% at 15% 0%, rgba(58,123,224,.35), transparent 60%), var(--navy); }

/* ---- Forms ---- */
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]), select, textarea {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 13.5px;
  padding: 8px 11px;
  transition: border-color .15s, box-shadow .15s;
  max-width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--soft); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,143,224,.22); }
select { appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%238DB4F0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
select option, select optgroup { background: var(--surface); color: var(--ink); }
input[type=checkbox], input[type=radio] { accent-color: var(--blue); width: 16px; height: 16px; vertical-align: middle; }
input[type=file] { color: var(--sub); font-size: 13px; max-width: 100%; }
input[type=file]::file-selector-button { background: transparent; color: var(--ink); border: 1px solid var(--line-2); border-radius: 7px; padding: 6px 12px; margin-right: 10px; cursor: pointer; font: inherit; }
label { color: var(--sub); }
textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: 500 13px/1.4 var(--sans);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, 0 4px 14px rgba(47,111,209,.25); }
.btn-primary:hover { background: var(--blue-hover); color: #fff; }
.btn-success { background: #1F8F66; color: #fff; }
.btn-success:hover { background: #24A576; color: #fff; }
.btn-danger { background: transparent; color: var(--red); border-color: rgba(240,138,117,.5); }
.btn-danger:hover { background: rgba(240,138,117,.12); color: #ffb3a3; }
.btn-warning { background: var(--amber); color: #2a1d00; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 7px; }
.btn-outline { background: transparent; border: 1px solid var(--line-2); color: var(--ink); }
.btn-outline:hover { background: rgba(91,143,224,.12); border-color: var(--accent); color: #fff; }
.btn + .btn { margin-left: 4px; }

/* ---- Tables ---- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
th { background: var(--band); font: 500 11px/1.2 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--soft); white-space: nowrap; }
td { color: var(--body); }
tbody tr:last-child td, table > tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: rgba(91,143,224,.07); }
td a { font-weight: 500; }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font: 600 10.5px/1.6 var(--sans);
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  background: rgba(127,147,179,.18);
  color: var(--sub);
  border: 1px solid rgba(127,147,179,.25);
}
.badge-new, .badge-queued, .badge-planned, .badge-former_client { background: rgba(127,147,179,.15); color: var(--sub); border-color: rgba(127,147,179,.28); }
.badge-researched, .badge-lead { background: rgba(91,143,224,.16); color: var(--bright); border-color: rgba(91,143,224,.35); }
.badge-message_ready, .badge-team, .badge-vendor { background: rgba(185,164,245,.15); color: var(--violet); border-color: rgba(185,164,245,.32); }
.badge-sent, .badge-opportunity, .badge-in_progress, .badge-running { background: rgba(242,196,109,.14); color: var(--amber); border-color: rgba(242,196,109,.32); }
.badge-replied, .badge-client { background: rgba(95,211,162,.13); color: var(--green); border-color: rgba(95,211,162,.32); }
.badge-meeting_booked, .badge-success, .badge-succeeded, .badge-delivered { background: rgba(95,211,162,.2); color: #8BE7C0; border-color: rgba(95,211,162,.45); }
.badge-archived, .badge-cancelled, .badge-expired { background: rgba(127,147,179,.1); color: var(--soft); border-color: rgba(127,147,179,.2); }
.badge-failed, .badge-needs_attention, .badge-lost, .badge-private, .badge-danger { background: rgba(240,138,117,.15); color: var(--red); border-color: rgba(240,138,117,.4); }
.sidebar .badge-needs_attention, .topbar .badge-needs_attention { background: var(--red); color: #2a0b05; border-color: var(--red); }

/* ---- Filters ---- */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filters select, .filters input { font-size: 13px; }

/* Geography multiselect (button + checkbox popover) */
.geo-filter { position: relative; }
.geo-filter-btn {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}
.geo-filter-btn.active { border-color: var(--accent); color: var(--bright); }
.geo-filter-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0,0,0,.45);
  padding: 8px;
  min-width: 240px;
  max-height: 300px;
  overflow-y: auto;
}
.geo-filter-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--body);
}
.geo-filter-panel label:hover { background: rgba(91,143,224,.1); }
.geo-filter-panel label input { width: auto; }
.geo-filter-panel .geo-count { color: var(--soft); margin-left: auto; font-size: 12px; }
.geo-filter-panel .geo-actions {
  display: flex;
  justify-content: space-between;
  padding: 6px 8px 2px;
  margin-top: 4px;
  border-top: 1px solid var(--line);
}
.geo-filter-panel .geo-actions a { font-size: 12px; cursor: pointer; color: var(--bright); }

/* ---- Cards / detail ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.18);
  min-width: 0;
}
.card h3 { margin-bottom: 12px; font: 600 15.5px/1.3 var(--sans); color: var(--ink); }
.card > h3:first-child .muted { font-weight: 400; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.detail-grid { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 8px 16px; font-size: 13px; }
.detail-grid dt { color: var(--soft); font-weight: 500; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; padding-top: 2px; }
.detail-grid dd { margin: 0; color: var(--body); overflow-wrap: anywhere; }

/* ---- Preview (rendered Markdown) ---- */
.preview-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 26px 30px;
  font-size: 15px;
  line-height: 1.75;
  color: var(--body);
}
.preview-panel h1 { font: 300 28px/1.2 var(--serif); margin-bottom: 16px; color: #fff; }
.preview-panel h2 { font: 600 20px/1.3 var(--serif); margin: 28px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.preview-panel h3 { font-size: 16px; margin: 20px 0 8px; }
.preview-panel p { margin-bottom: 14px; }
.preview-panel ul, .preview-panel ol { margin-left: 24px; margin-bottom: 14px; }
.preview-panel li { margin-bottom: 6px; }
.preview-panel img { max-width: 100%; border-radius: var(--radius); margin: 16px 0; }
.preview-panel blockquote {
  border-left: 3px solid var(--bright);
  margin: 20px 0;
  padding: 14px 22px;
  background: var(--band);
  border-radius: 0 var(--radius) var(--radius) 0;
  font: italic 300 17px/1.55 var(--serif);
  color: var(--ink);
}
.preview-panel blockquote p { margin-bottom: 0; }
.preview-panel hr { border: none; border-top: 1px solid var(--line); margin: 24px 0; }

/* ---- Actions bar ---- */
.actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  margin-top: 16px;
}
.actions-bar .btn + .btn { margin-left: 0; }

/* ---- Alerts ---- */
.alert {
  padding: 11px 16px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 13px;
  border: 1px solid;
  border-left-width: 3px;
}
.alert a { color: inherit; text-decoration: underline; font-weight: 600; }
.alert-success { background: rgba(95,211,162,.1); color: #A7EFCF; border-color: rgba(95,211,162,.35); }
.alert-danger { background: rgba(240,138,117,.1); color: #FFC2B5; border-color: rgba(240,138,117,.4); }
.alert-info { background: rgba(91,143,224,.12); color: var(--tint); border-color: rgba(91,143,224,.4); }

/* ---- Form page ---- */
.form-container { max-width: 640px; margin: 40px auto; padding: 0 20px; }
.form-container h1 { font-size: 26px; margin-bottom: 8px; }
.form-container p.subtitle { color: var(--soft); margin-bottom: 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font: 500 11px/1.2 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--soft); }
.form-group input, .form-group select, .form-group textarea { width: 100%; font-size: 14px; }
.form-group textarea { min-height: 80px; font-family: var(--sans); }
.radio-group { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 4px; }
.radio-group label { font-weight: normal; display: flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--body); }
.radio-group input[type="radio"] { width: auto; }
.checkbox-group label { font-weight: normal; display: flex; align-items: flex-start; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--body); }
.checkbox-group input[type="checkbox"] { width: auto; margin-top: 2px; flex-shrink: 0; }

/* Fit score */
.fit-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.fit-score-high { color: var(--green); }
.fit-score-mid { color: var(--amber); }
.fit-score-low { color: var(--soft); }

/* Prev/next nav */
.detail-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.detail-nav .spacer { flex: 1; }

/* Contact cards */
.contact-card {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  position: relative;
}
.contact-card.primary { border-color: var(--accent); background: rgba(47,111,209,.12); }
.contact-card .primary-star { color: var(--amber); margin-right: 4px; }
.contact-card .field-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.contact-card .field-row input { flex: 1; min-width: 140px; padding: 6px 9px; font-size: 12.5px; }
.contact-card .relevance-note { font-style: italic; color: var(--soft); margin-top: 6px; font-size: 12px; }

/* Collapsible */
details.collapsible { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: 16px; }
.card.collapsible { padding: 0; }
.card.collapsible > .row-list { padding: 0 18px 12px; }
details.collapsible summary { padding: 14px 18px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink); list-style: none; }
details.collapsible summary::-webkit-details-marker { display: none; }
details.collapsible summary::before { content: '▸ '; color: var(--bright); }
details.collapsible[open] summary::before { content: '▾ '; }
details.collapsible .collapsible-body { padding: 0 18px 18px; }

pre { white-space: pre-wrap; overflow-wrap: anywhere; }
pre.raw-block, pre.meeting-text {
  background: var(--band);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--body);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
}

.message-body { white-space: pre-wrap; font-size: 13.5px; line-height: 1.65; color: var(--body); }

.reply-item { border-left: 3px solid var(--green); padding: 10px 14px; margin-bottom: 8px; background: rgba(95,211,162,.07); border-radius: 0 var(--radius) var(--radius) 0; font-size: 13px; }
.reply-item .reply-meta { color: var(--soft); font-size: 11px; margin-top: 4px; }

.timeline-item { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.timeline-item:last-child { border-bottom: none; }
.timeline-item .timeline-action { font-weight: 600; color: var(--ink); }
.timeline-item .timeline-time { color: var(--soft); }

tr.row-incomplete { opacity: 0.6; }
tr.row-duplicate { opacity: 0.5; text-decoration: line-through; }
tr.row-senior td { background: rgba(240,138,117,.08); }

.empty-state { text-align: center; padding: 48px 16px; color: var(--soft); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3,9,20,.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.modal h2 { font-size: 20px; margin-bottom: 6px; }
.modal-close { position: absolute; top: 12px; right: 14px; background: none; border: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--soft); width: 36px; height: 36px; border-radius: 8px; }
.modal-close:hover { color: var(--ink); background: rgba(91,143,224,.12); }
.modal-back { background: none; border: none; color: var(--bright); cursor: pointer; font-size: 13px; padding: 0; margin-bottom: 14px; }
.modal-choice { display: flex; gap: 16px; margin-top: 20px; }
.modal-choice-card { flex: 1; border: 1px solid var(--line-2); border-radius: 12px; padding: 24px; text-align: center; cursor: pointer; background: var(--surface-2); }
.modal-choice-card:hover { border-color: var(--bright); background: rgba(47,111,209,.14); }
.modal-choice-card h4 { margin-bottom: 6px; }
.modal-choice-card p { color: var(--soft); font-size: 12px; }

/* Technical > System > Server card */
.err { color: var(--red); overflow-wrap: anywhere; }
#system-ops h4 { margin: 18px 0 6px; }
#system-ops ul { margin: 0; padding-left: 18px; }

/* ---- Tabs, pages, lists (02 on) ---- */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: none; padding: 10px 14px; cursor: pointer; font: 500 13px/1.2 var(--sans); color: var(--soft); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: #fff; border-bottom-color: var(--bright); }
.tab { display: none; }
.tab.active { display: block; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.card .page-head h3::before { display: none; }
.muted { color: var(--soft); }
.small { font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: rgba(91,143,224,.14); border: 1px solid rgba(91,143,224,.28); color: var(--tint); border-radius: 999px; padding: 2px 10px; font-size: 12px; }
.chip button { background: none; border: none; cursor: pointer; color: var(--soft); font-size: 14px; line-height: 1; padding: 0 0 0 2px; }
.chip button:hover { color: var(--red); }
.row-list { list-style: none; margin: 0; padding: 0; }
.row-list > li { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 8px 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.row-list > li:last-child { border-bottom: none; }
.row-list .grow { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.row-list .children { list-style: none; margin: 6px 0 0 18px; padding: 0; }
.row-list > li > .btn + .btn { margin-left: 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.inline-form input, .inline-form select { padding: 7px 10px; font-size: 13px; }
.inline-form input[type=text] { min-width: 180px; flex: 1; }
.inline-form .btn + .btn { margin-left: 0; }
.md-view { line-height: 1.65; color: var(--body); overflow-wrap: anywhere; }
.md-view h1 { font-size: 24px; margin: 4px 0 10px; }
.md-view h2 { font: 600 18px/1.3 var(--serif); margin: 20px 0 8px; color: var(--ink); }
.md-view h3 { font-size: 15px; margin: 16px 0 6px; }
.md-view h4, .md-view h5 { font-size: 14px; margin: 12px 0 4px; }
.md-view ul, .md-view ol { margin: 4px 0 8px 22px; }
.md-view li::marker { color: var(--accent); }
.md-view p { margin: 4px 0 8px; }
.md-view code { background: var(--band); border: 1px solid var(--line); padding: 0 5px; border-radius: 4px; color: var(--tint); }
.hub-editor textarea { min-height: 420px; }
.drop-zone { border: 2px dashed var(--line-2); border-radius: 12px; padding: 22px; text-align: center; color: var(--sub); cursor: pointer; background: rgba(13,32,65,.5); transition: border-color .15s, background .15s; }
.drop-zone:hover { border-color: var(--accent); }
.drop-zone.over { border-color: var(--bright); background: rgba(47,111,209,.15); color: var(--tint); }
.horizon h3 { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--bright); margin: 16px 0 6px; }
.horizon-overdue h3 { color: var(--red); }
.task-done { text-decoration: line-through; color: var(--soft); }

/* ---- Outputs (04) ---- */
.deck-preview { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #E6ECF4; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.deck-preview iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.output-message { white-space: pre-wrap; font-family: inherit; background: var(--band); border: 1px solid var(--line); color: var(--body); border-radius: 10px; padding: 14px 16px; max-width: 560px; line-height: 1.6; }
.output-doc { max-width: 820px; }
.md-view .md-table { border-collapse: collapse; margin: 8px 0 12px; font-size: 13px; display: block; overflow-x: auto; max-width: 100%; border: none; background: none; }
.md-view .md-table th, .md-view .md-table td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; vertical-align: top; }
.md-view .md-table th { background: var(--band); }
.md-view blockquote { border-left: 3px solid var(--bright); margin: 8px 0; padding: 4px 14px; color: var(--sub); background: rgba(7,18,38,.5); }
.page-preview { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.page-preview iframe { width: 100%; height: 100%; border: 0; }

/* Who was in a meeting (drop report, Needs you) */
.speakers-form { margin-top: 8px; }
.speaker-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.speaker-row label { display: block; margin-bottom: 4px; color: var(--body); }
.speaker-row .muted { overflow-wrap: anywhere; }
.speaker-row input[type=text] { display: block; width: 100%; max-width: 360px; margin-top: 6px; }
.speakers-form > .btn { margin-top: 10px; }
.internal-text { white-space: pre-wrap; }
.scope-list { margin: 4px 0 2px 0; padding-left: 18px; font-size: 13px; }
.scope-list li { padding: 1px 0; border: none; display: list-item; }
.scope-form input { margin-top: 4px; padding: 4px 8px; font-size: 12px; width: 260px; max-width: 100%; }
.link-btn { border: none; background: none; color: var(--soft); cursor: pointer; padding: 0 4px; font-size: 15px; }
.link-btn:hover { color: var(--red); }
.basis { margin-top: 2px; }
.task-quote { font-style: italic; }

/* While an output is being written */
.progress-card { border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); padding: 14px 16px; margin: 10px 0; }
.progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.progress-bar { height: 6px; background: var(--band); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; margin: 10px 0; }
.progress-bar > div { height: 100%; background: linear-gradient(90deg, var(--blue), var(--bright)); transition: width 1s linear; }
.progress-steps { list-style: none; padding: 0; margin: 0 0 8px; }
.progress-steps li { display: flex; gap: 8px; padding: 3px 0; }
.progress-steps .step-mark { width: 1em; flex: none; text-align: center; }
.progress-steps .step-done .step-mark { color: var(--green); }
.progress-steps .step-now .step-mark { color: var(--bright); animation: step-pulse 1.2s ease-in-out infinite; }
.progress-steps .step-next, .progress-steps .step-skipped { color: var(--soft); }
.progress-steps ul { margin: 4px 0 0; padding-left: 18px; }
@keyframes step-pulse { 50% { opacity: 0.3; } }

/* ---- Today and shared page pieces (09) ---- */
.today-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.today-col { min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h3 { margin: 0; }
.count { display: inline-block; min-width: 22px; padding: 1px 7px; margin-left: 4px; border-radius: 999px; background: rgba(91,143,224,.18); color: var(--bright); font: 600 12px/1.5 var(--sans); text-align: center; vertical-align: 1px; }
.eyebrow { font: 500 11px/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--bright); display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.eyebrow::before { content: ''; width: 22px; height: 2px; background: var(--bright); }
.next-card { background: linear-gradient(135deg, #1E56A8 0%, #143F80 45%, #10254A 100%); border-color: var(--line-2); }
.next-card h2 { font: 300 28px/1.15 var(--serif); color: #fff; margin-bottom: 6px; }
.next-card .eyebrow { color: var(--tint); } .next-card .eyebrow::before { background: var(--tint); }
.next-meta { color: var(--tint); font-size: 14px; }
.next-meta a { color: #fff; font-weight: 600; }
.next-who { margin-top: 6px; color: rgba(220,232,250,.8); }
.next-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.next-actions .btn + .btn { margin-left: 0; }
.next-card .btn-outline { border-color: rgba(220,232,250,.5); }
.check { flex: none; width: 20px; height: 20px; margin-top: 1px; border-radius: 6px; border: 1.5px solid var(--line-2); background: transparent; cursor: pointer; }
.check:hover { border-color: var(--green); background: rgba(95,211,162,.12); }
.done-row { opacity: .4; text-decoration: line-through; }
.age { flex: none; font: 600 12px/1.6 var(--sans); color: var(--soft); font-variant-numeric: tabular-nums; }
.age.old { color: var(--amber); }
.signals > li { align-items: center; }
.sig-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--soft); margin-top: 2px; }
.sig-red .sig-dot { background: var(--red); box-shadow: 0 0 0 3px rgba(240,138,117,.18); }
.sig-amber .sig-dot { background: var(--amber); box-shadow: 0 0 0 3px rgba(242,196,109,.16); }
.sig-info .sig-dot { background: var(--accent); }
.date-col { flex: none; width: 84px; font: 500 12px/1.5 var(--sans); color: var(--bright); font-variant-numeric: tabular-nums; }
.agenda .time, .time-col { flex: none; width: 56px; font: 600 13px/1.5 var(--sans); color: var(--bright); font-variant-numeric: tabular-nums; }
.subnav { display: flex; gap: 4px; margin: -6px 0 16px; border-bottom: 1px solid var(--line); }
.subnav a { padding: 9px 14px; color: var(--soft); font: 500 13.5px/1 var(--sans); border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; }
.subnav a.active { color: #fff; border-bottom-color: var(--bright); }
.subnav a:hover { color: var(--ink); text-decoration: none; }
.health { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.health-green { background: var(--green); box-shadow: 0 0 0 3px rgba(95,211,162,.16); }
.health-amber { background: var(--amber); box-shadow: 0 0 0 3px rgba(242,196,109,.16); }
.health-red { background: var(--red); box-shadow: 0 0 0 3px rgba(240,138,117,.18); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.stat .v { display: block; font: 300 30px/1.1 var(--serif); color: var(--bright); font-variant-numeric: tabular-nums; }
.stat .l { display: block; margin-top: 6px; font-size: 12px; color: var(--sub); }
.stat a { color: inherit; text-decoration: none; }
.stat a:hover .l { color: var(--ink); }

/* ---- Insights (09 §8) ---- */
.ins-section { scroll-margin-top: 80px; margin-bottom: 28px; }
.outreach-detail > summary { cursor: pointer; list-style: none; margin: 18px 0 10px; }
.outreach-detail > summary::-webkit-details-marker { display: none; }
.outreach-detail > summary::before { content: '▸ '; }
.outreach-detail[open] > summary::before { content: '▾ '; }
.ins-title { font: 300 24px/1.2 var(--serif); color: #fff; margin: 8px 0 12px; }
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 32%) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 12.5px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--body); }
.hbar-track { position: relative; height: 12px; background: var(--empty, #13294D); border-radius: 4px; }
.hbar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--cat-1, #3987e5); border-radius: 0 4px 4px 0; }
.hbar-tick { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--tint); border-radius: 1px; }
.hbar-value { font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.vbars { display: flex; gap: 6px; align-items: stretch; height: 170px; padding-bottom: 4px; }
.vcol { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.vplot { flex: 1; display: flex; align-items: flex-end; gap: 2px; border-bottom: 1px solid var(--line); }
.vplot .vbar { flex: 1; border-radius: 4px 4px 0 0; min-width: 0; }
.vstack { flex: 1; height: 100%; display: flex; flex-direction: column-reverse; gap: 2px; }
.vstack i { display: block; border-radius: 2px; }
.vstack i:last-child { border-radius: 4px 4px 2px 2px; }
.vlab { font-size: 10px; color: var(--soft); text-align: center; margin-top: 4px; white-space: nowrap; overflow: hidden; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 12px; color: var(--sub); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* ---- Clients portfolio (09 §7) ---- */
.portfolio { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; margin-bottom: 12px; }
.client-card { display: block; margin: 0; color: var(--body); text-decoration: none; border-left: 3px solid var(--green); transition: border-color .15s, transform .1s; }
.client-card:hover { text-decoration: none; color: var(--body); transform: translateY(-1px); border-color: var(--accent); }
.client-card.health-edge-amber { border-left-color: var(--amber); }
.client-card.health-edge-red { border-left-color: var(--red); }
.client-card .card-head h3 .health { margin-right: 6px; vertical-align: 1px; }
.client-card > div { margin-top: 3px; }
.client-card .reason { color: var(--ink); }
.late { color: var(--red); }
.general-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-decoration: none; color: var(--body); }
.general-card:hover { text-decoration: none; border-color: var(--accent); color: var(--body); }
.general-card > span { font-size: 26px; color: var(--bright); }

/* ---- Pipeline board (09 §6) ---- */
.pipeline-totals { margin-bottom: 16px; }
.stage-pick { display: none; }
.board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; overflow-x: auto; }
.board .col { background: rgba(7,18,38,.55); border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-width: 0; }
.board .col header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.board .col h3 { margin: 0; font-size: 13.5px; }
.deal { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; margin-bottom: 8px; color: var(--body); text-decoration: none; transition: border-color .15s, transform .1s; }
.deal:hover { border-color: var(--accent); text-decoration: none; color: var(--body); transform: translateY(-1px); }
.deal.warn { border-left: 3px solid var(--red); }
.deal-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.deal-top strong { color: var(--ink); }
.deal-value { font: 600 12.5px/1.3 var(--sans); color: var(--bright); white-space: nowrap; }
.deal-step { margin-bottom: 4px; }
.deal-flags { margin-top: 6px; font: 600 11px/1.3 var(--sans); color: var(--red); }
.empty-col { padding: 6px 2px; }
.queue h3 .count { margin-left: 6px; }
.queue { margin-bottom: 4px; }
.list-head { margin: 18px 0 10px; font: 500 11px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--bright); }

/* ---- Organization page (09 §5) ---- */
.org-head { align-items: flex-start; }
.org-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.org-actions .btn + .btn { margin-left: 0; }
.stepper { list-style: none; display: flex; gap: 4px; margin: 4px 0 14px; padding: 0; overflow-x: auto; scrollbar-width: none; }
.stepper::-webkit-scrollbar { display: none; }
.stepper li { flex: 1 0 auto; position: relative; padding-top: 10px; font: 500 11.5px/1.2 var(--sans); color: var(--soft); white-space: nowrap; }
.stepper li::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; border-radius: 2px; background: var(--line); }
.stepper li.done { color: var(--sub); } .stepper li.done::before { background: var(--strong); }
.stepper li.now { color: #fff; } .stepper li.now::before { background: var(--bright); box-shadow: 0 0 10px rgba(141,180,240,.5); }
.stepper li.lost { color: var(--red); } .stepper li.lost::before { background: var(--red); }
.stepper li span { padding-right: 10px; }
.org-strip { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 10px 14px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.org-strip:empty { display: none; }
.org-strip b { font: 500 10.5px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--bright); margin-right: 6px; }
.org-strip .late, .org-strip .late b { color: var(--red); }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font: 500 10.5px/1.2 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--soft); }
.form-grid label input, .form-grid label select { width: 100%; text-transform: none; letter-spacing: 0; }
.form-grid .wide { grid-column: 1 / -1; }
h4.sub { font: 500 10.5px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--bright); margin: 14px 0 4px; }
.reasons { margin: 0 0 4px 18px; color: var(--body); }
.card-head h3 .health { margin-right: 6px; vertical-align: 1px; }
.ids-card .chips { margin-bottom: 8px; }

/* Scrollbars that belong to the theme */
* { scrollbar-color: var(--line-2) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--line-2); background-clip: padding-box; border: 2px solid transparent; }

/* ================= Tablet and phone ================= */
@media (max-width: 900px) {
  .topbar {
    display: flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 10px 0 14px;
    background: rgba(7,18,38,.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    z-index: 50;
  }
  .topbar .brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--ink); text-decoration: none; }
  .topbar .topbar-title { font: 400 21px/1 var(--serif); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-tools { margin-left: auto; display: flex; gap: 6px; }
  .topbar .tool-btn { width: 40px; height: 40px; border-color: transparent; background: transparent; }
  .utilbar { display: none; }
  /* The page's name is in the top bar; its own heading would repeat it. */
  .dup-title { display: none !important; }

  .tabbar {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0;
    height: calc(62px + env(safe-area-inset-bottom));
    padding: 0 4px env(safe-area-inset-bottom);
    background: rgba(7,18,38,.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    z-index: 50;
  }
  .tabbar a, .tabbar button {
    flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    color: var(--soft); background: none; border: none; font: 500 11px/1 var(--sans); text-decoration: none; cursor: pointer; min-width: 0;
  }
  .tabbar a.active { color: #fff; }
  .tabbar a.active .nav-ico { color: var(--bright); }
  .tabbar a.active::before { content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; border-radius: 0 0 2px 2px; background: var(--bright); }
  .tabbar .tab-count { position: absolute; top: 7px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--red); color: #2a0b05; font: 700 10px/17px var(--sans); text-align: center; }

  .sheet { padding: 0; align-items: flex-end; }
  .sheet-panel { max-width: none; max-height: 88vh; border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .sheet-search { align-items: stretch; }
  .sheet-search .sheet-panel { max-height: none; height: 100%; border-radius: 0; padding-top: calc(12px + env(safe-area-inset-top)); }
  .sheet-bell .sheet-panel { max-width: none; border-left: none; padding-top: calc(14px + env(safe-area-inset-top)); }

  .sidebar {
    width: min(84vw, 300px);
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: 20px 0 50px rgba(0,0,0,.45);
    padding-top: calc(18px + env(safe-area-inset-top));
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .sidebar a { padding: 12px 14px; font-size: 15px; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open { overflow: hidden; }
  .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(3,9,20,.6); z-index: 55; opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }

  .main { margin-left: 0; padding: calc(var(--topbar-h) + env(safe-area-inset-top) + 16px) 16px calc(86px + env(safe-area-inset-bottom)); width: 100%; }
  h1, .main > h1 { font-size: 26px; }
  .card { padding: 16px; border-radius: 12px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .today-grid, .overview-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .stage-pick { display: flex; }
  .board { display: block; overflow: visible; }
  .board .col { display: none; background: none; border: none; padding: 0; }
  .board .col.picked { display: block; }
  .board .col header { display: none; }
  .pipeline-totals, #client-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portfolio { grid-template-columns: minmax(0, 1fr); }
  .vlab { font-size: 9px; }
  .vbars { gap: 3px; }
  .org-actions { justify-content: flex-start; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .next-card h2 { font-size: 24px; }
  .subnav { margin-left: -16px; margin-right: -16px; padding: 0 10px; overflow-x: auto; scrollbar-width: none; }
  .filters { flex-direction: row; align-items: stretch; }
  .filters > * { flex: 1 1 140px; min-width: 0; }
  .filters > .btn { flex: 0 0 auto; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .detail-grid dd { margin-bottom: 10px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-head > div { display: flex; flex-wrap: wrap; gap: 8px; }
  .page-head > div .btn + .btn { margin-left: 0; }

  /* Tabs: one scrolling strip, not a wrapped pile. */
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin-left: -16px; margin-right: -16px; padding: 0 12px; scroll-snap-type: x proximity; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { padding: 12px 12px; font-size: 14px; scroll-snap-align: start; flex: none; }

  /* Comfortable touch targets, and 16px inputs so iOS doesn't zoom in. */
  .btn { padding: 10px 16px; font-size: 14px; min-height: 42px; }
  .btn-sm { padding: 7px 12px; font-size: 13px; min-height: 36px; }
  input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]), select, textarea { font-size: 16px; padding: 10px 12px; min-height: 42px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  .inline-form input[type=text] { min-width: 0; flex: 1 1 100%; }
  .inline-form > * { max-width: 100%; }
  .inline-form select { flex: 1 1 160px; }
  select[style*="max-width"] { max-width: 100% !important; }

  .row-list > li { padding: 12px 0; }
  .row-list > li > .btn, .row-list > li > a.btn { flex: 0 0 auto; }

  /* Tables become a list of compact cards: the title first (with its
     checkbox), then labelled values, empty ones left out, buttons last. */
  table.stack, table.stack tbody { display: block; width: 100%; }
  table.stack { border: none; background: none; border-radius: 0; overflow: visible; }
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack tr:first-child:has(> th) { display: none; }
  table.stack tr { display: flex; flex-wrap: wrap; align-items: center; column-gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; padding: 10px 14px; }
  table.stack tbody tr:hover { background: var(--surface); }
  table.stack td { flex: 1 1 100%; border: none; padding: 3px 0; display: flex; gap: 12px; justify-content: space-between; align-items: baseline; text-align: right; overflow-wrap: anywhere; min-width: 0; }
  table.stack td::before { content: attr(data-label); flex: none; max-width: 45%; text-align: left; font: 500 10.5px/1.7 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--soft); }
  table.stack td[data-label=""]::before { display: none; }
  table.stack td[data-label=""] { justify-content: flex-start; text-align: left; }
  table.stack td.stack-empty, table.stack td:empty { display: none; }
  table.stack td.stack-check { flex: 0 0 auto; order: -2; padding: 4px 0; }
  table.stack td.stack-check::before { display: none; }
  table.stack td.stack-title { order: -1; flex: 1 1 0; display: block; text-align: left; font-size: 15.5px; font-weight: 600; padding: 4px 0 6px; }
  table.stack td.stack-title::before { display: none; }
  table.stack td.stack-actions { order: 10; justify-content: flex-start; flex-wrap: wrap; gap: 8px; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
  table.stack td.stack-actions::before { display: none; }
  table.stack td.stack-actions .btn + .btn { margin-left: 0; }

  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { max-width: none; max-height: 92vh; border-radius: 16px 16px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
  .modal-choice { flex-direction: column; }

  .preview-panel { padding: 18px; font-size: 15px; }
  .page-preview { height: 70vh; }
  .hub-editor textarea { min-height: 50vh; }
  .output-message { max-width: 100%; }
  .attention-banner { font-size: 13px; }

  .login-container { margin-top: 10vh; padding: 30px 22px 24px; }
}

@media (max-width: 480px) {
  .main { padding-left: 12px; padding-right: 12px; }
  .tabs, .subnav { margin-left: -12px; margin-right: -12px; }
  .card { padding: 14px; }
  .actions-bar { gap: 8px; }
  .actions-bar > .btn, .actions-bar > a.btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
