/* WD Sales CRM. Brand: navy #060b24 / #36426d, coral #e2836b (see WDMarketing/_brand/BRAND.md). */
:root {
  /* Soft light theme: off-white surfaces and softened ink to reduce glare and eye strain. */
  --navy-900: #060b24;
  --navy-700: #36426d;
  --coral: #e2836b;
  --coral-ink: #b4533a;
  --bg: #f3f4f8;
  --surface: #fbfbfd;
  --surface-2: #eef0f6;
  --ink: #262c45;
  --ink-2: #4f5674;
  --muted: #828aa6;
  --line: #e3e6ef;
  --bar: #6f7bab;
  --good: #2b8a5f;
  --warn: #b07a26;
  --bad: #c0503c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(6, 11, 36, .04), 0 2px 10px rgba(6, 11, 36, .03);
  --side-bg: #fbfbfd;
  --side-ink: #4f5674;
  --side-hover: #eef0f6;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
}
h1, h2, h3 { font-family: Manrope, Inter, system-ui, sans-serif; margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
a { color: var(--navy-700); }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.pre { white-space: pre-line; }

/* Layout */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--side-bg); color: var(--side-ink); border-right: 1px solid var(--line); padding: 18px 14px; position: sticky; top: 0;
  height: 100vh; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 16px; color: var(--navy-900); text-decoration: none; }
.brand-plate { background: #fff; border-radius: 8px; padding: 4px 6px; display: flex; border: 1px solid var(--line); }
.brand-plate img { height: 26px; display: block; }
.brand b { font-family: Manrope, sans-serif; font-size: 15px; letter-spacing: .2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--side-ink); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--side-hover); color: var(--ink); }
.nav a.active { background: rgba(226, 131, 107, .12); color: var(--coral-ink); box-shadow: inset 3px 0 0 var(--coral); font-weight: 600; }
.nav .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 10px 4px; }
.nav .pill { margin-left: auto; }
.sidebar .me { margin-top: auto; padding: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink); }
.sidebar .me button { background: none; border: 0; color: var(--ink-2); padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }
.sidebar .me a { color: var(--ink-2); }
.main { min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 28px; border-bottom: 1px solid var(--line);
  background: var(--surface); position: sticky; top: 0; z-index: 5;
}
.topbar form.search { flex: 1; max-width: 420px; }
.topbar .spacer { flex: 1; }
.btn.menu-btn { display: none; }
.content { padding: 24px 28px 60px; max-width: 1400px; }
.page-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* Components */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
/* Cards side by side in a grid line up: no stacking margin, equal heights. */
.grid > .card + .card, .grid > * { margin-top: 0; }
.grid { align-items: stretch; }
.grid.grid-side { align-items: start; }
.grid-side > .stack > :first-child, .grid-side > .card { margin-top: 0; }
.card h2 { display: flex; align-items: center; gap: 8px; }
.card h2 .more { margin-left: auto; font: 500 12.5px Inter, sans-serif; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-2.charts { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-side { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.stack > * + * { margin-top: 16px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); padding: 7px 13px; border-radius: 8px; font: 600 13px Inter, sans-serif; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--navy-700); }
.btn.primary { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn.primary:hover { background: #d4714f; }
.btn.dark { background: var(--navy-900); border-color: var(--navy-900); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.ai { background: linear-gradient(135deg, #36426d, #6b4fa0); border-color: transparent; color: #fff; }
.btn[disabled] { opacity: .6; cursor: progress; }
.link-btn { background: none; border: 0; padding: 0; color: var(--navy-700); cursor: pointer; font: inherit; text-decoration: underline; }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(226, 131, 107, .45); border-color: var(--coral); }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-weight: 600; font-size: 12.5px; color: var(--ink-2); margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 14px; }
.checks label { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; color: var(--ink); font-size: 13px; margin: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 140px; padding: 6px 9px; }
.inline-form { display: inline; }
.row-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.row-form > * { flex: 1; min-width: 130px; }
.row-form > .btn { flex: 0 0 auto; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap;
}
.badge.coral { background: rgba(226, 131, 107, .14); color: var(--coral-ink); border-color: transparent; }
.badge.s-New { background: rgba(54, 66, 109, .1); color: var(--navy-700); }
.badge.s-Qualified, .badge.s-Converted, .badge.s-Won { background: rgba(31, 138, 91, .12); color: var(--good); border-color: transparent; }
.badge.s-Lost, .badge.s-Unqualified { background: rgba(194, 65, 45, .1); color: var(--bad); border-color: transparent; }
.badge.ai { background: rgba(107, 79, 160, .14); color: #6b4fa0; border-color: transparent; }
.pill { background: var(--coral); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11.5px; font-weight: 700; min-width: 20px; text-align: center; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid; }
.flash.success { background: rgba(31, 138, 91, .08); border-color: rgba(31, 138, 91, .3); }
.flash.error { background: rgba(194, 65, 45, .08); border-color: rgba(194, 65, 45, .35); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { display: flex; flex-direction: column; min-width: 0; }
.kpi .k-sub { margin-top: auto; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .k-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi .k-value { font: 800 24px/1.2 Manrope, Inter, sans-serif; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .k-sub { color: var(--ink-2); font-size: 12px; }
.kpi.accent { border-top: 3px solid var(--coral); }

/* Bar lists: one series, single hue, value labels at the end. */
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(64px, 38%) minmax(48px, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .b-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.bar-track { height: 14px; position: relative; min-width: 48px; background: var(--surface-2); border-radius: 0 4px 4px 0; }
.bar-fill { height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-row .b-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.bar-row:hover .bar-fill { filter: brightness(1.2); }

/* Tasks */
.task { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.task:last-child { border-bottom: 0; }
.task .t-main { flex: 1; min-width: 0; }
.task .t-title { font-weight: 600; }
.task.done .t-title { text-decoration: line-through; color: var(--muted); }
.task .t-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.task:has(.check) { flex-wrap: wrap; }
.task:has(.check) .t-actions { flex: 1 0 100%; padding-left: 30px; }
.due { font-size: 12px; font-weight: 600; }
.due.overdue { color: var(--bad); }
.due.today { color: var(--warn); }
.due.upcoming { color: var(--ink-2); }
.due.done { color: var(--muted); }
.check {
  width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line); background: var(--surface);
  cursor: pointer; flex: 0 0 auto; margin-top: 2px; padding: 0; display: grid; place-items: center; color: #fff;
}
.check:hover { border-color: var(--good); }
.task.done .check { background: var(--good); border-color: var(--good); }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.timeline li.k-note::before { background: var(--coral); }
.timeline li.k-ai::before { background: #6b4fa0; }
.timeline li.k-stage::before, .timeline li.k-status::before { background: var(--navy-700); }

/* Kanban */
.board { display: grid; grid-template-columns: repeat(6, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.column { background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 300px; display: flex; flex-direction: column; }
.column.drag-over { outline: 2px dashed var(--coral); }
.col-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 8px; }
.col-head b { font-family: Manrope, sans-serif; }
.col-head .total { margin-left: auto; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.deal-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px;
  cursor: grab; box-shadow: var(--shadow);
}
.deal-card.dragging { opacity: .5; }
.deal-card a { text-decoration: none; color: var(--ink); font-weight: 600; }
.deal-card .d-value { font: 700 15px Manrope, sans-serif; margin: 2px 0; }
.deal-card .d-meta { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.deal-card .late { color: var(--bad); }

/* AI panel */
.ai-panel { border: 1px solid rgba(107, 79, 160, .35); background: rgba(107, 79, 160, .05); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.ai-panel h3 { display: flex; gap: 8px; align-items: center; }
.ai-panel dl { display: grid; grid-template-columns: 120px 1fr; gap: 4px 12px; margin: 8px 0; font-size: 13px; }
.ai-panel dt { color: var(--muted); }
.ai-panel dd { margin: 0; word-break: break-word; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Reminders */
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 10px; z-index: 50; width: min(360px, calc(100vw - 32px)); }
.toast { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--coral); border-radius: 10px; padding: 12px 14px; box-shadow: 0 8px 24px rgba(6, 11, 36, .18); }
.toast.overdue { border-left-color: var(--bad); }
.toast .t-head { display: flex; gap: 8px; align-items: baseline; }
.toast .t-head b { flex: 1; }
.toast .x { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; }
.toast .t-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.bell { position: relative; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }

.pager { display: flex; gap: 6px; align-items: center; margin-top: 14px; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }
.services-group { margin-bottom: 22px; }
.services-group > h2 { color: var(--coral-ink); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.service-card ul { margin: 6px 0 0; padding-left: 18px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, #eef0f7, #f7f1ee); padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border-radius: 14px; padding: 28px; border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(6, 11, 36, .06); }
.login-card .brand-plate { display: inline-flex; margin-bottom: 14px; }
.login-card .brand-plate img { height: 40px; }

@media (max-width: 1100px) {
  .grid-side, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px 16px 60px; }
  .grid-2, .form-grid { grid-template-columns: 1fr; }

  .ai-panel dl { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}

/* Org chart */
.org { list-style: none; margin: 0; padding: 0; }
.org li { padding-top: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.org li:last-child { border-bottom: 0; }
.org-line { color: var(--muted); margin-right: 4px; }

/* ---- Phone & tablet refinements ---- */
.nav-backdrop { display: none; }
@media (max-width: 820px) {
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(6, 11, 36, .25); z-index: 30; }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .topbar form.search { order: 10; flex: 1 0 100%; max-width: none; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi .k-value { font-size: 20px; }
  .filters input, .filters select { flex: 1 1 140px; min-width: 0; }
  .board { grid-template-columns: repeat(6, 82vw); scroll-snap-type: x mandatory; }
  .column { scroll-snap-align: start; }
  .card { padding: 14px; }
  .ai-panel .row-form > * { flex: 1 1 100%; }
}
@media (max-width: 640px) {
  /* Tables marked .stack-sm become one card per row. */
  table.stack-sm thead { display: none; }
  table.stack-sm, table.stack-sm tbody, table.stack-sm tr, table.stack-sm td { display: block; width: 100%; }
  table.stack-sm tr { padding: 10px 12px; border-bottom: 1px solid var(--line); position: relative; }
  table.stack-sm td { border: 0; padding: 2px 0; }
  table.stack-sm td.hide-sm { display: none; }
  table.stack-sm td.num { text-align: left; }
  table.stack-sm td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12px; }
  table.stack-sm td.select-cell { position: absolute; right: 12px; top: 12px; width: auto; }
  .kpi .k-value { font-size: 18px; }
  h1 { font-size: 1.3rem; }
  .bar-row { font-size: 12.5px; }
  .toasts { right: 12px; left: 12px; bottom: 12px; width: auto; }
}

/* Reference numbers and in-CRM company matches */
.ref { font: 600 11.5px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; vertical-align: middle; white-space: nowrap; }
h1 .ref { font-size: 13px; }
.matches { border: 1px solid var(--line); border-left: 3px solid var(--navy-700); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; background: var(--surface-2); }
.matches h3 { font-size: 13px; }
.match { padding: 8px 0; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.match:first-of-type { border-top: 0; }
.match .m-main { flex: 1; min-width: 0; font-size: 13px; }

/* Location links (open Google Maps in a new tab) */
.location { text-decoration: none; }
.location:hover { text-decoration: underline; }

/* Escalations and call-backs */
.badge.esc { background: rgba(192, 80, 60, .12); color: var(--bad); border-color: transparent; margin-left: 4px; }
.small-select { width: auto; padding: 3px 6px; font-size: 12px; }
.callback-form { display: inline-flex; gap: 4px; align-items: center; }
.attention li { padding: 6px 0; border-bottom: 1px solid var(--line); list-style: none; }
.attention { padding: 0; margin: 0; }

/* Key/value tables (deal commercials) */
table.kv th { text-transform: none; letter-spacing: 0; font-size: 12px; width: 18%; white-space: nowrap; }
table.kv td { font-variant-numeric: tabular-nums; }

/* Searchable select */
.ss { position: relative; display: block; }
.filters .ss { display: inline-block; min-width: 170px; }
.ss-native { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.ss-button { width: 100%; text-align: left; font: inherit; font-weight: 600; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 30px 8px 10px; cursor: pointer; position: relative; color: var(--ink); }
.ss-button::after { content: "▾"; position: absolute; right: 10px; color: var(--muted); }
.ss-button.placeholder { color: var(--muted); font-weight: 400; }
.ss-invalid .ss-button { border-color: var(--bad); box-shadow: 0 0 0 2px rgba(192, 80, 60, .15); }
.ss-panel { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(6, 11, 36, .12); padding: 6px; min-width: 220px; }
.ss-search { margin-bottom: 6px; }
.ss-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow-y: auto; }
.ss-list li { padding: 6px 8px; border-radius: 6px; cursor: pointer; font-weight: 500; }
.ss-list li.hover, .ss-list li:hover { background: var(--surface-2); }
.ss-list li.selected { background: rgba(54, 66, 109, .1); }
.req { color: var(--bad); }

/* Communication log */
.comm-box > summary { cursor: pointer; list-style: none; padding: 4px 0; }
.comm-box > summary::-webkit-details-marker { display: none; }
.comm { border-top: 1px solid var(--line); padding: 10px 0; }
.comm:first-child { border-top: 0; }
.comm-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }

/* Ticket stages */
.stages { list-style: none; display: flex; padding: 0; margin: 0 0 18px; overflow-x: auto; gap: 2px; }
.stages li { flex: 1 1 0; min-width: 96px; white-space: normal; line-height: 1.25; padding: 8px 10px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 600; text-align: center; white-space: nowrap; }
.stages li:first-child { border-radius: 8px 0 0 8px; }
.stages li:last-child { border-radius: 0 8px 8px 0; }
.stages li.done { background: rgba(54, 66, 109, .18); color: var(--ink-2); }
.stages li.current { background: var(--coral); color: #fff; }
.stage-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; margin-bottom: 14px; }
.stage-chip { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; text-decoration: none; color: var(--ink-2); display: flex; flex-direction: column; font-size: 12px; }
.stage-chip b { font: 800 20px Manrope, sans-serif; color: var(--ink); }
.stage-chip.active { border-color: var(--coral); box-shadow: inset 0 -3px 0 var(--coral); }
.stage-chip.closed b { color: var(--muted); }
.badge.prio-P1 { background: rgba(194, 65, 45, .14); color: var(--bad); border-color: transparent; }
.badge.prio-P2 { background: rgba(183, 121, 31, .14); color: var(--warn); border-color: transparent; }
.badge.s-Resolved, .badge.s-Closed, .badge.s-Active { background: rgba(31, 138, 91, .12); color: var(--good); border-color: transparent; }
.badge.s-Churned { background: rgba(194, 65, 45, .1); color: var(--bad); border-color: transparent; }
@media (max-width: 820px) { .stage-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Roles matrix */
table.matrix th.grp { text-align: center; border-bottom: 0; color: var(--coral-ink); }
table.matrix th.pg { height: 150px; vertical-align: bottom; padding: 6px 4px; }
table.matrix th.pg span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; text-transform: none; letter-spacing: 0; font-size: 12px; color: var(--ink-2); }
table.matrix td.c { text-align: center; }
table.matrix tr.admin-row td.c { color: var(--good); font-weight: 700; }

/* DSR table */
table.dsr th { white-space: nowrap; font-size: 10.5px; padding: 8px 6px; }
table.dsr td { padding: 8px 6px; font-size: 13px; }
table.dsr td:first-child, table.dsr th:first-child { min-width: 150px; padding-left: 12px; }
table.dsr tfoot td { border-top: 2px solid var(--line); background: var(--surface-2); }

/* Month calendar */
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 10px; color: var(--ink-2); }
.legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-head { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 0 4px; }
.cal-day { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 7px; min-height: 128px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; }
a.cal-day:hover { border-color: var(--coral); }
.cal-day.today { border-color: var(--coral); box-shadow: inset 0 0 0 1px var(--coral); }
.cal-day.other { background: transparent; border-style: dashed; opacity: .45; }
.cal-day.future { opacity: .6; }
.cal-num { font: 700 13px Manrope, sans-serif; margin-bottom: 4px; }
.cal-rows { display: grid; gap: 2px; font-size: 11.5px; }
.cal-rows .r { display: flex; justify-content: space-between; gap: 4px; padding-left: 6px; border-left: 3px solid; line-height: 1.35; }
.cal-rows .r span { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-rows .r b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.m-calls { border-color: #36426d; } .legend .m-calls { background: #36426d; }
.m-tickets { border-color: #b07a26; } .legend .m-tickets { background: #b07a26; }
.m-won { border-color: #2b8a5f; } .legend .m-won { background: #2b8a5f; }
.m-tickets_closed { border-color: #6f9a1d; } .legend .m-tickets_closed { background: #6f9a1d; }
.m-open_sales { border-color: #e2836b; } .legend .m-open_sales { background: #e2836b; }
.m-open_tickets { border-color: #a8322b; } .legend .m-open_tickets { background: #a8322b; }
@media (max-width: 900px) {
  .cal { grid-template-columns: 1fr; }
  .cal-head { display: none; }
  .cal-day { min-height: 0; }
  .cal-day.other, .cal-day.future { display: none; }
  .cal-rows { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* AI insights */
.badge.trend-improving { background: rgba(43, 138, 95, .12); color: var(--good); border-color: transparent; }
.badge.trend-declining { background: rgba(192, 80, 60, .12); color: var(--bad); border-color: transparent; }
.badge.trend-steady { background: rgba(54, 66, 109, .1); color: var(--navy-700); border-color: transparent; }
.trend { padding: 8px 0; border-bottom: 1px solid var(--line); }
.trend:last-of-type { border-bottom: 0; }
.trend-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 40px; background: var(--surface-2); border-radius: 6px; padding: 3px; }
.spark span { flex: 1; background: var(--bar); border-radius: 2px 2px 0 0; min-height: 2px; }
.spark span.missed { background: var(--bad); }

/* Help tags: "?" with an explanation on hover / focus / tap */
.help { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--ink-2); font: 700 10.5px Inter, sans-serif; cursor: help; position: relative;
  vertical-align: middle; margin-left: 2px; text-transform: none; letter-spacing: 0; }
.help:hover, .help:focus { background: var(--coral); color: #fff; border-color: var(--coral); outline: none; }
.help:hover::after, .help:focus::after { content: attr(data-help); position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%);
  width: max-content; max-width: min(300px, 80vw); background: var(--navy-900); color: #fff; font: 400 12.5px/1.45 Inter, sans-serif;
  padding: 8px 10px; border-radius: 8px; box-shadow: 0 8px 24px rgba(6, 11, 36, .2); z-index: 60; white-space: normal; text-align: left; }
h1 .help { width: 18px; height: 18px; font-size: 11.5px; }
.help-page ol, .help-page ul { padding-left: 18px; margin: 0; line-height: 1.7; }
.glossary { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.glossary dt { font-weight: 600; } .glossary dd { margin: 0; color: var(--ink-2); }


/* Page loader: slim bar at the top while a page loads or a form saves */
.page-loader { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100; pointer-events: none; opacity: 0; transition: opacity .2s; }
.page-loader span { display: block; height: 100%; width: 40%; background: linear-gradient(90deg, var(--coral), #f0a28d);
  border-radius: 0 3px 3px 0; animation: loader 1.1s ease-in-out infinite; }
body.loading .page-loader { opacity: 1; }
body.loading main.content { opacity: .55; transition: opacity .25s .15s; }
body.loading { cursor: progress; }
@keyframes loader { 0% { transform: translateX(-100%); } 60% { transform: translateX(180%); } 100% { transform: translateX(260%); } }
button[disabled] .spinner { width: 12px; height: 12px; margin-right: 2px; vertical-align: -2px; }
@media (prefers-reduced-motion: reduce) { .page-loader span { animation: none; width: 100%; } }


/* Ticket timeline */
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { position: relative; padding: 4px 0 12px 22px; border-left: 2px solid var(--line); margin-left: 6px; display: grid; grid-template-columns: 1fr auto; gap: 0 12px; }
.tl li:last-child { padding-bottom: 0; }
.tl li::before { content: ""; position: absolute; left: -7px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--navy-700); border: 2px solid var(--surface); }
.tl li.current::before { background: var(--coral); box-shadow: 0 0 0 3px rgba(226, 131, 107, .25); }
.tl .tl-stage { grid-column: 1; } .tl .tl-dur { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-weight: 600; color: var(--ink-2); white-space: nowrap; }


/* Deal form: provider picks */
.provider-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 12px; }
.provider-pick { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; color: var(--ink) !important; margin: 0 !important; }
.provider-pick span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.provider-pick select { width: auto; padding: 3px 6px; font-size: 12px; }
.deal-form > .card + .card, .deal-form > details.card { margin-top: 16px; }
details.card > summary { cursor: pointer; }
/* Quotes comparison */
table.quotes td, table.quotes th { vertical-align: middle; }
table.quotes tr.best td { background: rgba(43, 138, 95, .06); }
table.quotes tr.selected td { background: rgba(226, 131, 107, .08); }
table.quotes input, table.quotes select { padding: 4px 6px; font-size: 12.5px; min-width: 80px; }
.provider-pick[data-rank="0"] span, .provider-pick[data-rank="1"] span { font-weight: 600; }
.offers-hint { color: var(--good); font-style: normal; font-weight: 500; }
.spec-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 10px; }
.spec-picks label { display: flex; gap: 6px; align-items: center; font-weight: 500; font-size: 12.5px; color: var(--ink); margin: 0; }
table.catalog td { vertical-align: top; }

/* Provider: products offered and departments */
.offer-picks { display: grid; gap: 6px; }
.offer-cat, .dept { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.offer-cat summary, .dept summary { cursor: pointer; }
.offer-cat .checks { margin-top: 8px; }
.dept + .dept { margin-top: 8px; }
.dept .task { padding-left: 0; }
