/* AFC Media Group CRM — design system
   Brand: red #E3000B for fills only; red text uses --red-ink (AA on every ground).
   Archivo for the interface, Spline Sans Mono for figures and labels.
   Bright and white by default (Vito, 2026-10-07); a dark theme stays available from the
   Account menu. Every colour lives in these two token blocks — never hardcode one in a rule. */

:root {
  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Spline Sans Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;

  /* bright (default): pure-white surfaces on a near-white page, hairline neutral borders */
  --bg: #f9f9fa;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --surface-3: #ececef;
  --border: #e8e8ec;
  --border-strong: #d5d5db;
  --text: #141215;
  --text-2: #3b393e;
  --muted: #67646b;
  --faint: #8a878e;
  --red: #e3000b;
  --red-hover: #c8000a;
  --red-ink: #c4000a;
  --red-soft: rgba(227, 0, 11, 0.08);
  --green: #2bb673;  --green-ink: #13804b;  --green-soft: rgba(43, 182, 115, 0.12);
  --amber: #f5a623;  --amber-ink: #9a5b00;  --amber-soft: rgba(245, 166, 35, 0.15);
  --blue: #3b82f6;   --blue-ink: #1d5fd1;   --blue-soft: rgba(59, 130, 246, 0.10);
  --violet: #8b5cf6; --violet-ink: #6a3fd6; --violet-soft: rgba(139, 92, 246, 0.11);
  --gray-soft: rgba(103, 100, 107, 0.09);
  --shadow: 0 12px 32px rgba(20, 18, 22, 0.10), 0 2px 6px rgba(20, 18, 22, 0.04);
  --shadow-sm: 0 1px 2px rgba(20, 18, 22, 0.06);
  --input-bg: #ffffff;
  --topbar-bg: rgba(255, 255, 255, 0.9);
  --col-bg: #f2f2f5;
  --nav-active: rgba(227, 0, 11, 0.07);
  --backdrop: rgba(20, 18, 22, 0.32);
  --scrim: rgba(20, 18, 22, 0.28);
  --hero-glow: rgba(227, 0, 11, 0.10);
  --radius: 10px;
  --radius-sm: 7px;
  --sidebar-w: 236px;
  --topbar-h: 56px;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #0f0c0d;
  --bg-2: #141011;
  --surface: #1a1516;
  --surface-2: #211b1c;
  --surface-3: #2a2324;
  --border: #2f2729;
  --border-strong: #43393b;
  --text: #f5f0f0;
  --text-2: #d2c8c9;
  --muted: #a3979a;
  --faint: #7f7275;
  --red-hover: #ff1a24;
  --red-ink: #ff4d57;
  --red-soft: rgba(227, 0, 11, 0.16);
  --green-ink: #5fd99b;  --green-soft: rgba(43, 182, 115, 0.16);
  --amber-ink: #fbc55b;  --amber-soft: rgba(245, 166, 35, 0.16);
  --blue-ink: #7fb0ff;   --blue-soft: rgba(59, 130, 246, 0.16);
  --violet-ink: #b69cff; --violet-soft: rgba(139, 92, 246, 0.18);
  --gray-soft: rgba(163, 151, 154, 0.14);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --input-bg: #0f0c0d;
  --topbar-bg: rgba(15, 12, 13, 0.88);
  --col-bg: #141011;
  --nav-active: #2a2324;
  --backdrop: rgba(8, 5, 6, 0.66);
  --scrim: rgba(8, 5, 6, 0.55);
  --hero-glow: rgba(227, 0, 11, 0.22);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.45 var(--font);
  font-variation-settings: 'wdth' 100;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body.modal-open { overflow: hidden; }
a { color: inherit; }
a:not(.btn):not(.nav-item):not(.stat):not(.menu-item):not(.plain) { color: var(--text); text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
a:not(.btn):not(.nav-item):not(.stat):not(.menu-item):not(.plain):hover { text-decoration-color: var(--red); }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::selection { background: var(--red-soft); }

/* ───────── utilities ───────── */
.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1 1 auto; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.row.between { justify-content: space-between; }
.gap-sm { gap: 6px; }
.gap-lg { gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.text-red { color: var(--red-ink); }
.text-green { color: var(--green-ink); }
.text-amber { color: var(--amber-ink); }
.text-blue { color: var(--blue-ink); }
.text-violet { color: var(--violet-ink); }
.label-mono { font: 500 11px/1.2 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.pre { white-space: pre-wrap; word-break: break-word; }
.hide { display: none !important; }
.icon { flex: none; display: inline-block; vertical-align: middle; }

/* ───────── app shell ───────── */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--bg-2);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 14px 10px 10px;
  scrollbar-width: thin;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; text-decoration: none; }
.brand img { height: 26px; width: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 800; font-size: 13.5px; font-variation-settings: 'wdth' 118; letter-spacing: 0.02em; text-transform: uppercase; }
.brand-sub { font: 500 10px/1.2 var(--mono); color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; margin-top: 3px; }
.nav-group { margin-top: 10px; }
.nav-group-label { font: 500 10.5px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); padding: 8px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-weight: 500; font-size: 13.5px; position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--nav-active); color: var(--text); font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--red); }
.nav-item .count { margin-left: auto; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.me-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); text-decoration: none; }
.me-card:hover { background: var(--surface-2); }
.me-name { font-weight: 600; font-size: 13px; }
.me-role { font-size: 11.5px; color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.scrim { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: 10px;
  padding: 0 24px; background: var(--topbar-bg); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.search-trigger {
  display: flex; align-items: center; gap: 10px; flex: 0 1 420px; height: 36px; padding: 0 10px 0 12px;
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm); color: var(--muted);
  cursor: pointer; text-align: left;
}
.search-trigger:hover { border-color: var(--border-strong); color: var(--text-2); }
.search-trigger span { flex: 1; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.btn.menu-btn { display: none; }
.content { padding: 24px 28px 64px; width: 100%; max-width: 1480px; }
.bare .content { max-width: none; padding: 0; }

.announcement { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); background: var(--red-soft); border: 1px solid color-mix(in srgb, var(--red) 35%, transparent); margin-bottom: 18px; }

/* ───────── page ───────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head-text { min-width: 0; }
.page-title { font-size: 26px; font-weight: 800; font-variation-settings: 'wdth' 112; letter-spacing: -0.015em; line-height: 1.15; }
.page-sub { color: var(--muted); margin-top: 4px; max-width: 70ch; }
.page-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted) !important; text-decoration: none !important; font-size: 12.5px; margin-bottom: 6px; }
.back-link:hover { color: var(--text) !important; }

.section { margin-top: 22px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section-title { font: 600 12px/1.2 var(--mono); text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.split-main, .split-side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .search-input { flex: 0 1 280px; }

/* ───────── cards & stats ───────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 16px 0; }
.card-title { font-size: 14.5px; font-weight: 700; }
.card-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card-body { padding: 14px 16px 16px; }
.card-body.flush { padding: 10px 0 4px; }
.card-body.flush .table th:first-child, .card-body.flush .table td:first-child { padding-left: 16px; }
.card-body.flush .table th:last-child, .card-body.flush .table td:last-child { padding-right: 16px; }

.stat { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; min-width: 0; }
.stat-link:hover { border-color: var(--border-strong); background: var(--surface-2); }
.stat-label { display: flex; align-items: center; gap: 6px; font: 500 11px/1.2 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 800; font-variation-settings: 'wdth' 108; margin-top: 8px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

.kv { margin: 0; display: flex; flex-direction: column; }
.kv-row { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.kv-row:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ───────── buttons ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 13px;
  border-radius: var(--radius-sm); border: 1px solid transparent; font-weight: 600; font-size: 13.5px; cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: background 0.12s, border-color 0.12s, color 0.12s; user-select: none;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--red-hover); }
.btn-secondary { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-3); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--red) 55%, transparent); color: var(--red-ink); }
.btn-danger:hover:not(:disabled) { background: var(--red-soft); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12.5px; gap: 5px; }
.btn-icon-only { width: 34px; padding: 0; }
.btn-sm.btn-icon-only { width: 28px; }

.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────── badges, tones, avatars ───────── */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--gray-soft); color: var(--text-2); }
.badge .dot, .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; display: inline-block; }
.tone-neutral { background: var(--gray-soft); color: var(--text-2); }
.tone-gray { background: var(--gray-soft); color: var(--muted); }
.tone-red { background: var(--red-soft); color: var(--red-ink); }
.tone-green { background: var(--green-soft); color: var(--green-ink); }
.tone-amber { background: var(--amber-soft); color: var(--amber-ink); }
.tone-blue { background: var(--blue-soft); color: var(--blue-ink); }
.tone-violet { background: var(--violet-soft); color: var(--violet-ink); }
.dot.tone-neutral { background: var(--muted); } .dot.tone-gray { background: var(--faint); }
.dot.tone-red { background: var(--red); } .dot.tone-green { background: var(--green); }
.dot.tone-amber { background: var(--amber); } .dot.tone-blue { background: var(--blue); } .dot.tone-violet { background: var(--violet); }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font: 600 11px/1 var(--mono); }
.count.hot { background: var(--red); color: #fff; }

.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; letter-spacing: 0.02em; text-shadow: 0 1px 1px rgba(0,0,0,0.25); }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-left: -6px; }
.user-name { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.kbd { font: 500 11px/1 var(--mono); padding: 3px 5px; border-radius: 4px; border: 1px solid var(--border-strong); color: var(--muted); background: var(--surface-2); }
.link-out { display: inline-flex; align-items: center; gap: 4px; }

/* ───────── tables ───────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font: 500 11px/1.2 var(--mono); text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table.dense td { padding: 7px 12px; }
.table.clickable tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: var(--surface-2); }
.table th.right, .table td.right { text-align: right; }
.th-btn { background: none; border: 0; padding: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; }
.th-btn:hover { color: var(--text); }
.table tfoot td { font-weight: 700; border-top: 1px solid var(--border-strong); border-bottom: 0; }
.row-muted td { opacity: 0.6; }
.row-alert td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.cell-title { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ───────── forms ───────── */
.input {
  width: 100%; height: 36px; padding: 0 11px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--input-bg); color: var(--text); font: 400 14px/1.3 var(--font); transition: border-color 0.12s, box-shadow 0.12s;
}
.input::placeholder { color: var(--faint); }
.input:hover { border-color: color-mix(in srgb, var(--border-strong) 60%, var(--text-2)); }
.input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.input:disabled { opacity: 0.6; }
.textarea { height: auto; padding: 9px 11px; resize: vertical; line-height: 1.45; min-height: 70px; }
.select { appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a3979a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
select.input option { background: var(--surface); color: var(--text); }
input[type='date'].input, input[type='datetime-local'].input, input[type='time'].input { padding-right: 8px; }
.input-affix { position: relative; }
.input-affix .affix { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-affix .input { padding-left: 24px; }
.search-input { position: relative; display: flex; align-items: center; }
.search-input .icon { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.search-input .input { padding-left: 32px; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--red); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field-label .req { color: var(--red-ink); margin-left: 3px; }
.field-hint { font-size: 12px; color: var(--muted); }
.field-error { font-size: 12px; color: var(--red-ink); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2, .span-2 { grid-column: 1 / -1; }
.form-section { font: 600 11px/1.2 var(--mono); text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); padding-top: 6px; border-top: 1px solid var(--border); margin-top: 4px; }
.form-intro { color: var(--muted); font-size: 13px; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); }
.segmented button { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border: 0; background: transparent; color: var(--muted); border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }


.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 10px 12px; border: 0; background: none; color: var(--muted); font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--red); }

/* ───────── modal & overlays ───────── */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: var(--backdrop); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; animation: fade 0.12s ease-out; }
.modal { width: 100%; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: 88vh; animation: pop 0.14s ease-out; }
.modal-sm { max-width: 420px; } .modal-md { max-width: 620px; } .modal-lg { max-width: 860px; } .modal-xl { max-width: 1100px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 12px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 17px; font-weight: 750; }
.modal-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.modal-x { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; }
.modal-x:hover { color: var(--text); background: var(--surface-2); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--border); }
.confirm-msg { color: var(--text-2); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.99); } }

.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-weight: 600; font-size: 13.5px; animation: pop 0.16s ease-out; max-width: 380px; color: var(--text); }
.toast.tone-green .icon { color: var(--green-ink); }
.toast.tone-red { border-color: color-mix(in srgb, var(--red) 60%, transparent); }
.toast.tone-red .icon { color: var(--red-ink); }

.menu { position: relative; display: inline-flex; }
.menu-pop { position: absolute; top: calc(100% + 6px); z-index: 60; min-width: 200px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow); padding: 5px; animation: pop 0.1s ease-out; }
.menu-pop.align-right { right: 0; } .menu-pop.align-left { left: 0; }
.menu-item { display: flex; width: 100%; align-items: center; gap: 9px; padding: 8px 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; text-align: left; font-size: 13.5px; text-decoration: none; color: var(--text); }
.menu-item:hover:not(:disabled) { background: var(--surface-2); }
.menu-item.danger { color: var(--red-ink); }
.menu-item:disabled { opacity: 0.5; cursor: default; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 2px; }

.popover { position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; width: min(380px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow); animation: pop 0.1s ease-out; }
.popover-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.popover-body { max-height: 60vh; overflow-y: auto; }
.notif { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.notif:hover { background: var(--surface-2); }
.notif.unread { background: color-mix(in srgb, var(--red-soft) 50%, transparent); }
.notif-title { font-weight: 600; font-size: 13px; }
.notif-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* command palette */
.palette { max-width: 640px; }
.palette .modal-body { padding: 0; }
.palette-input { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; height: 52px; font-size: 16px; padding: 0 18px 0 44px; background: transparent; }
.palette-input:focus { box-shadow: none; border-color: var(--border); }
.palette-results { max-height: 56vh; overflow-y: auto; padding: 6px; }
.palette-group { font: 500 10.5px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); padding: 10px 10px 6px; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; text-decoration: none; color: var(--text); }
.palette-item.active, .palette-item:hover { background: var(--surface-2); }
.palette-item .icon { color: var(--muted); }

/* ───────── empty / loading / errors ───────── */
.empty { text-align: center; padding: 34px 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--muted); margin-bottom: 6px; }
.empty-title { font-weight: 700; }
.empty-body { color: var(--muted); max-width: 46ch; font-size: 13px; }
.empty-action { margin-top: 10px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px 16px; color: var(--muted); }
.loading.inline { padding: 8px 0; justify-content: flex-start; }
.error-box { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; background: var(--red-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--red) 40%, transparent); font-size: 13px; }
.error-box .icon { color: var(--red-ink); }
.error-box span { flex: 1; }

/* ───────── progress, charts, timeline ───────── */
.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; background: var(--red); }
.progress-bar.tone-green { background: var(--green); } .progress-bar.tone-amber { background: var(--amber); } .progress-bar.tone-blue { background: var(--blue); }
.minibars { display: flex; align-items: stretch; gap: 6px; }
.mb-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; gap: 4px; }
.mb-bar { width: 100%; max-width: 34px; border-radius: 4px 4px 1px 1px; background: var(--surface-3); }
.mb-bar.tone-red { background: var(--red); } .mb-bar.tone-green { background: var(--green); } .mb-bar.tone-blue { background: var(--blue); } .mb-bar.tone-amber { background: var(--amber); }
.mb-bar.tone-neutral { background: color-mix(in srgb, var(--text-2) 35%, var(--surface-3)); }
.mb-label { font: 500 10.5px/1 var(--mono); color: var(--muted); white-space: nowrap; }
.mb-val { font: 500 10.5px/1 var(--mono); color: var(--text-2); white-space: nowrap; }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; padding: 10px 0; position: relative; }
.tl-item:not(:last-child)::before { content: ''; position: absolute; left: 13.5px; top: 38px; bottom: -4px; width: 1px; background: var(--border); }
.tl-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.tl-title { font-weight: 600; font-size: 13.5px; }
.tl-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tl-body { color: var(--text-2); margin-top: 5px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; }

/* ───────── kanban ───────── */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; min-height: 300px; }
.kanban-col { flex: 0 0 272px; background: var(--col-bg); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 210px); }
.kanban-col.drag-over { border-color: var(--red); background: color-mix(in srgb, var(--red-soft) 40%, var(--col-bg)); }
.kanban-col-head { display: flex; align-items: center; gap: 8px; padding: 11px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.kanban-col-title { font-weight: 700; font-size: 13px; }
.kanban-col-head .count { margin-left: auto; }
.kanban-col-sub { width: 100%; font: 500 11px/1.2 var(--mono); color: var(--muted); }
.kanban-cards { padding: 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 10px 11px; cursor: grab; box-shadow: var(--shadow-sm); }
.kanban-card:hover { border-color: var(--border-strong); }
.kanban-card:active { cursor: grabbing; }
.kanban-empty { color: var(--faint); font-size: 12.5px; text-align: center; padding: 14px 0; }

/* ───────── lists ───────── */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item.link { text-decoration: none; color: var(--text); border-radius: 6px; }
.list-item.link:hover { background: var(--surface-2); }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { color: var(--muted); font-size: 12px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───────── calendar (shared base; calendar view may extend) ───────── */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-left: 1px solid var(--border); border-top: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.cal-dow { font: 500 10.5px/1 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 9px 8px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--bg-2); }
.cal-cell { min-height: 112px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-cell.other { background: color-mix(in srgb, var(--bg) 55%, var(--surface)); }
.cal-cell.other .cal-daynum { color: var(--faint); }
.cal-cell.past:not(.today) { background: color-mix(in srgb, var(--bg) 25%, var(--surface)); }
.cal-daynum { font: 600 12px/1 var(--mono); color: var(--text-2); padding: 3px 4px; align-self: flex-start; border-radius: 6px; }
.cal-cell.today .cal-daynum { background: var(--red); color: #fff; }
.cal-item { display: flex; align-items: center; gap: 5px; font-size: 11.5px; line-height: 1.25; padding: 3px 6px; border-radius: 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; border: 0; text-align: left; width: 100%; text-decoration: none; }
.cal-more { font-size: 11px; color: var(--muted); padding: 1px 6px; background: none; border: 0; cursor: pointer; text-align: left; }

/* ───────── print (invoices, call sheets, rate card) ───────── */
.print-page { background: #fff; color: #1a1415; min-height: 100vh; padding: 40px; font: 400 13.5px/1.5 var(--font); }
.print-toolbar { position: sticky; top: 0; z-index: 5; display: flex; gap: 8px; align-items: center; padding: 10px 16px; background: var(--bg-2); border-bottom: 1px solid var(--border); }
@media print {
  @page { margin: 14mm; }
  body { background: #fff !important; color: #000 !important; }
  .sidebar, .topbar, .print-toolbar, .toasts, .no-print { display: none !important; }
  .app { display: block; }
  .content { padding: 0 !important; max-width: none; }
  .print-page { padding: 0; }
  a { text-decoration: none !important; }
}

/* ───────── login ───────── */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.auth-hero { position: relative; overflow: hidden; background: radial-gradient(1200px 600px at 20% 10%, var(--hero-glow), transparent 60%), var(--surface); display: flex; flex-direction: column; justify-content: space-between; padding: 40px; border-right: 1px solid var(--border); color: var(--text); }
.auth-hero h1 { font-size: clamp(30px, 3.4vw, 46px); line-height: 1.02; font-weight: 800; font-variation-settings: 'wdth' 120; letter-spacing: -0.02em; text-transform: uppercase; max-width: 12ch; }
.auth-hero p { color: var(--muted); max-width: 42ch; margin-top: 14px; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 32px 20px; background: var(--surface); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 22px; font-weight: 800; }
.rec { display: inline-flex; align-items: center; gap: 8px; font: 500 11px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.rec::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px rgba(227,0,11,0.2); animation: rec 1.6s ease-in-out infinite; }
@keyframes rec { 50% { opacity: 0.35; } }

/* ───────── responsive ───────── */
@media (max-width: 1200px) {
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (max-width: 980px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; z-index: 90; transform: translateX(-100%); transition: transform 0.18s ease-out; box-shadow: var(--shadow); }
  .app.nav-open .sidebar { transform: translateX(0); }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 80; background: var(--scrim); }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 0 12px; }
  .search-trigger .kbd { display: none; }
  .content { padding: 18px 16px 72px; }
  .auth-wrap { grid-template-columns: minmax(0, 1fr); }
  .auth-hero { min-height: 220px; padding: 24px 20px; border-right: 0; border-bottom: 1px solid var(--border); }
  .auth-hero .auth-hero-foot { display: none; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: minmax(0, 1fr); }
  .grid-4.keep-2, .grid-5.keep-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .page-title { font-size: 22px; }
  .hide-sm { display: none !important; }
  .kv-row { grid-template-columns: 110px minmax(0, 1fr); }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-height: 94vh; border-radius: 14px 14px 0 0; }
  .toolbar .search-input { flex: 1 1 100%; }
  .kanban-col { flex-basis: 84vw; }
  .stat-value { font-size: 22px; }
  .cal-cell { min-height: 74px; padding: 3px; }
  .cal-item { font-size: 10.5px; padding: 2px 4px; }
  .topbar-actions .btn span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ───────── chips ───────── */
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-toggle { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px 0 5px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2); cursor: pointer; font-size: 13px; font-weight: 600; }
.chip-toggle:hover:not(:disabled) { border-color: var(--text-2); }
.chip-toggle.on { border-color: var(--red); background: var(--red-soft); color: var(--text); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 600; }
.task-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.task-row:last-child { border-bottom: 0; }
.task-check { width: 18px; height: 18px; margin-top: 1px; border-radius: 5px; border: 1.5px solid var(--border-strong); background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; color: #fff; padding: 0; }
.task-check:hover { border-color: var(--green); }
.task-check.done { background: var(--green); border-color: var(--green); }
.task-row.is-done .list-title { text-decoration: line-through; color: var(--muted); }
.composer-body { font: 400 13.5px/1.5 var(--font); min-height: 220px; }

/* ───────── delivery texts ───────── */
.dt-note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.dt-note.tone-amber { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 35%, transparent); color: var(--text); }
.dt-note .icon { margin-top: 2px; flex: none; }
.dt-people, .dt-lines { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 8px; margin-top: 6px; }
.dt-person, .dt-line-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--border); min-width: 0; }
.dt-person:last-child, .dt-line-row:last-child { border-bottom: 0; }
.dt-person { cursor: pointer; }
.dt-person input { width: 16px; height: 16px; accent-color: var(--red); flex: none; }
.dt-person.is-off { opacity: 0.55; cursor: default; }
.dt-name { flex: 1; min-width: 0; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-phone { color: var(--text-2); white-space: nowrap; }
.dt-from, .dt-link { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); min-width: 0; overflow-wrap: anywhere; }
.dt-preview { display: flex; flex-direction: column; gap: 6px; }
.dt-bubble { align-self: flex-start; max-width: 92%; background: var(--blue); color: #fff; padding: 10px 13px; border-radius: 18px 18px 4px 18px; white-space: pre-wrap; font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.dt-steps { margin: 0; padding-left: 18px; color: var(--text-2); display: flex; flex-direction: column; gap: 4px; }
.dt-steps code { font-family: var(--mono); font-size: 11.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
@media (max-width: 640px) { .dt-person { flex-wrap: wrap; } .dt-phone { width: 100%; padding-left: 26px; } }

/* ───────── Stripe sync chip ───────── */
.stripe-chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 4px 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.stripe-chip .btn { height: 26px; }
