/* The same look as Unreel, so the apps feel like one suite. */
[hidden] { display: none !important; }

:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0c11;
  --sidebar: #0e0f15;
  --panel: #12131a;
  --panel-raised: #181922;
  --field: #0b0c11;
  --line: #262732;
  --line-strong: #363846;
  --ink: #f5f3ef;
  --ink-2: #b9bac6;
  --ink-3: #9092a1;
  --avatar: #2a2b36;
  --danger: #ff8a8a;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  --backdrop: rgba(4, 4, 8, 0.72);
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --sidebar: #f6f7f9;
  --panel: #ffffff;
  --panel-raised: #f1f3f5;
  --field: #ffffff;
  --line: #e3e6ea;
  --line-strong: #cfd4da;
  --ink: #15171c;
  --ink-2: #4a4f59;
  --ink-3: #6b707b;
  --avatar: #e4e7eb;
  --danger: #c22f2f;
  --shadow: 0 16px 40px rgba(20, 24, 32, 0.14);
  --backdrop: rgba(20, 24, 32, 0.4);
}
:root {
  --accent: #018C83;
  --accent-ink: #14b8a6;
  --on-accent: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 40%, transparent);
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.4; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.6; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent-ink); }
svg.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Layout */
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100%; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--sidebar); border-right: 1px solid var(--line);
  padding: 24px 14px 18px;
}
.main { padding: 26px 30px; min-width: 0; }

/* Brand and navigation */
.brand { display: flex; align-items: center; gap: 10px; padding: 0 12px 26px; }
/* The logo: black "XYEIR" in light mode, white in dark mode. The toggle changes data-theme, so it swaps at once. */
.brand-logo { height: 34px; width: auto; flex: none; }
[data-theme="dark"] .logo-for-light, [data-theme="light"] .logo-for-dark { display: none; }
.brand-sub { align-self: flex-end; padding-bottom: 3px; font-size: 10px; line-height: 1.2; letter-spacing: 0.42em; color: var(--ink-2); white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; flex: 1; margin: 0 -4px; padding: 0 4px; }
.nav-item {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 42px; padding: 0 16px;
  background: none; border: 1px solid transparent; border-radius: 11px;
  color: var(--ink-2); text-align: left; font-size: 15px;
}
.nav-item:hover { background: var(--panel-raised); color: var(--ink); }
.nav-item[aria-current="page"] {
  color: var(--ink); font-weight: 500; border-color: var(--accent-line);
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 28%, transparent), color-mix(in srgb, var(--accent) 5%, transparent));
}
.nav-soon { margin-left: auto; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.nav-badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.nav-divider { border: 0; border-top: 1px solid var(--line); margin: 8px 6px; }

/* Light and dark switch */
.theme-switch { display: flex; padding: 3px; margin: 14px 0 12px; border: 1px solid var(--line-strong); border-radius: 11px; }
.theme-switch button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 34px; background: none; border: 0; border-radius: 8px; color: var(--ink-2); font-size: 14px; }
.theme-switch button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.theme-switch .icon { width: 17px; height: 17px; }

/* Company switcher */
.picker { position: relative; padding-top: 12px; border-top: 1px solid var(--line); }
.picker-button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; background: none; border: 0; border-radius: 12px; text-align: left; }
.picker-button:hover { background: var(--panel-raised); }
.avatar { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; background: var(--avatar); font-size: 14px; font-weight: 600; letter-spacing: 0.03em; }
.avatar-accent { background: var(--accent-soft); color: var(--accent-ink); }
.picker-text { min-width: 0; flex: 1; }
.picker-name { display: block; font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.picker-sub { display: block; font-size: 13px; color: var(--ink-3); }
.picker-menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); padding: 6px; z-index: 5;
  max-height: 60vh; overflow-y: auto;
  background: var(--panel-raised); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow);
}
.picker-menu button { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 10px 12px; background: none; border: 0; border-radius: 8px; text-align: left; }
.picker-menu button:hover { background: var(--accent-soft); }
.picker-menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.picker-menu .truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.picker-label { padding: 6px 12px 4px; font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-3); }

/* Page header */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 22px; flex-wrap: wrap; }
.eyebrow { font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--ink-2); }
.page-title { font-size: clamp(30px, 3.2vw, 48px); line-height: 1.08; font-weight: 500; letter-spacing: -0.02em; margin-top: 6px; }
.page-title em { font-style: normal; color: var(--accent-ink); }
.page-lead { margin: -8px 0 20px; max-width: 70ch; font-size: 16px; color: var(--ink-2); }
.page-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Buttons and controls */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 46px; padding: 0 22px;
  border: 0; border-radius: 12px; font-weight: 600; color: var(--on-accent); background: var(--accent);
  box-shadow: 0 8px 26px color-mix(in srgb, var(--accent) 22%, transparent);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; background: none; border: 1px solid var(--line-strong); border-radius: 10px; }
.btn-secondary:hover { background: var(--panel-raised); }
.btn-compact { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn-text { padding: 4px 2px; background: none; border: 0; color: var(--accent-ink); }
.btn-text:hover { text-decoration: underline; }
.btn-text.text-danger { color: var(--danger); }
.btn-danger { min-height: 44px; padding: 0 18px; background: none; border: 1px solid transparent; border-radius: 10px; color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-danger-solid { min-height: 44px; padding: 0 18px; border: 0; border-radius: 10px; background: #c43c3c; color: #fff; font-weight: 600; }
.search {
  display: inline-flex; align-items: center; gap: 10px; width: 280px; max-width: 100%; height: 42px; padding: 0 14px;
  background: var(--field); border: 1px solid var(--line-strong); border-radius: 10px; color: var(--ink-3);
}
.search:focus-within { border-color: var(--accent-ink); }
.search input { width: 100%; min-width: 0; background: none; border: 0; outline: 0; color: var(--ink); }
.search input::placeholder { color: var(--ink-3); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; background: none; border: 1px solid var(--line-strong); border-radius: 18px; color: var(--ink-2); font-size: 14px; }
.chip:hover { background: var(--panel-raised); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--ink); font-weight: 500; }
.chip-count { color: var(--ink-3); font-size: 13px; }
.count-pill { display: inline-grid; place-items: center; min-width: 26px; height: 26px; margin-left: 8px; padding: 0 8px; border-radius: 13px; background: var(--accent); color: var(--on-accent); font-size: 14px; vertical-align: middle; }

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-pad { padding: 22px; }
.panel-subtitle { font-size: 21px; font-weight: 600; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.sort-menu { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.sort-menu select { height: 34px; padding: 0 8px; background: var(--field); border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); font: inherit; }
.cell-source { min-width: 150px; }
.cell-dates span { display: block; font-size: 12px; margin-top: 2px; }
.muted { color: var(--ink-3); font-size: 14px; }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 20px 0; margin-bottom: 16px; }
.stat { padding: 0 28px; border-left: 1px solid var(--line); min-width: 0; }
.stat:first-child { border-left: 0; }
.stat-label { color: var(--ink-2); }
.stat-value { font-size: 34px; font-weight: 600; line-height: 1.25; }
.stat-note { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.dash-col { display: grid; gap: 16px; min-width: 0; }
.ok-box { border-color: var(--accent-line); }
.ok-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.ok-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; background: var(--panel-raised); border: 1px solid var(--line); border-radius: 12px; }
.ok-item > div:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ok-buttons { display: flex; gap: 8px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.ok-label { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-ink); font-weight: 600; }
.note-line { margin-top: 14px; color: var(--ink-3); font-size: 14px; }
.pipeline { display: grid; gap: 10px; margin-top: 14px; }
.pipe-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 30px; gap: 10px; align-items: center; font-size: 14px; background: none; border: 0; padding: 2px 0; text-align: left; color: var(--ink-2); }
.pipe-row:hover { color: var(--ink); }
.pipe-bar { height: 10px; border-radius: 5px; background: var(--avatar); overflow: hidden; }
.pipe-fill { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.pipe-count { text-align: right; font-weight: 600; color: var(--ink); }
.activity { list-style: none; margin: 12px 0 0; padding: 0; display: grid; }
.activity li { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.activity li:first-child { border-top: 0; }
.activity time { color: var(--ink-3); }
.activity .btn-text { padding: 0; font-weight: 500; text-align: left; }
.activity p { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* Empty states */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 46px 24px; text-align: center; border: 1px dashed var(--line-strong); border-radius: 12px; }
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 6px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-ink); }
.empty-icon .icon { width: 26px; height: 26px; }
.empty h3 { font-size: 21px; font-weight: 600; }
.empty p { max-width: 480px; color: var(--ink-2); }
.empty-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }

/* Contact table */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
.list th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.list td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.list tbody tr { cursor: pointer; }
.list tbody tr:hover td { background: var(--panel-raised); }
.cell-name { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.cell-name .avatar { width: 36px; height: 36px; font-size: 12px; }
.cell-name strong { display: block; font-weight: 500; white-space: nowrap; }
.cell-name > div > span { display: block; color: var(--ink-3); font-size: 13px; }
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 12px; font-size: 12px; font-weight: 600; background: var(--avatar); color: var(--ink-2); white-space: nowrap; }
.badge-test { background: none; border: 1px dashed var(--line-strong); color: var(--ink-3); font-weight: 500; margin-left: 6px; }
.status-New { background: var(--accent-soft); color: var(--accent-ink); }
.status-Contacted { background: color-mix(in srgb, #3b82f6 18%, transparent); color: light-dark(#1d4ed8, #93b8ff); }
.status-Follow { background: color-mix(in srgb, #f59e0b 20%, transparent); color: light-dark(#92400e, #fbbf62); }
.status-Quote { background: color-mix(in srgb, #8b5cf6 20%, transparent); color: light-dark(#5b21b6, #c4a8ff); }
.status-Booked { background: color-mix(in srgb, #22c55e 20%, transparent); color: light-dark(#166534, #7ee2a2); }
.status-Lost { background: var(--avatar); color: var(--ink-3); }
.status-select { height: 34px; padding: 0 8px; background: var(--field); border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); }
.cell-muted { color: var(--ink-3); }

/* Dialogs and forms */
.dialog {
  width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: var(--shadow);
}
.dialog-small { width: min(440px, calc(100vw - 32px)); }
.dialog::backdrop { background: var(--backdrop); }
.dialog form, .dialog-content { padding: 26px; }
.dialog h2 { font-size: 24px; font-weight: 600; margin-bottom: 4px; }
.dialog-lead { color: var(--ink-2); margin-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field label { font-size: 14px; font-weight: 500; }
.field .required { color: var(--accent-ink); }
.field input, .field select, .field textarea { width: 100%; padding: 11px 12px; background: var(--field); border: 1px solid var(--line-strong); border-radius: 9px; color: var(--ink); }
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent-ink); outline: 0; }
.field-hint { font-size: 12px; color: var(--ink-3); }
.field-error { font-size: 13px; color: var(--danger); }
.field-error:empty { display: none; }
.field-invalid input, .field-invalid select, .field-invalid textarea { border-color: var(--danger); }
/* Show/hide eye inside password boxes (password-eye.js). */
.password-wrap { position: relative; display: block; }
.field .password-wrap input { padding-right: 46px; }
.password-eye { position: absolute; top: 50%; right: 4px; display: grid; place-items: center; width: 38px; height: 38px; padding: 0; transform: translateY(-50%); background: none; border: 0; border-radius: 7px; color: var(--ink-3); cursor: pointer; }
.password-eye:hover { color: var(--ink); }
.password-eye:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: -2px; }
.password-eye svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.form-error { margin-top: 14px; color: var(--danger); }
.form-error:empty { display: none; }
.dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.dialog-actions .spacer { margin-right: auto; }

/* Contact detail */
.detail-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.detail-head .avatar { width: 56px; height: 56px; font-size: 18px; }
.detail-head h2 { margin: 0; }
.detail-sub { color: var(--ink-3); }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; margin: 0 0 18px; padding: 16px; background: var(--panel-raised); border-radius: 12px; }
.facts dt { font-size: 12px; color: var(--ink-3); }
.facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.status-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
/* Documents on a contact: contracts, invoices, quotes, questionnaires. Each opens in a new tab. */
.documents { list-style: none; margin: 10px 0 18px; padding: 0; display: grid; gap: 6px; max-height: 320px; overflow-y: auto; }
.documents li { display: grid; grid-template-columns: 112px 1fr auto; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel-raised); border-radius: 10px; }
.documents li .badge { justify-self: start; }
.documents a { color: var(--ink); overflow-wrap: anywhere; }
.documents a:hover { color: var(--accent-ink); }
.doc-meta { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.doc-contract { color: var(--accent-ink); }
@media (max-width: 640px) { .documents li { grid-template-columns: 1fr; } }
.notes { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.notes li { padding: 12px 14px; background: var(--panel-raised); border-radius: 10px; }
.notes p { white-space: pre-wrap; overflow-wrap: anywhere; }
.note-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 12px; color: var(--ink-3); }
.note-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; padding: 0 !important; }
.note-form textarea { width: 100%; min-height: 70px; padding: 11px 12px; background: var(--field); border: 1px solid var(--line-strong); border-radius: 9px; resize: vertical; }
.note-form textarea:focus { border-color: var(--accent-ink); outline: 0; }
.note-form .btn-primary { align-self: flex-end; min-height: 40px; }

/* Small helpers */
.flush { margin: 0 !important; }
.nowrap { white-space: nowrap; }
.gap-below { margin-bottom: 18px; }
.panel-subtitle.small { font-size: 18px; }
.setting-row.start { justify-content: flex-start; }
.avatar-small { width: 36px; height: 36px; font-size: 12px; }

/* Placeholder pages */
.soon { max-width: 640px; }
.soon ul { margin: 14px 0 0; padding-left: 20px; color: var(--ink-2); display: grid; gap: 6px; }

/* Settings */
.settings-grid { display: grid; gap: 16px; max-width: 760px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-top: 14px; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line-strong); border-radius: 10px; }
.segmented button { display: inline-flex; align-items: center; gap: 8px; min-width: 96px; justify-content: center; height: 36px; background: none; border: 0; border-radius: 7px; color: var(--ink-2); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line-strong); padding: 0; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.colour-input { display: inline-flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px; border: 1px solid var(--line-strong); border-radius: 10px; }
.colour-input input[type="color"] { width: 40px; height: 32px; padding: 0; border: 0; background: none; cursor: pointer; }
.colour-input code { font-size: 14px; }
.preview-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.company-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.company-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--panel-raised); border-radius: 10px; }
.company-list li > span:not(.avatar) { flex: 1; min-width: 0; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; padding: 12px 18px; background: var(--ink); color: var(--bg); border-radius: 12px; box-shadow: var(--shadow); font-weight: 500; max-width: calc(100vw - 32px); }

/* Login */
.login-page { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); padding: 32px; }
.login-card .brand { padding: 0 0 26px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn-primary { width: 100%; margin-top: 6px; }
.login-card .btn-secondary { width: 100%; }
.forgot-link { display: block; margin: 14px auto 0; }
a.btn-primary, a.btn-secondary { text-decoration: none; }
.login-card a.btn-primary, .login-card a.btn-secondary { display: flex; width: 100%; margin-top: 6px; }
.form-error:empty { margin: 0; }

/* Smaller screens */
@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; padding: 16px 12px; }
  .brand { padding-bottom: 14px; }
  .nav { flex-direction: row; overflow-x: auto; flex: none; }
  .nav-item { width: auto; white-space: nowrap; }
  .nav-soon, .nav-divider { display: none; }
  .main { padding: 20px 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 0; }
  .stat:nth-child(3) { border-left: 0; }
  .form-grid, .facts { grid-template-columns: minmax(0, 1fr); }
  .ok-item { flex-direction: column; align-items: stretch; }
}

/* Profiles */
.profile-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.profile-option { display: flex; align-items: center; gap: 12px; padding: 12px; background: none; border: 1px solid var(--line-strong); border-radius: 12px; text-align: left; }
.profile-option:hover:not(:disabled) { background: var(--panel-raised); }
.profile-option[aria-pressed="true"] { border-color: var(--accent-ink); background: var(--accent-soft); }
.profile-option .avatar { width: 38px; height: 38px; }
.profile-option strong, .profile-option .muted { display: block; }
.profile-option .muted { font-size: 13px; }
.profile-bar { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 8px 10px; border-radius: 12px; background: var(--panel-raised); }
.profile-bar .avatar { width: 32px; height: 32px; font-size: 13px; }
.profile-bar-name { flex: 1; min-width: 0; line-height: 1.2; overflow: hidden; }
.profile-bar-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-bar-name strong { display: block; font-size: 14px; font-weight: 600; }
.profile-bar-name span { font-size: 12px; color: var(--ink-3); }
.profile-switch { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; background: none; border: 1px solid var(--line-strong); border-radius: 8px; font-size: 13px; color: var(--ink); white-space: nowrap; }
.profile-switch:hover { background: var(--accent-soft); border-color: var(--accent-line); }
.profile-switch .icon { width: 15px; height: 15px; }

/* Pages for what came over from 17hats: invoice history, templates and products, draft workflows. */
.history-note { display: flex; gap: 12px; align-items: flex-start; margin: 0 0 16px; padding: 12px 16px; border: 1px solid var(--accent-line); border-radius: 12px; background: var(--accent-soft); color: var(--ink-2); }
.history-note .icon { flex: none; margin-top: 2px; color: var(--accent-ink); }
.history-note strong { color: var(--ink); }
.list .num, .list th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.list .clip { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.list tr[data-template] { cursor: pointer; }
.list tr[data-template]:hover td { background: var(--panel-raised); }
.panel > .table-wrap, .panel > .workflow-list { margin: 0; }
.panel-head .search { flex: 1 1 280px; max-width: 420px; }
.marker { padding: 0 4px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 500; white-space: nowrap; }
.template-subject { margin: 0 0 12px; }
.template-body { max-height: 56vh; overflow-y: auto; padding: 16px; border-radius: 10px; background: var(--panel-raised); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.badge-draft { background: var(--accent-soft); color: var(--accent-ink); }
.workflow-list { list-style: none; padding: 0; display: grid; gap: 8px; }
.workflow-list > li { border: 1px solid var(--line); border-radius: 12px; }
.workflow-head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: none; border: 0; color: var(--ink); text-align: left; }
.workflow-head:hover { background: var(--panel-raised); border-radius: 12px; }
.workflow-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.steps { margin: 0; padding: 4px 16px 14px 44px; display: grid; gap: 10px; }
.steps li p { margin: 2px 0 0; }
.steps .badge { margin-right: 6px; }
.money-value { font-size: 26px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* Leads page: Active and Lost tabs, and the Lost leads list with notes and documents. */
.lead-tabs { display: flex; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.lead-tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--ink-2); font-size: 15px; }
.lead-tab:hover { color: var(--ink); }
.lead-tab[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.lost-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.lost-card { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; }
.lost-head { display: flex; align-items: center; gap: 12px; }
.lost-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.lost-name .muted { overflow-wrap: anywhere; font-size: 13px; }
.lost-actions { display: flex; gap: 8px; flex: none; }
.lost-docs { margin: 12px 0 0; max-height: none; }
.lost-notes { margin-top: 10px; }
.lost-empty { margin: 8px 0 0 52px; font-size: 13px; }
@media (max-width: 640px) { .lost-head { flex-wrap: wrap; } .lost-actions { width: 100%; } }

/* New invoices (stage two) */
.dialog-wide { width: min(860px, calc(100vw - 32px)); }
.bill-open { background: color-mix(in srgb, #3b82f6 18%, transparent); color: light-dark(#1d4ed8, #93b8ff); }
.bill-partly-paid { background: color-mix(in srgb, #f59e0b 20%, transparent); color: light-dark(#92400e, #fcd34d); }
.bill-paid { background: var(--accent-soft); color: var(--accent-ink); }
.bill-void { background: var(--panel-raised); color: var(--ink-3); text-decoration: line-through; }
.list tr[data-invoice] { cursor: pointer; }
.list tr[data-invoice]:hover td { background: var(--panel-raised); }
.invoice-head h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.invoice-items { margin: 8px 0 12px; }
.item-desc { font-size: 13px; white-space: pre-wrap; max-height: 4.5em; overflow: hidden; }
.invoice-sums { margin: 0 0 16px auto; max-width: 340px; display: grid; gap: 4px; }
.invoice-sums > div { display: flex; justify-content: space-between; gap: 16px; font-variant-numeric: tabular-nums; }
.invoice-sums dt { color: var(--ink-2); }
.invoice-sums dd { margin: 0; }
.invoice-sums .sum-total { padding-top: 6px; border-top: 1px solid var(--line); font-weight: 600; }
.invoice-sums .sum-total dt { color: var(--ink); }
.payments { list-style: none; padding: 0; margin: 8px 0 16px; display: grid; gap: 6px; }
.payments li { display: grid; grid-template-columns: 110px 1fr auto auto; gap: 12px; align-items: center; padding: 8px 12px; border-radius: 10px; background: var(--panel-raised); }
.pay-succeeded { background: var(--accent-soft); color: var(--accent-ink); }
.pay-processing { background: color-mix(in srgb, #f59e0b 20%, transparent); }
.pay-failed { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.pay-link { display: flex; gap: 8px; align-items: center; }
.pay-link input { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-bottom: 8px; }
.form-grid .field-wide { grid-column: 1 / -1; }
.inline-pair { display: flex; gap: 8px; }
.inline-pair select { flex: 0 0 140px; }
.inline-pair input { flex: 1; min-width: 0; }
.chosen-client { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.client-results { list-style: none; margin: 6px 0 0; padding: 4px; border: 1px solid var(--line-strong); border-radius: 10px; display: grid; gap: 2px; max-height: 260px; overflow-y: auto; }
.client-results button { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px; background: none; border: 0; border-radius: 8px; color: var(--ink); text-align: left; }
.client-results button:hover, .client-results button:focus-visible { background: var(--panel-raised); }
.item-rows { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 10px; }
.item-row { display: grid; grid-template-columns: 1fr 90px 130px auto; gap: 8px 10px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.item-row .item-desc-field { grid-column: 1 / -1; }
.item-remove { align-self: center; margin-top: 18px; }
.item-adders { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.item-adders select { max-width: 360px; height: 40px; padding: 0 12px; background: var(--field); border: 1px solid var(--line-strong); border-radius: 9px; color: var(--ink); }
.pay-link input { padding: 9px 12px; background: var(--field); border: 1px solid var(--line-strong); border-radius: 9px; color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.stripe-status { display: flex; gap: 10px; align-items: center; padding: 10px 14px; margin-bottom: 14px; border-radius: 10px; background: var(--panel-raised); }
.stripe-status .icon { color: var(--accent-ink); flex: none; }
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr 1fr; }
  .payments li { grid-template-columns: 1fr 1fr; }
}

/* The client's pay page */
.pay-card { width: min(640px, calc(100vw - 32px)); }
.test-banner { margin: 0 0 16px; padding: 8px 12px; border-radius: 8px; background: color-mix(in srgb, #f59e0b 20%, transparent); color: var(--ink); font-size: 14px; }
.pay-page .eyebrow { margin: 0 0 4px; font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--ink-3); }
.pay-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.pay-buttons button { flex: 1 1 200px; }
.paid-note { padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); color: var(--ink); }
.pay-message { white-space: pre-wrap; color: var(--ink-2); }

/* Two-step login */
.setup-steps { margin: 0 0 18px; padding-left: 20px; display: grid; gap: 10px; color: var(--ink-2); }
.setup-steps li::marker { color: var(--ink); font-weight: 600; }
.qr-code { display: block; width: 196px; height: 196px; margin: 12px 0 8px; border-radius: 8px; }
.qr-light { fill: #ffffff; }
.qr-dark { fill: #000000; }
.manual-key summary { cursor: pointer; color: var(--ink); }
.manual-key p { margin: 6px 0 4px; }
.manual-key code, .recovery-codes code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink); word-break: break-all; }
.code-input { font-size: 22px; letter-spacing: 0.25em; font-variant-numeric: tabular-nums; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 20px; margin: 0 0 14px; padding-left: 26px; font-size: 16px; }
.recovery-actions { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.check-line { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; color: var(--ink); }
#two-step-form .btn-text { margin-top: 14px; }
.dialog-content #two-step-form { padding: 0; }
.dialog-content #two-step-form .btn-primary, .dialog-content [data-codes-done], .dialog-content [data-continue] { width: 100%; margin-top: 6px; }
.two-step-row { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

/* The live payments switch in Settings → Stripe, and the invoice list note once a company is live. */
.live-switch { display: grid; gap: 10px; margin: 0 0 18px; padding: 14px 16px; border: 1px dashed var(--line-strong); border-radius: 12px; }
.live-switch p { margin: 0; }
.live-switch.is-live { border: 1px solid #c43c3c; background: color-mix(in srgb, #c43c3c 8%, transparent); }
.live-switch .live-confirm { display: flex; gap: 10px; flex-wrap: wrap; }
.live-switch .live-confirm input { flex: 1 1 200px; }
.live-switch .field-error:empty, .live-switch .muted:empty { display: none; }
.live-switch .field-error { color: var(--danger); font-size: 14px; }
.live-switch > button { justify-self: start; }
.history-note.is-live { border-color: #c43c3c; background: color-mix(in srgb, #c43c3c 8%, transparent); }
.history-note.is-live .icon { color: #c43c3c; }

/* Contracts and e-signature */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sign-card { width: min(820px, calc(100vw - 24px)); }
.sign-text { margin: 8px 0 20px; line-height: 1.6; }
.sign-text p { margin: 0 0 10px; overflow-wrap: anywhere; }
.sign-heading { margin: 18px 0 8px; font-size: 16px; font-weight: 600; }
.sign-initials { max-width: 200px; margin: 6px 0 16px; padding: 10px 12px; border: 1px dashed var(--accent-line); border-radius: 10px; background: var(--accent-soft); }
.sign-initials input { text-transform: uppercase; }
.sign-initials-done { color: var(--ink-2); }
.sign-choice { margin: 6px 0 16px; padding: 10px 12px; border: 1px dashed var(--accent-line); border-radius: 10px; }
.sign-choice legend { padding: 0 6px; font-size: 13px; font-weight: 600; color: var(--accent-ink); }
.sign-option { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.sign-option input { margin-top: 5px; flex: none; }
.sign-section { margin: 26px 0 14px; padding-top: 18px; border-top: 1px solid var(--line); }
.sign-page .field { margin-bottom: 14px; }
.sign-consent { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.sign-consent input { margin-top: 4px; flex: none; width: 18px; height: 18px; }
.sign-button { width: 100%; margin-top: 8px; }
.sign-read summary { cursor: pointer; color: var(--accent-ink); margin-top: 18px; }
.sig-tabs { margin-bottom: 10px; }
.sig-input { width: 100%; }
.sig-typed { font-family: "Snell Roundhand", "Apple Chancery", "Segoe Script", "Brush Script MT", cursive; font-size: 34px; line-height: 1.3; color: var(--ink); }
.sig-typed-preview { min-height: 52px; padding: 6px 4px 0; border-bottom: 1px solid var(--line-strong); }
.sig-canvas { display: block; width: 100%; max-width: 600px; aspect-ratio: 3 / 1; height: auto; background: var(--field); border: 1px solid var(--line-strong); border-radius: 9px; color: var(--ink); touch-action: none; cursor: crosshair; }
.sig-static { max-width: 300px; cursor: default; background: none; border: 0; }
.sig-draw-row { display: flex; justify-content: space-between; align-items: center; max-width: 600px; margin-top: 4px; }
.contract-text { max-height: 46vh; overflow-y: auto; padding: 14px 16px; border-radius: 10px; background: var(--panel-raised); line-height: 1.55; }
.contract-text p { margin: 0 0 8px; overflow-wrap: anywhere; }
.contract-editor textarea { min-height: 46vh; font-family: inherit; line-height: 1.5; }
.contract-events { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.contract-events time { display: block; font-size: 12px; color: var(--ink-3); }
.warn-note { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; background: color-mix(in srgb, #f59e0b 18%, transparent); color: var(--ink); }
.approve-box { margin-top: 18px; padding: 16px; border: 1px solid var(--accent-line); border-radius: 12px; background: var(--accent-soft); }
.approve-box .sig-typed { font-size: 30px; }
.bill-client-signed { background: var(--accent-soft); color: var(--accent-ink); }
.bill-countersigned { background: color-mix(in srgb, #16a34a 20%, transparent); color: var(--ink); }
.bill-declined { background: color-mix(in srgb, #c43c3c 15%, transparent); color: var(--ink); }
.panel-pad.flush-top { padding-top: 0; }
