/* Ops System stylesheet. Colors come from the Denver AI Systems logo. */

:root {
  --purple-deep: #24103b;
  --violet: #6f34c8;
  --violet-bright: #8c4ae8;
  --gold: #b37d1a;
  --gold-soft: #dcb06c;
  --gray: #8b8291;

  --bg: #f6f4f9;
  --surface: #ffffff;
  --surface-2: #efeaf5;
  --text: #24103b;
  --muted: #675e70;
  --border: #e2d9ec;
  --primary: #6f34c8;
  --primary-text: #ffffff;
  --primary-hover: #5214a0;
  --accent: #b37d1a;
  --sidebar-bg: #ffffff;
  --menu-active-bg: #efe6fb;
  --menu-active-text: #4a1690;
  --danger-bg: #fdecef;
  --danger-text: #8a1530;
  --focus: #8c4ae8;
  --shadow: 0 1px 2px rgba(36, 16, 59, 0.06), 0 4px 16px rgba(36, 16, 59, 0.06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #130a20;
    --surface: #1d1230;
    --surface-2: #26193b;
    --text: #f1ecf7;
    --muted: #b2a9bb;
    --border: #3a2b50;
    --primary: #9c58f3;
    --primary-text: #ffffff;
    --primary-hover: #ad6af8;
    --accent: #dcb06c;
    --sidebar-bg: #180e28;
    --menu-active-bg: #2f1d4a;
    --menu-active-text: #e4d3fc;
    --danger-bg: #3d1420;
    --danger-text: #ffc2cf;
    --focus: #bd7bfa;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #130a20;
  --surface: #1d1230;
  --surface-2: #26193b;
  --text: #f1ecf7;
  --muted: #b2a9bb;
  --border: #3a2b50;
  --primary: #9c58f3;
  --primary-text: #ffffff;
  --primary-hover: #ad6af8;
  --accent: #dcb06c;
  --sidebar-bg: #180e28;
  --menu-active-bg: #2f1d4a;
  --menu-active-text: #e4d3fc;
  --danger-bg: #3d1420;
  --danger-text: #ffc2cf;
  --focus: #bd7bfa;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

/* Logo: the dark-text version on light surfaces, the white-text version on dark ones. */
.logo-for-dark { display: none; }
:root[data-theme="dark"] .logo-for-light { display: none; }
:root[data-theme="dark"] .logo-for-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .logo-for-light { display: none; }
  :root[data-theme="system"] .logo-for-dark { display: block; }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 0.75em; }

.muted { color: var(--muted); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.icon { width: 20px; height: 20px; flex: none; }

/* Buttons and forms */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.button:hover { border-color: var(--primary); }
.button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.button.small { padding: 5px 10px; font-size: 0.875rem; }
.button.ghost { background: transparent; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; width: 100%;
}
select { width: auto; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }

.stack { display: flex; flex-direction: column; gap: 14px; }
.stack label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 0.925rem; }
.stack label .muted { font-weight: 400; }

.alert {
  background: var(--danger-bg); color: var(--danger-text);
  border-radius: 8px; padding: 10px 12px;
}

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; box-shadow: var(--shadow);
}

/* Sign-in, setup and error pages */
body.standalone {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.standalone-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px 24px; box-shadow: var(--shadow);
}
.standalone-card h1 { font-size: 1.35rem; }
.standalone-logo { margin: 0 auto 20px; max-width: 260px; }
.standalone-logo .logo { width: 100%; height: auto; }
.standalone-card .button.primary { margin-top: 4px; }
body.standalone .site-footer { border: 0; }

/* App shell */
body.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; flex: none; background: var(--sidebar-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand {
  display: flex; flex-direction: column; gap: 6px; padding: 18px 18px 14px; text-decoration: none; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.brand-logo .logo { width: 170px; height: auto; }
.brand-business { font-weight: 700; font-size: 1rem; overflow-wrap: anywhere; }
/* The business's own logo (Settings, Logo). No display rule here: .logo-for-light and .logo-for-dark decide it. */
.business-logo { max-width: 170px; max-height: 64px; width: auto; height: auto; margin-top: 4px; }
.standalone-business .business-logo { max-width: 260px; max-height: 90px; margin: 0 0 8px; }
.logo-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.logo-card h3 { margin-top: 0; }
.logo-preview {
  display: flex; align-items: center; justify-content: center; min-height: 120px; padding: 20px; border-radius: 10px;
  border: 1px solid var(--border); margin-bottom: 8px;
}
.logo-preview img { max-width: 100%; max-height: 90px; width: auto; height: auto; }
/* Each preview keeps its own background in both themes, so each version is seen as it will be. */
.logo-preview-light { background: #ffffff; color: #24103b; }
.logo-preview-dark { background: #180e28; color: #f4effa; }
.logo-preview-name { font-weight: 700; font-size: 1.1rem; }

.menu ul { list-style: none; margin: 0; padding: 10px 10px 20px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-weight: 500;
}
.menu-item .icon { color: var(--muted); }
.menu-item:hover { background: var(--surface-2); color: var(--text); }
.menu-item.active { background: var(--menu-active-bg); color: var(--menu-active-text); font-weight: 650; }
.menu-item.active .icon { color: var(--menu-active-text); }
.menu-divider { height: 1px; background: var(--border); margin: 8px 6px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.page-title { font-size: 1.25rem; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-right form { margin: 0; }
.theme-select { padding: 5px 8px; font-size: 0.875rem; }
.user-name { font-weight: 600; font-size: 0.9rem; white-space: nowrap; }
.menu-button {
  display: none; background: transparent; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 6px; cursor: pointer;
}

.content { padding: 24px; flex: 1; }
.placeholder { max-width: 640px; }

.subnav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.subnav a {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  text-decoration: none; color: var(--text); background: var(--surface); font-size: 0.9rem;
}
.subnav a.active { background: var(--menu-active-bg); color: var(--menu-active-text); border-color: transparent; font-weight: 650; }

.site-footer {
  padding: 14px 24px; color: var(--muted); font-size: 0.825rem; border-top: 1px solid var(--border);
  text-align: center;
}

.scrim { position: fixed; inset: 0; background: rgba(10, 4, 20, 0.45); z-index: 19; }

/* Narrow screens: the sidebar slides in from the left behind a menu button. */
@media (max-width: 799px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 20; transform: translateX(-100%);
    transition: transform 0.2s ease; box-shadow: var(--shadow);
  }
  body.menu-open .sidebar { transform: none; }
  .menu-button { display: inline-flex; }
  .topbar { padding: 10px 16px; gap: 8px; }
  .content { padding: 16px; }
  .user-name { display: none; }
  .page-title { font-size: 1.1rem; }
}

/* ---- Shared pieces for content screens (Integrations, AI Usage) ---- */
:root {
  --ok-bg: #e6f5ec;
  --ok-text: #135c33;
  --info-bg: #f3ecfc;
  --info-text: #3d1577;
  --meter-bg: #ece6f3;
  --meter-over: #c0303f;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --ok-bg: #12321f;
    --ok-text: #a9e8c0;
    --info-bg: #2a1a42;
    --info-text: #e4d3fc;
    --meter-bg: #2e2142;
    --meter-over: #ff7b8c;
  }
}
:root[data-theme="dark"] {
  --ok-bg: #12321f;
  --ok-text: #a9e8c0;
  --info-bg: #2a1a42;
  --info-text: #e4d3fc;
  --meter-bg: #2e2142;
  --meter-over: #ff7b8c;
}

[hidden] { display: none !important; }

.section { margin-bottom: 20px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.sub-heading { font-size: 1rem; margin-top: 20px; }
.small-text { font-size: 0.85rem; }
.danger-text { color: var(--danger-text); }
.break { overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.back-link { margin-bottom: 12px; }
.empty p:last-child, .card > p:last-child { margin-bottom: 0; }
.empty-line { color: var(--muted); }
.plain-list { margin: 0 0 0.5em; padding-left: 1.2em; }
code { font-family: ui-monospace, Consolas, Menlo, monospace; font-size: 0.85em; overflow-wrap: anywhere; }

.flash { border-radius: 8px; padding: 10px 12px; margin: 0 0 16px; background: var(--info-bg); color: var(--info-text); overflow-wrap: anywhere; }
.flash p:last-child { margin-bottom: 0; }
.flash a { color: inherit; font-weight: 600; }
.flash-ok { background: var(--ok-bg); color: var(--ok-text); }
.flash-error { background: var(--danger-bg); color: var(--danger-text); }

.button.danger { background: var(--danger-bg); border-color: var(--danger-text); color: var(--danger-text); }
.button.danger:hover { border-color: var(--danger-text); color: var(--danger-text); filter: brightness(1.05); }
.button.ghost.danger-text { color: var(--danger-text); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.check { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 500 !important; }
.check input { width: auto; }

.form-card { max-width: 640px; }
.field-group { display: flex; flex-direction: column; gap: 5px; }
.field-group > label { font-weight: 600; font-size: 0.925rem; }
.presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 650; }
.badge-on { background: var(--ok-bg); color: var(--ok-text); }
.badge-off { background: var(--surface-2); color: var(--muted); }
.status { font-weight: 650; }
.status-ok { color: var(--ok-text); }
.status-bad { color: var(--danger-text); }
.flag { display: inline-block; padding: 0 6px; border-radius: 6px; background: var(--info-bg); color: var(--info-text); font-size: 0.8rem; font-weight: 600; }

/* Provider cards */
.provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; margin-bottom: 10px; align-items: start; }
.provider-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.provider-card.is-off { opacity: 0.8; }
.provider-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.provider-head h3 { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.facts { margin: 0; display: grid; gap: 6px; }
.facts > div { display: grid; grid-template-columns: 90px 1fr; gap: 8px; }
.facts dt { color: var(--muted); font-size: 0.875rem; }
.facts dd { margin: 0; min-width: 0; }
.facts .note { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.spend-line { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 0.925rem; margin-bottom: 5px; }
.spend .small-text { margin: 6px 0 0; }

.meter, .share-bar { height: 8px; border-radius: 999px; background: var(--meter-bg); overflow: hidden; }
.meter > span, .share-bar > span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.meter-over > span { background: var(--meter-over); }

/* Tables: on a narrow screen a wide table scrolls inside its own box, never the page. */
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; border: 1px solid var(--border); border-radius: 8px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table thead th { background: var(--surface-2); font-weight: 650; font-size: 0.825rem; color: var(--muted); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form { display: inline; margin: 0; }
/* Long names wrap between words; a single long name may break, but a cell never shrinks below this. */
.table td.break { overflow-wrap: break-word; min-width: 9em; }
.calls-table td.break { min-width: 140px; }
.rate-note-text { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 2px; }

.rate-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 10px; align-items: end; }
.rate-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; font-weight: 600; }
.rate-form label.rate-note { grid-column: 1 / -1; }
.rate-form label .muted { font-weight: 400; }
.rate-form-buttons { display: flex; gap: 8px; }
.table tr.editing td { background: var(--surface-2); }

/* AI Usage */
.month-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.month-pick input { width: 11em; padding: 5px 8px; }
.month-csv { margin-left: auto; }
.month-title { font-size: 1.15rem; margin-bottom: 12px; }
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-value { font-size: 1.45rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-note { color: var(--muted); font-size: 0.8rem; }
.chart-box { position: relative; height: 240px; }
.budget-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.budget-list .small-text { margin: 4px 0 0; }
.group-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; margin-bottom: 20px; }
.group-grid > .card { min-width: 0; }
.share-col { width: 26%; min-width: 110px; }
.share { display: flex; align-items: center; gap: 8px; }
.share .share-bar { flex: 1; min-width: 50px; }
.share-num { font-size: 0.8rem; color: var(--muted); width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 799px) {
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hide-narrow { display: none; }
  .card { padding: 16px; }
}

/* AI Usage: forecast by model */
.forecast-table .group-head { text-align: center; border-bottom: 1px solid var(--border); }
.cell-note { display: block; font-size: 0.78rem; color: var(--muted); font-weight: 400; }

/* ---- Org chart and Dashboard (brief 03) ---- */
:root {
  --ring-owner: #24103b;
  --ring-violet: #6f34c8;
  --ring-gold: #b37d1a;
  --ring-teal: #0f8a84;
  --ring-rose: #c23a6b;
  --ring-blue: #2f6fd0;
  --ring-green: #2e8b45;
  --ring-orange: #c95f14;
  --ring-slate: #5f6b7a;
  --edge: #c9bcd9;
  --waiting-bg: #fbf1de;
  --waiting-text: #7a520b;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --ring-owner: #e4d3fc;
    --ring-violet: #b383ff;
    --ring-gold: #e3b864;
    --ring-teal: #3fc7bd;
    --ring-rose: #f07aa3;
    --ring-blue: #7aa8f5;
    --ring-green: #6fcf86;
    --ring-orange: #f39a55;
    --ring-slate: #a5b0bf;
    --edge: #4d3b66;
    --waiting-bg: #3a2a0c;
    --waiting-text: #f2cf8a;
  }
}
:root[data-theme="dark"] {
  --ring-owner: #e4d3fc;
  --ring-violet: #b383ff;
  --ring-gold: #e3b864;
  --ring-teal: #3fc7bd;
  --ring-rose: #f07aa3;
  --ring-blue: #7aa8f5;
  --ring-green: #6fcf86;
  --ring-orange: #f39a55;
  --ring-slate: #a5b0bf;
  --edge: #4d3b66;
  --waiting-bg: #3a2a0c;
  --waiting-text: #f2cf8a;
}

.ring-owner { --ring: var(--ring-owner); }
.ring-violet { --ring: var(--ring-violet); }
.ring-gold { --ring: var(--ring-gold); }
.ring-teal { --ring: var(--ring-teal); }
.ring-rose { --ring: var(--ring-rose); }
.ring-blue { --ring: var(--ring-blue); }
.ring-green { --ring: var(--ring-green); }
.ring-orange { --ring: var(--ring-orange); }
.ring-slate { --ring: var(--ring-slate); }

.org-heading { overflow-wrap: anywhere; }
.oc-chart { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.oc-svg { display: block; height: auto; margin: 0 auto; font-family: inherit; }
/* Lines and outlines (Marcus, 10 Nov 2026: thicker and clearer on light and dark). Mixed from the theme's own text
   and surface, so they keep their contrast in both themes: AI staff violet, real people gold, the owner filled. */
.oc-svg, .oc-list, .oc-legend {
  --oc-line: color-mix(in srgb, var(--text) 58%, var(--surface));
  --oc-outline: color-mix(in srgb, var(--text) 38%, var(--surface));
  --oc-ai: var(--primary);
  --oc-person: var(--accent);
  --oc-owner-fill: color-mix(in srgb, var(--primary) 14%, var(--surface));
}
.oc-edge { fill: none; stroke: var(--oc-line); stroke-width: 3; stroke-linejoin: round; }
.oc-card { fill: var(--surface); stroke: var(--oc-outline); stroke-width: 2; }
[data-staff="ai"] .oc-card { stroke: var(--oc-ai); }
[data-staff="person"] .oc-card { stroke: var(--oc-person); }
.oc-owner .oc-card { fill: var(--oc-owner-fill); stroke: var(--primary); stroke-width: 3.5; }
.oc-node { cursor: default; }
a.oc-node { cursor: pointer; }
a.oc-node:hover .oc-card { stroke-width: 3.5; }
a.oc-node:focus { outline: none; }
a.oc-node:focus-visible .oc-card { stroke: var(--focus); stroke-width: 4; }
/* The key under the chart. */
.oc-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 0 0; font-size: 0.85rem; color: var(--muted); }
.oc-key { display: inline-flex; align-items: center; gap: 6px; }
.oc-key::before { content: ''; width: 22px; height: 14px; border-radius: 4px; border: 2px solid var(--oc-outline); background: var(--surface); }
.oc-key-owner::before { border: 3px solid var(--primary); background: var(--oc-owner-fill); }
.oc-key-ai::before { border-color: var(--oc-ai); }
.oc-key-person::before { border-color: var(--oc-person); }
.oc-key-line::before { height: 0; border: 0; border-top: 3px solid var(--oc-line); border-radius: 0; background: none; }
.oc-avatar { fill: color-mix(in srgb, var(--ring) 14%, var(--surface)); stroke: var(--ring); stroke-width: 3; }
.oc-initials { fill: var(--text); font-size: 13px; font-weight: 700; }
.oc-avatar-ring { fill: none; stroke: var(--ring); stroke-width: 3; }
/* The "AI" badge on AI staff: the text color as a fill, so it reads in both themes. */
.oc-badge-box { fill: var(--text); stroke: var(--surface); stroke-width: 1.5; }
.oc-badge-text { fill: var(--surface); font-size: 9.5px; font-weight: 800; letter-spacing: 0.04em; }
.oc-note { fill: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.oc-name { fill: var(--text); font-size: 18px; font-weight: 700; }
.oc-title { fill: var(--muted); font-size: 13px; }
.oc-pill { fill: var(--surface-2); }
.oc-pill-text { fill: var(--muted); font-size: 11px; font-weight: 600; }
.oc-pill.oc-pill-waiting { fill: var(--waiting-bg); }
.oc-pill-text.oc-pill-waiting { fill: var(--waiting-text); }

/* Under 600 px the chart becomes an indented list. */
.oc-narrow { display: none; }
@media (max-width: 599px) {
  .oc-chart { display: none; }
  .oc-narrow { display: block; }
}
.oc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
/* Each row carries a rail for every level above it, so a team's line runs down beside it; a tick joins the row. */
.oc-li {
  position: relative; padding: 0 0 6px calc(var(--level, 0) * 18px);
  background-image: repeating-linear-gradient(to right, transparent 0 7px, var(--oc-line) 7px 10px, transparent 10px 18px);
  background-size: calc(var(--level, 0) * 18px) 100%; background-repeat: no-repeat;
}
.oc-li:not(:first-child)::before {
  content: ''; position: absolute; left: calc((var(--level, 1) - 1) * 18px + 7px); width: 11px; height: 3px;
  top: calc(50% - 4.5px); background: var(--oc-line);
}
.oc-li-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 2px solid var(--oc-outline);
  border-radius: 10px; background: var(--surface); color: var(--text); text-decoration: none; min-width: 0;
}
.oc-li-row[data-staff="ai"] { border-color: var(--oc-ai); }
.oc-li-row[data-staff="person"] { border-color: var(--oc-person); }
div.oc-li-row { background: var(--oc-owner-fill); border: 3px solid var(--primary); }
a.oc-li-row:hover { border-color: var(--primary); color: var(--text); }
.oc-li-avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  border: 3px solid var(--ring); background: color-mix(in srgb, var(--ring) 14%, var(--surface));
  font-size: 0.8rem; font-weight: 700; position: relative;
}
.oc-li-avatar.has-photo img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.oc-li-badge {
  position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); background: var(--text); color: var(--surface);
  border: 1px solid var(--surface); border-radius: 999px; font-size: 0.56rem; font-weight: 800; line-height: 1; padding: 2px 4px;
}
.oc-li-note { color: var(--muted); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.oc-li-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* Names and titles wrap; nothing is cut. */
.oc-li-name, .oc-li-title { overflow-wrap: anywhere; }
.oc-li-name { font-weight: 700; font-size: 1.125rem; line-height: 1.25; }
.oc-li-title { color: var(--muted); font-size: 0.85rem; line-height: 1.3; }
.oc-li-counts { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.oc-li-count {
  font-size: 0.75rem; font-weight: 600; color: var(--muted); background: var(--surface-2);
  border-radius: 999px; padding: 0 8px; white-space: nowrap;
}
.oc-li-count.is-waiting { background: var(--waiting-bg); color: var(--waiting-text); }

/* Dashboard cards */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); gap: 16px; align-items: start; }
.dash-card { min-width: 0; }
.dash-card h2 { margin: 0; }
.dash-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.dash-count {
  min-width: 2em; text-align: center; padding: 1px 9px; border-radius: 999px; font-weight: 700;
  background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums;
}
.dash-count.is-waiting { background: var(--waiting-bg); color: var(--waiting-text); }
.dash-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; }
.dash-list > li { padding: 8px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.dash-list > li:first-child { padding-top: 0; }
.dash-list > li:last-child { border-bottom: 0; }
.dash-item-title { display: block; font-weight: 600; overflow-wrap: anywhere; }
.dash-item-note { display: block; color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.dash-staff-name { color: var(--text); font-weight: 700; }
.dash-event { display: flex; gap: 12px; }
.dash-event-time { flex: none; width: 4.8em; color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.dash-event-text { min-width: 0; }
.dash-ai { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.dash-ai-row .small-text { margin: 4px 0 0; }
.dash-ai-name { min-width: 0; overflow-wrap: anywhere; }
.dash-card > p.small-text:last-child { margin-bottom: 0; }

.start-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.start-item { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.start-item a, .start-item .link-button { overflow-wrap: anywhere; }
.start-check {
  flex: none; width: 20px; height: 20px; margin-top: 1px; border-radius: 6px; border: 2px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center; color: var(--primary-text);
}
.start-check svg { width: 14px; height: 14px; }
.start-item.is-done .start-check { background: var(--primary); border-color: var(--primary); }
.start-item.is-done a, .start-item.is-done .link-button { color: var(--muted); text-decoration: line-through; }
.start-form { margin: 0; display: inline; }
.link-button {
  background: none; border: 0; padding: 0; font: inherit; color: var(--primary); text-decoration: underline;
  cursor: pointer; text-align: left;
}
.link-button:hover { color: var(--primary-hover); }
.start-dismiss { margin: 0; }

/* ---- Setup interview (first run and Admin rerun) ---- */
.setup-card { max-width: 760px; padding: 28px 28px 24px; }
.setup-logo { max-width: 200px; margin-bottom: 14px; }
.setup h1 { font-size: 1.4rem; margin-top: 4px; }
.setup h2 { font-size: 1.05rem; }
.setup h3 { font-size: 1rem; margin: 0; }
.setup-progress { margin-bottom: 18px; }
.setup-count { margin: 0 0 6px; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.setup-meter { margin-bottom: 10px; }
.setup-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 6px; font-size: 0.8rem; }
.setup-steps li { padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.setup-steps li a { color: inherit; text-decoration: none; }
.setup-steps li a:hover { text-decoration: underline; }
.setup-steps li.done { color: var(--text); }
.setup-steps li.current { background: var(--menu-active-bg); color: var(--menu-active-text); font-weight: 650; }
.setup-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.setup-nav-gap { flex: 1; }
.setup-note { background: var(--info-bg); color: var(--info-text); border-radius: 8px; padding: 8px 12px; margin: 0; }
.field-error { color: var(--danger-text); font-weight: 600; font-size: 0.875rem; }
.setup-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.setup-fieldset legend { font-weight: 600; font-size: 0.925rem; padding: 0; margin-bottom: 6px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 6px 12px; }
.choice-list { display: flex; flex-direction: column; gap: 6px; }
.stack label.choice, label.choice {
  flex-direction: row; align-items: center; gap: 8px; font-weight: 500;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--surface); cursor: pointer;
}
label.choice input { width: auto; margin: 0; accent-color: var(--primary); }
label.choice:has(input:checked) { border-color: var(--primary); background: var(--menu-active-bg); }
.day-row { display: flex; flex-wrap: wrap; gap: 6px; }
label.choice.day { padding: 6px 10px; }
.time-input { max-width: 10em; }
.budget-input { max-width: 10em; }
.setup-section { margin: 20px 0; }
.provider-choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 14px; }
.provider-choice { display: flex; flex-direction: column; gap: 10px; padding: 16px; min-width: 0; }
.provider-choice label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 0.9rem; }
.provider-choice label .muted { font-weight: 400; }
.provider-choice label.choice { flex-direction: row; }
.provider-choice .button.primary { align-self: flex-start; }
.note-list { margin: 0; padding-left: 1.1em; display: flex; flex-direction: column; gap: 3px; }
.provider-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.provider-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.provider-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 260px; }
.setup-final { margin-top: 10px; }
.position-card { margin: 0; padding: 14px 16px 16px; min-width: 0; }
.position-legend { display: flex; align-items: center; gap: 8px; font-weight: 650; padding: 0 6px; flex-wrap: wrap; max-width: 100%; overflow-wrap: anywhere; }
.position-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.position-fields .wide { grid-column: 1 / -1; }
.position-fields select { width: 100%; }
.position-actions { margin-top: 12px; }
.avatar-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; flex: none; border: 3px solid var(--ring-slate, #5f6b7a); background: var(--surface); vertical-align: middle; }
.avatar-dot.color-violet { border-color: var(--ring-violet, #6f34c8); }
.avatar-dot.color-gold { border-color: var(--ring-gold, #b37d1a); }
.avatar-dot.color-teal { border-color: var(--ring-teal, #0f8a84); }
.avatar-dot.color-rose { border-color: var(--ring-rose, #c23a6b); }
.avatar-dot.color-blue { border-color: var(--ring-blue, #2f6fd0); }
.avatar-dot.color-green { border-color: var(--ring-green, #2e8b45); }
.avatar-dot.color-orange { border-color: var(--ring-orange, #c95f14); }
.avatar-dot.color-slate { border-color: var(--ring-slate, #5f6b7a); }
.models-table th[scope="row"] { font-weight: 600; white-space: normal; min-width: 8em; }
.models-table th[scope="row"] .avatar-dot { margin-right: 6px; }
.models-table select { width: 100%; min-width: 10em; }
.typed-label { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; font-weight: 500; }
.estimate-note { margin: 0; }
.rule-list { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 10px; }
.rule-item { display: flex; gap: 8px; align-items: flex-start; }
.rule-item textarea { flex: 1; min-width: 0; }
.review { display: flex; flex-direction: column; gap: 14px; }
.review-block { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.review-block p:last-child, .review-block ol:last-child, .review-block ul:last-child { margin-bottom: 0; }
.review-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.review-head h2 { margin: 0; }
.review-list { margin: 0; display: grid; gap: 4px; }
.review-list > div { display: grid; grid-template-columns: 120px 1fr; gap: 8px; }
.review-list dt { color: var(--muted); font-size: 0.9rem; }
.review-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.review-staff { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.review-staff li { display: flex; gap: 8px; align-items: baseline; overflow-wrap: anywhere; }
.setup-discard { margin-top: 12px; }
.setup-discard .button { white-space: normal; text-align: left; }
.content .setup { max-width: 780px; }

@media (max-width: 599px) {
  .setup-card { padding: 20px 16px; }
  .setup-steps { display: none; }
  .position-fields { grid-template-columns: minmax(0, 1fr); }
  .review-list > div { grid-template-columns: minmax(0, 1fr); gap: 0; }
  /* The models table becomes one card per staff member. */
  .models-wrap { border: 0; overflow: visible; }
  .models-table, .models-table tbody, .models-table tr, .models-table th, .models-table td { display: block; width: 100%; }
  .models-table thead { display: none; }
  .models-table tr { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
  .models-table th, .models-table td { border: 0; padding: 4px 0; text-align: left; }
  .models-table td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: 0.8rem; font-weight: 600; }
  .models-table td.num { text-align: left; }
}
.setup input, .setup textarea, .setup select { font-weight: 400; }
.models-table tbody tr:last-child th { border-bottom: 0; }
@media (min-width: 600px) {
  .models-table td.js-estimate { white-space: nowrap; }
  /* A select at width 100% gives its column no width of its own, so the table squeezed it and cut the
     model name short. The column now grows to the longest model name in the list. */
  .models-table select.js-model { min-width: max-content; }
}

/* Dashboard: rename link beside the system name */
.heading-edit { font-weight: 500; margin-left: 8px; vertical-align: middle; }

/* ---- Tasks and Queue (brief 04, tasks part) ---- */
.menu-badge {
  margin-left: auto; min-width: 1.6em; padding: 0 7px; border-radius: 999px; text-align: center;
  background: var(--waiting-bg); color: var(--waiting-text); font-size: 0.78rem; font-weight: 700;
  font-variant-numeric: tabular-nums; line-height: 1.6;
}
.topbar-new { white-space: nowrap; }
.topbar-new .icon { width: 16px; height: 16px; }
@media (max-width: 599px) {
  .topbar-new { padding: 6px; }
  .topbar-new-label { display: none; }
}

.new-task-form textarea, .tp-task-side textarea, .tp-history-note textarea { resize: vertical; }
/* Typed text is regular weight, though .stack labels are bold. */
.new-task-form :is(input, select, textarea), .tp-task-side :is(input, select, textarea), .tp-history-note textarea, .queue-send-form input { font-weight: 400; }
.nt-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 14px; align-items: end; }
.nt-row select, .new-task-form select { width: 100%; }

.tp-task-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 16px; align-items: start; }
.tp-task-main, .tp-task-side { min-width: 0; }
.tp-task-side .card h2 { font-size: 1.05rem; }
.tp-task-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tp-task-title { overflow-wrap: anywhere; margin: 0 0 10px; font-size: 1.3rem; }
.tp-task-status { flex: none; padding: 2px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 650; background: var(--surface-2); color: var(--muted); }
.tp-task-status.status-open { background: var(--info-bg); color: var(--info-text); }
.tp-task-status.status-waiting_owner { background: var(--waiting-bg); color: var(--waiting-text); }
.tp-task-status.status-done { background: var(--ok-bg); color: var(--ok-text); }
.tp-task-label { font-size: 0.85rem; color: var(--muted); font-weight: 650; margin: 14px 0 4px; }
.tp-task-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 8px; }
.tp-task-facts { margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--border); display: grid; gap: 6px; }
.tp-task-facts > div { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); gap: 8px; }
.tp-task-facts dt { color: var(--muted); font-size: 0.9rem; }
.tp-task-facts dd { margin: 0; overflow-wrap: anywhere; }
.tp-history { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; }
.tp-history-item { padding: 8px 0 8px 14px; border-left: 2px solid var(--border); position: relative; }
.tp-history-item::before {
  content: ""; position: absolute; left: -5px; top: 15px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--primary);
}
.tp-history-item.kind-note::before { border-color: var(--gold-soft); }
.tp-history-meta { font-size: 0.9rem; overflow-wrap: anywhere; }
.tp-history-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.tp-history-note { padding-top: 12px; border-top: 1px solid var(--border); }
.tp-task-edit > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.tp-task-edit > summary::-webkit-details-marker { display: none; }
.tp-task-edit > summary::before { content: "+"; font-weight: 700; color: var(--primary); width: 1em; }
.tp-task-edit[open] > summary::before { content: "\2212"; }
.tp-task-edit > summary h2 { margin: 0; display: inline; }
.tp-task-edit[open] > summary { margin-bottom: 14px; }

.queue-intro { margin-bottom: 16px; }
.queue-heading { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.dash-count.count-overdue { background: var(--danger-bg); color: var(--danger-text); }
.queue-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.queue-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; padding: 12px 14px; }
.group-overdue .queue-item { border-left: 3px solid var(--danger-text); }
.queue-main { min-width: 0; flex: 1 1 280px; display: flex; flex-direction: column; gap: 2px; }
.queue-title { font-weight: 650; overflow-wrap: anywhere; }
.queue-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; color: var(--muted); font-size: 0.85rem; }
.badge-waiting { background: var(--waiting-bg); color: var(--waiting-text); font-size: 0.75rem; padding: 0 8px; }
.queue-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; }
.queue-form { margin: 0; }
.queue-send > summary { list-style: none; }
.queue-send > summary::-webkit-details-marker { display: none; }
.queue-send[open] { flex-basis: 100%; }
.queue-send-form { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; font-weight: 600; }
.queue-send-row { display: flex; gap: 6px; }
.queue-send-row input { padding: 5px 9px; font-size: 0.9rem; min-width: 0; }
.queue-empty p { margin: 0; }

@media (max-width: 899px) {
  .tp-task-layout { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Talk tab (staff page, brief 04) ---- */
:root {
  --talk-user-bg: #efe6fb;
  --talk-user-text: #2c0f55;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] { --talk-user-bg: #2f1d4a; --talk-user-text: #f1ecf7; }
}
:root[data-theme="dark"] { --talk-user-bg: #2f1d4a; --talk-user-text: #f1ecf7; }

.talk-state { margin-bottom: 16px; }
.talk-state p:last-child { margin-bottom: 0; }
.talk-state-links { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.talk-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.talk-side { min-width: 0; }
.talk-side-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.talk-side-head .sub-heading { margin: 0; }
.talk-pick select { width: 100%; }
.talk-pick { display: flex; gap: 6px; }
.talk-list { display: none; list-style: none; margin: 0; padding: 0; }
.talk-list-item {
  display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 8px;
  color: var(--text); text-decoration: none; border: 1px solid transparent;
}
.talk-list-item:hover { background: var(--surface-2); color: var(--text); }
.talk-list-item.active { background: var(--menu-active-bg); color: var(--menu-active-text); }
.talk-list-title { font-weight: 600; overflow-wrap: anywhere; }
.talk-list-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 0.8rem; color: var(--muted); }
.talk-list-item.active .talk-list-meta { color: inherit; }
.talk-main { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.talk-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px; }
.talk-title { margin: 0; font-size: 1.1rem; overflow-wrap: anywhere; min-width: 0; flex: 1 1 200px; }
.talk-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
.talk-tool > summary { list-style: none; }
.talk-tool > summary::-webkit-details-marker { display: none; }
.talk-tool[open] { flex-basis: 100%; }
.talk-tool-form {
  margin-top: 8px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; max-width: 420px;
}
.talk-tool-form label:not(.check) { font-weight: 600; font-size: 0.9rem; }
.talk-tool-form .small-text { margin: 0; }
.talk-messages {
  display: flex; flex-direction: column; gap: 12px; padding: 4px 0;
}
.talk-empty { margin: 8px 0; }
.talk-msg {
  max-width: 100%; border-radius: 12px; padding: 10px 14px; border: 1px solid var(--border);
  background: var(--surface); overflow-wrap: anywhere;
}
.talk-msg.talk-user { background: var(--talk-user-bg); color: var(--talk-user-text); border-color: transparent; align-self: flex-end; max-width: min(100%, 680px); }
.talk-msg.talk-assistant { align-self: stretch; }
.talk-who { font-weight: 650; font-size: 0.85rem; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.talk-who .staff-avatar-sm { width: 26px; height: 26px; font-size: 0.62rem; }
.talk-text p { margin: 0 0 0.6em; }
.talk-text p:last-child, .talk-text ul:last-child, .talk-text ol:last-child { margin-bottom: 0; }
.talk-text ul, .talk-text ol { margin: 0 0 0.6em; padding-left: 1.4em; }
.talk-text code { font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.talk-text pre { background: var(--surface-2); padding: 10px; border-radius: 8px; overflow-x: auto; margin: 0 0 0.6em; }
.talk-text pre code { background: none; padding: 0; }
.talk-plain { white-space: pre-wrap; }
.talk-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: 0.78rem; color: var(--muted); }
.talk-user .talk-meta { color: inherit; opacity: 0.75; }
.talk-meta a { font-weight: 600; }
.talk-note { margin: 6px 0 0; font-size: 0.8rem; color: var(--muted); font-style: italic; }
.talk-msg.is-streaming .talk-meta { font-style: italic; }
.talk-form { display: flex; flex-direction: column; gap: 8px; }
.talk-form textarea { resize: vertical; min-height: 84px; }
.talk-form-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.talk-status { margin: 0; flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.talk-error { margin: 0; }

@media (min-width: 1000px) {
  .talk-layout { grid-template-columns: 240px minmax(0, 1fr); align-items: start; }
  .talk-side { position: sticky; top: 72px; max-height: calc(100vh - 96px); overflow-y: auto; }
  .talk-pick { display: none; }
  .talk-list { display: block; }
  .talk-messages { max-height: 62vh; overflow-y: auto; padding-right: 4px; }
}

/* ---- Staff screen, Edit staff and staff pages (brief 04) ---- */
.staff-avatar {
  flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
  border: 3px solid var(--ring, var(--ring-slate)); background: color-mix(in srgb, var(--ring, var(--ring-slate)) 14%, var(--surface));
  color: var(--text); font-weight: 700; line-height: 1;
}
.staff-avatar-sm { width: 30px; height: 30px; font-size: 0.7rem; border-width: 2px; }
.staff-avatar-md { width: 44px; height: 44px; font-size: 0.85rem; }
.staff-avatar-lg { width: 64px; height: 64px; font-size: 1.2rem; border-width: 4px; }
/* A photo fills the same circle the initials use, inside the colored ring, so nothing moves. */
.staff-avatar.has-photo { overflow: hidden; padding: 0; background: var(--surface-2); }
.staff-avatar.has-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }

.rule-view { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 4px; }
.rules-form .rule-item .button { flex: none; }

.staff-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.staff-card {
  display: flex; gap: 12px; align-items: flex-start; height: 100%; padding: 14px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface); color: var(--text); text-decoration: none; min-width: 0;
}
.staff-card:hover { border-color: var(--primary); color: var(--text); }
.staff-card-text { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.staff-card-name { font-size: 1.125rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.staff-card-full, .staff-card-reports { color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.staff-card-title { font-size: 0.925rem; overflow-wrap: anywhere; }
.staff-counts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.count-pill {
  font-size: 0.75rem; font-weight: 600; color: var(--muted); background: var(--surface-2);
  border-radius: 999px; padding: 1px 8px; white-space: nowrap;
}
.count-pill.is-waiting { background: var(--waiting-bg); color: var(--waiting-text); }
.count-pill.is-overdue { background: var(--danger-bg); color: var(--danger-text); }

/* Edit staff */
.reporting-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.reporting-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.reporting-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.reporting-name { display: flex; align-items: center; gap: 8px; flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.reporting-row select { flex: 0 1 340px; min-width: 0; max-width: 100%; }
.edit-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); align-items: start; }
.edit-card { min-width: 0; scroll-margin-top: 80px; }
.edit-card.has-error { border-color: var(--danger-text); }
.edit-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.edit-card-head h3, .edit-card > h3 { margin: 0 0 0; font-size: 1.05rem; overflow-wrap: anywhere; min-width: 0; }
.edit-card > h3 { margin-bottom: 12px; }
.edit-card select { width: 100%; }
.edit-card label { font-weight: 600; font-size: 0.925rem; display: flex; flex-direction: column; gap: 5px; }
.edit-card label .muted { font-weight: 400; }

/* Staff member page: header and tabs */
.staff-head { margin-bottom: 14px; }
.staff-head-main { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.staff-head-text { flex: 1 1 200px; min-width: 0; }
.staff-name { font-size: 1.75rem; margin: 0; line-height: 1.15; overflow-wrap: anywhere; }
.staff-full { margin: 2px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.staff-title { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.staff-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.staff-facts { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 10px 32px; }
.staff-facts > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.staff-facts dt { color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.staff-facts dd { margin: 0; min-width: 0; }
.reports-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.reports-form select { padding: 5px 8px; max-width: 100%; min-width: 0; }

.staff-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.staff-tab {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); text-decoration: none; font-size: 0.925rem; font-weight: 500;
}
.staff-tab:hover { border-color: var(--primary); color: var(--text); }
.staff-tab.active { background: var(--menu-active-bg); color: var(--menu-active-text); border-color: transparent; font-weight: 650; }
.tab-panel h3 { font-size: 1.05rem; margin: 0; }
.tab-panel .section-head h3 { display: flex; align-items: center; gap: 8px; }

/* Overview */
.overview-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); align-items: start; }
.overview-card { min-width: 0; }
.overview-card > h3, .overview-card .dash-card-head { margin-bottom: 10px; }
.overview-card .dash-card-head h3 { margin: 0; }
.overview-wide { grid-column: 1 / -1; }
.role-text { white-space: pre-line; overflow-wrap: anywhere; }
.edit-details summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: 0.9rem; margin-bottom: 8px; }
.model-fields { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.model-fields .wide { grid-column: 1 / -1; }
.model-fields label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 0.925rem; min-width: 0; }
.model-fields label .muted { font-weight: 400; }
.model-fields select { width: 100%; }
.model-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.count-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.count-list strong { font-variant-numeric: tabular-nums; }

/* Task lists on the Outstanding and Old tabs */
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.task-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.task-row:last-child { border-bottom: 0; padding-bottom: 0; }
.task-main { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.task-title { font-weight: 600; overflow-wrap: anywhere; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; color: var(--muted); font-size: 0.85rem; }
.task-outcome { font-size: 0.9rem; overflow-wrap: anywhere; white-space: pre-line; }
.task-actions { flex: 0 1 auto; display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: 100%; }
.task-form { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; align-items: center; }
.task-form input[type="text"] { width: 13em; padding: 5px 8px; min-width: 0; flex: 1 1 10em; }
.task-form select { padding: 5px 8px; min-width: 0; flex: 1 1 8em; }
.flag-overdue { background: var(--danger-bg); color: var(--danger-text); }
.flag-waiting { background: var(--waiting-bg); color: var(--waiting-text); }
.flag-done { background: var(--ok-bg); color: var(--ok-text); }
.flag-cancelled { background: var(--surface-2); color: var(--muted); }
.new-task-details { margin-top: 16px; }
.new-task-details summary { cursor: pointer; font-weight: 600; }

.search-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.search-form input[type="search"] { flex: 1 1 200px; width: auto; min-width: 0; padding: 6px 10px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.button.is-disabled { opacity: 0.45; cursor: default; pointer-events: none; }
/* Brief Y: a disabled button looks it (such as Switch on, while a pack still needs something). */
.button:disabled { opacity: 0.45; cursor: not-allowed; }

/* Activity */
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.filter-chip {
  padding: 4px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); text-decoration: none; font-size: 0.85rem;
}
.filter-chip:hover { border-color: var(--primary); color: var(--text); }
.filter-chip.active { background: var(--menu-active-bg); color: var(--menu-active-text); border-color: transparent; font-weight: 650; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: 0; }
.timeline-kind {
  flex: none; width: 4.4em; text-align: center; font-size: 0.75rem; font-weight: 650; border-radius: 6px;
  padding: 2px 0; background: var(--surface-2); color: var(--muted); align-self: flex-start;
}
.kind-talk .timeline-kind { background: var(--info-bg); color: var(--info-text); }
.kind-model .timeline-kind, .kind-staff .timeline-kind { background: var(--waiting-bg); color: var(--waiting-text); }
.timeline-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.timeline-what { overflow-wrap: anywhere; }
.timeline-text { font-size: 0.9rem; color: var(--muted); overflow-wrap: anywhere; white-space: pre-line; }
.timeline-when { font-size: 0.8rem; color: var(--muted); }

@media (max-width: 599px) {
  .staff-name { font-size: 1.5rem; }
  .model-fields { grid-template-columns: minmax(0, 1fr); }
  .task-actions { flex-basis: 100%; }
  .staff-facts { gap: 10px 20px; }
}

/* ---- Records and Contacts, Quick add, Mention a record (brief 05) ---- */
/* Quick add: a details menu in the top bar. */
.quick-add { position: relative; }
.quick-add > summary { list-style: none; }
.quick-add > summary::-webkit-details-marker { display: none; }
.quick-add-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 190px; margin: 0; padding: 6px;
  list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
}
.quick-add-menu a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none; font-weight: 500; white-space: nowrap; }
.quick-add-menu a:hover, .quick-add-menu a:focus-visible { background: var(--surface-2); color: var(--text); }
.quick-add-menu li:first-child a { font-weight: 650; }

/* Lists */
.rec-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.rec-filters input[type="search"] { padding: 6px 10px; }
.rec-filters select { padding: 6px 8px; font-size: 0.9rem; max-width: 100%; }
.rec-filter-q { flex: 1 1 240px; min-width: 0; }
.rec-filter-check { font-size: 0.9rem; }
.rec-empty p:last-child { margin-bottom: 0; }
.rec-name { font-weight: 650; overflow-wrap: anywhere; }
.rec-table td.rec-name-cell { min-width: 12em; }
/* A date may wrap between its words, so a list of eight columns fits at 1280 px without cutting Updated off. */
.rec-table td[data-label="Updated"] { white-space: normal; }
.rec-table tr.is-archived td { color: var(--muted); }
.rec-status {
  display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 650;
  background: var(--info-bg); color: var(--info-text); white-space: nowrap;
}
.rec-status.status-won, .rec-status.status-active { background: var(--ok-bg); color: var(--ok-text); }
.rec-status.status-proposal, .rec-status.status-paused { background: var(--waiting-bg); color: var(--waiting-text); }
.rec-status.status-lost, .rec-status.status-former, .rec-status.status-inactive { background: var(--surface-2); color: var(--muted); }
.rec-status-lg { font-size: 0.875rem; padding: 2px 11px; flex: none; }

/* Record and contact pages */
.rec-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 360px); gap: 16px; align-items: start; }
.rec-main, .rec-side { min-width: 0; }
.rec-side .card h2 { font-size: 1.05rem; }
.rec-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.rec-head-text { min-width: 0; flex: 1 1 200px; }
.rec-kind { margin: 0; color: var(--muted); font-size: 0.8rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; }
.rec-title { margin: 0; font-size: 1.4rem; overflow-wrap: anywhere; }
.rec-subtitle { margin: 2px 0 0; overflow-wrap: anywhere; }
.rec-convert {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px;
  margin-top: 14px; padding: 10px 12px; border-radius: 8px; background: var(--ok-bg); color: var(--ok-text);
}
.rec-convert p { margin: 0; flex: 1 1 240px; }
.rec-address { white-space: pre-line; }
.rec-actions { margin-top: 14px; }
.rec-closed { margin-top: 12px; }
.rec-closed > summary, .rec-more > summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.rec-more { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.rec-more[open] > summary { margin-bottom: 10px; }
.rec-inline-form :is(input, select, textarea), .rec-form :is(input, select, textarea), .rec-side textarea { font-weight: 400; }
.rec-form select { width: 100%; }
.rec-notes-box { resize: vertical; }
.rec-contacts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rec-contact { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.rec-contact:first-child { padding-top: 0; }
.rec-contact:last-child { border-bottom: 0; }
.rec-contact form { margin: 0; flex: none; }
.rec-contact-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.rec-contact-name { font-weight: 650; overflow-wrap: anywhere; }
.rec-contact-title { font-size: 0.9rem; overflow-wrap: anywhere; }
.rec-contact-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; min-width: 0; }
.rec-contact-meta a { overflow-wrap: anywhere; }
.rec-archived-note { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.rec-archived-note p { margin: 0; }
.rec-archived-note form { margin: 0; }
.search-form select { min-width: 0; max-width: 100%; flex: 1 1 200px; padding: 6px 8px; }

@media (max-width: 899px) {
  .rec-layout { grid-template-columns: minmax(0, 1fr); }
}

/* Lists: the header area stays at the top while the list scrolls, under the top bar, and a copy of the column
   headings shows at its foot once the table's own have scrolled under it (app/public/js/list-sticky.js). 600 px and
   wider: narrower, a list is cards and nothing is held at the top. */
@media (min-width: 600px) {
  .list-head { position: sticky; top: var(--sticky-top, 0px); z-index: 4; background: var(--surface); padding-top: 4px; margin-top: -4px; }
}
.list-colheads { position: absolute; top: 100%; overflow: hidden; border: 1px solid var(--border); border-radius: 0 0 8px 8px;
  background: var(--surface-2); box-shadow: 0 8px 14px -10px rgba(0, 0, 0, 0.45); }
.list-colheads table { table-layout: fixed; }
.list-colheads th { border-bottom: 0; overflow: hidden; text-overflow: ellipsis; }

/* Under 600 px a list row becomes a small card. */
@media (max-width: 599px) {
  .rec-table-wrap { border: 0; overflow: visible; }
  .rec-table, .rec-table tbody, .rec-table tr, .rec-table td { display: block; width: 100%; }
  .rec-table thead { display: none; }
  .rec-table tr { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; }
  .rec-table td { border: 0; padding: 2px 0; text-align: left; }
  .rec-table td.num { text-align: left; }
  .rec-table td.rec-name-cell { min-width: 0; padding-bottom: 4px; }
  .rec-table td[data-label] { display: flex; gap: 8px; font-size: 0.875rem; }
  .rec-table td[data-label]::before { content: attr(data-label); flex: none; width: 6.5em; color: var(--muted); font-size: 0.8rem; font-weight: 600; }
  /* In a card a long email or web address breaks rather than running past the card's edge. */
  .rec-table td[data-label] { overflow-wrap: anywhere; }
  .rec-table td[data-label]:empty { display: none; }
  .rec-table td.nowrap { white-space: normal; }
  .rec-filters > label:not(.rec-filter-q):not(.check) { flex: 1 1 40%; }
  .rec-filters select { width: 100%; }
}

/* Talk tab: Mention a record */
.talk-mention > summary { list-style: none; align-self: flex-start; }
.talk-mention > summary::-webkit-details-marker { display: none; }
.talk-mention-box {
  margin-top: 8px; display: flex; flex-direction: column; gap: 8px; padding: 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.talk-mention-box p { margin: 0; }
.talk-mention-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.talk-mention-row input, .talk-mention-row select { flex: 1 1 200px; min-width: 0; max-width: 100%; padding: 6px 9px; }
/* On a narrow screen the Quick add menu hangs from the right of the top bar, inside the screen. */
@media (max-width: 599px) {
  .quick-add { position: static; }
  .quick-add-menu { top: calc(100% - 2px); right: 12px; }
}

/* Narrow screens: the theme picker and Sign out move into the menu, so the page title is never cut short. */
.sidebar-account { display: none; }
@media (max-width: 799px) {
  .topbar .theme-form, .topbar .topbar-signout { display: none; }
  .page-title { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; line-height: 1.25; }
  /* Placed under the logo, above the menu items, so it is in view without scrolling the menu. */
  .sidebar .menu { order: 2; }
  .sidebar-account {
    order: 1; display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 10px;
    padding: 12px 18px; border-bottom: 1px solid var(--border);
  }
  .sidebar-user { flex-basis: 100%; }
  .sidebar-account .theme-form { display: flex; flex-direction: column; gap: 4px; margin: 0; flex: 1; }
  .sidebar-account .theme-select { width: 100%; }
  .sidebar-account form { margin: 0; }
  .sidebar-user { margin: 0; font-weight: 650; }
}

/* Calendar linking (brief 06): the Calendar section of Integrations and the guided setup pages. */
.cal-link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 16px; margin-bottom: 10px; align-items: start; }
.cal-link-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.cal-link-card .provider-head { align-items: flex-start; }
.cal-link-provider { display: block; font-size: 0.8rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.cal-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cal-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--border); }
.cal-row:first-child { border-top: 0; }
.cal-row.is-hidden .cal-name { color: var(--muted); }
.cal-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.cal-name { flex: 1; min-width: 0; }
.cal-shown-form { margin: 0; flex: none; }
.cal-link-card .small-text { margin: 0; }
.guide { display: flex; flex-direction: column; gap: 16px; max-width: 760px; }
.guide-intro h2 { font-size: 1.3rem; }
.guide-intro .sub-heading { font-size: 1rem; margin-top: 12px; }
.guide-steps { list-style: none; counter-reset: guide; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.guide-step { counter-increment: guide; position: relative; padding-left: 64px; min-width: 0; }
.guide-step::before {
  content: counter(guide); position: absolute; left: 18px; top: 18px; width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: var(--primary-text); font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.guide-step h3 { font-size: 1.05rem; margin-top: 4px; }
.guide-sub { margin: 0 0 0.75em; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
.guide-step .plain-list { margin-top: 6px; }
.shot {
  border: 1px dashed var(--border); border-radius: 8px; background: var(--surface-2); color: var(--muted);
  padding: 18px 12px; text-align: center; font-size: 0.875rem;
}
.copy-box { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); }
.copy-box code { font-size: 0.95em; }
.saved-note { background: var(--ok-bg); color: var(--ok-text); border-radius: 8px; padding: 8px 10px; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .guide-step { padding-left: 16px; padding-top: 58px; }
  .guide-step::before { left: 16px; top: 16px; }
}

/* ==== Calendar screen, event form, Brief and the Dashboard Today card (brief 06) ==== */
/* --cal is the calendar's color, set on the element. Tints mix it with the surface, so both themes work. */
.cal-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 8px; }
.cal-nav { display: flex; gap: 6px; }
.cal-title { margin: 0; font-size: 1.25rem; flex: 1 1 auto; min-width: 0; }
.cal-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.cal-views { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.cal-view { padding: 5px 12px; font-size: 0.875rem; font-weight: 600; color: var(--text); text-decoration: none; }
.cal-view + .cal-view { border-left: 1px solid var(--border); }
.cal-view:hover { background: var(--surface-2); color: var(--text); }
.cal-view.active { background: var(--menu-active-bg); color: var(--menu-active-text); }
.cal-subbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; margin-bottom: 12px; }
.cal-zone { margin: 0; }
.cal-jump { display: flex; gap: 6px; align-items: center; margin: 0; }
.cal-jump input[type="date"] { width: auto; padding: 5px 8px; }

.cal-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--cal); border: 2px solid var(--cal); flex: none; vertical-align: -1px; }
/* Calendars legend: one row of chips. A linked calendar's chip is its show/hide button. More calendars
   than fit scroll sideways inside the bar; the page itself never does. */
.cal-legend { padding: 8px 10px; margin-bottom: 14px; }
.cal-legend-list {
  list-style: none; margin: 0; padding: 2px; display: flex; flex-wrap: nowrap; gap: 8px;
  overflow-x: auto; scrollbar-width: thin;
}
.cal-legend-item { flex: none; }
.cal-legend-form { margin: 0; }
.cal-chip {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 5px 12px 5px 9px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: 0.875rem; font-weight: 600; line-height: 1.2;
}
button.cal-chip { cursor: pointer; }
button.cal-chip:hover { border-color: var(--cal); }
.cal-chip .cal-swatch { flex: none; }
.cal-chip-warn {
  display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
  background: var(--danger-bg); color: var(--danger-text); font-size: 0.7rem; font-weight: 800;
}
.cal-legend-item.is-hidden .cal-chip { color: var(--muted); border-style: dashed; }
.cal-legend-item.is-hidden .cal-chip-name { text-decoration: line-through; }
.cal-legend-item.is-hidden .cal-swatch { background: transparent; box-shadow: inset 0 0 0 2px var(--cal); }
.cal-legend-note { margin: 8px 0 0; }

.cal-grid { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); overflow: hidden; margin-bottom: 20px; }
.cal-gridrow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head-cell { padding: 6px 8px; font-size: 0.8rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); }
.cal-cell { min-height: 112px; padding: 4px 4px 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cal-gridrow > .cal-cell:last-child { border-right: 0; }
.cal-month .cal-gridrow:last-child .cal-cell { border-bottom: 0; }
.cal-cell.is-other { background: var(--bg); }
.cal-cell.is-other .cal-daynum { color: var(--muted); }
.cal-daynum {
  align-self: flex-start; display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 26px; padding: 0 4px; border-radius: 999px; font-size: 0.875rem; font-weight: 600; color: var(--text); text-decoration: none;
}
.cal-daynum:hover { background: var(--surface-2); color: var(--text); }
.cal-cell.is-today .cal-daynum, .cal-col.is-today .cal-col-num { background: var(--primary); color: var(--primary-text); }
.cal-cell-events, .cal-col-events, .cal-agenda-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.cal-ev {
  display: block; padding: 1px 6px; border-left: 3px solid var(--cal); border-radius: 4px;
  font-size: 0.8rem; line-height: 1.35; color: var(--text); text-decoration: none; overflow-wrap: anywhere;
}
.cal-ev:hover { background: color-mix(in srgb, var(--cal) 14%, var(--surface)); color: var(--text); }
.cal-ev-allday { background: color-mix(in srgb, var(--cal) 18%, var(--surface)); }
.cal-ev-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-ev-title { font-weight: 600; }
.cal-more { padding-left: 6px; }

.cal-week .cal-gridrow { min-height: 320px; }
.cal-col { border-right: 1px solid var(--border); min-width: 0; padding: 6px 5px 10px; display: flex; flex-direction: column; gap: 6px; }
.cal-col:last-child { border-right: 0; }
.cal-col-head { display: flex; flex-direction: column; align-items: center; gap: 2px; padding-bottom: 6px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.cal-col-head:hover { color: var(--primary); }
.cal-col-wd { font-size: 0.8rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.cal-col-num { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; border-radius: 999px; font-weight: 650; }
.cal-col-events { gap: 6px; }
.cal-ev-block { display: flex; flex-direction: column; gap: 1px; padding: 4px 6px; background: color-mix(in srgb, var(--cal) 9%, var(--surface)); }
.cal-ev-block.cal-ev-allday { background: color-mix(in srgb, var(--cal) 18%, var(--surface)); }
.cal-ev-block .cal-ev-time { font-size: 0.75rem; }
.cal-ev-loc { font-size: 0.75rem; color: var(--muted); }
.cal-empty-day { margin: 0; text-align: center; }

/* Day view at every width; under 600 px the agenda replaces the month and week grids. */
.cal-agenda { display: none; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.cal-agenda.cal-day { display: flex; }
.cal-agenda-day { padding: 12px 14px; }
.cal-agenda-date { font-size: 1rem; margin: 0 0 8px; }
.cal-agenda-date a { color: var(--text); text-decoration: none; }
.cal-agenda-date a:hover { color: var(--primary); }
.cal-agenda-list { gap: 8px; }
.cal-agenda-item {
  display: flex; gap: 12px; padding: 6px 10px; border-left: 4px solid var(--cal); border-radius: 6px;
  background: color-mix(in srgb, var(--cal) 8%, var(--surface)); color: var(--text); text-decoration: none;
}
.cal-agenda-item:hover { background: color-mix(in srgb, var(--cal) 16%, var(--surface)); color: var(--text); }
.cal-agenda-time { flex: 0 0 10em; color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.cal-agenda-text { display: flex; flex-direction: column; min-width: 0; }
.cal-agenda-text .small-text { overflow-wrap: anywhere; }
.cal-agenda-title { font-weight: 650; overflow-wrap: anywhere; }
.cal-agenda-empty p:last-child { margin-bottom: 0; }

@media (max-width: 599px) {
  .cal-grid { display: none; }
  .cal-agenda { display: flex; }
  .cal-title { flex-basis: 100%; order: -1; }
  .cal-agenda-item { flex-direction: column; gap: 2px; }
  .cal-agenda-time { flex: none; }
}

/* The event form */
.cal-when { border: 0; margin: 0; padding: 0; min-width: 0; }
.cal-field-label { display: block; font-weight: 600; font-size: 0.925rem; padding: 0; margin-bottom: 5px; }
.cal-when-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 10px 14px; }
.stack .cal-when-row label { font-weight: 500; }
.cal-form.is-all-day .cal-time { display: none; }
.cal-form-zone { margin: -4px 0 0; }
.cal-cal-name { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; overflow-wrap: anywhere; }
.cal-notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.cal-readonly h2 { border-left: 4px solid var(--cal); padding-left: 10px; overflow-wrap: anywhere; }
.cal-readonly .cal-swatch { margin-right: 2px; }

/* Dashboard Today card and the Brief's calendar lists */
/* The time sits above the title (a range such as "9:00 AM to 10:30 AM" is too long for a column), and the
   calendar's color runs down the left of both. */
.dash-event { display: block; }
.dash-event-time, .dash-event-text { display: block; width: auto; border-left: 3px solid var(--cal, var(--border)); padding-left: 10px; }
.dash-event-time { font-size: 0.85rem; }

/* The Brief */
.brief-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 10px 16px; margin-bottom: 16px; }
.brief-heading { min-width: 0; }
.brief-heading p { margin: 0; }
.brief-date { margin: 0 0 2px; font-size: 1.25rem; }
.brief-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.brief-tools form { margin: 0; }
.brief-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 16px; margin-bottom: 20px; align-items: start; }
.brief-card { min-width: 0; }
.brief-card .dash-item-title, .brief-card .dash-item-note { overflow-wrap: anywhere; }
.brief-group { font-size: 0.95rem; margin: 10px 0 4px; }
.brief-summary { border-left: 4px solid var(--primary); }
.brief-summary h2 { font-size: 1rem; }
.brief-note { margin: 0 0 14px; }
.brief-recent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.brief-recent-list a.active { font-weight: 700; color: var(--text); text-decoration: none; }
.guide-step .button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Narrow screens: the legend row scrolls sideways inside its bar; a soft fade at the right edge shows there is more. */
@media (max-width: 599px) {
  .cal-legend-list { -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); padding-right: 28px; }
}

/* ==== Processes, Duties and Jobs (brief 07) ==== */
.wk-intro { margin-bottom: 16px; max-width: 60em; }
.wk-desc { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 2px; overflow-wrap: anywhere; }
.wk-desc-lg { margin: 4px 0 6px; overflow-wrap: anywhere; white-space: pre-line; }
.wk-problem { display: block; margin-top: 4px; font-size: 0.85rem; color: var(--danger-text); overflow-wrap: anywhere; }
/* break-word, not anywhere: "anywhere" lets the table squeeze a column down to one letter ("Nor / a").
   Words stay whole; only a word too long for any column breaks, and a wide table scrolls in its box. */
.wk-table td { overflow-wrap: break-word; }
.wk-table td.nowrap { overflow-wrap: normal; }
.wk-row-actions { white-space: nowrap; text-align: right; }
.wk-row-actions form { display: inline; margin: 0; }

/* Status words: the same colors as task statuses. */
.wk-status {
  display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 650; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); text-decoration: none;
}
a.wk-status:hover { text-decoration: underline; }
.wk-status.status-running { background: var(--info-bg); color: var(--info-text); }
.wk-status.status-waiting_owner, .wk-status.status-waiting { background: var(--waiting-bg); color: var(--waiting-text); }
.wk-status.status-done { background: var(--ok-bg); color: var(--ok-text); }
.wk-status.status-failed { background: var(--danger-bg); color: var(--danger-text); }
.wk-status-lg { font-size: 0.875rem; padding: 2px 11px; flex: none; }

/* Process and job page headers */
.wk-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.wk-head-text { min-width: 0; flex: 1 1 240px; }
.wk-title { margin: 0; font-size: 1.35rem; overflow-wrap: anywhere; }
.wk-onoff { flex: none; }
.wk-head code { overflow-wrap: anywhere; }
.wk-actions { margin-top: 14px; }
.wk-problems { margin-top: 12px; }
.wk-problems p { margin: 0 0 6px; }
.wk-problems li { overflow-wrap: anywhere; }
.wk-facts > div { grid-template-columns: 6.5em minmax(0, 1fr); }
.wk-error { margin-top: 14px; }
.wk-error p { margin: 0 0 4px; }
.wk-error p:last-child { margin-bottom: 0; }
.wk-pre-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.wk-running { margin: 12px 0 0; }

/* Steps of a process */
.wk-steps { margin: 0; padding-left: 1.6em; display: flex; flex-direction: column; gap: 10px; }
.wk-step { padding-left: 4px; }
.wk-step-kind { display: inline-block; margin-right: 6px; padding: 0 7px; border-radius: 6px; background: var(--info-bg); color: var(--info-text); font-size: 0.78rem; font-weight: 650; }
.wk-step-text { overflow-wrap: anywhere; white-space: pre-line; }

/* The process editor's step order */
.wk-form :is(input, select, textarea) { font-weight: 400; }
.wk-form select { width: 100%; }
.wk-order { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 0; min-width: 0; }
.wk-order legend { font-weight: 600; font-size: 0.925rem; padding: 0 4px; }
.wk-order-list { margin: 0; padding-left: 1.5em; display: flex; flex-direction: column; gap: 8px; }
.wk-order-item { padding-left: 2px; }
.wk-order-item > * { vertical-align: middle; }
.wk-order-text { display: inline; overflow-wrap: anywhere; font-weight: 400; }
.wk-order-buttons { display: inline-flex; gap: 6px; margin-left: 8px; }
.wk-order-buttons .button:disabled { opacity: 0.45; cursor: default; }

/* Build a new process */
.wk-build { border-left: 4px solid var(--primary); }
.wk-copy { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 10px; margin: 0 0 14px; padding: 12px; border-radius: 8px; background: var(--surface-2); }
.wk-copy-text { flex: 1 1 260px; min-width: 0; font-size: 0.95rem; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }

/* Recent jobs on a process page */
.wk-joblist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.wk-joblist li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }

/* Duties: empty state and the schedule picker */
.wk-empty { max-width: 60em; }
.wk-schedule { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px 12px; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.wk-schedule legend { font-weight: 600; font-size: 0.925rem; padding: 0 4px; }
.wk-schedule p { margin: 0; }
.wk-every { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.wk-schedule input[type="time"] { width: 100%; }

/* Jobs list filters */
.wk-filters .wk-date { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; }
.wk-filters input[type="date"] { width: auto; padding: 5px 8px; }

/* A job's steps: input and output wrap inside the card, never past it. */
.wk-jobsteps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.wk-jobstep { border: 1px solid var(--border); border-left: 3px solid var(--border); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.wk-jobstep.status-done { border-left-color: var(--ok-text); }
.wk-jobstep.status-failed { border-left-color: var(--danger-text); }
.wk-jobstep.status-running { border-left-color: var(--primary); }
.wk-jobstep.status-waiting_owner, .wk-jobstep.status-waiting { border-left-color: var(--waiting-text); }
.wk-jobstep-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.wk-jobstep-title { font-weight: 650; overflow-wrap: anywhere; }
.wk-jobstep .tp-task-label { margin-top: 10px; }
.wk-pre {
  margin: 6px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); color: var(--text);
  font-family: ui-monospace, Consolas, Menlo, monospace; font-size: 0.85rem; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 28em; overflow-y: auto;
}
.wk-io { margin-top: 8px; }
.wk-io > summary, .wk-more > summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.wk-more { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.wk-more[open] > summary { margin-bottom: 10px; }
.wk-review { border-left: 4px solid var(--waiting-text); }
.wk-review :is(input, textarea) { font-weight: 400; }
.wk-edit { resize: vertical; font-family: ui-monospace, Consolas, Menlo, monospace; font-size: 0.875rem; }

/* A cell's content as one piece, so a table row turned into a small card (under 600 px) keeps it together. */
.wk-cell { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; min-width: 0; }
.wk-table td.wk-wide-cell { min-width: 8.5em; }
.wk-review-text { margin-bottom: 14px; }

/* Jobs on the Queue */
.queue-item.is-job { border-left: 3px solid var(--waiting-text); }

@media (max-width: 599px) {
  .wk-row-actions { white-space: normal; text-align: left; display: flex !important; flex-wrap: wrap; gap: 6px; padding-top: 6px !important; }
  .wk-order-buttons { display: flex; margin: 6px 0 0; }
  .wk-filters .wk-date { flex: 1 1 40%; }
  .wk-filters input[type="date"] { width: 100%; min-width: 0; }
}

/* Admin: Users and Log (brief 08) */
.au-role-form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.au-role-form select { padding: 4px 8px; font-size: 0.875rem; }
.au-restart { margin: 12px 0; }
.au-restart form { margin: 8px 0 0; }
.au-log-form { margin: 0; }
.au-log-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 10px; }
.au-log-table td.au-log-pick { width: 2.2em; }
.au-log-table td.au-log-message { min-width: 16em; overflow-wrap: anywhere; }
.au-log-text { white-space: pre-line; }
.wk-status.au-level-warn { background: var(--waiting-bg); color: var(--waiting-text); }
.wk-status.au-level-error { background: var(--danger-bg); color: var(--danger-text); }
.au-log-fallback {
  display: block; width: 100%; margin-top: 10px; resize: vertical;
  font-family: ui-monospace, Consolas, Menlo, monospace; font-size: 0.85rem; line-height: 1.5;
}
.au-days { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.925rem; }
.au-days input { width: 6em; padding: 5px 8px; }
@media (max-width: 599px) {
  .au-log-table td.au-log-pick { width: 100%; padding-bottom: 2px; }
  .au-log-table td.au-log-message { min-width: 0; padding-top: 4px; }
}

/* Admin: Backup/Restore (brief 08) */
.bk-file { display: block; overflow-wrap: anywhere; }
span.bk-file { display: inline; }
.rec-name-cell .bk-file { display: block; }
.stack input.bk-short { max-width: 12rem; }
.bk-warning { margin-top: -6px; }

/* Admin: import-export (brief 08) */
.imp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; align-items: start; }
.imp-grid > .card { min-width: 0; margin-bottom: 0; }
.imp-samples { margin: 0; padding-left: 1.2em; }
.imp-downloads { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.imp-fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px 14px; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.imp-fieldset legend { font-weight: 650; padding: 0 6px; }
.imp-fieldset p { margin: 0; }
.imp-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 12px; }
.imp-map label { min-width: 0; }
.imp-map select { width: 100%; max-width: 100%; }
.imp-hint { font-weight: 400; }
/* td.break too: the shared ".table td.break" (9em) would win otherwise, and nine columns of 9em cut Notes off. */
.imp-table td, .imp-table td.break { min-width: 6em; }
.imp-table td.num { min-width: 0; }
.imp-table td.imp-bad { background: var(--danger-bg); }
.imp-value { display: block; }
.imp-value:empty { display: none; }
.imp-problem { display: block; color: var(--danger-text); font-size: 0.825rem; font-weight: 600; }
.imp-dup { display: block; color: var(--info-text); font-size: 0.825rem; }
.imp-ok { color: var(--ok-text); font-size: 0.825rem; font-weight: 600; }
.imp-check { min-width: 11em; }
.imp-more { margin: 10px 0 0; }
.imp-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.imp-done-actions { margin-top: 16px; }
@media (max-width: 599px) {
  .imp-table td.imp-bad { border-radius: 6px; padding: 4px 6px; }
  .imp-table td[data-label] { flex-wrap: wrap; }
  .imp-table td[data-label] > span { min-width: 0; flex: 1 1 60%; }
  .imp-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .imp-stats .stat { padding: 10px; }
}
/* Admin: Update (brief 08) */
details.file-list { margin: 0 0 10px; }
details.file-list summary { cursor: pointer; }
details.file-list ul { margin: 6px 0 0; overflow-wrap: anywhere; }

/* Starter library on Processes (brief 10) */
.st-library > p { max-width: 60em; }
.st-group { border-top: 1px solid var(--border); padding: 10px 0; }
.st-group > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.st-group > summary::-webkit-details-marker { display: none; }
.st-group > summary::before { content: "+"; font-weight: 700; color: var(--primary); width: 1em; flex: none; }
.st-group[open] > summary::before { content: "\2212"; }
.st-group-title { margin: 0; font-size: 1.05rem; display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.st-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 12px; }
.st-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--surface); min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.st-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.st-name { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.st-added { flex: none; text-decoration: none; }
.st-desc { margin: 0; font-size: 0.9rem; overflow-wrap: anywhere; }
.st-meta { margin: 0; }
.st-steps { margin: 0; padding-left: 1.4em; font-size: 0.85rem; display: flex; flex-direction: column; gap: 4px; }
.st-steps .wk-step-text { white-space: normal; }
.st-add { margin-top: auto; padding-top: 6px; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.st-add label { display: flex; flex-direction: column; gap: 2px; font-size: 0.85rem; flex: 1 1 160px; min-width: 0; }
.st-add select { width: 100%; }
.wk-notes { white-space: pre-line; overflow-wrap: anywhere; margin: 0; font-size: 0.925rem; max-width: 60em; }
.wk-suggested { margin: 10px 0 0; }

/* ---- People on the chart, photos, expertise, suggested rules (brief 11) ---- */
.kind-tag {
  display: inline-block; vertical-align: middle; margin-left: 6px; padding: 2px 8px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em; line-height: 1.4;
  background: var(--text); color: var(--surface);
}
.kind-tag.is-person { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.detail-list { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; }
.detail-list > div { display: contents; }
.detail-list dt { color: var(--muted); font-size: 0.9rem; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.detail-sub { font-size: 0.95rem; margin: 14px 0 4px; }
.photo-row { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.photo-row p { margin: 0; }
.photo-remove { margin-top: 8px; }
.suggested-rules { border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; padding: 12px 14px; margin: 0 0 14px; }
.suggested-rules h3 { font-size: 1rem; margin: 0 0 4px; }
.suggested-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.suggested-list li { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 12px; }
.suggested-list .suggested-text { flex: 1 1 280px; min-width: 0; }
.suggested-list form { display: inline; }
.suggested-actions { display: flex; gap: 6px; flex: none; }
.staff-card .kind-tag { margin-left: 0; align-self: flex-start; }
.edit-kind-note { margin: 0 0 8px; }
@media (max-width: 480px) {
  .detail-list { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .detail-list dd { margin-bottom: 8px; }
}
.setup-sub { font-size: 1.15rem; margin: 18px 0 0; }
.review-sub { font-size: 0.95rem; margin: 12px 0 4px; }
.link-person { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.link-person select { max-width: 220px; }
/* Admin, Users: turning two-step off for everyone sits apart from the switch that requires it. */
.ts-off-all { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ---- Account, two-step sign-in, setup code (brief 13) ---- */
.form-narrow { max-width: 420px; }
.ts-steps { padding-left: 1.3em; display: flex; flex-direction: column; gap: 10px; }
.ts-qr { width: 200px; height: 200px; margin: 10px 0; background: #ffffff; padding: 0; border-radius: 6px; }
.ts-qr svg { width: 100%; height: 100%; display: block; }
.ts-key { overflow-wrap: anywhere; font-size: 1rem; }
.rc-list { list-style: none; padding: 0; margin: 12px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 16px; }
.rc-list code { font-size: 1.05rem; }
.setup-code-help { margin-top: 18px; }
.setup-code-help p { margin: 0 0 8px; }
/* Admin, Users: the row's buttons wrap into the column instead of running past the table's edge. */
.au-table .wk-row-actions { white-space: normal; min-width: 200px; }
.au-table .wk-row-actions > * { margin: 0 0 4px 4px; }
/* Your name in the top bar and the menu opens your account page; it reads as a name, not a link. */
a.user-name, .sidebar-user a { color: inherit; text-decoration: none; }
a.user-name:hover, .sidebar-user a:hover { text-decoration: underline; }

/* Admin, Modules (client edition, brief A). */
.module-list { list-style: none; margin: 0; padding: 0; }
.module-row { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--border); }
.module-row:first-child { border-top: 0; }
.module-text { min-width: 0; flex: 1; }
.module-text p { margin: 4px 0 0; }
.module-name { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.module-action { flex: none; }
.module-features { list-style: none; margin: 8px 0 0; padding: 0; }
.module-features .inline-form { margin-top: 4px; padding-top: 0; border-top: 0; }
.check-list dt { font-weight: 600; margin-top: 8px; }
.check-list dd { margin: 2px 0 0; overflow-wrap: anywhere; }
@media (max-width: 600px) { .module-row { flex-direction: column; } }
/* Brief D: the staff removal screen. Each group is a block of its own; pick lists keep to a readable width. */
.removal-groups { display: grid; gap: 12px; }
.removal-group { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 0; min-width: 0; }
.removal-group legend { padding: 0 6px; font-weight: 600; }
.removal-group.is-empty { padding-top: 6px; padding-bottom: 6px; }
.removal-group.is-empty p { margin: 0; }
.removal-group label, .removal-card .form-narrow { display: block; max-width: 440px; margin-top: 8px; }
.removal-items { margin: 4px 0 0; padding-left: 20px; }
.removal-each { margin-top: 8px; }
.removal-each label { margin-left: 12px; }

/* Brief E: records. Status and tag colors come from the eight ring colors (both themes define them). */
.rec-status[class*="tone-"], .rec-tag { background: color-mix(in srgb, var(--tone) 15%, var(--surface)); color: var(--tone); }
.tone-violet { --tone: var(--ring-violet); } .tone-gold { --tone: var(--ring-gold); } .tone-teal { --tone: var(--ring-teal); }
.tone-rose { --tone: var(--ring-rose); } .tone-blue { --tone: var(--ring-blue); } .tone-green { --tone: var(--ring-green); }
.tone-orange { --tone: var(--ring-orange); } .tone-slate { --tone: var(--ring-slate); }
.rec-tag { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.rec-tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.rec-tag-choices { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.rec-more-filters { flex-basis: 100%; }
.rec-more-filters summary { cursor: pointer; }
.rec-more-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-top: 8px; }
.rec-more-grid label, .rec-range label { display: flex; flex-direction: column; gap: 3px; }
.rec-range { border: 0; padding: 0; margin: 0; display: flex; gap: 8px; min-width: 0; }
.rec-range input { width: 100%; min-width: 0; }
.rec-views { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 12px; }
.rec-views-pick { display: flex; align-items: flex-end; gap: 6px; }
.rec-save-view summary, .types-fields summary { cursor: pointer; }
.rec-save-view-form { margin-top: 8px; max-width: 420px; }
.rec-columns { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.rec-mass-link { margin-left: auto; }
.rec-custom-facts { margin-top: 4px; }
.rec-file-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.rec-file-form input[type=file] { max-width: 100%; }
.rec-subhead { font-size: 0.95rem; margin: 16px 0 6px; }
.rec-link-form { flex-wrap: wrap; margin-top: 10px; }
.rec-link-form select { min-width: 0; max-width: 100%; }
.records-type-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 6px 0; }
.records-type-name input { min-width: 0; width: 220px; max-width: 100%; }
.subnav-inner { margin-top: -6px; }
.subnav-inner a { font-size: 0.85rem; padding: 4px 10px; }
.types-list, .status-list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.types-row { padding: 12px 14px; display: grid; gap: 8px; }
.types-row.is-retired { opacity: 0.75; }
.types-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.types-moves { margin-left: auto; display: flex; gap: 4px; }
.types-rename, .status-edit { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.types-rename label, .status-edit label { display: flex; flex-direction: column; gap: 3px; }
.types-rename input, .status-edit input { width: 170px; max-width: 100%; }
.status-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.status-moves { display: flex; gap: 4px; margin-left: auto; }
.status-add { margin-top: 12px; }
.mode-preview { padding: 12px 14px; margin: 4px 0; }
.mass-choices label.check { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mass-choices select, .mass-choices input[type=text] { max-width: 100%; }
.rec-range label { min-width: 0; flex: 1 1 0; }
.rec-more-grid > * { min-width: 0; }
.rec-list-card { min-width: 0; }
.act-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }

/* Brief F: the timeline. */
.tl-add { margin: 4px 0 14px; }
.tl-add textarea { width: 100%; resize: vertical; }
.tl-kind { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 650; background: var(--surface-2); color: var(--muted); margin-right: 4px; }
.tl-email_in, .tl-email_out { background: color-mix(in srgb, var(--ring-blue) 15%, var(--surface)); color: var(--ring-blue); }
.tl-call, .tl-text { background: color-mix(in srgb, var(--ring-teal) 15%, var(--surface)); color: var(--ring-teal); }
.tl-task, .tl-job { background: color-mix(in srgb, var(--ring-violet) 15%, var(--surface)); color: var(--ring-violet); }
.tl-preview { white-space: pre-wrap; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.tl-list .tp-history-meta { overflow-wrap: anywhere; }

/* Mail (client edition, brief G) */
.mail-boxes { flex-wrap: wrap; }
.mail-filters input[type="search"] { flex: 1 1 220px; min-width: 0; }
.mail-list { list-style: none; margin: 0; padding: 0; }
.mail-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.mail-row:first-child { border-top: 0; }
.mail-link { display: grid; grid-template-columns: minmax(0, 12rem) minmax(0, 1fr); gap: 2px 12px; flex: 1 1 320px; min-width: 0; color: var(--text); text-decoration: none; }
.mail-link:hover .mail-subject { text-decoration: underline; }
.mail-who, .mail-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-preview { grid-column: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row.is-unread .mail-who, .mail-row.is-unread .mail-subject { font-weight: 700; }
.mail-meta { flex: 0 1 auto; text-align: right; }
.mail-status { font-weight: 600; }
.mail-status.status-active { color: var(--ok-text); }
.mail-status.status-needs_signin { color: var(--danger-text); }
.mail-head { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 0 0 12px; }
.mail-head dt { color: var(--muted); }
.mail-head dd { margin: 0; overflow-wrap: anywhere; }
.mail-body { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border-radius: 8px; padding: 12px; max-height: 70vh; overflow: auto; }
.mail-admin-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.mail-handler { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; width: 100%; }
.mail-handler-ticks { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.input-short { width: 6rem; }
.inline-fields { display: flex; flex-wrap: wrap; gap: 8px 16px; }
@media (max-width: 640px) {
  .mail-link { grid-template-columns: minmax(0, 1fr); }
  .mail-preview { grid-column: 1; }
  .mail-meta { text-align: left; }
  .mail-admin-actions { justify-content: flex-start; }
}
.mail-apps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 16px; }
.guide-more { margin: 8px 0; }
.guide-more > summary { cursor: pointer; padding: 6px 0; }
.rule-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 8px 16px; }
.rule-list { list-style: decimal; padding-left: 1.5rem; margin: 0; }
.rule-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.rule-row:first-child { border-top: 0; }
.rule-row.is-paused .rule-text { opacity: 0.6; }
.rule-text { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }
.rule-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.rule-test tr.is-new td { background: var(--surface-2); }
.mail-box-picker select { max-width: 100%; }
.doc-list { list-style: none; margin: 0 0 12px; padding: 0; }
.doc-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; padding: 8px 0; border-top: 1px solid var(--border); }
.doc-row:first-child { border-top: 0; }
.doc-row a { overflow-wrap: anywhere; }
.doc-main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 220px; }
.doc-tags input { width: 12rem; max-width: 100%; }
.tpl-edit { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 18rem); gap: 16px; align-items: start; }
@media (max-width: 900px) { .tpl-edit { grid-template-columns: minmax(0, 1fr); } }
.tpl-pick label { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tpl-pick select { max-width: 100%; }
.doc-preview { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 24px; max-width: 46rem; overflow-wrap: anywhere; }
.doc-preview h1 { font-size: 1.25rem; margin: 12px 0 6px; } .doc-preview h2 { font-size: 1.05rem; margin: 10px 0 4px; } .doc-preview h1.doc-title { font-size: 1.5rem; margin-top: 0; }
.doc-preview p { margin: 0 0 8px; } .doc-preview p.li { padding-left: 18px; text-indent: -18px; margin-bottom: 3px; }
.tpl-make { align-items: center; margin-top: 12px; }
.proj-list { list-style: none; margin: 0; padding: 0; }
.proj-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; padding: 10px 0; border-top: 1px solid var(--border); }
.proj-row:first-child { border-top: 0; }
.proj-main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 240px; overflow-wrap: anywhere; }
.proj-progress { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.proj-progress .bar { display: inline-block; width: 6rem; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.proj-progress .bar span { display: block; height: 100%; background: var(--primary); }
.proj-progress-big .bar { width: 10rem; }
.ptask-list { list-style: none; margin: 0; padding: 0; }
.ptask { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.ptask-sub > .ptask-list { padding-left: 34px; }
.ptask-sub > .ptask-list .ptask { border-top: 1px dashed var(--border); }
.ptask-check, .ptask-box { width: 24px; height: 24px; flex: 0 0 24px; border: 2px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--ok-text); font-weight: 700; line-height: 18px; text-align: center; cursor: pointer; padding: 0; }
.ptask-box { cursor: default; border-style: dashed; }
.ptask.is-done .ptask-title { text-decoration: line-through; color: var(--muted); }
.ptask.is-late .ptask-title { color: var(--danger-text); }
.ptask-text { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.tt-list { padding-left: 1.4rem; }
.tt-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; align-items: center; padding: 4px 0; }
.tt-sub { list-style: circle; padding-left: 1.4rem; }
/* Billing (brief L) */
.bill-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 8px 0 14px; }
.bill-card { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: inherit; text-decoration: none; }
.bill-card:hover { border-color: var(--primary); }
.bill-card.is-late .bill-num { color: var(--danger-text); }
.bill-num { font-size: 1.25rem; font-weight: 700; }
.bill-list { list-style: none; margin: 0; padding: 0; }
.bill-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; padding: 10px 0; border-top: 1px solid var(--border); }
.bill-row:first-child { border-top: 0; }
.bill-main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 220px; overflow-wrap: anywhere; }
.bill-amount { display: flex; flex-direction: column; align-items: flex-end; flex: 0 0 auto; text-align: right; }
.bill-amount-big > span:first-child { font-size: 1.5rem; font-weight: 700; }
.bill-row.is-late .bill-status, .bill-status.bill-void { color: var(--danger-text); }
.bill-status.bill-paid { color: var(--ok-text); }
.bill-lines { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 0; min-width: 0; }
.bill-lines legend { font-weight: 600; padding: 0 4px; }
.bill-line { display: grid; grid-template-columns: minmax(120px, 1.2fr) minmax(160px, 3fr) minmax(56px, 0.6fr) minmax(80px, 0.9fr) minmax(64px, 0.6fr); gap: 8px; padding: 8px 0; border-top: 1px dashed var(--border); }
.bill-line:first-of-type { border-top: 0; }
.bill-line label { display: flex; flex-direction: column; font-size: 0.85rem; min-width: 0; }
.bill-line input, .bill-line select { width: 100%; min-width: 0; }
@media (max-width: 720px) {
  .bill-line { grid-template-columns: 1fr 1fr; }
  .bill-line .bill-desc { grid-column: 1 / -1; }
}
.bill-table td.num, .bill-table th.num { text-align: right; white-space: nowrap; }
.bill-table tfoot td { font-weight: 600; }
.bill-table tr.bill-total td { border-top: 2px solid var(--border); font-size: 1.05rem; }
.copy-box { margin: 10px 0; }
.copy-box textarea { width: 100%; }
.input-short { width: 7rem; display: inline-block; }
.module-text > .small-text { display: block; }
/* Leads and map rankings (brief M) */
.lead-list { list-style: none; margin: 0; padding: 0; }
.lead-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; padding: 12px 0; border-top: 1px solid var(--border); }
.lead-row:first-child { border-top: 0; }
.lead-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 260px; overflow-wrap: anywhere; }
.lead-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
.lead-match { color: var(--accent); font-weight: 600; }
.cost-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 0 14px; }
.cost-facts dt { font-weight: 600; }
.cost-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.rank-figure { margin: 12px 0; max-width: 520px; }
.rank-grid { width: 100%; height: auto; display: block; }
.rank-bg { fill: var(--surface-2); }
.rank-dot { stroke: var(--surface); stroke-width: 2; }
.rank-center { stroke: var(--text, #111); stroke-width: 3; }
.rank-num { fill: #fff; font-size: 16px; font-weight: 700; font-family: inherit; }
.rank-r1 { fill: #0b6b2d; background: #0b6b2d; } .rank-r3 { fill: #2e8b3d; background: #2e8b3d; } .rank-r5 { fill: #6b7d1f; background: #6b7d1f; }
.rank-r7 { fill: #9a7b00; background: #9a7b00; } .rank-r10 { fill: #b85a00; background: #b85a00; } .rank-r19 { fill: #b3261e; background: #b3261e; }
.rank-r20 { fill: #7a1712; background: #7a1712; } .rank-none { fill: #6b6b6b; background: #6b6b6b; } .rank-wait { fill: transparent; stroke: var(--border); stroke-dasharray: 4 3; }
.rank-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 0; margin: 6px 0 12px; }
.rank-legend li { display: flex; align-items: center; gap: 6px; }
.rank-key { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
/* Outreach (brief N) */
.seq-list { list-style: none; margin: 0; padding: 0; }
.seq-step { border-top: 1px solid var(--border); padding: 10px 0; }
.seq-step:first-child { border-top: 0; }
.seq-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.seq-body { white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; font-size: 0.9rem; background: var(--surface-2); border-radius: 6px; padding: 8px 10px; margin: 6px 0 0; }
.day-picks { display: flex; flex-wrap: wrap; gap: 6px 14px; border: 0; padding: 0; margin: 0; }
.day-picks legend { font-weight: 600; font-size: 0.925rem; margin-bottom: 4px; }
/* Forms (brief O) */
.form-field-row { display: grid; grid-template-columns: minmax(140px, 2fr) minmax(120px, 1.3fr) minmax(120px, 1.3fr) minmax(120px, 1.5fr) auto; gap: 8px; align-items: end; padding: 8px 0; border-top: 1px dashed var(--border); }
.form-field-row:first-of-type { border-top: 0; }
.form-field-row label { font-size: 0.85rem; min-width: 0; }
.form-field-row input, .form-field-row select { width: 100%; min-width: 0; }
@media (max-width: 720px) { .form-field-row { grid-template-columns: 1fr 1fr; } .form-field-row > label:first-child { grid-column: 1 / -1; } }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.public-form .form-card { max-width: 560px; }
.form-intro { white-space: pre-wrap; }

/* Brief P: one website chat on the conversation screen. */
.chat-log { list-style: none; margin: 12px 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.chat-line { display: flex; flex-direction: column; gap: 2px; max-width: 80%; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); }
.chat-line .chat-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-visitor { align-self: flex-start; }
.chat-ai, .chat-person { align-self: flex-end; background: var(--menu-active-bg); }
.chat-system { align-self: center; background: transparent; font-style: italic; }
@media (max-width: 600px) { .chat-line { max-width: 100%; } }

/* Brief S (and brief R's shadow results): a proposed note change or a job's output, wrapped to the card. */
.pack-output { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; margin: 6px 0; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; }

/* Brief T: a webhook or spreadsheet link block, and a value shown once. */
.hook { border-top: 1px solid var(--border); padding: 10px 0; }
.hook p { margin: 0 0 6px; overflow-wrap: anywhere; }
.mono-input { width: 100%; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

/* Brief W: model rows (name and two prices) on an Other model or TypeSafe provider form */
.provider-models .model-rows { display: grid; gap: 8px; margin-bottom: 8px; }
.model-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: end; }
.model-row label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; font-weight: 600; min-width: 0; }
.model-row input { min-width: 0; width: 100%; }
@media (max-width: 560px) {
  .model-row { grid-template-columns: 1fr 1fr; }
  .model-row label:first-child { grid-column: 1 / -1; }
}

/* Brief Z: the Demo screen and the demo badge. */
.demo-badge { display: inline-block; margin-left: 0.6rem; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; background: var(--primary); color: var(--primary-text); vertical-align: middle; }
.demo-filters { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: end; margin-top: 0.5rem; }
.demo-filters input, .demo-filters select { min-width: 12rem; }
.demo-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 0.9rem; }
.demo-card { border: 1px solid var(--border); border-radius: 12px; padding: 0.9rem; display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.demo-card[hidden], .demo-section[hidden] { display: none; }
.demo-card p { margin: 0; }
.demo-card .actions { margin-top: auto; padding-top: 0.4rem; }
.demo-card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem; }
.demo-num { font-weight: 700; color: var(--muted); min-width: 1.6rem; }
.demo-example { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.demo-note pre, .demo-draft { white-space: pre-wrap; overflow-wrap: anywhere; }
.demo-steps { padding-left: 1.2rem; }
.demo-steps li { margin: 0.35rem 0; }
.demo-wait { display: flex; align-items: center; gap: 0.6rem; }
.demo-spinner { width: 1rem; height: 1rem; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: demo-spin 0.9s linear infinite; }
@keyframes demo-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .demo-spinner { animation: none; } }

/* Live lists (app/public/js/live-list.js): blank spacers for the rows not in the page, zero-height markers between
   blocks, and a row that says a block is loading. */
.rec-table tr.rec-spacer, .rec-table tr.rec-mark, .rec-table tr.rec-loading { border: 0; padding: 0; margin: 0; background: none; box-shadow: none; }
.rec-table tr.rec-spacer td, .rec-table tr.rec-mark td { padding: 0; border: 0; }
.rec-table tr.rec-mark { height: 0; }
.rec-table tr.rec-loading td { color: var(--muted); font-size: 0.875rem; text-align: center; vertical-align: middle; border: 0; }


/* ---- Brief Z2: formatted text (app/lib/rich-text.js) and results a person acts on (views/partials/result.ejs) ---- */
.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; }
.rt { overflow-wrap: anywhere; line-height: 1.55; }
.rt > :first-child { margin-top: 0; }
.rt > :last-child { margin-bottom: 0; }
.rt p { margin: 0 0 0.6em; }
.rt .rt-h { margin: 1em 0 0.4em; font-size: 1.02rem; }
.rt h3.rt-h { font-size: 1.08rem; }
.rt ul, .rt ol { margin: 0 0 0.7em; padding-left: 1.4em; }
.rt li { margin: 0.15em 0; }
.rt ul.rt-checks { list-style: none; padding-left: 0.2em; }
.rt .rt-box { display: inline-block; width: 0.9em; height: 0.9em; margin-right: 0.45em; border: 2px solid var(--muted); border-radius: 3px; vertical-align: -0.1em; }
.rt .rt-box.is-done { background: var(--primary); border-color: var(--primary); }
.rt .rt-quote { margin: 0 0 0.7em; padding: 0.3em 0.9em; border-left: 3px solid var(--border); color: var(--muted); }
.rt .rt-rule { border: 0; border-top: 1px solid var(--border); margin: 0.9em 0; }
.rt .rt-pre { white-space: pre-wrap; }
.rt .rt-table-wrap { overflow-x: auto; margin: 0 0 0.8em; }
.rt .rt-table td, .rt .rt-table th { vertical-align: top; }
.rs { display: flex; flex-direction: column; gap: 14px; }
.rs-next { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--info-bg); color: var(--info-text); font-weight: 600; }
.rs-next.is-held { background: #fff4e0; color: #7a4a00; }
.rs-next.is-sent { background: var(--ok-bg); color: var(--ok-text); }
.rs-block { border-top: 1px solid var(--border); padding-top: 12px; }
.rs-block > h3 { margin: 0 0 8px; font-size: 1rem; }
.rs-before { border: 1px solid var(--gold-soft); border-radius: 12px; padding: 12px 14px; background: color-mix(in srgb, var(--gold-soft) 12%, var(--surface)); }
.rs-questions { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 10px; }
.rs-q p { margin: 0 0 6px; }
.rs-q.is-answered { opacity: 0.85; }
.rs-who { display: inline-block; margin-right: 6px; padding: 0 7px; border-radius: 6px; background: var(--surface-2); font-weight: 700; font-size: 0.85rem; }
.rs-answer-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rs-answer-form input[type="text"] { flex: 1 1 200px; min-width: 0; }
.rs-files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rs-file { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: inherit; background: var(--surface); }
.rs-file:hover { border-color: var(--primary); }
.rs-file-icon { flex: 0 0 auto; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; background: var(--primary); color: var(--primary-text); font-size: 0.72rem; font-weight: 700; }
.rs-mail { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.rs-mail-head { margin: 0; padding: 10px 14px; background: var(--surface-2); display: grid; gap: 4px; }
.rs-mail-head div { display: flex; gap: 8px; }
.rs-mail-head dt { min-width: 4.5em; color: var(--muted); font-weight: 600; }
.rs-mail-head dd { margin: 0; overflow-wrap: anywhere; }
.rs-mail-body { padding: 14px; }
.rs-signoff { margin: 0.8em 0 0; }
.rs-gap { background: #fff0c2; color: #6a4600; padding: 0 4px; border-radius: 4px; font-weight: 600; }
.rs-chips { list-style: none; margin: 0; padding: 0 14px 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.rs-chip { display: inline-flex; gap: 6px; align-items: center; padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: inherit; text-decoration: none; font-size: 0.9rem; overflow-wrap: anywhere; }
.rs-chip.is-missing { border-style: dashed; color: var(--danger-text); }
.rs-noattach { padding: 0 14px 12px; margin: 0; }
.rs-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.rs-sent { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--ok-bg); color: var(--ok-text); }
.rs-edit { margin-top: 10px; }
.rs-steps { margin: 6px 0 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; }
.rs-by { display: inline-block; min-width: 3.2em; text-align: center; padding: 0 6px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; }
.rs-by-ai { background: var(--violet); color: #fff; }
.rs-by-code { background: var(--gray); color: #fff; }
.rs-how summary { cursor: pointer; font-weight: 600; }
.queue-summary { display: block; color: var(--muted); margin-top: 2px; }
.wk-io-text { max-height: 420px; overflow: auto; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .rs-next.is-held { background: #3a2a0c; color: #ffd98a; }
  :root:not([data-theme="light"]) .rs-gap { background: #4a3a10; color: #ffe2a0; }
}
:root[data-theme="dark"] .rs-next.is-held { background: #3a2a0c; color: #ffd98a; }
:root[data-theme="dark"] .rs-gap { background: #4a3a10; color: #ffe2a0; }

/* ---- Brief Z2: the Demo screen as a presenter's tool, story pages, Who's who, large type for a projector ---- */
.demo-head-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.demo-search input[type="search"] { width: 100%; font-size: 1.15rem; padding: 0.7rem 0.9rem; border-radius: 12px; }
.demo-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.75rem 0 0.4rem; }
.demo-chip { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 0.35rem 0.8rem; font: inherit; font-size: 0.9rem; cursor: pointer; }
.demo-chip.is-on { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.demo-chip.is-on .muted { color: var(--primary-text); opacity: 0.85; }
.demo-chip:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.demo-cards { margin-top: 0.9rem; }
.demo-card { padding: 0; }
.demo-card-link { display: flex; gap: 0.75rem; padding: 0.9rem; color: inherit; text-decoration: none; border-radius: 12px; height: 100%; }
.demo-card-link:hover, .demo-card-link:focus-visible { background: var(--surface-2); }
.demo-card .demo-num { flex: 0 0 auto; display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 50%; background: var(--surface-2); color: var(--text); font-size: 0.95rem; }
.demo-card-body { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.demo-card-name { font-size: 1.02rem; }
.demo-card-see { color: var(--text); }
.demo-card-asks { font-style: italic; }
.demo-story-title { margin: 0.1rem 0 0.4rem; font-size: 1.5rem; }
.demo-see { font-size: 1.05rem; margin: 0; }
.demo-step { display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; margin-right: 0.4rem; border-radius: 50%; background: var(--primary); color: var(--primary-text); font-size: 0.9rem; vertical-align: 0.1em; }
.demo-situation { font-size: 1.05rem; }
.demo-who-list, .demo-knows, .demo-files { padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.45rem; }
.demo-files { list-style: none; padding-left: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.8rem; }
.demo-files li { display: flex; flex-direction: column; gap: 0.35rem; }
.demo-thumb { width: 100%; max-width: 22rem; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); display: block; }
.demo-audio { width: 100%; max-width: 22rem; }
.demo-incoming { margin-bottom: 0.6rem; }
.demo-incoming .rs-mail-body p { margin: 0 0 0.35rem; }
.demo-progress { margin-top: 0.8rem; }
.demo-who-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.6rem; }
.demo-who-grid li { border: 1px solid var(--border); border-radius: 10px; padding: 0.55rem 0.7rem; }
.demo-who-companies { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.demo-who-companies > li { border-top: 1px solid var(--border); padding-top: 0.6rem; }
.demo-who-companies ul { margin: 0.3rem 0; padding-left: 1.2rem; }
.demo-who-biz { margin-top: 0.4rem; }
:target { scroll-margin-top: 5rem; }
.demo-who-grid li:target, .demo-who-companies li:target { background: color-mix(in srgb, var(--gold-soft) 25%, var(--surface)); }
html.demo-large { font-size: 125%; }
html.demo-large .demo-story-title { font-size: 1.8rem; }

/* ---- Guided demos (brief Z3): the guide box, the outline around what a step is about, the popup ---- */
.guide-box { position: fixed; right: 16px; bottom: 16px; z-index: 1000; width: min(380px, calc(100vw - 32px)); max-height: min(78vh, 680px); overflow: auto; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-top: 4px solid var(--primary); border-radius: 14px; box-shadow: 0 12px 40px rgba(20, 8, 40, 0.28); padding: 0.75rem 0.9rem 0.8rem; display: flex; flex-direction: column; gap: 0.45rem; }
.guide-box.is-left { right: auto; left: 16px; }
.guide-head { display: flex; align-items: center; gap: 0.6rem; }
.guide-avatar { flex: none; width: 2.4rem; height: 2.4rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 0.95rem; color: #fff; background: var(--violet); box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 30%, transparent); }
.guide-who { flex: 1; min-width: 0; }
.guide-name { margin: 0; font-weight: 700; }
.guide-of { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guide-tag { flex: none; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; padding: 0.2rem 0.55rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.guide-tag-ai { background: var(--violet); border-color: var(--violet); color: #fff; }
.guide-tag-person { background: var(--gold); border-color: var(--gold); color: #fff; }
.guide-tag-rule { background: var(--surface-2, var(--bg)); color: var(--text); }
.guide-progress { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.guide-progress > span { display: block; height: 100%; background: var(--primary); }
.guide-count { margin: 0; }
.guide-title { margin: 0.1rem 0 0; font-size: 1.15rem; line-height: 1.3; }
.guide-title:focus { outline: none; }
.guide-text-p { margin: 0.3rem 0 0; line-height: 1.5; }
.guide-list { margin: 0.4rem 0 0; padding-left: 1.2rem; line-height: 1.45; }
.guide-list li + li { margin-top: 0.25rem; }
.guide-note { margin: 0; padding: 0.4rem 0.55rem; border-radius: 8px; background: color-mix(in srgb, var(--gold-soft) 30%, var(--surface)); }
.guide-end { display: flex; flex-wrap: wrap; gap: 0.4rem; padding-top: 0.4rem; border-top: 1px solid var(--border); }
.guide-end form { margin: 0; }
.guide-actions { display: flex; align-items: center; gap: 0.4rem; padding-top: 0.2rem; }
.guide-spacer { flex: 1; }
.guide-actions .is-disabled { opacity: 0.45; cursor: default; }
.guide-keys { margin: 0; }
.guide-dim { position: fixed; inset: 0; z-index: 900; pointer-events: none; width: 100vw; height: 100vh; }
.guide-dim rect.guide-shade { fill: rgba(20, 8, 40, 0.22); }
:root[data-theme="dark"] .guide-dim rect.guide-shade { fill: rgba(0, 0, 0, 0.42); }
.guide-mark { position: fixed; z-index: 960; pointer-events: none; border: 3px solid var(--gold); border-radius: 10px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 28%, transparent); transition: top 120ms ease, left 120ms ease, width 120ms ease, height 120ms ease; }
.guide-pop { position: fixed; z-index: 950; left: 16px; top: 5.5rem; width: min(560px, calc(100vw - 440px)); max-height: calc(100vh - 7.5rem); overflow: auto; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 40px rgba(20, 8, 40, 0.3); padding: 0.85rem 1rem 1rem; animation: guide-in 260ms ease-out; }
.guide-pop.is-closed { display: none; }
.guide-pop-head { display: flex; align-items: center; gap: 0.5rem; justify-content: space-between; }
.guide-pop-label { margin: 0; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--primary); }
.guide-pop-title { margin: 0.3rem 0 0.6rem; font-size: 1.2rem; }
.guide-mail-head { margin: 0 0 0.6rem; display: grid; gap: 0.15rem; }
.guide-mail-head > div { display: flex; gap: 0.5rem; }
.guide-mail-head dt { flex: none; width: 5.2rem; color: var(--muted); }
.guide-mail-head dd { margin: 0; overflow-wrap: anywhere; }
.guide-mail-body { border-top: 1px solid var(--border); padding-top: 0.6rem; line-height: 1.5; }
.guide-mail-body p { margin: 0 0 0.5rem; }
.guide-files { list-style: none; padding: 0; margin: 0.6rem 0 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.guide-files li { display: flex; flex-direction: column; gap: 0.3rem; }
.guide-files img { width: 9rem; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.guide-reading { width: 100%; }
.guide-reading td:first-child { width: 42%; color: var(--muted); }
.guide-reading tr.is-missing td:last-child { color: var(--muted); font-style: italic; }
.guide-lines { margin: 0; padding-left: 1.2rem; line-height: 1.5; }
.guide-lines li + li { margin-top: 0.3rem; }
.guide-photo { width: 100%; border-radius: 10px; border: 1px solid var(--border); }
.guide-pdf { width: 100%; height: min(70vh, 640px); border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.guide-text { white-space: pre-wrap; font-size: 0.9rem; background: var(--bg); padding: 0.6rem; border-radius: 8px; max-height: 50vh; overflow: auto; }
.is-staged.is-new { animation: guide-new 1.6s ease-out 1; }
.is-staged { background-color: color-mix(in srgb, var(--gold-soft) 18%, transparent); }
@keyframes guide-new { 0% { background-color: color-mix(in srgb, var(--gold-soft) 85%, transparent); } 100% { background-color: color-mix(in srgb, var(--gold-soft) 18%, transparent); } }
@keyframes guide-in { from { opacity: 0; } to { opacity: 1; } }
/* Room to scroll the page out from under the box. */
.has-guide .content { padding-bottom: 50vh; }
/* On a wide screen the page keeps clear of the box. */
@media (min-width: 1400px) {
  .has-guide .content { padding-right: 410px; }
}
.guide-summary { max-width: 620px; }
@media (max-width: 720px) {
  .guide-box, .guide-box.is-left { left: 0; right: 0; bottom: 0; width: 100%; max-height: 52vh; border-radius: 14px 14px 0 0; padding: 0.6rem 0.8rem 0.7rem; }
  .guide-keys { display: none; }
  .guide-pop { left: 8px; width: calc(100vw - 16px); top: 3.8rem; max-height: calc(48vh - 4.4rem); padding: 0.7rem 0.8rem; }
  .guide-mail-head dt { width: 4.4rem; }
  .has-guide .content { padding-bottom: 60vh; }
}
html.demo-large .guide-box { width: min(460px, calc(100vw - 32px)); }
@media (prefers-reduced-motion: reduce) {
  .guide-mark { transition: none; }
  .is-staged.is-new, .guide-pop { animation: none; }
}
@media print { .guide-box, .guide-pop, .guide-dim, .guide-mark { display: none !important; } }
.guide-summary h2 { margin-top: 0.3rem; }
.guide-sum-list { margin: 0.4rem 0 0.9rem; padding-left: 1.4rem; line-height: 1.55; }
.guide-sum-list li + li { margin-top: 0.3rem; }
.guide-sum-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0.8rem 1.4rem; }
.guide-sum-cols h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.guide-sum-steps { list-style: none; margin: 0 0 0.8rem; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.guide-sum-steps .guide-tag { margin-right: 0.35rem; }
.demo-card-more { padding: 0 0.9rem 0.6rem 3.4rem; }
.demo-shown { font-weight: 700; color: var(--gold); }

/* Brief Z4: Ask and search the Second Brain. */
.brain-search { margin-top: 14px; }
.brain-line { margin: 4px 0 0; font-size: 0.9rem; overflow-wrap: anywhere; }
.brain-line mark, .brain-quote mark { background: color-mix(in srgb, var(--gold) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.brain-answer p { margin: 0 0 10px; line-height: 1.55; overflow-wrap: anywhere; }
.brain-answer p:last-child { margin-bottom: 0; }
.brain-ref { text-decoration: none; font-weight: 600; }
.brain-sources { margin: 6px 0 0; padding-left: 26px; }
.brain-sources li { margin-bottom: 10px; overflow-wrap: anywhere; }
.brain-quote { margin: 4px 0 0; padding: 6px 10px; border-left: 3px solid var(--border); color: var(--muted); font-size: 0.9rem; }
.small-heading { font-size: 0.95rem; margin: 16px 0 6px; }
.connector-address { font-size: 0.95rem; overflow-wrap: anywhere; user-select: all; }
.connector-steps { margin: 6px 0 12px; padding-left: 22px; }
.connector-steps li { margin-bottom: 6px; }
.connector-can { margin: 8px 0 12px; padding-left: 22px; text-align: left; }
.connector-can li { margin-bottom: 4px; }

/* Brief Z5: the quick model beside the main one, and Models and routing. */
.quick-model { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.quick-model .actions { margin-top: 6px; }
.tier-badge { display: inline-block; font-size: 0.78rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); }
.tier-quick { background: color-mix(in srgb, var(--gold) 18%, transparent); }
.measure-equal { color: var(--ok-text); font-weight: 600; }
.measure-worse { color: var(--danger-text); font-weight: 600; }
.measure-none { color: var(--muted); }
.wk-step-tier { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.tier-form { display: inline-flex; align-items: center; gap: 6px; }
.tier-form select { padding: 3px 6px; max-width: 100%; }
.mr-pack summary { cursor: pointer; }
.mr-steps li { padding: 6px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.mr-steps li:last-child { border-bottom: 0; }
.mr-detail { margin-top: 4px; }
.mr-detail pre { white-space: pre-wrap; max-width: 100%; overflow-x: auto; }
.input-short { width: 5.5em; display: inline-block; }

.quick-suggest { margin-top: 6px; font-weight: normal; }

/* Brief A01: a company's types, each with its status. */
.rec-type-statuses { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.rec-type-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.rec-type-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rec-type-row .act-form { display: inline-flex; align-items: center; gap: 6px; }

/* Brief A01: the company filter builder. */
.fb-root { display: grid; gap: 10px; }
.fb-group { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 0; display: grid; gap: 8px; min-width: 0; }
.fb-group .fb-group { background: var(--surface-2); }
.fb-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 4px; }
.fb-cond { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.fb-cond select, .fb-cond input[type="text"], .fb-cond input[type="number"], .fb-cond input[type="date"] { max-width: 100%; }
.fb-choices { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; }
.fb-related { border-left: 3px solid var(--accent, var(--border)); padding-left: 10px; display: grid; gap: 6px; }
.fb-add { display: flex; flex-wrap: wrap; gap: 6px; }
.fb-reading { margin-top: 12px; }
.fb-reading-text { font-weight: 600; }
.fb-preview { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 2px; }

/* Brief A01: the filters under Companies in the menu. */
.menu-item.menu-sub { padding-left: 2.6rem; font-size: 0.93em; }
.menu-item.menu-sub .icon { width: 16px; height: 16px; }

/* Brief A01: the Companies screen's tabs. */
.co-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; }
.co-tab-list { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0; padding: 0; flex: 1 1 auto; min-width: 0; }
.co-tab a { display: inline-block; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; color: inherit; text-decoration: none; background: var(--surface); }
.co-tab a:hover, .co-tab a:focus-visible { background: var(--surface-2); }
.co-tab.is-current a { background: var(--accent, #5b3fd1); border-color: var(--accent, #5b3fd1); color: #fff; font-weight: 600; }
.co-tab.is-dragging { opacity: 0.5; }
.co-more, .co-arrange { position: relative; }
.co-more > summary, .co-arrange > summary { list-style: none; cursor: pointer; }
.co-more > summary::-webkit-details-marker, .co-arrange > summary::-webkit-details-marker { display: none; }
.co-more-list, .co-arrange-panel { position: absolute; z-index: 20; right: 0; top: calc(100% + 4px); min-width: 260px; max-width: min(92vw, 420px); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; margin: 0; display: grid; gap: 6px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18); }
.co-arrange-list { margin: 0; padding-left: 1.2rem; display: grid; gap: 6px; }
.co-more-list { list-style: none; }
.co-more-list li, .co-arrange-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; justify-content: space-between; }
/* Arrange tabs: a board of two lists, Tabs and Under More; drag within or across (app/public/js/company-tabs.js). */
.co-arrange-panel { min-width: min(92vw, 300px); max-width: min(92vw, 620px); width: max-content; }
.co-board { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 10px; }
.co-zone { display: grid; align-content: start; gap: 6px; min-height: 120px; padding: 8px; border: 1px dashed var(--border); border-radius: 10px; background: var(--surface-2); }
.co-zone.is-over { border-style: solid; border-color: var(--accent, #5b3fd1); }
.co-zone-title { margin: 0; font-size: 0.9rem; }
.co-zone-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; min-height: 44px; }
.co-zone-empty { display: none; margin: 0; }
.co-zone-more.is-empty .co-zone-empty { display: block; }
.co-chip { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: grab; user-select: none; -webkit-user-select: none; }
.co-chip.is-dragging { opacity: 0.6; outline: 2px dashed var(--accent, #5b3fd1); outline-offset: 1px; }
.co-grip { flex: none; width: 22px; height: 30px; margin: -4px 0 -4px -4px; touch-action: none; cursor: grab; opacity: 0.6;
  background-image: radial-gradient(circle, currentColor 1.3px, transparent 1.6px); background-size: 7px 7px; background-position: center; }
.co-chip-name { flex: 1 1 8rem; min-width: 0; overflow-wrap: anywhere; }
.co-chip-acts { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.is-sorting, .is-sorting .co-chip, .is-sorting .co-grip { cursor: grabbing; }
.co-more.is-drop-target > summary { outline: 2px dashed var(--accent, #5b3fd1); outline-offset: 2px; }
.co-more.is-over > summary { background: var(--surface-2); }
.co-arrange-status:empty { display: none; }
.co-reading { margin-top: -4px; }
.co-columns { margin: 8px 0; }

/* Brief A01: Your account, Menu. */
.am-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.am-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: grab; }
.am-row.is-dragging { opacity: 0.5; }
.am-pos { width: 4.5rem; }

@media (max-width: 640px) {
  /* On a phone the panels hang from the whole row of tabs, edge to edge, not from their button. */
  .co-tabs { position: relative; }
  .co-more, .co-arrange { position: static; }
  .co-more-list { left: 0; right: auto; }
  .co-arrange-panel { left: 0; right: 0; width: auto; min-width: 0; max-width: none; }
  .co-board { grid-template-columns: 1fr; }
}

/* Brief A01 part 5: choosing companies on a list, and acting on them. */
.sel-cell { width: 2.2rem; text-align: center; }
.co-select-bar { position: sticky; bottom: 0; z-index: 5; margin-top: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.co-select-bar.has-choice { border-color: var(--accent, #5b3fd1); box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.12); }
.co-select-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.co-select-form [data-sel-count] { flex: 1 1 auto; }
.act-list { max-height: 18rem; overflow: auto; margin: 6px 0; padding-left: 1.2rem; }
.act-progress { width: 100%; height: 12px; }
@media (max-width: 640px) { .rec-table .sel-cell { width: auto; text-align: left; } }


/* Brief A01 part 6: email campaigns. */
.ec-steps { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 12px; }
.ec-steps li { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.ec-body { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; margin: 6px 0; max-width: 100%; }
.ec-domain { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }

/* Brief A03: connected systems on a company or contact page, and the API's Admin pages. */
.cs-refs { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 4px; }
.cs-refs code, .api-ref code { overflow-wrap: anywhere; }
.cs-conflict { border-top: 1px solid var(--border); padding: 8px 0 2px; }
.cs-conflict p { margin: 0 0 6px; overflow-wrap: anywhere; }
.api-writes { color: var(--danger-text); background: var(--danger-bg); border-radius: 6px; padding: 1px 6px; font-weight: 600; }
.api-perm-group { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin: 0; min-width: 0; }
.api-perm-group.writes { border-color: var(--danger-text); }
.api-perm-group label.check { display: block; }
.api-perm-group .says { display: block; margin-left: 1.6rem; }
.api-tabs { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 12px; }
.api-tabs a[aria-current="page"] { font-weight: 700; text-decoration: none; }
.api-ref { border-top: 1px solid var(--border); padding: 10px 0; min-width: 0; }
.api-ref h3 { margin: 0 0 4px; font-size: 1rem; overflow-wrap: anywhere; }
.api-ref pre { margin: 6px 0; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); overflow-x: auto; max-width: 100%; font-size: 0.85rem; }
.api-activity td { overflow-wrap: anywhere; }
.api-search { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 10px; }
.api-limit-form { margin-top: 8px; align-items: end; }
form.stack + .api-limit-form { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.api-activity td[data-label="Record"] { white-space: nowrap; }
.api-result { display: inline-flex; gap: 6px; align-items: baseline; min-width: 0; }
.api-result .badge { flex: none; white-space: nowrap; }

/* Brief A04: inbox clean-ups. */
.cleanup-line { margin: 8px 0 0; overflow-wrap: anywhere; }
.cu-offer { border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 10px; padding: 10px 12px; margin: 10px 0; background: var(--surface-2); }
.cu-offer p { margin: 0 0 6px; }
.cu-offer p:last-child { margin: 0; }
.cu-table td { overflow-wrap: anywhere; }
.cu-notes { margin: 8px 0; padding-left: 1.2rem; }
.cu-counts { list-style: none; padding: 0; margin: 6px 0 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 16px; }
.cu-sample { margin: 6px 0; }
.cu-sample summary { cursor: pointer; }
.cu-sample li { overflow-wrap: anywhere; }
.cu-start { margin: 12px 0 6px; align-items: end; }
/* Brief A04: a long address in a card's heading wraps instead of pushing the page sideways (the Mail screen's mailbox
   header and a clean-up's page, at phone width). */
.section-head > div { min-width: 0; }
.section-head h2, .section-head p { overflow-wrap: anywhere; }

/* Brief A05: Newsletters. The list, an issue's page, the editor (blocks beside a preview), Admin, Newsletters. */
.nl-filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin: 10px 0; }
.nl-filters label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; }
.nl-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 10px 0; }
.nl-facts dt { font-weight: 600; }
.nl-facts dd { margin: 0; overflow-wrap: anywhere; }
.nl-schedule, .nl-test { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-top: 12px; }
.nl-schedule label, .nl-test label { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.nl-test input[type="text"] { min-width: 240px; flex: 1 1 240px; }
.nl-template summary { list-style: none; cursor: pointer; }
.nl-template[open] form { margin-top: 8px; }
.nl-previews { display: flex; gap: 16px; align-items: flex-start; overflow-x: auto; padding-bottom: 6px; }
.nl-frame { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.nl-frame iframe { border: 1px solid var(--border); border-radius: 8px; background: #ffffff; height: 640px; }
.nl-frame-wide iframe { width: 640px; }
.nl-frame-phone iframe { width: 375px; }
.nl-text-frame { width: 100%; height: 360px; border: 1px solid var(--border); border-radius: 8px; background: #ffffff; }
.nl-ev { display: inline-block; margin-right: 8px; white-space: nowrap; }
.nl-events { margin-top: 12px; }
.nl-rec-table td { overflow-wrap: anywhere; }
.nl-code { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 0.85rem; }
.nl-domain { margin-top: 12px; }
.nl-records code { overflow-wrap: anywhere; }
.nl-logo-preview { max-width: 200px; height: auto; border: 1px solid var(--border); border-radius: 6px; background: #ffffff; padding: 6px; }
.nl-gap { margin-top: 12px; }
.nl-provider-pick { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.nl-provider-fields { margin-top: 8px; }
.brief-approvals .act-form { margin-left: 8px; }

.nl-head .nl-saved { margin: 0; }
.nl-merge { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.nl-subjects { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.nl-workspace { display: grid; grid-template-columns: minmax(340px, 1fr) minmax(0, 680px); gap: 16px; align-items: start; }
.nl-preview-card { position: sticky; top: calc(var(--sticky-top, 64px) + 8px); }
.nl-preview-card .nl-previews { flex-direction: column; align-items: stretch; }
.nl-preview-card .nl-frame-wide { overflow-x: auto; }
.nl-preview-card .nl-frame-wide iframe { width: 640px; height: 520px; }
.nl-preview-card .nl-frame-phone iframe { width: 375px; max-width: 100%; height: 520px; }
.nl-tabs { display: flex; gap: 6px; }
.nl-text { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; }
.nl-warn { margin-top: 8px; }
.nl-blocks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.nl-block { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 10px; }
.nl-block-footer { background: var(--surface-2); }
.nl-dragging { outline: 2px dashed var(--primary); opacity: 0.85; }
.nl-block-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.nl-block-tools { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.nl-grip { cursor: grab; touch-action: none; user-select: none; padding: 2px 6px; border-radius: 6px; color: var(--muted); }
.nl-grip:active { cursor: grabbing; }
.nl-block-body { display: flex; flex-direction: column; gap: 8px; }
.nl-row { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-end; }
.nl-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.nl-field > span:first-child { font-weight: 600; font-size: 0.9rem; }
.nl-rich { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.nl-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border-bottom: 1px solid var(--border); align-items: center; }
.nl-toolbar input[type="color"] { width: 32px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: 6px; }
.nl-toolbar select { width: auto; }
.nl-swatch { width: 26px; height: 26px; min-width: 26px; padding: 0; border-radius: 50%; border: 1px solid var(--border); }
.nl-linkrow { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border-bottom: 1px solid var(--border); }
.nl-linkrow input { flex: 1 1 200px; }
.nl-rich-area { min-height: 90px; padding: 10px; outline: none; overflow-wrap: anywhere; }
.nl-rich-area:focus { box-shadow: inset 0 0 0 2px var(--focus); border-radius: 0 0 8px 8px; }
.nl-pic { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.nl-pic-thumb { max-width: 120px; max-height: 80px; border-radius: 6px; border: 1px solid var(--border); }
.nl-ai details { margin-top: 4px; }
.nl-ai input { width: 100%; margin: 6px 0; }
.nl-ai-text { border-left: 3px solid var(--primary); padding-left: 10px; margin: 6px 0; }
.nl-col { border: 1px solid var(--border); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.nl-found label { display: flex; }
.nl-post { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; }
.nl-post textarea { width: 100%; }
.nl-aud fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.nl-checks { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.nl-dialog { max-width: 720px; width: calc(100% - 32px); border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 16px; }
.nl-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.nl-library { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; max-height: 320px; overflow-y: auto; }
.nl-thumb { display: flex; flex-direction: column; gap: 4px; align-items: stretch; padding: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; text-align: left; }
.nl-thumb img { width: 100%; height: 90px; object-fit: cover; border-radius: 4px; }
.nl-thumb span { overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .nl-workspace { grid-template-columns: minmax(0, 1fr); }
  .nl-preview-card { position: static; }
}
@media (max-width: 600px) {
  .nl-frame-wide { display: none; }
  .nl-previews .nl-frame-phone iframe, .nl-preview-card .nl-frame-phone iframe { width: 100%; }
  .nl-facts { grid-template-columns: minmax(0, 1fr); }
  .nl-facts dt { margin-top: 6px; }
  .nl-test input[type="text"] { min-width: 0; }
}
/* Only the chosen sending system's fields (every set shows until one is chosen, or without :has). */
.nl-system:has(input[name="provider"]:checked) [data-provider-fields] { display: none; }
.nl-system:has(input[name="provider"][value="postmark"]:checked) [data-provider-fields="postmark"],
.nl-system:has(input[name="provider"][value="ses"]:checked) [data-provider-fields="ses"] { display: block; }
.nl-rec-table td[data-label="Status"] { min-width: 7.5em; overflow-wrap: normal; }
.nl-rec-table td[data-label="Sent"] { min-width: 9em; }
.nl-rec-table td[data-label="Message id"] { max-width: 14em; }
@media (max-width: 600px) {
  .nl-ev { display: block; white-space: normal; margin-right: 0; }
}
