/* Brand per area: Business Solutions (CBS purple + crimson) and Marketing Solutions (CMS orange + navy). */
:root[data-brand="cms"] { --bridge: #b44a18; --bridge-wash: #fbeee6; --brand-2: #283078; --word: url('brand/cms-word-light.png'); --cube: url('brand/cms-cube.png'); }
@media (prefers-color-scheme: dark) { :root[data-brand="cms"]:not([data-theme="light"]) { --bridge: #f2955f; --bridge-ink: #2a1408; --bridge-wash: #3a2418; --brand-2: #8d97e8; --word: url('brand/cms-word-dark.png'); } }
:root[data-brand="cms"][data-theme="dark"] { --bridge: #f2955f; --bridge-ink: #2a1408; --bridge-wash: #3a2418; --brand-2: #8d97e8; --word: url('brand/cms-word-dark.png'); }

/* Cornerstone AI portal.
   Identity: an operations ledger for a Teesside MSP. Light steel paper, Transporter-bridge blue,
   one typeface (Schibsted Grotesk) with tabular figures. The recurring visual idea is honesty
   about evidence: FACT = filled square, INFERENCE = open circle, UNKNOWN = hatched. */

:root {
  --paper: #f2f3f1;
  --sheet: #ffffff;
  --ink: #1b2422;
  --ink-2: #4c5856;
  --ink-3: #7b8684;
  --rule: #d9dddb;
  --rule-2: #e8ebe9;
  --bridge: #4a3c96;
  --bridge-ink: #ffffff;
  --bridge-wash: #ebe8f6;
  --high: #b3261e; --high-wash: #fbe9e7;
  --med: #a35f00; --med-wash: #fbf0dc;
  --low: #2c7a4b; --low-wash: #e3f2e8;
  --hatch: repeating-linear-gradient(135deg, var(--rule) 0 2px, transparent 2px 6px);
  --radius: 6px;
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Barlow Semi Condensed', 'Barlow', system-ui, sans-serif;
  --brand-2: #d8104c;
  --word: url('brand/cbs-word-light.png');
  --cube: url('brand/cbs-cube.png');
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141a19; --sheet: #1b2321; --ink: #e8eceb; --ink-2: #b4bfbc; --ink-3: #85918e;
    --rule: #2f3a38; --rule-2: #252e2c; --bridge: #b3a8e6; --bridge-ink: #17132b; --bridge-wash: #262142; --brand-2: #ff5a86; --word: url('brand/cbs-word-dark.png');
    --high: #f08a80; --high-wash: #3a1f1c; --med: #e7b058; --med-wash: #382c17; --low: #79c896; --low-wash: #1a3324;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #141a19; --sheet: #1b2321; --ink: #e8eceb; --ink-2: #b4bfbc; --ink-3: #85918e;
  --rule: #2f3a38; --rule-2: #252e2c; --bridge: #b3a8e6; --bridge-ink: #17132b; --bridge-wash: #262142; --brand-2: #ff5a86; --word: url('brand/cbs-word-dark.png');
  --high: #f08a80; --high-wash: #3a1f1c; --med: #e7b058; --med-wash: #382c17; --low: #79c896; --low-wash: #1a3324;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
a { color: var(--bridge); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--bridge); outline-offset: 2px; }

/* ---------- Frame ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.nav { background: var(--sheet); border-right: 1px solid var(--rule); padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.nav a.brand { display: grid; border-radius: 0; font-size: inherit; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; padding: 0 6px 16px; color: inherit; }
.nav a.brand:hover { text-decoration: none; background: none; }
.brand-cube { width: 44px; height: 33px; background: var(--cube) center / contain no-repeat; }
.brand-word { display: block; height: 38px; background: var(--word) left center / contain no-repeat; }
.brand-ai { grid-column: 2; font-size: 12px; font-weight: 600; color: var(--brand-2); margin-top: -4px; }
.nav h4 .mark { display: inline-block; width: 16px; height: 12px; margin-right: 6px; vertical-align: -1px; background: center / contain no-repeat; }
.nav h4 .mark.cbs { background-image: url('brand/cbs-cube.png'); }
.nav h4 .mark.cms { background-image: url('brand/cms-cube.png'); }
.nav h4 { font-size: 12px; font-weight: 600; color: var(--ink-3); margin: 18px 8px 6px; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 7px 8px; border-radius: var(--radius); color: var(--ink-2); font-size: 14px; }
.nav a:hover { background: var(--rule-2); text-decoration: none; color: var(--ink); }
.nav a.on { background: var(--bridge-wash); color: var(--bridge); font-weight: 600; }
.nav .count { font-size: 12px; background: var(--rule-2); color: var(--ink-2); border-radius: 10px; padding: 0 7px; }
.nav .demo { margin: 22px 8px 0; font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--rule); padding-top: 14px; }

.main { min-width: 0; }
.topbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 32px; border-bottom: 1px solid var(--rule); background: var(--paper); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; }
.ask { display: flex; flex: 1; max-width: 560px; }
.ask input { flex: 1; border: 1px solid var(--rule); background: var(--sheet); border-radius: var(--radius) 0 0 var(--radius); padding: 7px 12px; }
.ask button { border-radius: 0 var(--radius) var(--radius) 0; }
.who { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--ink-2); }
.who select { border: 1px solid var(--rule); background: var(--sheet); border-radius: var(--radius); padding: 5px 8px; }
.menu-btn { display: none; }
.page { padding: 28px 32px 64px; max-width: 1240px; }

/* ---------- Type ---------- */
h1 { font-family: var(--display); font-size: 32px; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 6px; font-weight: 700; }
h2 { font-family: var(--display); font-size: 19px; letter-spacing: -0.01em; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 15px; margin: 0 0 6px; font-weight: 650; }
.lede { font-size: 17px; color: var(--ink-2); max-width: 70ch; margin: 0 0 24px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Owner headline: the sentence is the hero */
.brief-head { font-family: var(--display); font-size: 36px; line-height: 1.2; letter-spacing: -0.025em; font-weight: 700; max-width: 26ch; margin: 4px 0 10px; }
.brief-head em { font-style: normal; color: var(--bridge); }
.tally { display: flex; flex-wrap: wrap; gap: 28px; margin: 18px 0 30px; padding: 14px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.tally div { font-size: 13px; color: var(--ink-2); }
.tally b { display: block; font-family: var(--display); font-size: 26px; color: var(--ink); letter-spacing: -0.02em; }

/* ---------- Surfaces ---------- */
.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-wide { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.panel > h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.panel > h2 small { font-size: 13px; font-weight: 400; color: var(--ink-3); }
.section { margin-top: 28px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; text-align: right; white-space: normal; overflow-wrap: anywhere; }
.stat b { display: block; font-size: 22px; letter-spacing: -0.02em; }
.stat span { font-size: 13px; color: var(--ink-3); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 16px; }
.delta-up { color: var(--high); } .delta-down { color: var(--low); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--rule); }
td { padding: 10px; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--rule-2); }
.scroll-x { overflow-x: auto; }

/* ---------- Status ---------- */
.pill { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; font-weight: 600; border-radius: 20px; padding: 2px 9px; white-space: nowrap; }
.pill.HIGH, .pill.ACTION, .pill.UNDER_BILLED, .pill.OVER { background: var(--high-wash); color: var(--high); }
.pill.MEDIUM, .pill.WATCH, .pill.LOW_CONFIDENCE, .pill.AT_RISK, .pill.PROPOSED, .pill.CANDIDATE { background: var(--med-wash); color: var(--med); }
.pill.LOW, .pill.MATCH, .pill.OK, .pill.APPROVED, .pill.DONE, .pill.CONFIRMED { background: var(--low-wash); color: var(--low); }
.pill.INFO, .pill.NO_MAPPING, .pill.REJECTED, .pill.UNMATCHED, .pill.OVER_BILLED, .pill.FAILED { background: var(--rule-2); color: var(--ink-2); }
.pill.FAILED { color: var(--high); }

/* Service matrix: the signature element */
.matrix { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; }
.svc { border-radius: 4px; padding: 10px 8px 8px; min-height: 64px; font-size: 12.5px; font-weight: 600; line-height: 1.25; border: 1px solid var(--rule); position: relative; cursor: default; }
.svc small { display: block; font-weight: 400; margin-top: 4px; font-size: 11.5px; }
.svc.ACTIVE { background: var(--bridge); color: var(--bridge-ink); border-color: var(--bridge); }
.svc.ACTIVE small { opacity: .85; }
.svc.NOT_DETECTED { background: var(--sheet); color: var(--ink-2); }
.svc.UNKNOWN { background: var(--hatch), var(--sheet); color: var(--ink-2); }
.svc .tip { display: none; position: absolute; z-index: 10; left: 0; top: 100%; margin-top: 6px; width: 260px; background: var(--ink); color: var(--paper); padding: 10px 12px; border-radius: var(--radius); font-weight: 400; font-size: 13px; }
.svc:hover .tip, .svc:focus .tip { display: block; }
.mini-matrix { display: inline-grid; grid-template-columns: repeat(9, 10px); gap: 2px; }
.mini-matrix i { width: 10px; height: 10px; border-radius: 2px; border: 1px solid var(--rule); }
.mini-matrix i.ACTIVE { background: var(--bridge); border-color: var(--bridge); }
.mini-matrix i.UNKNOWN { background: var(--hatch); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-3); margin-top: 10px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 2px; border: 1px solid var(--rule); vertical-align: -1px; margin-right: 5px; }
.legend i.a { background: var(--bridge); border-color: var(--bridge); } .legend i.u { background: var(--hatch); }

/* Evidence: FACT vs INFERENCE */
.evidence { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13.5px; }
.evidence li { position: relative; padding: 3px 0 3px 20px; color: var(--ink-2); }
.evidence li::before { content: ''; position: absolute; left: 2px; top: 9px; width: 8px; height: 8px; }
.evidence li.FACT::before { background: var(--ink-2); }
.evidence li.INFERENCE::before { border: 1.5px solid var(--bridge); border-radius: 50%; }
.evidence .src { color: var(--ink-3); font-size: 12px; margin-left: 6px; }
.key { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 14px; }
.key span { position: relative; padding-left: 14px; }
.key span::before { content: ''; position: absolute; left: 0; top: 6px; width: 8px; height: 8px; }
.key .f::before { background: var(--ink-2); } .key .i::before { border: 1.5px solid var(--bridge); border-radius: 50%; }

/* Insight + action items */
.item { border-top: 1px solid var(--rule-2); padding: 14px 0; }
.item:first-child { border-top: 0; padding-top: 4px; }
.item p { margin: 4px 0 0; color: var(--ink-2); font-size: 14px; max-width: 78ch; }
.item details summary { cursor: pointer; font-size: 13px; color: var(--bridge); margin-top: 6px; list-style: none; }
.item details summary::-webkit-details-marker { display: none; }
.item details summary::before { content: '+ '; }
.item details[open] summary::before { content: '− '; }
.would { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; }

/* Buttons */
.btn { border: 1px solid var(--rule); background: var(--sheet); border-radius: var(--radius); padding: 6px 12px; cursor: pointer; font-size: 13.5px; font-weight: 550; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--bridge); color: var(--bridge-ink); border-color: var(--bridge); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn:disabled { opacity: .5; cursor: default; }

/* Banner */
.banner { border-left: 3px solid var(--bridge); background: var(--bridge-wash); padding: 10px 14px; border-radius: 0 var(--radius) var(--radius) 0; font-size: 14px; color: var(--ink); margin-bottom: 20px; max-width: 90ch; }
.banner.warn { border-color: var(--med); background: var(--med-wash); }

/* Bars */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 70px; }
.bars span { flex: 1; background: var(--bridge); opacity: .85; border-radius: 2px 2px 0 0; min-height: 2px; }
.bars span.prev { background: var(--rule); opacity: 1; }
.bar-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.hbar { height: 6px; background: var(--rule-2); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.hbar i { display: block; height: 100%; background: var(--bridge); }

/* Answer */
.answer { white-space: pre-wrap; font-size: 14.5px; line-height: 1.6; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--rule); background: var(--sheet); border-radius: 20px; padding: 5px 12px; font-size: 13.5px; cursor: pointer; }
.chip:hover { border-color: var(--bridge); color: var(--bridge); }

/* Kanban */
.board { display: grid; grid-template-columns: repeat(6, minmax(170px, 1fr)); gap: 12px; overflow-x: auto; }
.col h3 { font-size: 13px; color: var(--ink-3); display: flex; justify-content: space-between; }
.card { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; font-size: 13.5px; }
.card b { display: block; font-size: 14px; }
.brand-tag { font-size: 11.5px; font-weight: 700; color: var(--ink-3); }

/* Forms */
textarea, .field input, .field select { width: 100%; border: 1px solid var(--rule); background: var(--paper); border-radius: var(--radius); padding: 8px 10px; }
textarea { min-height: 62px; resize: vertical; }
.field { display: block; margin-bottom: 10px; }
.field span { display: block; font-size: 13px; color: var(--ink-3); margin-bottom: 4px; }

.toast { position: fixed; right: 20px; bottom: 20px; max-width: 420px; background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: var(--radius); font-size: 14px; z-index: 50; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.empty { color: var(--ink-3); font-size: 14px; padding: 8px 0; }
.loading { color: var(--ink-3); padding: 40px 0; }
.back { font-size: 13.5px; display: inline-block; margin-bottom: 10px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 18px; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--bridge); border-color: var(--bridge); font-weight: 600; }

@media (max-width: 1020px) {
  .g2, .g3, .g-wide { grid-template-columns: minmax(0, 1fr); }
  .matrix { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .nav { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .nav.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .menu-btn { display: inline-block; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .ask { order: 3; flex-basis: 100%; max-width: none; }
  .page { padding: 20px 16px 48px; }
  h1 { font-size: 24px; } .brief-head { font-size: 26px; }
  .who label { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.row select { border: 1px solid var(--rule); border-radius: var(--radius); padding: 6px 8px; background: var(--paper); }

/* Service desk intake */
.desk { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.inbox { padding: 14px; }
.mail { display: grid; gap: 3px; width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: var(--radius); padding: 10px; cursor: pointer; border-top-color: var(--rule-2); }
.mail:hover { background: var(--rule-2); }
.mail.on { background: var(--bridge-wash); border-color: var(--bridge); }
.mail-sub { font-size: 13.5px; color: var(--ink-2); }
.mail-head { display: grid; gap: 2px; color: var(--ink-2); }
.mail-head .muted { display: inline-block; width: 72px; }
.mail-body { white-space: pre-wrap; border-left: 3px solid var(--rule); padding: 4px 0 4px 14px; color: var(--ink); max-width: 70ch; }
.booked { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; padding: 12px 14px; border-radius: var(--radius); background: var(--bridge-wash); margin-bottom: 14px; }
.booked b { font-size: 20px; letter-spacing: -0.01em; }
.booked span:nth-child(2) { font-size: 20px; font-weight: 650; color: var(--bridge); }
.cands td { vertical-align: top; }
.cands tr.muted td { opacity: .55; }
.cands .evidence { margin: 0; }
.slot { display: inline-flex; gap: 4px; align-items: center; margin: 0 8px 6px 0; font-size: 13.5px; white-space: nowrap; cursor: pointer; }
.steps { margin: 6px 0 0; padding-left: 20px; font-size: 14px; color: var(--ink-2); }
.steps li { padding: 2px 0; }
.diary { border-collapse: separate; border-spacing: 2px; min-width: 760px; table-layout: fixed; width: 100%; }
.diary thead th:first-child, .diary th[scope=row] { width: 120px; }
.diary thead th:last-child { width: 44px; }
.diary thead th { overflow: visible; text-align: left; }
.diary th { font-size: 11.5px; font-weight: 500; padding: 0 0 4px; border: 0; white-space: nowrap; }
.diary th[scope=row] { font-size: 13px; font-weight: 600; color: var(--ink); padding-right: 10px; text-align: left; }
.diary td { padding: 0; border: 0; height: 26px; min-width: 22px; border-radius: 3px; background: var(--rule-2); }
.diary td.r { background: none; padding-left: 8px; }
.diary td.busy { background: var(--ink-3); opacity: .55; }
.diary td.hold { background: var(--bridge); }
.diary td.past { background: var(--hatch); }
.diary td.pick { background: var(--low); outline: 2px solid var(--low); outline-offset: 1px; }
.legend i.d-busy { background: var(--ink-3); opacity: .55; } .legend i.d-hold { background: var(--bridge); } .legend i.d-pick { background: var(--low); }
@media (max-width: 1020px) { .desk { grid-template-columns: minmax(0, 1fr); } }

/* Brand tags for the three Cornerstone businesses */
.brand-tag.CBS { color: #4a3c96; } .brand-tag.CMS { color: #b44a18; } .brand-tag.VMS { color: var(--ink-3); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-tag.CBS { color: #b3a8e6; } :root:not([data-theme="light"]) .brand-tag.CMS { color: #f2955f; } }
:root[data-theme="dark"] .brand-tag.CBS { color: #b3a8e6; } :root[data-theme="dark"] .brand-tag.CMS { color: #f2955f; }
.area-strip { height: 4px; background: linear-gradient(90deg, var(--bridge) 0 70%, var(--brand-2) 70% 100%); }

/* Two databases */
.dbgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(200px, 260px) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.dbcard.biz { border-top: 3px solid #4a3c96; } .dbcard.mkt { border-top: 3px solid #b44a18; }
.bridge { display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 8px 4px; }
.flow { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: baseline; }
.flow span { font-weight: 600; font-size: 14px; }
.flow b { font-size: 20px; color: var(--ink-3); }
.flow small { grid-column: 1 / -1; color: var(--ink-3); font-size: 12px; }
.flow.back { grid-template-columns: auto 1fr; }
.draft { font-size: 14px; margin-top: 6px; }
@media (max-width: 1020px) { .dbgrid { grid-template-columns: minmax(0, 1fr); } .bridge { padding: 0; } }

/* Stalk Bot diff */
.diff { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13.5px; }
.diff li { padding: 3px 8px; border-left: 3px solid; margin-bottom: 2px; border-radius: 0 4px 4px 0; }
.diff.add li { border-color: var(--low); background: var(--low-wash); }
.diff.del li { border-color: var(--high); background: var(--high-wash); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--high) 50%, transparent); }
.legend i.d-add { background: var(--low); } .legend i.d-del { background: var(--high); }
.pagerow { padding: 8px 0; border-top: 1px dashed var(--rule-2); }

/* =====================================================================
   v2 look: navy sidebar, white top bar, coloured headline tiles, charts.
   Colour coding per business:
     CBS Business Solutions  - purple #4a3c96 + crimson #d8104c
     CMS Marketing Solutions - orange #d4581f + navy #283078
     VMS Visual Media        - slate teal #2f6f7e (placeholder until VMS colours are supplied)
   ===================================================================== */
:root {
  --paper: #eef1f7; --sheet: #ffffff; --ink: #141c33; --ink-2: #49526b; --ink-3: #7a8197; --rule: #dbe0ea; --rule-2: #edf0f6;
  --navy: #101a3c; --navy-2: #1a2652; --navy-ink: #e9ecf7; --navy-dim: #9aa3c4;
  --cbs: #4a3c96; --cbs-2: #d8104c; --cms: #d4581f; --cms-2: #283078; --vms: #2f6f7e;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 26, 60, .06), 0 4px 14px rgba(16, 26, 60, .05);
  --s1: #6250d6; --s2: #1baf7a; --s3: #eb6834;            /* chart series (validated) */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --paper: #0d1222; --sheet: #161d33; --ink: #e8ebf5; --ink-2: #b6bdd3; --ink-3: #8790ab; --rule: #2a3352; --rule-2: #1f2742;
    --navy: #0a0f22; --navy-2: #151d3a; --cbs: #9d90ec; --cbs-2: #ff5a86; --cms: #f2955f; --cms-2: #8d97e8; --vms: #6fb3c2; --shadow: none;
    --s1: #9085e9; --s2: #199e70; --s3: #d95926; }
}
:root[data-theme="dark"] { --paper: #0d1222; --sheet: #161d33; --ink: #e8ebf5; --ink-2: #b6bdd3; --ink-3: #8790ab; --rule: #2a3352; --rule-2: #1f2742;
  --navy: #0a0f22; --navy-2: #151d3a; --cbs: #9d90ec; --cbs-2: #ff5a86; --cms: #f2955f; --cms-2: #8d97e8; --vms: #6fb3c2; --shadow: none;
  --s1: #9085e9; --s2: #199e70; --s3: #d95926; }

.app { grid-template-columns: 248px 1fr; }
.panel { border-radius: var(--radius); box-shadow: var(--shadow); border-color: var(--rule); }
h1 { color: var(--ink); }

/* Sidebar */
.nav { background: var(--navy); border-right: 0; color: var(--navy-ink); padding: 18px 12px; --word: url('brand/cbs-word-dark.png'); }
:root[data-brand="cms"] .nav { --word: url('brand/cms-word-dark.png'); }
.nav .brand-ai { color: var(--navy-dim); }
.nav h4 { color: var(--navy-dim); font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; margin: 20px 10px 6px; }
.nav h4.cbs { color: #b3a8e6; } .nav h4.cms { color: #f2a272; }
.nav a { color: #c7cde4; gap: 10px; justify-content: flex-start; padding: 8px 10px; }
.nav a .ico { width: 18px; height: 18px; flex: none; opacity: .8; }
.nav a .lbl { flex: 1; }
.nav a:hover { background: var(--navy-2); color: #fff; }
.nav a.on { color: #fff; font-weight: 600; background: var(--area, #4a3c96); }
.nav a.on .ico { opacity: 1; }
.nav a.cbs { --area: #4a3c96; } .nav a.cms { --area: #c04f1b; } .nav a.data { --area: #3a4570; }
.nav .count { background: rgba(255,255,255,.12); color: #fff; }
.nav a.on .count { background: rgba(255,255,255,.25); }
.nav .demo { color: var(--navy-dim); border-top-color: rgba(255,255,255,.1); }
.area-strip { background: linear-gradient(90deg, var(--bridge) 0 70%, var(--brand-2) 70% 100%); }

/* Top bar */
.topbar { background: var(--sheet); border-bottom: 1px solid var(--rule); padding: 10px 28px; }
.topbar .ask input { border-radius: 22px 0 0 22px; padding: 8px 16px; background: var(--paper); }
.topbar .ask button { border-radius: 0 22px 22px 0; }
.bell { position: relative; border: 1px solid var(--rule); background: var(--sheet); width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.bell .dot { position: absolute; top: -4px; right: -4px; min-width: 19px; height: 19px; border-radius: 10px; background: var(--cbs-2); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 5px; }
.notif { position: absolute; right: 28px; top: 58px; width: min(380px, calc(100vw - 32px)); background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(16,26,60,.18); z-index: 40; padding: 8px; }
.notif a { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 8px; color: var(--ink); }
.notif a:hover { background: var(--rule-2); text-decoration: none; }
.notif b { min-width: 28px; text-align: center; border-radius: 12px; padding: 1px 6px; color: #fff; font-size: 13px; }
.notif .k-decision b, .notif .k-service b, .notif .k-sla b { background: var(--cbs); } .notif .k-sla b { background: var(--cbs-2); }
.notif .k-marketing b { background: var(--cms); } .notif .k-admin b { background: #3a4570; }
.who .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--cbs); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }

/* Headline tiles, coloured by business */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { border-radius: var(--radius); padding: 16px 18px; color: #fff; position: relative; overflow: hidden; display: block; min-height: 112px; box-shadow: var(--shadow); }
.kpi:hover { text-decoration: none; filter: brightness(1.05); }
.kpi .k-label { font-size: 15px; font-weight: 600; opacity: .95; }
.kpi .k-value { font-family: var(--display); font-size: 38px; font-weight: 700; line-height: 1.1; margin-top: 6px; letter-spacing: -.01em; }
.kpi .k-note { font-size: 13px; opacity: .9; margin-top: 2px; }
.kpi::after { content: ''; position: absolute; right: -24px; top: -24px; width: 110px; height: 110px; border-radius: 50%; background: rgba(255,255,255,.08); }
.kpi.service { background: linear-gradient(135deg, #4a3c96, #6a59c9); }
.kpi.sla { background: linear-gradient(135deg, #b70d40, #e2366c); }
.kpi.marketing { background: linear-gradient(135deg, #c04f1b, #e8793f); }
.kpi.pipeline { background: linear-gradient(135deg, #283078, #3f4aa6); }
.kpi.finance { background: linear-gradient(135deg, #3a4570, #56628f); }

.welcome { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.welcome h1 { margin: 0; }

/* Charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--rule); stroke-width: 1; }
.chart .axis text { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:hover { fill: var(--rule-2); fill-opacity: .55; }
.chart-tip { position: absolute; pointer-events: none; background: var(--navy); color: #fff; font-size: 12.5px; padding: 8px 10px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); z-index: 5; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.chart-tip i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.chart-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); flex-wrap: wrap; }
.chart-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-legend i.line { height: 3px; border-radius: 2px; vertical-align: 3px; }
.chart-legend i.dash { height: 0; border-top: 2px dashed var(--ink-3); border-radius: 0; vertical-align: 3px; background: none !important; }
details.tableview summary { font-size: 12.5px; color: var(--ink-3); cursor: pointer; margin-top: 6px; }
.statusbars .sb { display: grid; grid-template-columns: 150px 1fr 40px; gap: 10px; align-items: center; font-size: 14px; padding: 5px 0; }
.statusbars .sb span.track { height: 10px; background: var(--rule-2); border-radius: 5px; overflow: hidden; }
.statusbars .sb span.track i { display: block; height: 100%; border-radius: 5px; background: var(--cbs); }

/* Feed */
.feed .f { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; padding: 9px 0; border-top: 1px solid var(--rule-2); align-items: start; }
.feed .f:first-child { border-top: 0; }
.feed .f .fi { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.feed .fi.ticket, .feed .fi.decision { background: var(--cbs); } .feed .fi.risk { background: var(--cbs-2); }
.feed .fi.prospect, .feed .fi.competitor { background: var(--cms); }
.feed .f b { font-size: 14px; font-weight: 600; } .feed .f div small { display: block; color: var(--ink-3); font-size: 12.5px; }
.feed .f time { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

/* Tickets */
.subkpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.subkpi { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--shadow); }
.subkpi span { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 6px; align-items: center; }
.subkpi span i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.subkpi b { display: block; font-family: var(--display); font-size: 26px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { border: 1px solid var(--rule); background: var(--sheet); border-radius: 8px; padding: 7px 10px; }
.toolbar input { flex: 1; min-width: 180px; }
table.tk td, table.tk th { padding: 9px 10px; }
table.tk tbody tr { cursor: pointer; }
table.tk tbody tr:hover td { background: var(--rule-2); }
.pill.P1 { background: var(--high-wash); color: var(--high); } .pill.P2 { background: #fde6ee; color: #b70d40; } .pill.P3 { background: var(--med-wash); color: var(--med); } .pill.P4 { background: var(--rule-2); color: var(--ink-2); }
.pill.ST-Open { background: #e6ecfb; color: #2a4fa8; } .pill.ST-In { background: #fbf0dc; color: #a35f00; } .pill.ST-Waiting { background: #efe9fb; color: #5b3fb0; } .pill.ST-On { background: var(--rule-2); color: var(--ink-2); } .pill.ST-Closed { background: var(--low-wash); color: var(--low); }
.pill.MET, .pill.ON_TRACK { background: var(--low-wash); color: var(--low); } .pill.AT_RISK { background: var(--med-wash); color: var(--med); } .pill.BREACHED, .pill.MISSED { background: var(--high-wash); color: var(--high); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.ST-Open { background: #1d2a4d; color: #9db6f2; } :root:not([data-theme="light"]) .pill.ST-Waiting { background: #2a2147; color: #c0aef5; } :root:not([data-theme="light"]) .pill.P2 { background: #3a1a26; color: #ff8fb0; } }
:root[data-theme="dark"] .pill.ST-Open { background: #1d2a4d; color: #9db6f2; } :root[data-theme="dark"] .pill.ST-Waiting { background: #2a2147; color: #c0aef5; } :root[data-theme="dark"] .pill.P2 { background: #3a1a26; color: #ff8fb0; }

.tl { list-style: none; margin: 0; padding: 0; }
.tl li { position: relative; padding: 0 0 14px 26px; }
.tl li::before { content: ''; position: absolute; left: 6px; top: 18px; bottom: -2px; width: 2px; background: var(--rule); }
.tl li:last-child::before { display: none; }
.tl li i { position: absolute; left: 0; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--low); border: 3px solid var(--sheet); box-shadow: 0 0 0 1px var(--rule); }
.tl li.NOW i { background: var(--med); } .tl li.REOPENED i, .tl li.ESCALATED i { background: var(--high); } .tl li.WORK i { background: var(--cbs); }
.tl li b { display: block; font-size: 14px; } .tl li small { color: var(--ink-3); font-size: 12.5px; }
.progress { height: 10px; border-radius: 5px; background: var(--rule-2); overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; background: var(--low); border-radius: 5px; }
.progress.warn i { background: var(--med); } .progress.bad i { background: var(--high); }
.ticket-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.ticket-head h1 { margin: 0; }
.ticket-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--bridge-wash); color: var(--bridge); display: grid; place-items: center; flex: none; }

/* Email assistant */
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--sheet); padding: 7px 14px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--bridge); color: var(--bridge-ink); }
.email-out textarea { min-height: 300px; font-size: 14.5px; line-height: 1.55; }
.email-out input { width: 100%; border: 1px solid var(--rule); background: var(--paper); border-radius: 8px; padding: 8px 10px; font-weight: 600; }

/* Brand chip */
.bchip { display: inline-block; font-size: 11.5px; font-weight: 700; color: #fff; border-radius: 4px; padding: 1px 6px; }
.bchip.CBS { background: #4a3c96; } .bchip.CMS { background: #c04f1b; } .bchip.VMS { background: #2f6f7e; }

@media (max-width: 1020px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .subkpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .kpis { grid-template-columns: minmax(0, 1fr); } .subkpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .statusbars .sb { grid-template-columns: 110px 1fr 32px; } .nav { background: var(--navy); } }
/* mobile: tab rows scroll sideways instead of widening the page */
.tabs { overflow-x: auto; scrollbar-width: none; min-width: 0; }
.tabs button { white-space: nowrap; flex: 0 0 auto; }
.main, .main > * { min-width: 0; }
@media (max-width: 760px) { .toolbar select { flex: 1 1 140px; } .toolbar input { min-width: 0; flex-basis: 100%; } }
@media (max-width: 760px) { .app { grid-template-columns: minmax(0, 1fr); } }
