/* Handled CRM.
   Brand: Ink #0E0E10, Signal Red #E02B20, Bone #F4F2ED, White.
   Red is only for the mark, the primary button and the active tab.
   Status colours (good / warning / info) are separate from the red and always come with text. */

@font-face { font-family: 'General Sans'; src: url('/fonts/general-sans-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'General Sans'; src: url('/fonts/general-sans-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'General Sans'; src: url('/fonts/general-sans-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Montserrat'; src: url('/fonts/montserrat-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --h-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect x='18' y='12' width='18' height='76' rx='9'/%3E%3Crect x='64' y='12' width='18' height='76' rx='9'/%3E%3Crect x='18' y='54' width='64' height='18' rx='9'/%3E%3C/svg%3E");
  --ink: #0e0e10;
  --red: #e02b20;
  --red-press: #c4241a;
  --bone: #f4f2ed;
  --white: #ffffff;

  --bg: #f4f2ed;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --sunk: #ebe8e1;
  --line: rgba(14, 14, 16, 0.1);
  --line-strong: rgba(14, 14, 16, 0.2);
  --text: #0e0e10;
  --muted: #5d5a55;
  --header: #0e0e10;
  --header-text: #f4f2ed;
  --header-muted: rgba(244, 242, 237, 0.66);
  --header-line: rgba(244, 242, 237, 0.12);

  --good: #1b6e43;   --good-bg: #e1f0e7;
  --warn: #8a4f00;   --warn-bg: #fbe9cc;
  --info: #2a5394;   --info-bg: #e3ebf8;
  --quiet: #5d5a55;  --quiet-bg: #ebe8e1;

  --sans: 'General Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --brand: 'Montserrat', var(--sans);
  --r: 20px;
  --r-sm: 12px;
  --shadow: 0 1px 2px rgba(14, 14, 16, 0.04), 0 12px 32px -12px rgba(14, 14, 16, 0.12);
  --maxw: 1240px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0e0e10; --surface: #17171a; --surface-2: #1c1c20; --sunk: #242428;
    --line: rgba(244, 242, 237, 0.1); --line-strong: rgba(244, 242, 237, 0.22);
    --text: #f4f2ed; --muted: #aaa69e;
    --header: #08080a; --header-line: rgba(244, 242, 237, 0.1);
    --good: #74d3a1; --good-bg: rgba(116, 211, 161, 0.13);
    --warn: #f3b866; --warn-bg: rgba(243, 184, 102, 0.13);
    --info: #94b8f4; --info-bg: rgba(148, 184, 244, 0.13);
    --quiet: #aaa69e; --quiet-bg: rgba(244, 242, 237, 0.08);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0e0e10; --surface: #17171a; --surface-2: #1c1c20; --sunk: #242428;
  --line: rgba(244, 242, 237, 0.1); --line-strong: rgba(244, 242, 237, 0.22);
  --text: #f4f2ed; --muted: #aaa69e;
  --header: #08080a; --header-line: rgba(244, 242, 237, 0.1);
  --good: #74d3a1; --good-bg: rgba(116, 211, 161, 0.13);
  --warn: #f3b866; --warn-bg: rgba(243, 184, 102, 0.13);
  --info: #94b8f4; --info-bg: rgba(148, 184, 244, 0.13);
  --quiet: #aaa69e; --quiet-bg: rgba(244, 242, 237, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow-x: clip; /* the ink bands reach the screen edges; nothing may scroll sideways */
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 18px; line-height: 1.3; }
h3 { font-size: 15px; line-height: 1.35; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 6px; }
.site-header :focus-visible { outline-color: var(--header-text); }
.num { font-variant-numeric: tabular-nums; }
::selection { background: var(--text); color: var(--bg); }
html { caret-color: var(--text); scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin; }
a { text-underline-offset: 3px; text-decoration-thickness: 1px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -80px; z-index: 50; background: var(--surface); color: var(--text); padding: 10px 14px; border-radius: var(--r-sm); }
.skip:focus { top: 12px; }

/* ---------- ink surfaces ----------
   The header and each page's masthead are Handled's ink world (as on handledtc.co.uk).
   .on-ink re-points the tokens, so every component inside adapts without its own rules. */
.on-ink {
  --surface: #1b1b1f; --surface-2: #222227; --sunk: #26262b;
  --line: rgba(244, 242, 237, 0.11); --line-strong: rgba(244, 242, 237, 0.24);
  --text: #f4f2ed; --muted: rgba(244, 242, 237, 0.66);
  --good: #74d3a1; --good-bg: rgba(116, 211, 161, 0.14);
  --warn: #f3b866; --warn-bg: rgba(243, 184, 102, 0.14);
  --info: #94b8f4; --info-bg: rgba(148, 184, 244, 0.14);
  --quiet: rgba(244, 242, 237, 0.72); --quiet-bg: rgba(244, 242, 237, 0.09);
  --shadow: none;
  background: var(--header); color: var(--text); color-scheme: dark;
}

/* ---------- preview strip ---------- */
.preview-strip {
  background: var(--sunk); color: var(--text); font-size: 13px;
  padding-block: 7px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.preview-strip .wrap { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; justify-content: space-between; }
.preview-strip strong { font-weight: 600; }
.view-as { display: inline-flex; gap: 4px; align-items: center; }
.view-as button {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 2px 10px 2px 3px;
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
}
.view-as button[aria-pressed='true'] { border-color: var(--text); font-weight: 600; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.wrap { max-width: var(--maxw); margin: 0 auto; }
.bar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px 20px; min-height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.brand svg { width: 34px; height: 34px; display: block; border-radius: 9px; }
.brand .word { font-family: var(--brand); font-weight: 700; font-size: 20px; letter-spacing: -0.015em; }
.brand .tag { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding-left: 11px; border-left: 1px solid var(--line-strong); }
.me-chip {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 4px 13px 4px 4px; font-size: 14px; font-weight: 500; white-space: nowrap; transition: border-color 0.2s;
  justify-self: end; cursor: pointer;
}
.me-chip:hover { border-color: var(--line-strong); }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  font-size: 12px; font-weight: 600; color: #fff; background: var(--c, #555);
}

/* The tab dock: a pill track with a red glider behind the active tab (the site's floating dock). */
.tabs-wrap { justify-self: center; max-width: 100%; overflow-x: auto; scrollbar-width: none; border-radius: 999px; }
.tabs-wrap::-webkit-scrollbar { display: none; }
.tabs { position: relative; display: inline-flex; gap: 2px; padding: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.tab {
  position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; text-decoration: none;
  color: var(--muted); font-weight: 500; font-size: 14px; height: 36px; padding: 0 15px; border-radius: 999px; transition: color 0.25s;
}
.tab:hover { color: var(--text); }
.tab[aria-current='page'] { color: #fff; }
.glider {
  position: absolute; z-index: 0; top: 4px; left: 0; height: 36px; border-radius: 999px; background: var(--red);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
  font-size: 11.5px; font-weight: 600; background: var(--quiet-bg); color: var(--text); font-variant-numeric: tabular-nums;
}
.tab[aria-current='page'] .badge { background: rgba(255, 255, 255, 0.22); color: #fff; }
@media (max-width: 1060px) {
  .bar { grid-template-columns: auto auto; justify-content: space-between; padding-top: 6px; }
  .tabs-wrap { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; margin-bottom: 10px; }
}

/* ---------- page and masthead ---------- */
main {
  padding-block: 0 72px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
main:focus { outline: none; }
.page { max-width: var(--maxw); margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }
.page > * { min-width: 0; }

/* The masthead continues the header's ink to the screen edges without widening the page. */
.masthead {
  box-shadow: 0 0 0 100vmax var(--header); clip-path: inset(0 -100vmax);
  padding-block: 26px 34px; display: grid; gap: 26px; position: relative;
}
.masthead h1 { font-size: clamp(30px, 3.6vw, 44px); line-height: 1.08; letter-spacing: -0.03em; font-weight: 600; }
.page-head { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: flex-end; justify-content: space-between; }
.page-head .lede { color: var(--muted); margin-top: 8px; font-size: 15.5px; }
.masthead .back { margin-bottom: -10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grid-2 { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.grid-main { display: grid; gap: 24px; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.stack { display: grid; gap: 24px; align-content: start; min-width: 0; }
@media (max-width: 900px) { .grid-2, .grid-main { grid-template-columns: minmax(0, 1fr); } }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
.panel-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 20px 22px 0; flex-wrap: wrap; }
.panel-head h2 { font-size: 17px; letter-spacing: -0.015em; }
.panel-head .count { min-width: 24px; height: 24px; padding: 0 8px; border-radius: 999px; display: inline-grid; place-items: center; font-size: 12.5px; font-weight: 600; background: var(--sunk); color: var(--muted); font-variant-numeric: tabular-nums; }
.panel-body { padding: 14px 22px 22px; }

/* ---------- figures (live in the masthead) ---------- */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.figures.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.figure { padding: 20px 24px 0; border-left: 1px solid var(--line); min-width: 0; }
.figure:first-child { border-left: 0; padding-left: 0; }
.figure .label { font-size: 13px; color: var(--muted); font-weight: 500; }
.figure .value { font-size: clamp(30px, 3.4vw, 46px); font-weight: 600; letter-spacing: -0.035em; line-height: 1.05; margin-top: 10px; font-variant-numeric: tabular-nums; }
.figure .value .unit { font-size: 0.5em; letter-spacing: -0.01em; color: var(--muted); margin-left: 3px; }
.figure .sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
.figure.lead .value { color: var(--text); }
@media (max-width: 760px) {
  .figures, .figures.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure { padding: 16px 0 0 16px; }
  .figure:nth-child(odd) { border-left: 0; padding-left: 0; }
  .figure:nth-child(n + 3) { border-top: 1px solid var(--line); margin-top: 16px; }
  .figures.three .figure:last-child { grid-column: 1 / -1; border-left: 0; padding-left: 0; }
}

/* ---------- monogram tiles (clients) ---------- */
.mono {
  width: 36px; height: 36px; border-radius: 11px; flex: none; display: inline-grid; place-items: center;
  background: var(--sunk); color: var(--text); font-weight: 600; font-size: 13px; letter-spacing: 0.01em;
}
.mono.lg { width: 60px; height: 60px; border-radius: 18px; font-size: 21px; background: var(--bone); color: var(--ink); }
.name-cell { display: flex; gap: 12px; align-items: center; min-width: 0; }
.client-title { display: flex; gap: 18px; align-items: center; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 0 18px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font-weight: 500; font-size: 14px; text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn:active { transform: scale(0.97); }
.btn:hover { background: var(--surface-2); border-color: var(--text); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 2px 6px rgba(14, 14, 16, 0.18); }
.btn-primary:hover { background: var(--red-press); border-color: var(--red-press); }
.btn-dark { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn-dark:hover { background: var(--text); opacity: 0.88; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--sunk); border-color: transparent; }
.btn-sm { min-height: 32px; padding: 0 13px; font-size: 13px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.icon { width: 16px; height: 16px; flex: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--text); text-decoration: underline; text-underline-offset: 2px; font-weight: 500; }

/* ---------- chips and pills ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; border-radius: 999px; padding: 2px 9px 2px 3px;
  font-size: 13px; font-weight: 500; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); white-space: nowrap;
}
.chip .dot { width: 16px; height: 16px; border-radius: 50%; background: var(--c); display: inline-grid; place-items: center; color: #fff; font-size: 10px; font-weight: 600; }
.chip.none { --c: #8a867f; padding-left: 9px; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; background: var(--quiet-bg); color: var(--quiet);
}
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); min-width: 0; }
.list > li:first-child { border-top: 0; }
.list .main { flex: 1; min-width: 0; }
.list .title { font-weight: 500; overflow-wrap: anywhere; }
.list .meta { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; color: var(--muted); font-size: 13px; margin-top: 3px; }
.list a.title { text-decoration: none; }
.list a.title:hover { text-decoration: underline; }
.row-link { text-decoration: none; display: block; }

/* ---------- empty states ---------- */
.empty { border: 1px dashed var(--line-strong); border-radius: calc(var(--r) - 6px); padding: 24px; display: grid; gap: 8px; justify-items: start; background: var(--surface-2); }
.empty::before {
  content: ''; width: 34px; height: 34px; margin-bottom: 4px; background: var(--line-strong);
  -webkit-mask: var(--h-mark) center / contain no-repeat; mask: var(--h-mark) center / contain no-repeat;
}
.empty h3 { font-size: 15px; }
.empty p { color: var(--muted); max-width: 60ch; }
.empty .btn { margin-top: 6px; }
.panel .empty { margin: 0; }

/* ---------- tables ---------- */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background-color 0.15s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tfoot td { font-weight: 600; border-top: 1px solid var(--line-strong); }
.tbl a { text-decoration: none; font-weight: 500; }
.tbl a:hover { text-decoration: underline; }

/* ---------- forms ---------- */
.form { display: grid; gap: 14px; }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 560px) { .form-row, .form-row.three { grid-template-columns: minmax(0, 1fr); } }
.field { display: grid; gap: 5px; min-width: 0; align-content: start; }
.field > label, .field > .label { font-size: 13px; font-weight: 500; }
.field .hint { font-size: 12.5px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 42px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface);
  padding: 8px 11px; font-size: 15px;
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.5; }
.input:focus { outline: 2px solid var(--text); outline-offset: 0; border-color: transparent; }
.input[aria-invalid='true'] { border-color: var(--warn); }
.err { color: var(--warn); font-size: 13px; font-weight: 500; }
.err:empty { display: none; }
.warning-note { display: flex; gap: 8px; align-items: flex-start; background: var(--warn-bg); color: var(--warn); border-radius: var(--r-sm); padding: 8px 11px; font-size: 13px; font-weight: 500; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input {
  appearance: none; -webkit-appearance: none; width: 20px; height: 20px; margin: 1px 0 0; flex: none; cursor: pointer;
  border: 1.5px solid var(--line-strong); border-radius: 50%; background: var(--surface) no-repeat center / 12px;
  transition: background-color 0.2s, border-color 0.2s;
}
.check input:hover { border-color: var(--text); }
.check input:checked {
  background-color: #2b8a57; border-color: #2b8a57;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.3l2.3 2.3 4.7-5' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
@media (prefers-reduced-motion: no-preference) {
  .check input:checked { animation: tick 0.32s cubic-bezier(0.16, 1, 0.3, 1); }
  @keyframes tick { 0% { transform: scale(0.6); } }
}
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches label { position: relative; }
.swatches input { position: absolute; opacity: 0; inset: 0; }
.swatches span { display: block; width: 32px; height: 32px; border-radius: 50%; background: var(--c); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line-strong); }
.swatches input:checked + span { box-shadow: 0 0 0 2px var(--text); }
.swatches input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 3px; }
.segmented { display: inline-flex; background: var(--sunk); border-radius: 999px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.segmented button, .segmented a {
  border: 0; background: transparent; border-radius: 999px; padding: 6px 14px; font-size: 13.5px; font-weight: 500; color: var(--muted); text-decoration: none;
}
.segmented [aria-pressed='true'], .segmented [aria-current='page'] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar .input { width: auto; min-width: 0; }
.search { flex: 1 1 220px; }

/* ---------- dialog ---------- */
dialog {
  border: 0; padding: 0; border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
}
dialog.wide { width: min(760px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(14, 14, 16, 0.5); }
.dlg { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: calc(100dvh - 24px); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px 6px; }
.dlg-body { padding: 10px 20px 18px; overflow-y: auto; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.dlg-foot .left { margin-right: auto; }
.close-x { border: 0; background: transparent; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.close-x:hover { background: var(--sunk); color: var(--text); }

/* ---------- toast ---------- */
.toasts { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--text); color: var(--bg); border-radius: 10px; padding: 10px 16px; font-size: 14px; font-weight: 500; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); }
.toast.bad { background: var(--warn); color: #fff; }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
  @keyframes rise { from { transform: translateY(8px); opacity: 0; } }
}

/* ---------- loading ---------- */
.loading { display: grid; place-items: center; min-height: 40vh; color: var(--muted); }
.fail { max-width: 520px; margin: 10vh auto; text-align: center; display: grid; gap: 12px; justify-items: center; }

/* ---------- details lists ---------- */
.dl { display: grid; grid-template-columns: minmax(110px, 0.8fr) minmax(0, 2fr); gap: 9px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13.5px; }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 420px) { .dl { grid-template-columns: minmax(0, 1fr); gap: 2px; } .dl dd { margin-bottom: 8px; } }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.back:hover { color: var(--text); }
.title-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }

/* ---------- progress ---------- */
.progress { height: 8px; border-radius: 99px; background: var(--sunk); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--good); border-radius: 99px; }
.checklist { display: grid; gap: 2px; margin-top: 12px; }
.checklist .group { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 12px 0 4px; }
.checklist .group:first-child { margin-top: 0; }
.checklist .check { padding: 6px 0; }
.checklist .check.done span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }

/* ---------- pipeline board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
.lane { background: color-mix(in srgb, var(--sunk) 70%, transparent); border-radius: var(--r); padding: 12px; display: grid; gap: 8px; align-content: start; min-height: 160px; }
.lane-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 4px; }
.lane-head h2 { font-size: 14px; }
.lane-head .sum { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 13px; display: grid; gap: 8px; box-shadow: var(--shadow); transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
.card:hover { transform: translateY(-2px); }
.card-top { display: flex; gap: 10px; align-items: center; min-width: 0; }
.card a.name { font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.card a.name:hover { text-decoration: underline; }
.card .meta { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 8px; }
.card select.input { min-height: 32px; padding: 4px 8px; font-size: 13px; }
.lane .none { color: var(--muted); font-size: 13px; padding: 6px 4px; }

/* ---------- log (notes, activity) ---------- */
.log { list-style: none; margin: 0; padding: 0; display: grid; }
.log > li { padding: 12px 0; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.log > li:first-child { border-top: 0; }
.log .who { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 13px; color: var(--muted); }
.log .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.composer { display: grid; gap: 8px; margin-bottom: 8px; }
.composer .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 12px; font-family: var(--sans); font-variant-numeric: tabular-nums; }
.chart .axis { stroke: var(--line-strong); }
.chart .grid { stroke: var(--line); }
.chart .bar-a { fill: var(--text); }
.chart .bar-b { fill: var(--muted); opacity: 0.45; }
.chart .val { fill: var(--text); font-weight: 600; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--k); }
.trend { font-weight: 500; }

/* ---------- calendar ---------- */
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
@media (max-width: 1000px) { .cal-layout { grid-template-columns: minmax(0, 1fr); } }
.cal-nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cal-nav h2 { min-width: 150px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.cal .dow { font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.cal .day {
  min-height: 108px; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; display: grid; align-content: start; gap: 3px;
  background: var(--surface); text-align: left; cursor: pointer; min-width: 0; color: inherit;
}
.cal .day:hover { background: var(--surface-2); }
.cal .day.out { background: var(--surface-2); color: var(--muted); }
.cal .day[aria-pressed='true'] { box-shadow: inset 0 0 0 2px var(--text); }
.cal .day .n { font-size: 13px; font-weight: 600; width: 24px; height: 24px; display: inline-grid; place-items: center; border-radius: 50%; }
.cal .day.today .n { background: var(--text); color: var(--bg); }
.ev { display: block; font-size: 11.5px; line-height: 1.3; padding: 2px 6px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--c) 15%, transparent); }
.ev::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--c); margin-right: 5px; vertical-align: 1px; }
.ev.off { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c) 24%, transparent) 0 5px, color-mix(in srgb, var(--c) 10%, transparent) 5px 10px); font-weight: 600; }
.ev.auto { --c: #8a867f; background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.dots { display: none; flex-wrap: wrap; gap: 3px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.dots i.off { box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 3px var(--c); }
.dots i.auto { background: var(--muted); }
@media (max-width: 700px) {
  .cal .day { min-height: 62px; padding: 4px; }
  .cal .ev { display: none; }
  .cal .dots { display: flex; }
  .cal .dow { padding: 6px 4px; }
}
.status-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.status-row:first-child { border-top: 0; }

/* ---------- files ---------- */
.drop { border: 2px dashed var(--line-strong); border-radius: var(--r); padding: 22px; display: grid; gap: 8px; justify-items: center; text-align: center; background: var(--surface-2); }
.drop.over { border-color: var(--text); background: var(--sunk); }
.meter { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.ftype { display: inline-grid; place-items: center; min-width: 38px; height: 22px; padding: 0 6px; border-radius: 5px; background: var(--sunk); font-size: 11px; font-weight: 600; letter-spacing: 0.03em; color: var(--muted); }
.preview-frame { width: 100%; height: min(70vh, 720px); border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; }
.preview-img { max-width: 100%; border-radius: var(--r-sm); display: block; margin: 0 auto; }

/* ---------- written pages (markdown) ---------- */
.prose { max-width: 72ch; line-height: 1.65; overflow-wrap: anywhere; }
.prose > * + * { margin-top: 0.8em; }
.prose h1 { font-size: 22px; }
.prose h2 { font-size: 18px; margin-top: 1.4em; }
.prose h3 { font-size: 15.5px; margin-top: 1.2em; }
.prose ul, .prose ol { padding-left: 1.3em; margin-bottom: 0; }
.prose li + li { margin-top: 0.25em; }
.prose code { background: var(--sunk); padding: 1px 5px; border-radius: 5px; font-size: 0.92em; }
.prose blockquote { margin-left: 0; margin-right: 0; padding: 10px 14px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--muted); }
.prose .tblwrap { overflow-x: auto; }
.prose table { border-collapse: collapse; font-size: 14px; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.prose hr { border: 0; border-top: 1px solid var(--line); }
.decision { display: flex; gap: 8px; align-items: flex-start; }
.star-btn { border: 0; background: transparent; padding: 2px; border-radius: 6px; color: var(--muted); flex: none; }
.star-btn[aria-pressed='true'], .starred { color: var(--warn); }
.star-btn[aria-pressed='true'] .icon path, .starred .icon path { fill: currentColor; }
.star-btn:hover { color: var(--text); }
.pinned-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.pin-card { text-decoration: none; display: grid; gap: 6px; padding: 16px; }
.pin-card:hover { border-color: var(--line-strong); }
.pin-card .excerpt { color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.editor { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 14px; min-height: 320px; }
.pager { display: flex; justify-content: center; padding-top: 12px; }

/* =========================================================
   Warm and colourful layer (Toby, 2026-10-21)
   Red returns as Handled's warmth: a glow in the ink band, blush on what needs attention,
   and the money chart. Stages, clients and sections each carry their own hue.
   ========================================================= */
:root { --blush: #fbe9e6; --blush-line: rgba(224, 43, 32, 0.16); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) { --blush: rgba(224, 43, 32, 0.1); --blush-line: rgba(224, 43, 32, 0.26); } }
:root[data-theme='dark'] { --blush: rgba(224, 43, 32, 0.1); --blush-line: rgba(224, 43, 32, 0.26); }

/* The ink band glows red from its lower right, like the site's lit statement. */
.masthead::before {
  content: ''; position: absolute; inset: 0 -100vmax; pointer-events: none;
  background:
    radial-gradient(38% 120% at 88% 115%, rgba(224, 43, 32, 0.34), transparent 70%),
    radial-gradient(30% 90% at 8% -20%, rgba(244, 242, 237, 0.06), transparent 70%);
}
.masthead > * { position: relative; z-index: 1; }
/* A large ghosted H sits behind the Overview band; its pull bar keeps a softened red. */
.masthead > .mast-mark { position: absolute; z-index: 0; right: -18px; top: -14px; width: 170px; height: 170px; color: rgba(244, 242, 237, 0.07); pointer-events: none; }
.mast-mark svg { width: 100%; height: 100%; }
.mast-mark svg rect:last-child { fill: rgba(224, 43, 32, 0.55); }
@media (max-width: 640px) { .masthead > .mast-mark { display: none; } }

/* Tab icons */
.tab .icon { width: 17px; height: 17px; opacity: 0.85; }
.tab[aria-current='page'] .icon { opacity: 1; }

/* Section heading icon tiles */
.h-ico { width: 30px; height: 30px; border-radius: 9px; display: inline-grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--h) 14%, transparent); color: color-mix(in srgb, var(--h) 78%, var(--text)); }
.h-ico .icon { width: 17px; height: 17px; }
.panel-head h2 { display: inline-flex; align-items: center; gap: 10px; }

/* What needs attention sits on blush, the site's red-into-bone card colour. */
.panel.attention { background: var(--blush); border-color: var(--blush-line); }
.panel.attention .list > li { border-color: var(--blush-line); }
.panel.attention .empty { background: transparent; border-color: var(--blush-line); }

/* Hue pills: stages, calendar kinds. Text always names the state. */
.pill.hue { background: color-mix(in srgb, var(--h) 15%, transparent); color: color-mix(in srgb, var(--h) 72%, var(--text)); }

/* Client tiles take the client's own colour. */
.mono.hue { background: var(--m); color: #fff; }
.mono.lg.hue { box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.5); }

/* Pipeline lanes tinted by stage */
.lane { background: color-mix(in srgb, var(--h, var(--sunk)) 7%, var(--surface-2)); border: 1px solid color-mix(in srgb, var(--h, var(--line)) 18%, transparent); }
.lane-head h2 { display: inline-flex; gap: 8px; align-items: center; }
.lane-head h2::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--h); }

/* Charts in colour: money in Handled red; calls and bookings in blue and green. */
.chart .bar-money { fill: var(--red); }
.chart .bar-calls { fill: #2f6fd6; }
.chart .bar-book { fill: #1e8e5a; }

/* Figures: a coloured dot names each figure's hue in the ink band. */
.figure .label { display: flex; align-items: center; gap: 8px; }
.figure .label::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--h, var(--muted)); flex: none; }

/* Motion: sections settle in when you open a page; figures count up (main.ts). */
@media (prefers-reduced-motion: no-preference) {
  main.enter .page > *:not(.masthead), main.enter .stack > *, main.enter .grid-2 > * {
    animation: settle 0.36s cubic-bezier(0.16, 1, 0.3, 1) both; animation-delay: calc(var(--i, 0) * 28ms);
  }
  main.enter .masthead h1 { animation: settle 0.4s cubic-bezier(0.16, 1, 0.3, 1) both; }
  @keyframes settle { from { opacity: 0.35; transform: translateY(6px); } }
}

/* ---------- goals ---------- */
.section-title { display: flex; align-items: center; gap: 10px; font-size: 19px; letter-spacing: -0.015em; }
.goal-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.goal { display: grid; gap: 12px; align-content: start; }
.goal.panel { padding: 20px 22px; }
.goal-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.goal-top h3 { font-size: 17px; letter-spacing: -0.015em; overflow-wrap: anywhere; }
.goal-pct { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; color: var(--red); }
.goal.compact .goal-top h3 { font-size: 15px; }
.goal.compact .goal-pct { font-size: 18px; }
/* The bar: a bone track with Handled's red pull filling it, ending in a rounded cap like the mark's crossbar. */
.goal-bar { height: 12px; border-radius: 999px; background: var(--sunk); overflow: hidden; }
.goal-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--red); min-width: 12px; }
.goal.compact .goal-bar { height: 8px; }
.goal-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; font-size: 13.5px; color: var(--muted); }
.goal-meta strong { color: var(--text); font-weight: 600; }
.goal-stack { display: grid; gap: 18px; }
.goal.compact + .goal.compact { padding-top: 18px; border-top: 1px solid var(--line); }
.latest-win { margin-top: 16px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--blush); color: var(--text); }
.wins .win { align-items: center; }
.win-ico { flex: none; }

/* ---------- celebration ---------- */
dialog.celebration {
  width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; background: transparent; box-shadow: none;
  display: grid; place-items: center; padding: 16px;
}
dialog.celebration::backdrop { background: rgba(14, 14, 16, 0.78); }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cel-card {
  position: relative; width: min(460px, 100%); background: #0e0e10; color: #f4f2ed; border-radius: 28px; padding: 34px 30px 28px;
  display: grid; gap: 10px; justify-items: center; text-align: center;
  box-shadow: 0 30px 80px -24px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(244, 242, 237, 0.1);
}
.cel-badge { width: 84px; height: 84px; border-radius: 26px; background: rgba(224, 43, 32, 0.14); display: grid; place-items: center; margin-bottom: 6px; }
.cel-badge svg { width: 56px; height: 56px; }
.cel-card h2 { font-size: clamp(24px, 5vw, 32px); line-height: 1.12; letter-spacing: -0.03em; }
.cel-detail { color: rgba(244, 242, 237, 0.78); max-width: 36ch; }
.cel-detail strong { color: #f4f2ed; }
.cel-date { font-size: 13px; color: rgba(244, 242, 237, 0.55); }
.cel-more { list-style: none; margin: 8px 0 4px; padding: 12px 0 0; border-top: 1px solid rgba(244, 242, 237, 0.12); display: grid; gap: 6px; font-size: 14px; width: 100%; }
.cel-more span { color: rgba(244, 242, 237, 0.66); }
.cel-card .btn { margin-top: 12px; min-width: 160px; }
@media (prefers-reduced-motion: no-preference) {
  dialog.celebration[open] .cel-card { animation: pop 0.55s cubic-bezier(0.16, 1, 0.3, 1); }
  dialog.celebration[open] .cel-badge { animation: pop 0.7s 0.08s cubic-bezier(0.16, 1, 0.3, 1) both; }
  @keyframes pop { from { transform: scale(0.86); opacity: 0.001; } }
}

/* ---------- sign-in page ---------- */
body.login-page { min-height: 100dvh; background: var(--header); }
.login {
  min-height: 100dvh; display: grid; place-items: center; position: relative; overflow: hidden;
  padding-block: 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: radial-gradient(50% 60% at 80% 100%, rgba(224, 43, 32, 0.3), transparent 70%), radial-gradient(40% 50% at 10% 0%, rgba(244, 242, 237, 0.06), transparent 70%);
}
.login-mark { position: absolute; right: -6vw; bottom: -12vw; width: min(70vw, 720px); aspect-ratio: 1; color: rgba(244, 242, 237, 0.04); pointer-events: none; }
.login-mark svg { width: 100%; height: 100%; }
.login-mark svg rect:last-child { fill: rgba(224, 43, 32, 0.28); }
.login-card {
  position: relative; width: min(400px, 100%); display: grid; gap: 16px; padding: 30px 28px 26px; border-radius: 26px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.7);
}
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.login-brand svg { width: 38px; height: 38px; border-radius: 10px; }
.login-brand .word { font-family: var(--brand); font-weight: 700; font-size: 21px; letter-spacing: -0.015em; }
.login-brand .tag { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding-left: 11px; border-left: 1px solid var(--line-strong); }
.login-card h1 { font-size: 30px; letter-spacing: -0.03em; }
.login-go { min-height: 46px; font-size: 15px; margin-top: 4px; }
.login-note { font-size: 13px; color: var(--muted); }

/* reminder to replace the starting password */
.pw-strip { background: var(--blush); color: var(--text); font-size: 13.5px; padding-block: 9px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.pw-strip .wrap { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; justify-content: space-between; }
