/* TSG Hub — dark by default like Site Ledger, light theme available. */
:root {
  --bg: #161718;
  --panel: #1e1f21;
  --panel-2: #252629;
  --raise: #2c2d31;
  --line: #333438;
  --line-2: #414247;
  --ink: #f2f0eb;
  --ink-2: #c4c2bc;
  --muted: #8d8c88;
  --blue: #5b7cf0;
  --blue-ink: #8ea4ff;
  --blue-wash: rgba(91, 124, 240, .14);
  --good: #4cc38a;
  --good-wash: rgba(76, 195, 138, .13);
  --warn: #e7b04b;
  --warn-wash: rgba(231, 176, 75, .13);
  --bad: #ef6b5a;
  --bad-wash: rgba(239, 107, 90, .13);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --radius: 10px;
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f7f5f0;
  --panel: #ffffff;
  --panel-2: #f3f1ec;
  --raise: #ebe8e1;
  --line: #e3e0d8;
  --line-2: #d2cec4;
  --ink: #17181a;
  --ink-2: #45464b;
  --muted: #7b7c80;
  --blue: #3457d5;
  --blue-ink: #2947bd;
  --blue-wash: rgba(52, 87, 213, .09);
  --good: #1f8a57;
  --good-wash: rgba(31, 138, 87, .1);
  --warn: #a36a00;
  --warn-wash: rgba(163, 106, 0, .1);
  --bad: #c2412f;
  --bad-wash: rgba(194, 65, 47, .09);
  --shadow: 0 10px 40px -14px rgba(23, 24, 26, .25);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* ── Shell ─────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow-y: auto; }
.brand { padding: 20px 18px 16px; border-bottom: 1px solid var(--line); }
.brand .mark { font-weight: 700; font-size: 22px; letter-spacing: -.02em; line-height: 1; }
.brand .mark i { display: inline-block; width: .22em; height: .22em; background: var(--blue); border-radius: 2px; margin-left: .06em; }
.brand .sub { color: var(--muted); font-size: 12px; margin-top: 6px; }
.nav { padding: 10px 8px 20px; flex: 1; }
.nav h6 { margin: 16px 10px 6px; font-size: 11px; font-weight: 500; color: var(--muted); text-transform: none; letter-spacing: .02em; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--panel-2); text-decoration: none; color: var(--ink); }
.nav a.on { background: var(--raise); color: var(--ink); }
.nav a .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line-2); flex: none; }
.nav a.on .dot { background: var(--blue); }
.nav a .badge-slot { margin-left: auto; }
.me { border-top: 1px solid var(--line); padding: 12px; display: flex; gap: 10px; align-items: center; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--blue-wash); color: var(--blue-ink); display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }
.me .who { min-width: 0; flex: 1; }
.me .who b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .who span { font-size: 11px; color: var(--muted); }

.main { overflow-y: auto; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding: 14px 28px; display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
#page-actions { flex-wrap: wrap; row-gap: 8px; }
.topbar h1 { font-size: 18px; margin: 0; letter-spacing: -.01em; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.content { padding: 24px 28px 60px; max-width: 1400px; }
.menu-btn { display: none; }

/* ── Cards & bits ──────────────────────────────────── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.card h3 .muted { font-weight: 400; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.section-title { font-size: 15px; font-weight: 600; margin: 28px 0 12px; display: flex; align-items: center; gap: 10px; }

.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font: 600 28px/1.15 var(--mono); letter-spacing: -.02em; margin-top: 6px; }
.kpi .foot { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi .value.good { color: var(--good); }

.bar { height: 6px; border-radius: 99px; background: var(--raise); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--blue); border-radius: 99px; }
.bar.good > i { background: var(--good); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--raise); color: var(--ink-2); white-space: nowrap; }
.badge.blue { background: var(--blue-wash); color: var(--blue-ink); }
.badge.good { background: var(--good-wash); color: var(--good); }
.badge.warn { background: var(--warn-wash); color: var(--warn); }
.badge.bad { background: var(--bad-wash); color: var(--bad); }
.pill-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--blue); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink); padding: 7px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; color: var(--blue-ink); cursor: pointer; font-weight: 500; }

.input, select.input, textarea.input { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; color: var(--ink); min-width: 0; }
input.input[type="number"]::-webkit-inner-spin-button, input.input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input.input[type="number"] { -moz-appearance: textfield; }
.pf-next { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; border-color: var(--blue); background: var(--blue-wash); }
.pf-next .f { flex: 1; min-width: 200px; }
select.input { padding-right: 26px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%; background-size: 4px 4px; background-repeat: no-repeat; }
textarea.input { resize: vertical; min-height: 80px; line-height: 1.5; }
.input:focus { outline: none; border-color: var(--blue); }
label.f { display: block; }
label.f > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .input { width: auto; }
.toolbar .search { flex: 1 1 220px; max-width: 320px; }
.filter-chip { display: inline-flex; gap: 6px; align-items: center; padding: 5px 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 12.5px; color: var(--ink-2); }
.filter-chip.on { border-color: var(--blue); background: var(--blue-wash); color: var(--ink); }
.filter-chip b { font-family: var(--mono); }

/* ── Tables ────────────────────────────────────────── */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); position: sticky; top: 0; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover td { background: var(--panel-2); }
table.t td .title { font-weight: 600; }
table.t td .sub { color: var(--muted); font-size: 12px; }
table.t select.inline { background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 3px 6px; cursor: pointer; max-width: 170px; }
table.t select.inline:hover { border-color: var(--line-2); background: var(--panel-2); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 6px; }

/* ── Board ─────────────────────────────────────────── */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: 250px; gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 230px); }
.col header { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: baseline; font-weight: 600; font-size: 13px; }
.col header .num { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 400; }
.col .cards { padding: 8px; overflow-y: auto; flex: 1; min-height: 60px; }
.col.drop { border-color: var(--blue); }
.pcard { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; cursor: grab; }
.pcard:hover { border-color: var(--line-2); }
.pcard .ref { font: 11px var(--mono); color: var(--muted); }
.pcard .nm { font-weight: 600; margin: 2px 0 6px; line-height: 1.3; }
.pcard .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

/* ── Drawer & modal ────────────────────────────────── */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 100vw; background: var(--bg); z-index: 41; overflow-y: auto; box-shadow: var(--shadow); }
.drawer-head { position: sticky; top: 0; background: var(--bg); border-bottom: 1px solid var(--line); padding: 16px max(22px, calc((100% - 1100px) / 2)); display: flex; gap: 12px; align-items: flex-start; z-index: 2; }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-body { padding: 18px max(22px, calc((100% - 1100px) / 2)) 40px; }
.modal { position: fixed; z-index: 42; left: 50%; top: 8vh; transform: translateX(-50%); width: min(640px, calc(100vw - 32px)); max-height: 84vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); }
.modal.wide { width: min(920px, calc(100vw - 32px)); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal header h2 { margin: 0; font-size: 16px; }
.modal .mbody { padding: 18px 20px; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.x { background: none; border: 0; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; margin-left: auto; padding: 4px; }

.stepper { display: flex; gap: 3px; margin: 4px 0 18px; }
.stepper button { flex: 1; height: 30px; border: 0; background: var(--raise); color: var(--muted); font-size: 10.5px; font-weight: 600; cursor: pointer; padding: 0 2px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.stepper button:first-child { border-radius: 6px 0 0 6px; }
.stepper button:last-child { border-radius: 0 6px 6px 0; }
.stepper button.done { background: var(--blue-wash); color: var(--blue-ink); }
.stepper button.cur { background: var(--blue); color: #fff; }

.notes { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.note { display: flex; gap: 10px; }
.note .bubble { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; flex: 1; white-space: pre-wrap; }
.note .bubble .by { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.list-item { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.attention-item { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.attention-item:last-child { border-bottom: 0; }

/* ── Calls (week calendar) ──────────────────────────── */
.wk { min-width: 760px; }
.wk-head { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.wk-head > div { padding: 10px 8px; font-size: 12px; color: var(--muted); }
.wk-head > div b { color: var(--ink); font-size: 14px; margin-left: 2px; }
.wk-head > div.today b { color: var(--blue-ink); }
.wk-body { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); position: relative; }
.wk-hours > div { font-size: 11px; color: var(--muted); text-align: right; padding: 0 8px; transform: translateY(-7px); }
.wk-hours > div:first-child { transform: none; }
.wk-col { position: relative; border-left: 1px solid var(--line); background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 63px, var(--line) 63px, var(--line) 64px); }
.wk-col.closed { background-color: var(--panel-2); }
.wk-open { position: absolute; left: 0; right: 0; background: var(--blue-wash); opacity: .45; pointer-events: none; }
.wk-now { position: absolute; left: 0; right: 0; border-top: 2px solid var(--bad); z-index: 2; pointer-events: none; }
.wk-ev { position: absolute; left: 3px; right: 3px; z-index: 1; overflow: hidden; text-align: left; border-radius: 6px; padding: 3px 7px; font-size: 11.5px; line-height: 1.3; cursor: pointer; border: 1px solid transparent; display: flex; flex-direction: column; }
.wk-ev b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-ev span { opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-ev.call { background: var(--blue); color: #fff; }
.wk-ev.block { background: repeating-linear-gradient(135deg, var(--raise) 0 6px, var(--panel-2) 6px 12px); color: var(--ink-2); border-color: var(--line-2); }
.wk-ev:hover { filter: brightness(1.08); }
.wk-ev.short { flex-direction: row; align-items: center; gap: 5px; padding: 0 7px; }
.wk-ev.short span { flex: 1; min-width: 0; }

/* ── Messages ──────────────────────────────────────── */
.inbox { display: grid; grid-template-columns: 320px 1fr 280px; height: calc(100vh - 67px); }
.inbox .threads { border-right: 1px solid var(--line); overflow-y: auto; background: var(--panel); }
.inbox .threads .tools { padding: 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.titem { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.titem:hover { background: var(--panel-2); }
.titem.on { background: var(--raise); }
.titem .top { display: flex; gap: 6px; align-items: baseline; }
.titem .nm { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titem.unread .nm::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); margin-right: 6px; vertical-align: 1px; }
.titem .snip { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.convo { display: flex; flex-direction: column; min-width: 0; }
.convo .msgs { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 72%; }
.msg .b { padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.in { align-self: flex-start; }
.msg.in .b { background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; }
.msg.out .b { background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.msg.internal { align-self: center; max-width: 86%; }
.msg.internal .b { background: var(--warn-wash); border: 1px dashed var(--warn); color: var(--ink); border-radius: 10px; }
.msg .m { font-size: 11px; color: var(--muted); margin-top: 3px; display: flex; gap: 6px; }
.msg.out .m { justify-content: flex-end; }
.msg .subj { font-weight: 600; font-size: 12px; opacity: .85; margin-bottom: 4px; }
.composer { border-top: 1px solid var(--line); padding: 12px 16px; background: var(--panel); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 5px 11px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--raise); color: var(--ink); }
.inbox .side-info { border-left: 1px solid var(--line); padding: 16px; overflow-y: auto; background: var(--panel); }

/* ── Estimator ─────────────────────────────────────── */
.est { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.est .result { position: sticky; top: 84px; }
.est table.t { min-width: 900px; }
.est table.t td { padding: 5px 6px; }
.est table.t input, .est table.t select { width: 100%; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 5px 6px; }
.est table.t input:hover, .est table.t select:hover { border-color: var(--line); }
.est table.t input:focus { border-color: var(--blue); outline: none; background: var(--panel-2); }
.versus { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.versus .box { background: var(--panel-2); border-radius: 8px; padding: 12px; }
.versus .box .v { font: 600 20px var(--mono); margin-top: 4px; }
.versus .box.tsg { background: var(--blue-wash); }
.saving { margin: 14px 0; padding: 14px; border-radius: 10px; background: var(--good-wash); }
.saving .v { font: 700 26px var(--mono); color: var(--good); }
.saving.neg { background: var(--bad-wash); }
.saving.neg .v { color: var(--bad); }
.kv { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv b { font-family: var(--mono); font-weight: 500; }

/* ── Ask ───────────────────────────────────────────── */
.ask { display: grid; grid-template-columns: 240px 1fr; height: calc(100vh - 67px); }
.ask .chats { border-right: 1px solid var(--line); overflow-y: auto; padding: 12px; background: var(--panel); }
.ask .chats a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.ask .chats a.on, .ask .chats a:hover { background: var(--raise); color: var(--ink); text-decoration: none; }
.ask .turns { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; max-width: 860px; width: 100%; margin: 0 auto; }
.turn.user { align-self: flex-end; background: var(--raise); padding: 10px 14px; border-radius: 14px; max-width: 80%; white-space: pre-wrap; }
.turn.assistant { line-height: 1.6; }
.turn.assistant p { margin: 0 0 10px; }
.turn.assistant ul, .turn.assistant ol { margin: 0 0 10px; padding-left: 20px; }
.turn.assistant table { border-collapse: collapse; margin: 6px 0 12px; font-size: 13px; }
.turn.assistant th, .turn.assistant td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; }
.turn.assistant code { font-family: var(--mono); background: var(--raise); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.turn.assistant h1, .turn.assistant h2, .turn.assistant h3, .turn.assistant h4 { font-size: 14px; margin: 14px 0 6px; }
.ask-input { border-top: 1px solid var(--line); padding: 14px 24px; }
.ask-input .inner { max-width: 860px; margin: 0 auto; display: flex; gap: 10px; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.thinking { color: var(--muted); font-style: italic; }

/* ── Sign-in ───────────────────────────────────────── */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.gate .card { width: min(400px, 100%); padding: 28px; }
.gate h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.02em; }
.gate h1 i { display: inline-block; width: .22em; height: .22em; background: var(--blue); border-radius: 2px; margin-left: .06em; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 500; z-index: 60; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.toast.err { background: var(--bad); color: #fff; }
.job { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); margin-bottom: 8px; font-size: 13px; }
.preview-mail { background: #fff; color: #17181a; border-radius: 8px; padding: 18px; border: 1px solid var(--line); max-height: 420px; overflow-y: auto; }

@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: 1fr 1fr; }
  .inbox { grid-template-columns: 280px 1fr; }
  .inbox .side-info { display: none; }
  .est { grid-template-columns: 1fr; }
  .est .result { position: static; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 60px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 1fr; }
  .inbox.has-thread .threads { display: none; }
  .inbox:not(.has-thread) .convo { display: none; }
  .ask { grid-template-columns: 1fr; }
  .ask .chats { display: none; }
  .msg { max-width: 90%; }
}
@media print {
  .side, .topbar, .no-print, .btn { display: none !important; }
  .shell { display: block; height: auto; }
  .main { overflow: visible; }
  body { background: #fff; color: #000; }
  .est { grid-template-columns: 1fr; }
  .card, .table-wrap { border-color: #ccc; background: #fff; }
  /* A printed modal (the spec sheet) shouldn't clip at its screen height. */
  .scrim { display: none !important; }
  .modal { position: static; transform: none; max-height: none; overflow: visible; width: auto; box-shadow: none; border: 0; }
  .modal header { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ── Product catalogue (Products page + supplier drawer) ───────────── */
.cat-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
.cat-side { padding: 8px; position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; }
.cat-nav { display: flex; width: 100%; justify-content: space-between; gap: 8px; text-align: left; background: none; border: 0; border-radius: 7px; padding: 7px 10px; color: var(--ink-2); font-weight: 500; cursor: pointer; }
.cat-nav span { font: 11px var(--mono); color: var(--muted); }
.cat-nav:hover { background: var(--panel-2); color: var(--ink); }
.cat-nav.on { background: var(--blue-wash); color: var(--ink); }
.cat-nav.sub { padding-left: 22px; font-size: 13px; font-weight: 400; }
.cat-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.cat-head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.cat-head p { margin: 4px 0 0; }
.cat-sups { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cat-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 20px; }
.cat-tile { position: relative; height: 130px; border: 0; border-radius: var(--radius); background: var(--raise) center/cover; overflow: hidden; cursor: pointer; text-align: left; padding: 12px 14px; display: flex; flex-direction: column; justify-content: flex-end; color: #fff; }
.cat-tile::before { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 30%, rgba(0, 0, 0, .65)); }
.cat-tile b, .cat-tile span { position: relative; }
.cat-tile b { font-size: 15px; }
.cat-tile span { font: 11px var(--mono); opacity: .85; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.cat-card { display: flex; flex-direction: column; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; overflow: hidden; cursor: pointer; color: inherit; }
.cat-card:hover { border-color: var(--blue); }
.cat-img { aspect-ratio: 1; background: #fff; display: grid; place-items: center; overflow: hidden; }
.cat-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.cat-meta { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cat-code { font-size: 10.5px; color: var(--muted); }
.cat-name { font-weight: 600; font-size: 13px; line-height: 1.3; }
.cat-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-more { display: flex; justify-content: center; padding: 16px 0; }
.cat-detail { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; }
.cat-hero { background: #fff; border-radius: var(--radius); display: grid; place-items: center; aspect-ratio: 1; overflow: hidden; }
.cat-hero img { max-width: 100%; max-height: 100%; object-fit: contain; }
.cat-thumbs { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.cat-thumbs button { width: 56px; height: 56px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: #fff; overflow: hidden; cursor: pointer; }
.cat-thumbs button.on { border-color: var(--blue); }
.cat-thumbs img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 900px) {
  .cat-layout { grid-template-columns: 1fr; }
  .cat-side { position: static; max-height: 260px; }
  .cat-detail { grid-template-columns: 1fr; }
}

/* Leads (pipeline) */
.lead-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.lead-kpis .card { padding: 14px 16px; }
.lead-kpis .value { font-size: 24px; }
.kpi .value.warnv { color: var(--warn); }
.lead-tabs { gap: 6px; margin-bottom: 12px; }
.lead-list { padding: 0; overflow: hidden; }
.lead-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.lead-row:last-child { border-bottom: 0; }
.lead-row:hover { background: var(--panel-2); }
.lr-name { line-height: 1.3; }
.lr-tags, .lr-acts { display: flex; gap: 6px; align-items: center; }
.heat { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font: 500 11.5px var(--mono); white-space: nowrap; }
.heat.hot { background: var(--bad-wash); color: var(--bad); }
.heat.warm { background: var(--warn-wash); color: var(--warn); }
.heat.cool { background: var(--blue-wash); color: var(--blue-ink); }
.overdue { color: var(--bad); font-weight: 600; }
.lead-board { grid-auto-columns: 240px; }
.lead-board .col[data-stage="won"] header { color: var(--good); }
.lead-board .col[data-stage="lost"] header, .lead-board .col[data-stage="nurture"] header { color: var(--muted); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
.lead-actions { gap: 6px; }
.callout { border-color: var(--blue); background: var(--blue-wash); }
.next-card.missing { border-color: var(--warn); }
.next-card.late { border-color: var(--bad); }
select.input.inline-stage { width: auto; max-width: 220px; padding: 3px 8px; font-weight: 600; }
.kv .input.inline { padding: 3px 6px; font: inherit; }
.timeline { margin-top: 14px; display: flex; flex-direction: column; }
.tl { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.tl-ic { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); color: var(--muted); font-size: 12px; }
.tl.msg_in .tl-ic, .tl.gmail_in .tl-ic, .tl.enquiry .tl-ic { background: var(--blue-wash); color: var(--blue-ink); }
.tl.booked .tl-ic, .tl.call .tl-ic { background: var(--good-wash); color: var(--good); }
.tl.stage .tl-ic { background: var(--warn-wash); color: var(--warn); }
.tl-body { white-space: pre-wrap; font-size: 13px; color: var(--ink-2); margin: 3px 0; max-height: 220px; overflow: auto; }
.tpl summary { cursor: pointer; }
@media (max-width: 1100px) { .lead-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .lead-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lead-row { grid-template-columns: 34px minmax(0, 1fr); }
  .lr-tags, .lr-acts { grid-column: 2; flex-wrap: wrap; }
}

.ai-row { display: flex; gap: 8px; align-items: center; margin-top: -4px; }
.ai-row .input { flex: 1; font-size: 13px; padding: 6px 10px; }
.compose-notes { display: flex; flex-direction: column; gap: 4px; }
textarea.ai-busy { opacity: .55; background-image: linear-gradient(90deg, transparent, var(--blue-wash), transparent); background-size: 200% 100%; animation: ai-shimmer 1.4s linear infinite; }
@keyframes ai-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { textarea.ai-busy { animation: none; } }

.auto-first { border: 1px solid var(--blue); background: var(--blue-wash); border-radius: 10px; padding: 12px 14px; margin: 12px 0 14px; }
.sig-preview { margin-top: 8px; background: #fff; border-radius: 8px; padding: 10px 14px; overflow-x: auto; color: #17181a; }

/* Leads bulk edit bar */
.bulkbar { position: sticky; top: 8px; z-index: 6; margin: 0 0 12px; padding: 12px 16px; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.bulkbar .f { margin: 0; }
.lead-row .sel, .pcard .sel, td .sel { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent, #3457D5); }
