:root {
  --bg: #0a0a0b;
  --panel: #151517;
  --panel-2: #1c1c1f;
  --panel-3: #232327;
  --border: #2a2a2e;
  --border-strong: #3a3a40;
  --grey: #9a9aa2;
  --grey-dim: #6b6b73;
  --text: #f2f2f3;
  --red: #e0263f;
  --red-dim: #a01c30;
  --red-glow: rgba(224, 38, 63, 0.25);
  --green: #3ddc84;
  --amber: #f5a623;
  --gold: #d4a94a;
  --blue: #4d8bff;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
h1 { margin: 4px 0 0; font-size: 22px; letter-spacing: -0.01em; }
h2 { margin: 0 0 4px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
h2 svg { width: 16px; height: 16px; color: var(--red); }
svg { width: 1em; height: 1em; flex-shrink: 0; vertical-align: -0.15em; }
.muted { color: var(--grey-dim); font-size: 12px; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 28px;
  background: linear-gradient(180deg, #141416 0%, #0f0f11 100%);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-lg { font-size: 19px; justify-content: center; margin-bottom: 4px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 12px var(--red-glow); }
.nav { display: flex; gap: 22px; }
.nav a { color: var(--grey); font-size: 14px; font-weight: 600; padding: 8px 2px; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.active { color: var(--text); border-bottom-color: var(--red); }
.user-area { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 5px; border-radius: 100px; border: 1px solid transparent; color: var(--grey); font-size: 13px; }
.user-chip:hover, .user-chip.active { border-color: var(--border-strong); background: var(--panel-2); color: var(--text); text-decoration: none; }
.user-avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--red-dim); color: #fff; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.admin-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--red); border: 1px solid var(--red-dim); border-radius: 4px; padding: 1px 5px; }
.main-content { flex: 1; padding: 24px 28px 64px; max-width: 1240px; width: 100%; margin: 0 auto; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); padding: 9px 15px; border-radius: 7px; font-size: 13px; font-weight: 600; line-height: 1; transition: border-color .15s, background .15s; white-space: nowrap; }
.btn svg { width: 14px; height: 14px; }
.btn:hover { border-color: var(--border-strong); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: #c91f36; border-color: #c91f36; }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: var(--red-dim); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: 14px; }
.icon-btn { background: transparent; border: none; color: var(--grey-dim); padding: 6px; border-radius: 5px; display: inline-flex; }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover { color: var(--red); background: var(--panel-3); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 20%, #1a0e10 0%, var(--bg) 60%); padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 36px 32px; width: 100%; max-width: 340px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.login-sub { color: var(--grey); font-size: 13px; text-align: center; margin: 4px 0 22px; }
.login-card label { display: block; font-size: 12px; color: var(--grey); margin: 12px 0 6px; }
.login-card input { width: 100%; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font-size: 14px; }
.login-card input:focus { outline: none; border-color: var(--red); }
.login-card button { margin-top: 20px; }
.error-text { color: var(--red); font-size: 12px; margin-top: 8px; min-height: 14px; }

/* ---------- page header / filters ---------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.page-header .muted { margin: 4px 0 0; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.back-link { display: inline-flex; align-items: center; gap: 6px; width: fit-content; padding: 7px 14px 7px 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--text); font-size: 13px; font-weight: 600; line-height: 1.2; transition: border-color .15s, background .15s; }
.back-link svg { width: 15px; height: 15px; color: var(--red); }
.back-link { margin-bottom: 10px; }
.editor-title .back-link { margin-bottom: 0; }
.back-link:hover { border-color: var(--red); background: var(--panel-3); color: var(--text); text-decoration: none; }
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters select, .search-box { padding: 9px 12px; border-radius: 7px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font-size: 13px; }
.filters select:focus { outline: none; border-color: var(--red); }
.search-box { flex: 1; min-width: 220px; display: flex; align-items: center; gap: 8px; padding: 0 12px; }
.search-box svg { color: var(--grey-dim); width: 15px; height: 15px; }
.search-box input { flex: 1; border: none; background: transparent; padding: 9px 0; color: var(--text); font-size: 13px; min-width: 0; }
.search-box input:focus { outline: none; }
.search-box:focus-within { border-color: var(--red); }

/* ---------- KPI strip ---------- */
.kpi-strip { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; text-align: left; display: flex; flex-direction: column; gap: 2px; color: var(--text); transition: border-color .15s; }
.kpi:hover { border-color: var(--border-strong); }
.kpi.active { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.kpi-num { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.kpi-label { font-size: 11px; color: var(--grey); text-transform: uppercase; letter-spacing: .05em; }

/* ---------- table ---------- */
.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; }
.crm-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.crm-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--grey-dim); padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--panel-2); white-space: nowrap; cursor: pointer; user-select: none; }
.crm-table th:hover { color: var(--text); }
.crm-table th .sort-ic { margin-left: 5px; opacity: .35; }
.crm-table th .sort-ic.on { opacity: 1; color: var(--red); }
.crm-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.crm-table tr:last-child td { border-bottom: none; }
.clickable-row { cursor: pointer; transition: background .1s; }
.clickable-row:hover { background: var(--panel-2); }
.cell-name { font-weight: 600; }
.cell-sub { font-size: 11.5px; margin-top: 2px; }
.empty-state { padding: 40px 20px; text-align: center; color: var(--grey-dim); font-size: 14px; }
.loading { padding: 40px; text-align: center; color: var(--grey-dim); }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 100px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; border: 1px solid currentColor; white-space: nowrap; }
.pill svg { width: 11px; height: 11px; }
.pill-draft { color: var(--amber); }
.pill-complete { color: var(--green); }
.pill-vip { color: var(--gold); }
.pill-lfa { color: var(--red); }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- editor layout ---------- */
.main-content.wide { max-width: 1560px; }
.editor-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; }
.editor-layout.with-notes { grid-template-columns: 200px minmax(0, 1fr) 320px; }
.notes-panel { display: none; }
.with-notes .notes-panel { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 140px; height: calc(100vh - 160px); min-height: 360px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.np-head { display: flex; align-items: center; justify-content: space-between; }
.np-head h3 { margin: 0; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.np-head h3 svg { color: var(--amber); width: 15px; height: 15px; }
.notes-panel textarea { flex: 1; width: 100%; resize: none; padding: 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font: 14px/1.55 inherit; font-family: inherit; color-scheme: dark; }
.notes-panel textarea:focus { outline: none; border-color: var(--amber); }
.np-foot { font-size: 11.5px; }
.btn.on { border-color: var(--amber); color: var(--text); background: rgba(245,166,35,.1); }
.btn.on svg { color: var(--amber); }

.presence-note { font-size: 12px; color: var(--amber); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.presence-note:empty { display: none; }
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px rgba(245,166,35,.2); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(245,166,35,0); } }
.editing-note { font-size: 11.5px; color: var(--amber); margin-top: 3px; font-weight: 600; }
.editing-note:empty { display: none; }
.editing-note::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); margin-right: 6px; vertical-align: 1px; }
.pill-followup { color: var(--blue); }

.conn-banner { position: fixed; left: 50%; top: 70px; transform: translate(-50%, -12px); z-index: 60; display: flex; align-items: center; gap: 10px; max-width: min(720px, calc(100% - 32px)); padding: 12px 16px; border-radius: 10px; background: #3a1016; border: 1px solid var(--red); color: var(--text); font-size: 13px; box-shadow: 0 12px 40px rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.conn-banner.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.conn-banner svg { color: var(--red); width: 18px; height: 18px; flex-shrink: 0; }
.section-nav { position: sticky; top: 140px; display: flex; flex-direction: column; gap: 2px; }
.section-nav a { display: flex; align-items: center; gap: 9px; color: var(--grey); font-size: 13px; font-weight: 600; padding: 9px 12px; border-radius: 7px; border-left: 2px solid transparent; }
.section-nav a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.section-nav a.active { color: var(--text); background: var(--panel); border-left-color: var(--red); }
.section-nav .sn-num { font-size: 10px; color: var(--grey-dim); width: 16px; }
.section-nav .sn-done { margin-left: auto; color: var(--green); width: 12px; height: 12px; }
.section-nav .sep { height: 1px; background: var(--border); margin: 8px 4px; }

.editor-bar {
  position: sticky; top: 61px; z-index: 15;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: rgba(10,10,11,.92); backdrop-filter: blur(8px);
  padding: 12px 0; margin: -12px 0 16px; border-bottom: 1px solid var(--border);
}
.editor-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.editor-title .back-link { flex-shrink: 0; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(135deg, var(--red) 0%, var(--red-dim) 100%); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; box-shadow: 0 0 0 4px rgba(224,38,63,.12); flex-shrink: 0; }
.editor-name { font-size: 19px; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-state { font-size: 12px; color: var(--grey-dim); display: inline-flex; align-items: center; gap: 6px; }
.save-state .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--grey-dim); }
.save-state.dirty .dot { background: var(--amber); }
.save-state.saved .dot { background: var(--green); }

.form-section { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 22px; margin-bottom: 18px; scroll-margin-top: 140px; }
.form-section > header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.sec-kicker { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--red); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-field label { display: block; font-size: 11.5px; color: var(--grey); margin-bottom: 6px; font-weight: 600; }
.form-field .hint { font-weight: 400; color: var(--grey-dim); }
.form-field input[type=text], .form-field input[type=date], .form-field input[type=number], .form-field select, .form-field textarea {
  width: 100%; padding: 10px 12px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-size: 14px; font-family: inherit; resize: vertical; color-scheme: dark; line-height: 1.45;
}
.form-field textarea { min-height: 76px; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { outline: none; border-color: var(--red); }
.form-field input.invalid { border-color: var(--red); }

.toggle-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel-2); cursor: pointer; user-select: none; transition: border-color .15s, background .15s; }
.toggle-card:hover { border-color: var(--border-strong); }
.toggle-card input { display: none; }
.toggle-card .tc-box { width: 20px; height: 20px; border-radius: 5px; border: 1.5px solid var(--border-strong); display: inline-flex; align-items: center; justify-content: center; color: transparent; flex-shrink: 0; }
.toggle-card .tc-box svg { width: 13px; height: 13px; }
.toggle-card.on { border-color: var(--red); background: rgba(224,38,63,.1); }
.toggle-card.on .tc-box { background: var(--red); border-color: var(--red); color: #fff; }
.toggle-card .tc-label { font-weight: 700; font-size: 13px; }
.toggle-card .tc-sub { font-size: 11.5px; color: var(--grey-dim); margin-top: 1px; }

/* garage rows */
.garage-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.garage-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) minmax(0, 1.4fr) 32px; gap: 16px; align-items: start; padding: 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel-2); }
.garage-row .g-num { font-size: 13px; font-weight: 700; color: var(--red); text-align: center; padding-top: 22px; }
.garage-row .g-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.garage-row .g-f { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.garage-row .g-f > span { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--grey-dim); }
.garage-row .g-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.garage-row [data-rm] { margin-top: 20px; }
.garage-row input { width: 100%; padding: 9px 11px; border-radius: 7px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 13.5px; color-scheme: dark; }
.garage-row input:focus { outline: none; border-color: var(--red); }
.use-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.use-chip { padding: 5px 10px; border-radius: 100px; border: 1px solid var(--border); background: transparent; color: var(--grey); font-size: 11.5px; font-weight: 600; }
.use-chip:hover { color: var(--text); border-color: var(--border-strong); }
.use-chip.on { border-color: var(--red); color: var(--text); background: rgba(224,38,63,.14); }
.garage-total { font-size: 12px; color: var(--grey); margin-left: auto; }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: 9px; border: 1px solid var(--amber); background: rgba(245,166,35,.08); color: var(--text); font-size: 13px; margin-bottom: 16px; flex-wrap: wrap; }
.banner.error { border-color: var(--red); background: rgba(224,38,63,.08); }

/* ---------- outputs ---------- */
.outputs-grid { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 22px; align-items: start; }
.out-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.out-card.sticky { position: sticky; top: 140px; }
.out-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.out-text { width: 100%; min-height: 420px; padding: 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font: 12.5px/1.55 ui-monospace, "SF Mono", Consolas, monospace; resize: vertical; white-space: pre-wrap; }
.out-text:focus { outline: none; border-color: var(--red); }
.out-meta { display: flex; justify-content: space-between; margin-top: 8px; }
.out-toggle { display: flex; gap: 4px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px; padding: 3px; }
.out-toggle button { border: none; background: transparent; color: var(--grey); font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 5px; }
.out-toggle button.on { background: var(--panel-3); color: var(--text); }

/* ---------- account ---------- */
.account-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.trash-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.trash-row:last-child { border-bottom: none; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--panel-3); border: 1px solid var(--border-strong); color: var(--text); padding: 11px 18px; border-radius: 8px; font-size: 13px; font-weight: 600; opacity: 0; transition: opacity .2s, transform .2s; z-index: 100; pointer-events: none; display: flex; align-items: center; gap: 8px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast svg { color: var(--green); }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 7px; border: 1px solid var(--border); background: var(--panel-2); font-size: 13px; font-weight: 500; color: var(--grey); }
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.active { border-color: var(--red); color: var(--text); background: rgba(224,38,63,.12); }

/* ---------- analytics ---------- */
.an-kpis { grid-template-columns: repeat(5, 1fr); margin-bottom: 8px; }
.an-kpis .kpi-num { font-size: 26px; }
.an-section-title { font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--grey); margin: 26px 0 10px; display: flex; align-items: center; gap: 12px; }
.an-section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.an-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.an-grid .span-12 { grid-column: span 12; } .an-grid .span-6 { grid-column: span 6; } .an-grid .span-8 { grid-column: span 8; } .an-grid .span-3 { grid-column: span 3; } .an-grid .span-4 { grid-column: span 4; } .an-grid .span-5 { grid-column: span 5; } .an-grid .span-7 { grid-column: span 7; }
.an-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; min-width: 0; }
.an-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.an-head h2 { font-size: 15px; margin: 0; }
.an-note { font-size: 12px; color: var(--grey-dim); }
.an-empty { color: var(--grey-dim); font-size: 13px; padding: 24px 0; text-align: center; }
.an-card button { font-family: inherit; color: var(--text); }
.an-card button:disabled { cursor: default; }

/* columns */
.cols { display: flex; align-items: stretch; gap: 10px; height: 200px; margin-top: auto; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; background: transparent; border: none; padding: 0; border-radius: 6px; min-width: 0; }
.col-val { font-size: 15px; font-weight: 700; height: 18px; }
.col-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; border-bottom: 1px solid var(--border-strong); }
.col-bar { width: 100%; max-width: 56px; margin: 0 auto; background: var(--red); border-radius: 4px 4px 0 0; min-height: 0; transition: filter .15s; }
.col-label { font-size: 12.5px; color: var(--grey); white-space: nowrap; }
.col:hover:not(:disabled) .col-bar { filter: brightness(1.2); }
.col:hover:not(:disabled) .col-label { color: var(--text); }
.col:disabled .col-label { color: var(--grey-dim); }

/* horizontal bars */
.hbars { display: flex; flex-direction: column; gap: 4px; }
.hbar { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; row-gap: 6px; align-items: center; background: transparent; border: none; padding: 8px 10px; margin: 0 -10px; border-radius: 8px; text-align: left; }
.hbar:hover:not(:disabled) { background: var(--panel-2); }
.hbar:disabled { opacity: .45; }
.hbar-rank { grid-row: span 2; width: 24px; height: 24px; border-radius: 50%; background: var(--panel-3); color: var(--grey); font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.hbar.top .hbar-rank { background: rgba(224,38,63,.18); color: var(--text); }
.hbar-text { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; grid-column: -2; }
.hbar-label { font-size: 13.5px; font-weight: 600; }
.hbar-num { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hbar-pct { font-size: 12px; color: var(--grey-dim); font-weight: 500; margin-left: 8px; display: inline-block; min-width: 34px; text-align: right; }
.hbar-track { grid-column: -2; height: 8px; background: var(--panel-3); border-radius: 100px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: #6b6b78; border-radius: 100px; }
.hbar.top .hbar-fill { background: var(--red); }

/* split bar + legend */
.split { display: flex; gap: 2px; height: 30px; border-radius: 6px; overflow: hidden; margin-bottom: 18px; }
.split.thin { height: 12px; margin: 18px 0 12px; }
.seg { border: none; padding: 0; min-width: 6px; transition: filter .15s; }
.seg:hover { filter: brightness(1.2); }
.legend { display: flex; flex-direction: column; gap: 2px; }
.leg { display: grid; grid-template-columns: 12px 1fr auto 44px; align-items: center; gap: 10px; background: transparent; border: none; padding: 8px 10px; margin: 0 -10px; border-radius: 8px; text-align: left; font-size: 13.5px; }
.leg:hover:not(:disabled) { background: var(--panel-2); }
.leg:disabled { opacity: .45; }
.leg-dot { width: 12px; height: 12px; border-radius: 3px; }
.leg-num { font-weight: 700; font-variant-numeric: tabular-nums; }
.leg-pct { color: var(--grey-dim); font-size: 12px; text-align: right; }
.legend.inline { flex-direction: row; gap: 16px; }
.span-12 .legend { flex-direction: row; flex-wrap: wrap; gap: 4px 24px; }
.span-12 .leg { margin: 0; }
.legend.inline .leg { grid-template-columns: 12px auto auto; margin: 0; padding: 4px 6px; font-size: 12.5px; }

/* hero */
.hero { display: flex; align-items: center; gap: 16px; background: transparent; border: none; padding: 6px 0 0; text-align: left; border-radius: 8px; }
.hero-num { font-size: 56px; font-weight: 800; letter-spacing: -.03em; line-height: 1; color: var(--text); }
.hero-num small { font-size: 26px; color: var(--grey); margin-left: 2px; }
.hero-cap { font-size: 13px; color: var(--grey); line-height: 1.5; }
.hero-cap b { color: var(--text); }

/* compare table */
.an-select { padding: 6px 10px; border-radius: 7px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font-size: 12.5px; color-scheme: dark; }
.cmp-wrap { overflow-x: auto; }
.cmp { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.cmp th { text-align: right; padding: 0 0 10px 12px; font-weight: 600; }
.cmp th button { background: transparent; border: none; padding: 4px 8px; margin-right: -8px; border-radius: 6px; font-weight: 700; font-size: 13px; display: inline-flex; flex-direction: column; align-items: flex-end; }
.cmp th button span { font-size: 11px; color: var(--grey-dim); font-weight: 500; }
.cmp th button:hover { background: var(--panel-2); }
.cmp td { text-align: right; padding: 9px 0 9px 12px; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; color: var(--grey); }
.cmp td.cmp-label { text-align: left; padding-left: 0; color: var(--text); }
.cmp td.hi { color: var(--text); font-weight: 700; }
.weekly .col-label { font-size: 11px; }
.weekly .cols { gap: 6px; }

/* change history */
.history-box > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 14px; user-select: none; }
.history-box > summary::-webkit-details-marker { display: none; }
.history-box > summary > div:first-child { flex-shrink: 0; }
.history-box .hist-sum { margin-left: auto; text-align: right; font-size: 12.5px; }
.history-box .hist-chev { display: inline-flex; color: var(--grey); transform: rotate(-90deg); transition: transform .15s; }
.history-box .hist-chev svg { width: 16px; height: 16px; }
.history-box[open] .hist-chev { transform: rotate(90deg); }
.history-box > summary:hover h2, .history-box > summary:hover .hist-chev { color: var(--text); }
.history-box[open] > summary { padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.history { display: flex; flex-direction: column; gap: 12px; max-height: 420px; overflow-y: auto; padding-right: 6px; }
.hist-item { border-left: 2px solid var(--border-strong); padding: 2px 0 2px 14px; }
.hist-meta { display: flex; gap: 10px; align-items: baseline; font-size: 13px; margin-bottom: 4px; }
.hist-item ul { margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--grey); }
.hist-item li { padding: 2px 0; }
.hist-field { color: var(--text); font-weight: 600; margin-right: 6px; }
.hist-from { text-decoration: line-through; color: var(--grey-dim); }
.hist-to { color: var(--text); }

/* allocation pills */
.pill-alloc-pending { color: var(--grey); }
.pill-alloc-awarded { color: var(--green); }
.pill-alloc-waitlist { color: var(--amber); }
.pill-alloc-declined { color: var(--grey-dim); }

/* tiles */
.tiles-stack .tiles { grid-template-columns: 1fr; gap: 8px; }
.tiles-stack .tile { display: grid; grid-template-columns: 64px 1fr; grid-template-rows: auto auto auto; column-gap: 12px; row-gap: 2px; align-items: center; padding: 10px 12px; }
.tiles-stack .tile-num { grid-row: 1 / span 3; grid-column: 1; }
.tiles-stack .tile-label, .tiles-stack .tile-sub, .tiles-stack .tile-track { grid-column: 2; }
.tiles-stack .tile-track { margin-top: 4px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 3px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; text-align: left; transition: border-color .15s; }
.tile:hover:not(:disabled) { border-color: var(--border-strong); }
.tile:disabled { opacity: .55; }
.tile-num { font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.tile-num small { font-size: 13px; color: var(--grey); margin-left: 1px; }
.tile-label { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.tile-sub { font-size: 11.5px; color: var(--grey-dim); }
.tile-track { height: 4px; background: var(--panel-3); border-radius: 100px; overflow: hidden; margin-top: 6px; }
.tile-track span { display: block; height: 100%; background: var(--red); border-radius: 100px; }

.drawer-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40; }
.drawer-scrim.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 100%; background: var(--panel); border-left: 1px solid var(--border); transform: translateX(100%); transition: transform .22s; z-index: 41; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 20px; border-bottom: 1px solid var(--border); }
.drawer-list { overflow-y: auto; padding: 8px; }
.drawer-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--text); font-size: 13px; }
.drawer-item:hover { background: var(--panel-2); text-decoration: none; }
.chip.active svg, .chip svg { width: 12px; height: 12px; }
@media (max-width: 980px) { .an-kpis { grid-template-columns: repeat(3, 1fr); } .an-grid { grid-template-columns: 1fr; } .an-grid > * { grid-column: auto !important; } }
@media (max-width: 720px) { .an-kpis { grid-template-columns: repeat(2, 1fr); } }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .editor-layout.with-notes { grid-template-columns: 200px minmax(0, 1fr); }
  .with-notes .notes-panel { grid-column: 2; grid-row: 1; position: static; height: 240px; min-height: 0; }
  .with-notes #ed-form { grid-column: 2; grid-row: 2; }
}
@media (max-width: 980px) {
  .editor-layout, .outputs-grid, .editor-layout.with-notes { grid-template-columns: 1fr; }
  .with-notes .notes-panel, .with-notes #ed-form { grid-column: 1; }
  .section-nav { display: none; }
  .out-card.sticky { position: static; }
  .kpi-strip { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 720px) {
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .nav { gap: 14px; order: 3; width: 100%; }
  .user-name { display: none; }
  .main-content { padding: 16px 16px 48px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .account-grid { grid-template-columns: 1fr; }
  .editor-bar { position: static; margin: 8px 0 16px; }
}


/* ---------- update 4: new form pieces ---------- */
.btn-sm { padding: 7px 11px; font-size: 12px; }
.ed-id { font-size: 12px; font-weight: 600; color: var(--grey-dim); margin-left: 10px; letter-spacing: .03em; }
.field-foot { font-size: 11.5px; color: var(--grey-dim); margin-top: 5px; text-align: right; }
.field-foot.over { color: var(--amber); }
.rows-ed { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.rows-ed:empty { display: none; }
.row-ed { display: grid; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel-2); }
.row-ed input, .row-ed select { width: 100%; min-width: 0; padding: 8px 10px; border-radius: 7px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 13.5px; font-family: inherit; color-scheme: dark; }
.row-ed input:focus, .row-ed select:focus { outline: none; border-color: var(--red); }
.tag-ed { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 44px; padding: 6px 8px; border-radius: 7px; border: 1px solid var(--border); background: var(--panel-2); cursor: text; }
.tag-ed:focus-within { border-color: var(--red); }
.tag-list { display: contents; }
.tag-in { flex: 1; min-width: 160px; border: none; background: transparent; color: var(--text); font-size: 14px; padding: 4px; font-family: inherit; }
.tag-in:focus { outline: none; }
.tag-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 10px; border-radius: 100px; background: var(--panel-3); border: 1px solid var(--border-strong); font-size: 12.5px; font-weight: 600; }
.tag-chip.pri { border-color: var(--red); background: rgba(224,38,63,.16); }
.tag-chip button { border: none; background: transparent; color: var(--grey-dim); padding: 0 3px; display: inline-flex; font-size: 11px; }
.tag-chip button:hover { color: var(--text); }
.tag-chip .tag-star { order: -1; padding-left: 0; }
.tag-chip.pri .tag-star { color: var(--red); }
.split-ed { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 10px; align-items: end; }
.split-in { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--grey); font-weight: 600; }
.pct-wrap { position: relative; }
.pct-wrap input { width: 100%; padding: 10px 26px 10px 12px; border-radius: 7px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font-size: 14px; color-scheme: dark; }
.pct-wrap input:focus { outline: none; border-color: var(--red); }
.pct-wrap i { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--grey-dim); font-size: 13px; }
.split-total { grid-column: 1 / -1; font-size: 12px; color: var(--grey-dim); display: flex; align-items: center; gap: 6px; }
.split-total.ok { color: var(--green); } .split-total.off { color: var(--amber); }
.split-total svg { width: 13px; height: 13px; }
.style-ed { padding: 12px 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--panel-2); }
.style-ends { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--grey); }
.style-ed input[type=range] { width: 100%; margin: 10px 0 6px; accent-color: var(--red); }
.style-ed.unset input[type=range] { opacity: .35; }
.style-foot { display: flex; justify-content: space-between; align-items: center; font-size: 13px; min-height: 30px; }
.style-ed.unset .style-foot b { color: var(--grey-dim); font-weight: 500; }
.an-stack { display: flex; flex-direction: column; gap: 16px; }
.pill-alloc-approve { color: var(--green); } .pill-alloc-waitlist { color: var(--amber); } .pill-alloc-decline { color: var(--red); } .pill-alloc-pending { color: var(--grey); }

/* PDF preview on the Outputs page */
.outputs-grid { grid-template-columns: 360px minmax(0, 1fr); }
.pdf-wrap { position: relative; overflow: hidden; border-radius: 8px; background: #6b6b70; }
.pdf-wrap iframe { border: 0; display: block; transform-origin: 0 0; background: #6b6b70; }
.pdf-drop { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: rgba(10,10,11,.82); border: 2px dashed var(--red); border-radius: 8px; color: var(--text); font-size: 16px; font-weight: 700; z-index: 2; }
.pdf-drop svg { width: 34px; height: 34px; color: var(--red); }
.pdf-drop.show { display: flex; }
@media (max-width: 760px) { .split-ed { grid-template-columns: 1fr 1fr; } .row-ed { grid-template-columns: 1fr 1fr !important; } .row-ed [data-rc="model"], .row-ed [data-rc="handle"], .row-ed [data-rc="note"] { grid-column: 1 / -1; } .row-ed [data-rm-row] { justify-self: end; } .garage-row { grid-template-columns: 1fr 32px; } .garage-row .g-num { display: none; } .garage-row .g-col { grid-column: 1; } .garage-row [data-rm] { grid-column: 2; grid-row: 1; margin-top: 18px; } }

/* ---------- print (Analytics report) ---------- */
.print-only { display: none; }
@media print {
  @page { size: letter portrait; margin: 0.5in; }
  :root { --panel: #fff; --panel-2: #f4f4f6; --panel-3: #ececf0; --border: #dcdce2; --text: #111114; --grey: #4a4a52; --grey-dim: #7a7a82; }
  html, body { background: #fff !important; color: #111114; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .topbar, .no-print, .drawer, .drawer-scrim, .toast { display: none !important; }
  .print-only { display: block; }
  .print-meta { margin: 4px 0 0; font-size: 11px; color: #4a4a52; }
  .main-content { padding: 0; max-width: none; }
  .page-header { margin-bottom: 12px; }
  .kpi, .an-card { box-shadow: none; }
  .kpi { padding: 8px 10px; }
  .an-kpis .kpi-num { font-size: 18px; }
  .an-section-title { margin: 14px 0 6px; color: #4a4a52; }
  .an-grid { gap: 10px; grid-template-columns: repeat(12, minmax(0, 1fr)) !important; }
  .an-kpis { grid-template-columns: repeat(5, 1fr) !important; gap: 6px; }
  .an-grid > .span-12 { grid-column: span 12 !important; } .an-grid > .span-6 { grid-column: span 6 !important; } .an-grid > .span-8 { grid-column: span 8 !important; } .an-grid > .span-3 { grid-column: span 3 !important; } .an-grid > .span-4 { grid-column: span 4 !important; }
  .an-grid > .span-5 { grid-column: span 5 !important; } .an-grid > .span-7 { grid-column: span 7 !important; }
  .hero { flex-direction: column; align-items: flex-start; gap: 4px; }
  .tiles { gap: 6px; } .tile-num { font-size: 18px; }
  .an-section-title { break-after: avoid; page-break-after: avoid; }
  .legend.inline { flex-direction: column; gap: 0; }
  .an-card { padding: 12px 14px; break-inside: avoid; page-break-inside: avoid; }
  .an-head { margin-bottom: 8px; }
  .an-head h2 { font-size: 13px; }
  .cols { height: 130px; }
  .hbar, .leg { padding: 3px 10px; }
  .hero-num { font-size: 40px; }
  .hbar-fill { background: #9a9aa6; }
  .tile { padding: 8px; }
}

/* ---------- tool switch (top left, shared with the other tool) ---------- */
.tool-switch { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 12px; border: 1px solid var(--border); border-radius: 100px; background: var(--panel-2); flex-shrink: 0; }
.tool-switch .brand-dot { margin-right: 6px; }
.ts-opt { padding: 6px 14px; border-radius: 100px; font-size: 12.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--grey); white-space: nowrap; transition: background .15s, color .15s; }
.ts-opt:hover { color: var(--text); text-decoration: none; background: var(--panel-3); }
.ts-opt.on { background: var(--red); color: #fff; box-shadow: 0 0 14px var(--red-glow); }
.ts-opt.on:hover { background: var(--red); }

/* ---------- top navigation: single line pill tabs (shared look across both tools) ---------- */
.topbar { gap: 20px; }
.nav { display: flex; align-items: center; gap: 2px; padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.015); flex-wrap: nowrap; min-width: 0; }
.nav a { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; border-bottom: none !important; color: var(--grey); font-size: 13.5px; font-weight: 600; white-space: nowrap; line-height: 1.2; transition: background .15s, color .15s; }
.nav a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--panel-3); }
.nav a.active::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 2px; height: 2px; border-radius: 2px; background: var(--red); }
.user-area { flex-shrink: 0; }
@media (max-width: 1440px) { .ts-long { display: none; } .search-kbd { display: none; } }
@media (max-width: 1240px) { .user-name { display: none; } .nav a { padding: 7px 10px; } .nav a.active::after { left: 10px; right: 10px; } .topbar { padding-left: 18px; padding-right: 18px; gap: 12px; } }
@media (max-width: 980px) { .nav { overflow-x: auto; scrollbar-width: none; } .nav::-webkit-scrollbar { display: none; } }

/* ---------- phones (iPhone Safari) ---------- */
@media (max-width: 720px) {
  /* 16px fields stop Safari from zooming in when you tap one */
  input, select, textarea { font-size: 16px !important; }
  .topbar { flex-wrap: wrap; row-gap: 10px; column-gap: 8px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
  .tool-switch { order: 1; }
  .user-area { order: 2; margin-left: auto; gap: 6px; }
  .nav { order: 3; width: 100%; }
  .nav a { padding: 7px 11px; font-size: 13px; }
  .user-name, .admin-tag, .search-kbd { display: none !important; }
  #logout-btn { font-size: 0; padding: 8px 9px; gap: 0; }
  #logout-btn::after { content: ""; width: 17px; height: 17px; background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpath d='m16 17 5-5-5-5'/%3E%3Cpath d='M21 12H9'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpath d='m16 17 5-5-5-5'/%3E%3Cpath d='M21 12H9'/%3E%3C/svg%3E") center / contain no-repeat; }
  .ts-opt { padding: 6px 12px; }
  .main-content { padding-bottom: calc(48px + env(safe-area-inset-bottom)); }
  #save-btn .muted { display: none; }
}
