/* ============================================================
   Paperserve ClientPulse — design system (M5)
   POC layout language (casm-client-pulse) re-tokened onto the
   official CASM palette (S10). No external requests: fonts and
   scripts are bundled under wwwroot (S3).
   ============================================================ */

/* ---- Open Sans, bundled locally (R2) ---- */
@font-face {
  font-family: "Open Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/open-sans-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Open Sans";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/open-sans-latin-400-italic.woff2") format("woff2");
}

@font-face {
  font-family: "Open Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/open-sans-latin-700-normal.woff2") format("woff2");
}

/* ---- Brand tokens (S10) + derived system tokens ---- */
:root {
  --brand-primary: #1769a3;
  --brand-sky: #31aae1;
  --brand-teal: #6bcad5;
  --brand-coral: #ff6666;
  --brand-gray: #8b8d98;

  /* Shades of Primary Blue for chrome depth */
  --primary-700: #125a8d;
  --primary-800: #0e4a75;
  --primary-900: #0b3a5d;

  /* Wordmark navy sampled from the Paperserve letterhead — anchors the shell */
  --brand-navy: #205078;

  /* Vision-2031 rail navy — the one big dark mass that anchors every screen */
  --rail-top: #0c2c44;
  --rail-bottom: #0e3350;

  /* Neutrals (blue-tinted derivatives of Primary Blue — nothing pure grey) */
  --ink-strong: #0c2c44;     /* headings, KPI values */
  --ink: #1d3547;            /* body */
  --muted: #5f7789;          /* AA-safe secondary text, labels */
  --faint: #8fa3b2;          /* timestamps, tertiary */
  --line: #dfe8ee;
  --line-soft: #ecf2f5;      /* in-card dividers */
  --paper: #f2f6f8;
  --surface: #ffffff;
  --surface-tint: #fafcfd;

  /* Semantic (pill/alert) inks — dark enough for AA on their tints */
  --ok: #1a7a50;
  --warn: #915613;
  --danger-ink: #b03636;
  --danger-solid: #c23b3b;   /* deepened coral for solid destructive buttons */

  /* State tint pairs (pale fill + darkened ink) */
  --teal-bg: #e9f7f8;
  --teal-ink: #1d7f8c;
  --sky-bg: #e8f5fc;
  --sky-ink: #176e9e;
  --coral-bg: #ffefef;

  --radius: 8px;
  --radius-lg: 10px;
  --shadow: 0 18px 45px rgba(11, 58, 93, 0.12);
  --shadow-card: 0 1px 2px rgba(12, 44, 68, 0.06), 0 4px 16px rgba(12, 44, 68, 0.05);
  --focus-ring: 0 0 0 3px rgba(49, 170, 225, 0.4);

  --sidebar-width: 264px;
}

/* ---- Base ---- */
* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Open Sans", Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  color: var(--ink-strong);
  font-weight: 700;
  line-height: 1.25;
}

p {
  margin: 0 0 10px;
}

a {
  color: var(--brand-primary);
  font-weight: 700;
  text-decoration: none;
}

a:hover {
  color: var(--primary-800);
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--surface);
  color: var(--brand-primary);
  padding: 10px 14px;
  border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
  left: 0;
}

/* ============================================================
   App shell: CASM Primary Blue sidebar + paper canvas
   ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 18px 18px;
  background: linear-gradient(180deg, var(--rail-top) 0%, var(--rail-bottom) 100%);
  color: #cfe1ee;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  padding: 0 6px;
}

/* Blue-on-transparent wordmark sits on a light chip so it reads on the navy shell */
.brand-logo {
  display: block;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 1px 0 rgba(11, 58, 93, 0.25);
}

.brand-logo img {
  display: block;
  width: 176px;
  height: auto;
}

.brand-name {
  padding-left: 2px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.82);
}

.nav-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-section {
  margin: 12px 0 2px;
  padding: 0 12px;
  color: #6d94b0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.nav-section:first-child {
  margin-top: 0;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: #cfe1ee;
  font-weight: 700;
  text-decoration: none;
}

.nav-item svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  stroke: var(--brand-teal);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
  text-decoration: none;
}

/* Active nav: sky-tinted fill + inset sky stripe (Vision-2031 rail language). */
.nav-item.active {
  background: rgba(49, 170, 225, 0.18);
  color: #ffffff;
  box-shadow: inset 3px 0 0 var(--brand-sky);
}

.nav-item.active svg,
.nav-item:hover svg {
  stroke: #ffffff;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.05);
  color: #b9d2e4;
  font-size: 12px;
  line-height: 1.5;
}

.sidebar-foot strong {
  display: block;
  color: #ffffff;
}

.sidebar-backdrop {
  display: none;
}

/* ---- Main column ---- */
.main-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
  padding: 24px 26px 40px;
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar-title .eyebrow {
  margin-bottom: 3px;
}

.topbar-title h1 {
  font-size: 24px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.search-wrap {
  flex: 0 1 380px;
  min-width: 160px;
}

.search-wrap input[type="search"] {
  background: var(--surface-tint);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  white-space: nowrap;
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--brand-primary);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.user-name {
  font-size: 13px;
  font-weight: 700;
  color: #344456;
}

.signout-form {
  display: inline;
}

.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.nav-toggle svg {
  width: 20px;
  height: 20px;
  stroke: var(--ink);
  vertical-align: middle;
}

/* ============================================================
   Typography helpers
   ============================================================ */
.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.text-muted {
  color: var(--muted);
}

.text-danger {
  color: var(--danger-ink);
}

/* ============================================================
   Panels, cards, metrics
   ============================================================ */
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  padding: 18px;
  margin-bottom: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 14px;
}

.panel-heading h2,
.panel-heading h3 {
  font-size: 17px;
}

.panel-count {
  display: inline-flex;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* Clickable KPI tiles: same card, plus an affordance on hover. */
a.metric {
  display: block;
  color: inherit;
  font-weight: inherit;
  text-decoration: none;
}

a.metric:hover {
  border-color: var(--brand-sky);
  text-decoration: none;
}

.metric strong {
  display: block;
  margin: 8px 0 6px;
  color: var(--ink-strong);
  font-size: 28px;
  font-variant-numeric: tabular-nums;
}

.metric small {
  color: var(--muted);
  line-height: 1.4;
}

/* Teal→sky kicker bar: the second brand hue, woven through the chrome so
   screens stop reading as blue-on-blue. Panel headings + page title only. */
.panel-heading .eyebrow::before,
.topbar-title .eyebrow::before {
  content: "";
  display: inline-block;
  vertical-align: 2px;
  width: 14px;
  height: 3px;
  margin-right: 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-teal), var(--brand-sky));
}

/* Attention tiles: coral left stripe + coral value — applied only while the
   count is non-zero, so colour keeps meaning state, never decoration. */
.metric-alert {
  border-left: 3px solid var(--brand-coral);
}

.metric-alert strong {
  color: var(--danger-ink);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stack-list {
  display: grid;
  gap: 10px;
}

.row-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-tint);
  padding: 13px;
}

.row-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.row-title {
  margin: 0 0 4px;
  font-weight: 700;
}

.row-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.empty-row {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 12px;
  font-size: 13px;
}

/* Hero band (client 360 header) */
.hero-band {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(620px 220px at 92% -30%, rgba(107, 202, 213, 0.28), transparent 60%),
    linear-gradient(135deg, var(--brand-primary) 0%, var(--primary-900) 100%);
  color: #ffffff;
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.hero-band .eyebrow {
  color: var(--brand-teal);
}

.hero-band h2,
.hero-band h3 {
  color: #ffffff;
  font-size: 28px;
}

.hero-copy {
  max-width: 850px;
  margin: 12px 0 0;
  color: #d5e7f3;
  line-height: 1.55;
}

/* Pills sit on the dark band as solid light chips so their semantic inks
   stay AA-readable (the tinted defaults vanish on Primary Blue). */
.hero-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
}

.hero-pills .pill {
  background: rgba(255, 255, 255, 0.94);
}

.hero-pills small {
  color: #cfe3f2;
}

/* Client 360 hero: compact disclosure explaining what health / status /
   at risk mean, styled to sit quietly on the dark band. */
.hero-legend {
  max-width: 850px;
  margin-top: 10px;
  color: #cfe3f2;
  font-size: 12px;
}

.hero-legend summary {
  cursor: pointer;
  color: var(--brand-teal);
  font-weight: 700;
}

.hero-legend p {
  margin: 6px 0 0;
  color: #cfe3f2;
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: flex-start;
}

/* Derived metrics live BELOW the band as normal light cards. */
.client-hero-metrics {
  margin-bottom: 18px;
}

/* ---- Segmented tabs (client 360, pricing version) — Vision-2031
   segmented control: bordered white track, solid-blue active pill. ---- */
.tab-bar {
  display: inline-flex;
  max-width: 100%;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  margin-bottom: 18px;
  overflow-x: auto;
}

.tab-btn {
  border: 0;
  border-radius: 7px;
  background: transparent;
  padding: 8px 14px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.tab-btn:hover {
  background: var(--paper);
  color: var(--ink);
}

.tab-btn.active {
  background: var(--brand-primary);
  color: #ffffff;
}

.tab-btn.active:hover {
  background: var(--primary-700);
  color: #ffffff;
}

/* Phase sub-tabs (project workspace / template editor). Completed phases
   (Done == Total, Total > 0) go green — pill-green tones, readable whether
   the sub-tab is active or not. */
.tab-btn.tab-done {
  color: var(--ok);
}

.tab-btn.tab-done:hover {
  color: #14603f;
}

.tab-btn.tab-done.active {
  background: var(--ok);
  color: #ffffff;
}

.tab-btn.tab-done.active:hover {
  background: #14603f;
  color: #ffffff;
}

/* Out-of-scope phases stay reachable (their re-include button lives inside)
   but read as muted in the bar. */
.tab-btn.tab-off {
  color: var(--brand-gray);
  font-style: italic;
  font-weight: 400;
}

.tab-btn.tab-off:hover {
  color: var(--muted);
}

.tab-btn.tab-off.active {
  background: var(--brand-gray);
  color: #ffffff;
}

[x-cloak] {
  display: none !important;
}

/* ---- Dashboard work queue (POC daily-view feel) ---- */
.queue-list {
  display: grid;
  gap: 10px;
}

.queue-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--brand-gray);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  padding: 12px 14px;
}

.queue-row--green {
  border-left-color: #1f8a5b;
}

.queue-row--amber {
  border-left-color: #e09b28;
}

.queue-row--red {
  border-left-color: var(--brand-coral);
}

.queue-row-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.queue-row-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  font-size: 15px;
}

.queue-row-sub,
.queue-row-counts {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.queue-row-actions {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

@media (max-width: 720px) {
  .queue-row {
    flex-direction: column;
  }

  .queue-row-actions {
    justify-content: flex-start;
  }
}

/* Inline quick-note capture on the client 360 */
.quick-note-form {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}

.quick-note-form textarea {
  flex: 1;
  resize: vertical;
}

/* ============================================================
   Pills & tags — classes emitted by Common/StatusPillMap (S9)
   ============================================================ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
}

/* Status dot inherits the pill's ink for free via currentColor. */
.pill::before {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}

.pill-green {
  background: rgba(31, 138, 91, 0.13);
  color: var(--ok);
}

.pill-amber {
  background: rgba(178, 106, 24, 0.14);
  color: var(--warn);
}

.pill-red {
  background: var(--coral-bg);
  color: var(--danger-ink);
}

.pill-blue {
  background: rgba(23, 105, 163, 0.12);
  color: var(--brand-primary);
}

.pill-sky {
  background: var(--sky-bg);
  color: var(--sky-ink);
}

.pill-teal {
  background: var(--teal-bg);
  color: var(--teal-ink);
}

.pill-violet {
  background: rgba(102, 80, 143, 0.13);
  color: #5d4787;
}

.pill-gray {
  background: #edf1f4;
  color: #4d6274;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: var(--teal-bg);
  color: var(--teal-ink);
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.btn:hover {
  background: var(--surface-tint);
  border-color: #c5d4e0;
  color: var(--ink);
  text-decoration: none;
}

.btn-primary {
  border-color: var(--brand-primary);
  background: var(--brand-primary);
  color: #ffffff;
}

.btn-primary:hover {
  border-color: var(--primary-700);
  background: var(--primary-700);
  color: #ffffff;
}

/* Destructive: deepened coral so white text keeps AA contrast;
   Coral Red proper carries the alert accents (PRD §4.2). */
.btn-danger {
  border-color: var(--danger-solid);
  background: var(--danger-solid);
  color: #ffffff;
}

.btn-danger:hover {
  border-color: #a52f2f;
  background: #a52f2f;
  color: #ffffff;
}

.btn-light {
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.btn-light:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 700;
}

.link-button {
  border: 0;
  background: transparent;
  padding: 0;
  min-height: 0;
  text-align: left;
  color: var(--brand-primary);
  font-weight: 700;
}

.link-button:hover {
  color: var(--primary-800);
  text-decoration: underline;
}

/* ============================================================
   Forms
   ============================================================ */
/* input:not([type]) — an <input> without a type attribute IS a text input,
   but attribute selectors miss it; without this the bare inputs in workspace
   tables and quick-add rows fall back to the browser-default look. */
input:not([type]),
input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-sky);
  box-shadow: var(--focus-ring);
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-primary);
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  color: #344456;
  font-weight: 700;
}

.field label {
  color: #344456;
  font-weight: 700;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
  color: #344456;
  font-weight: 700;
}

/* ASP.NET validation hooks */
.field-validation-error {
  color: var(--danger-ink);
  font-size: 12px;
  font-weight: 700;
}

.input-validation-error {
  border-color: var(--brand-coral);
}

/* Assignee picker — multi-select of people rendered as toggleable pills.
   Native checkboxes (visually hidden, still focusable) inside pill labels:
   binds as a plain List<string> post, no JS. Selected = solid brand blue. */
.assignee-field {
  border: 0;
  margin: 0 0 14px;
  padding: 0;
  min-width: 0;
}

.assignee-field legend {
  margin-bottom: 6px;
  padding: 0;
  color: #344456;
  font-weight: 700;
}

.assignee-field .field-hint {
  display: block;
  margin-top: 6px;
}

.assignee-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.assignee-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: #4d6274;
  padding: 4px 13px 4px 11px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
  user-select: none;
}

.assignee-option::before {
  content: "+";
  opacity: 0.5;
}

.assignee-option:hover {
  border-color: var(--brand-sky);
  color: var(--brand-primary);
}

.assignee-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.assignee-option:has(input:checked) {
  border-color: var(--brand-primary);
  background: var(--brand-primary);
  color: #fff;
}

.assignee-option:has(input:checked)::before {
  content: "✓";
  opacity: 1;
}

.assignee-option:has(input:focus-visible) {
  border-color: var(--brand-sky);
  box-shadow: var(--focus-ring);
}

@media (prefers-reduced-motion: no-preference) {
  .assignee-option {
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  }
}

/* Multi-action capture rows (note capture): each row = its own field block. */
.action-row {
  padding: 12px 0;
}

.action-row + .action-row {
  border-top: 1px dashed var(--line);
}

.validation-summary-errors {
  border: 1px solid var(--brand-coral);
  border-left: 5px solid var(--brand-coral);
  border-radius: var(--radius);
  background: rgba(255, 102, 102, 0.08);
  color: var(--danger-ink);
  padding: 11px 13px;
  margin-bottom: 14px;
  font-weight: 700;
}

.validation-summary-errors ul {
  margin: 0;
  padding-left: 18px;
}

.validation-summary-valid {
  display: none;
}

/* Alerts (coral = alert accent, never the sole signal) */
.alert {
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand-coral);
  border-radius: var(--radius);
  background: rgba(255, 102, 102, 0.07);
  padding: 12px 14px;
  margin-bottom: 14px;
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--line);
  background: var(--surface-tint);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.table td {
  padding: 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.table tbody tr:hover {
  background: #f7fafc;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  white-space: nowrap;
}

/* --- UIFIX sortable registers (wwwroot/js/site.js) ------------------------- */
table.sortable th:not([data-nosort]) {
  cursor: pointer;
  user-select: none;
  padding-right: 20px;
  position: relative;
}

table.sortable th:not([data-nosort]):hover {
  background: var(--surface-tint);
  color: var(--brand-primary);
}

table.sortable th[aria-sort]:not([data-nosort])::after {
  content: "";
  position: absolute;
  right: 7px;
  top: 50%;
  border: 4px solid transparent;
}

table.sortable th[aria-sort="ascending"]:not([data-nosort])::after {
  border-bottom-color: var(--brand-primary);
  margin-top: -6px;
}

table.sortable th[aria-sort="descending"]:not([data-nosort])::after {
  border-top-color: var(--brand-primary);
  margin-top: 2px;
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  max-width: 360px;
  border-radius: var(--radius);
  border-left: 4px solid var(--brand-teal);
  background: var(--primary-900);
  color: #ffffff;
  padding: 13px 15px;
  font-weight: 700;
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
  .toast {
    transition: transform 180ms ease, opacity 180ms ease;
  }

  .nav-item,
  .btn,
  input,
  select,
  textarea {
    transition: background-color 120ms ease, border-color 120ms ease,
      box-shadow 120ms ease, color 120ms ease;
  }

  .sidebar {
    transition: transform 200ms ease;
  }
}

/* ============================================================
   Auth layout (sign in / access denied)
   ============================================================ */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(49, 170, 225, 0.12), transparent 60%),
    radial-gradient(900px 420px at -10% 110%, rgba(107, 202, 213, 0.14), transparent 55%),
    var(--paper);
}

.auth-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-navy) 100%);
  color: #ffffff;
  padding: 22px 24px;
}

.auth-body {
  padding: 24px;
}

.auth-body h1 {
  font-size: 20px;
  margin-bottom: 6px;
}

.auth-foot {
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: var(--sidebar-width);
    transform: translateX(-105%);
    overflow-y: auto;
  }

  .app-shell.nav-open .sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 25;
    border: 0;
    padding: 0;
    background: rgba(11, 58, 93, 0.5);
  }

  .app-shell:not(.nav-open) .sidebar-backdrop {
    display: none;
  }

  .app-shell.nav-open .sidebar-backdrop {
    display: block;
  }

  .nav-toggle {
    display: inline-grid;
    place-items: center;
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .main {
    padding: 16px;
  }

  .topbar {
    flex-wrap: wrap;
    padding: 12px 16px;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .search-wrap {
    flex-basis: 100%;
    order: 3;
  }

  .form-grid,
  .card-grid {
    grid-template-columns: 1fr;
  }

  .hero-band {
    flex-direction: column;
    align-items: stretch;
  }

  .toast {
    left: 16px;
    right: 16px;
    max-width: none;
  }
}

/* Print: content only, no chrome */
@media print {
  .sidebar,
  .topbar,
  .toast {
    display: none !important;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  body {
    background: #ffffff;
  }
}

/* --- M6 layout utilities ------------------------------------------------ */
.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 18px;
  align-items: start;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.metric-row .metric strong {
  font-size: 17px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

/* Inline filter/quick-add controls: consistent height and sane intrinsic
   widths (the global width:100% otherwise lets flex shrink them oddly —
   collapsing date inputs, ragged text boxes). */
.filter-row input,
.filter-row select {
  width: auto;
  min-height: 38px;
  padding: 8px 12px;
}

.filter-row input[type="text"],
.filter-row input[type="search"],
.filter-row input:not([type]) {
  min-width: 140px;
}

.filter-row input[type="date"] {
  min-width: 150px;
}

.filter-row input[type="number"] {
  min-width: 90px;
}

.filter-row select {
  min-width: 130px;
}

.filter-row .check-field {
  margin-bottom: 0;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 6px 16px;
}

.panel h3 {
  margin: 18px 0 6px;
  font-size: 15px;
}

fieldset.field {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px 16px;
}

fieldset.field legend {
  font-weight: 700;
  font-size: 14px;
  padding: 0 6px;
}

/* --- M7 contact cards ---------------------------------------------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.contact-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.contact-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.contact-card small {
  color: var(--muted);
}

.contact-card p {
  margin: 4px 0;
}

/* --- M8 kanban board ------------------------------------------------------ */
.kanban {
  display: grid;
  grid-template-columns: repeat(7, minmax(280px, 1fr));
  gap: 16px;
  overflow-x: auto;
  align-items: stretch;
  padding-bottom: 10px;
}

.kanban-col {
  display: flex;
  flex-direction: column;
  background: var(--paper, #f4f6f8);
  border: 1px solid var(--line);
  border-top: 3px solid var(--brand-gray);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 420px;
}

.kanban-col-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  margin-bottom: 12px;
}

.kanban-col-head small {
  color: var(--muted);
}

.kanban-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

/* Dashed placeholder shown only when a column has no cards (kept live
   during drag via :has so drops into empty columns stay obvious). */
.kanban-empty {
  border: 1px dashed #c3cfda;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 26px 12px;
  margin-top: 10px;
}

.kanban-col:has(.kanban-card) .kanban-empty {
  display: none;
}

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(11, 58, 93, 0.04);
  overflow: hidden;
}

.kanban-drag-handle {
  display: grid;
  place-items: center;
  padding: 5px 0;
  background: #eef3f7;
  border-bottom: 1px solid var(--line);
  cursor: grab;
}

.kanban-drag-handle:active {
  cursor: grabbing;
}

.kanban-drag-handle span {
  width: 34px;
  height: 8px;
  background-image: radial-gradient(circle, #9fb2c2 1.3px, transparent 1.4px);
  background-size: 7px 4.5px;
  background-position: center;
}

.kanban-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 11px 13px 12px;
}

.kanban-card small {
  color: var(--muted);
}

.kanban-card-client .tag {
  margin-left: 4px;
  min-height: 20px;
  padding: 1px 8px;
  font-size: 11px;
}

.kanban-card-pain {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  line-height: 1.4;
}

.kanban-card-value {
  font-weight: 700;
}

.kanban-card-next {
  color: #14618f;
  font-size: 12px;
}

.kanban-card-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.kanban-card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 2px;
}

.kanban-stage-select {
  font-size: 12px;
  padding: 4px 6px;
  flex: 1;
}

/* --- UIFIX dashboard companies-by-status board -----------------------------
   Read-only distribution view (no drag, no status change) — recessive
   styling per dataviz sensibilities, counts as plain text in a pill. */
.status-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(200px, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.status-board-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 3px solid var(--brand-gray);
  border-radius: var(--radius);
  padding: 12px;
  min-width: 200px;
}

/* Column accents ride the status pill already in the column head, so board
   colours can never drift from StatusPillMap (S9 single vocabulary). */
.status-board-col:has(.status-board-col-head .pill-green),
.kanban-col:has(.kanban-col-head .pill-green) {
  border-top-color: #1f8a5b;
}

.status-board-col:has(.status-board-col-head .pill-amber),
.kanban-col:has(.kanban-col-head .pill-amber) {
  border-top-color: #e09b28;
}

.status-board-col:has(.status-board-col-head .pill-red),
.kanban-col:has(.kanban-col-head .pill-red) {
  border-top-color: var(--brand-coral);
}

.status-board-col:has(.status-board-col-head .pill-sky),
.kanban-col:has(.kanban-col-head .pill-sky) {
  border-top-color: var(--brand-sky);
}

.status-board-col:has(.status-board-col-head .pill-teal),
.kanban-col:has(.kanban-col-head .pill-teal) {
  border-top-color: var(--brand-teal);
}

.status-board-col:has(.status-board-col-head .pill-blue),
.kanban-col:has(.kanban-col-head .pill-blue) {
  border-top-color: var(--brand-primary);
}

.status-board-col:has(.status-board-col-head .pill-violet),
.kanban-col:has(.kanban-col-head .pill-violet) {
  border-top-color: #7a63a8;
}

.status-board-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.status-board-col-head strong {
  font-size: 13px;
}

.status-board-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.status-board-list li {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-board-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.status-board-more {
  font-size: 12px;
  font-weight: 700;
}

/* --- M11 modal + snooze --------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 32, 44, 0.45);
  display: grid;
  place-items: center;
  z-index: 60;
  padding: 20px;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 24px;
  max-width: 620px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 18px 45px rgba(30, 40, 54, 0.3);
}

.snooze-details summary {
  cursor: pointer;
  color: var(--brand-sky, #31aae1);
}

/* --- M18 quote builder ---------------------------------------------------- */
.quote-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.quote-main {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.quote-summary-wrap {
  position: sticky;
  top: 16px;
}

.quote-summary-panel {
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.tb-group-row td {
  background: var(--paper, #f4f6f8);
}

@media (max-width: 1100px) {
  .quote-layout {
    grid-template-columns: 1fr;
  }
  .quote-summary-wrap {
    position: static;
  }
}
