/* Keli CRM — dark (cinematic gold) and light (navy + university red) themes, built on CSS variables */
:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b0e;
  --bg-2: #111116;
  --panel: #16161c;
  --panel-2: #1c1c24;
  --line: #2a2a34;
  --line-2: #363642;
  --text: #ecebe6;
  --heading: #ecebe6;
  --muted: #9a98a0;
  --dim: #6c6a73;
  --accent: #d4a944;          /* main accent: buttons, stripes, headings marks */
  --accent-2: #f0cd74;
  --on-accent: #1a1407;
  --accent-soft: rgba(212, 169, 68, .14);
  --hl: #f0cd74;              /* secondary accent: highlights, eyebrows, active states */
  --hl-line: #d4a944;
  --hl-soft: rgba(212, 169, 68, .14);
  --hl-border: rgba(212, 169, 68, .45);
  --price: #f0cd74;
  --link: #f0cd74;
  --warn: #f0cd74;
  --red: #e0675c;
  --green: #5fbf8a;
  --blue: #6ea8e6;
  --violet: #a68be0;
  --today-bg: #d4a944;
  --today-text: #1a1407;
  --hdr-bg: rgba(11, 11, 14, .92);
  --hdr-text: #ecebe6;
  --hdr-muted: #9a98a0;
  --hdr-field: #16161c;
  --hdr-line: #2a2a34;
  --hdr-brand: #d4a944;
  --hdr-cta-bg: linear-gradient(180deg, #f0cd74, #d4a944);
  --hdr-cta-text: #1a1407;
  --tab-active: #f0cd74;
  --tab-line: #d4a944;
  --tab-active-bg: transparent;
  --thumb-bg: linear-gradient(180deg, #f0cd74, #d4a944);
  --thumb-text: #1a1407;
  --glow: radial-gradient(1200px 500px at 85% -10%, rgba(212,169,68,.08), transparent 60%), radial-gradient(900px 400px at -10% 110%, rgba(110,168,230,.05), transparent 60%);
  --cal-other: #0d0d11;
  --ev-shoot-bg: rgba(212,169,68,.16); --ev-shoot-line: #d4a944; --ev-shoot-text: #f0cd74;
  --ev-due-bg: rgba(110,168,230,.13); --ev-due-line: #6ea8e6; --ev-due-text: #a9cdf3;
  --ev-rev-bg: rgba(166,139,224,.13); --ev-rev-line: #a68be0; --ev-rev-text: #c9b8f0;
  --path-done-bg: rgba(212,169,68,.25); --path-done-text: #f0cd74;
  --chart-bar: linear-gradient(180deg, #f0cd74, rgba(212,169,68,.35));
  --chart-seg: rgba(110,168,230,.55);
  --backdrop: rgba(0,0,0,.65);
  --row-hover: rgba(255,255,255,.025);
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --shadow-sm: 0 6px 16px rgba(0,0,0,.35);
  --radius: 12px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #FFFFFF;
  --bg-2: #F6F8FC;
  --panel: #FFFFFF;
  --panel-2: #F1F4FA;
  --line: #E2E7F0;
  --line-2: #C9D2E3;
  --text: #121C33;
  --heading: #0B1F4D;
  --muted: #4A5670;
  --dim: #6B7690;
  --accent: #0B1F4D;
  --accent-2: #233F85;
  --on-accent: #FFFFFF;
  --accent-soft: rgba(11, 31, 77, .08);
  --hl: #9E1B32;
  --hl-line: #9E1B32;
  --hl-soft: rgba(158, 27, 50, .07);
  --hl-border: rgba(158, 27, 50, .35);
  --price: #0B1F4D;
  --link: #9E1B32;
  --warn: #A3540A;
  --red: #9E1B32;
  --green: #1D7A4A;
  --blue: #1F5FA8;
  --violet: #5B3FA8;
  --today-bg: #9E1B32;
  --today-text: #FFFFFF;
  --hdr-bg: #0B1F4D;
  --hdr-text: #FFFFFF;
  --hdr-muted: rgba(255,255,255,.74);
  --hdr-field: rgba(255,255,255,.10);
  --hdr-line: rgba(255,255,255,.22);
  --hdr-brand: #FFFFFF;
  --hdr-cta-bg: #9E1B32;
  --hdr-cta-text: #FFFFFF;
  --tab-active: #FFFFFF;
  --tab-line: #9E1B32;
  --tab-active-bg: rgba(255,255,255,.10);
  --thumb-bg: #FFFFFF;
  --thumb-text: #0B1F4D;
  --glow: none;
  --cal-other: #FAFBFD;
  --ev-shoot-bg: rgba(11,31,77,.08); --ev-shoot-line: #0B1F4D; --ev-shoot-text: #0B1F4D;
  --ev-due-bg: rgba(158,27,50,.08); --ev-due-line: #9E1B32; --ev-due-text: #9E1B32;
  --ev-rev-bg: rgba(91,63,168,.10); --ev-rev-line: #5B3FA8; --ev-rev-text: #4A3290;
  --path-done-bg: rgba(11,31,77,.12); --path-done-text: #0B1F4D;
  --chart-bar: linear-gradient(180deg, #233F85, #0B1F4D);
  --chart-seg: rgba(158,27,50,.8);
  --backdrop: rgba(11,31,77,.45);
  --row-hover: rgba(11,31,77,.035);
  --shadow: 0 12px 32px rgba(11,31,77,.14);
  --shadow-sm: 0 6px 16px rgba(11,31,77,.10);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font);
  background-image: var(--glow); background-attachment: fixed; min-height: 100vh;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: .01em; color: var(--heading); }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--hdr-bg); color: var(--hdr-text); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--hdr-line); padding-top: env(safe-area-inset-top); }
.topbar-row { display: flex; align-items: center; gap: 14px; padding: 10px 20px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--hdr-text); text-decoration: none !important; flex-shrink: 0; min-width: 0; }
.brand-mark { width: 32px; height: 32px; color: var(--hdr-brand); display: grid; place-items: center; border: 1px solid var(--hdr-line); border-radius: 9px; background: var(--hdr-field); flex-shrink: 0; }
.brand-mark svg { width: 20px; height: 20px; }
.brand-text { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand-name { font-family: var(--display); font-size: 19px; letter-spacing: .02em; white-space: nowrap; }
.brand-sub { font-family: var(--font); font-size: 10px; letter-spacing: .25em; color: var(--hdr-brand); margin-left: 6px; vertical-align: 3px; }
.brand-dot { color: var(--hdr-muted); }
.brand-biz { font-weight: 600; font-size: 15px; color: var(--tab-active); white-space: nowrap; display: inline-block; }
.brand-biz.swap { animation: fadeUp .25s var(--ease) both; }
.search-wrap { position: relative; flex: 1; max-width: 460px; margin: 0 auto; color: var(--text); }
.search-wrap input { width: 100%; height: 38px; padding: 0 12px 0 36px; border-radius: 10px; border: 1px solid var(--hdr-line); background: var(--hdr-field); color: var(--hdr-text); outline: none; transition: border-color .15s, box-shadow .15s; }
.search-wrap input::placeholder { color: var(--hdr-muted); }
.search-wrap input:focus { border-color: var(--hl-line); box-shadow: 0 0 0 3px var(--hl-soft); }
.search-ico { position: absolute; left: 11px; top: 11px; width: 16px; height: 16px; color: var(--hdr-muted); }
.search-results { position: absolute; left: 0; right: 0; top: 44px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto; padding: 6px; animation: fadeIn .15s ease both; z-index: 41; }
.search-results .sr-group { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--dim); padding: 8px 10px 4px; }
.search-results a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.search-results a:hover { background: var(--hl-soft); }
.search-results small { color: var(--muted); display: block; }
.top-actions { position: relative; display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.topbar .icon-btn { background: var(--hdr-field); border-color: var(--hdr-line); color: var(--hdr-text); }
.topbar .icon-btn:hover { border-color: var(--hl-line); }
.topbar .btn-gold { background: var(--hdr-cta-bg); color: var(--hdr-cta-text); }

/* Business switcher (segmented control with sliding thumb) */
.biz-switch { position: relative; display: grid; grid-template-columns: 1fr 1fr; align-items: stretch; height: 36px; padding: 3px; border-radius: 10px; background: var(--hdr-field); border: 1px solid var(--hdr-line); flex-shrink: 0; }
.biz-switch button { position: relative; z-index: 1; border: 0; background: none; color: var(--hdr-muted); padding: 0 12px; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: 13px; white-space: nowrap; transition: color .2s ease; }
.biz-switch button:hover { color: var(--hdr-text); }
/* the active option follows the page's data-business attribute, which is set before first paint */
[data-business="visuals"] .biz-switch [data-biz="visuals"], [data-business="vault"] .biz-switch [data-biz="vault"] { color: var(--thumb-text); }
.biz-thumb { position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: 7px; background: var(--thumb-bg); box-shadow: 0 2px 8px rgba(0,0,0,.25); transition: transform .28s var(--ease); }
[data-business="vault"] .biz-thumb { transform: translateX(100%); }

/* Theme toggle */
.theme-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; transition: transform .3s var(--ease), opacity .2s; }
[data-theme="dark"] .theme-btn .ico-moon, [data-theme="light"] .theme-btn .ico-sun { display: none; }
.theme-btn.spin svg { animation: spinIn .3s var(--ease); }

.tabs { display: flex; gap: 2px; padding: 0 14px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 10px 14px 11px; color: var(--hdr-muted); white-space: nowrap; border-bottom: 2px solid transparent; text-decoration: none; font-weight: 500; border-radius: 6px 6px 0 0; transition: color .15s, border-color .2s, background .2s; }
.tabs a:hover { color: var(--hdr-text); }
.tabs a.active { color: var(--tab-active); border-bottom: 3px solid var(--tab-line); background: var(--tab-active-bg); }

.menu { position: absolute; right: 0; top: 44px; min-width: 250px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; z-index: 40; animation: popIn .18s var(--ease) both; }
.menu button { display: block; width: 100%; text-align: left; padding: 9px 10px; border: 0; background: none; border-radius: 7px; cursor: pointer; color: var(--text); }
.menu button:hover { background: var(--hl-soft); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu .danger { color: var(--red); }
.menu .menu-label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--dim); padding: 6px 10px 2px; }

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); cursor: pointer; white-space: nowrap; font-weight: 500; transition: transform .15s ease, box-shadow .15s ease, border-color .15s, background .15s, filter .15s; }
.btn:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0) scale(.98); box-shadow: none; }
.btn-gold { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: var(--on-accent); border-color: transparent; font-weight: 600; }
.btn-gold:hover { filter: brightness(1.07); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); cursor: pointer; padding: 0; transition: transform .15s ease, border-color .15s, background .15s; }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }
.icon-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=search]:not(#globalSearch), select, textarea {
  width: 100%; min-height: 38px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s;
}
select { appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--hl-line); box-shadow: 0 0 0 3px var(--hl-soft); }
input.invalid, select.invalid { border-color: var(--red); }
input[type=checkbox] { accent-color: var(--accent); }
.native-date { position: fixed; left: -100px; top: 0; width: 1px; height: 1px; opacity: 0; }

/* ---------- Layout ---------- */
.view { padding: 20px; max-width: 1400px; margin: 0 auto; outline: none; padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-family: var(--display); font-size: 26px; font-weight: 500; }
.page-head .eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .18em; color: var(--hl); display: block; }
.page-head .spacer { flex: 1; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel { background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line); border-radius: var(--radius); }
[data-theme="light"] .panel { background: var(--panel); box-shadow: 0 1px 2px rgba(11,31,77,.05); }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 15px; }
.panel-head .count { color: var(--hl); font-size: 12px; background: var(--hl-soft); padding: 1px 8px; border-radius: 99px; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 14px 16px; }
.empty { color: var(--dim); padding: 16px; text-align: center; }

.sample-banner { display: flex; align-items: center; gap: 12px; justify-content: center; flex-wrap: wrap; background: var(--hl-soft); border-bottom: 1px solid var(--hl-border); padding: 8px 16px; font-size: 13px; text-align: center; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; min-width: 150px; }
.toolbar .spacer { flex: 1; }
.toolbar .meta { color: var(--muted); font-size: 13px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
table.list th.sorted { color: var(--hl); }
table.list th.sorted::after { content: " ▾"; }
table.list th.sorted.asc::after { content: " ▴"; }
table.list td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tbody tr { cursor: pointer; transition: background .15s; }
table.list tbody tr:hover { background: var(--row-hover); }
table.list td.num, table.list th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.plain { width: 100%; border-collapse: collapse; }
table.plain th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line); }
table.plain td { padding: 9px 12px; border-bottom: 1px solid var(--line); }
table.plain .num { text-align: right; font-variant-numeric: tabular-nums; }
table.plain tfoot td { border-bottom: 0; }
.cell-title { font-weight: 600; color: var(--text); }
.cell-sub { color: var(--muted); font-size: 12px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; }
.badge.gold { color: var(--hl); border-color: var(--hl-border); background: var(--hl-soft); }
.badge.green { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); background: color-mix(in srgb, var(--green) 10%, transparent); }
.badge.red { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); background: color-mix(in srgb, var(--red) 10%, transparent); }
.badge.blue { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 40%, transparent); background: color-mix(in srgb, var(--blue) 10%, transparent); }
.badge.violet { color: var(--violet); border-color: color-mix(in srgb, var(--violet) 40%, transparent); background: color-mix(in srgb, var(--violet) 10%, transparent); }
.badge.sample { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; padding: 0 6px; margin-left: 6px; vertical-align: 1px; }
.overdue { color: var(--red); font-weight: 600; }
.soon { color: var(--warn); font-weight: 600; }
.price { color: var(--price); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; position: relative; overflow: hidden; transition: transform .18s ease, box-shadow .18s ease, border-color .18s; }
.kpi[data-href] { cursor: pointer; }
.kpi[data-href]:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); border-color: var(--line-2); }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: .85; }
.kpi .label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.kpi .value { font-family: var(--display); font-size: 28px; margin-top: 2px; color: var(--heading); }
.kpi .hint { color: var(--dim); font-size: 12px; }
.kpi.warn::before { background: var(--red); }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.dash-grid .wide { grid-column: 1 / -1; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .15s; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list li:hover { background: var(--row-hover); }
.mini-list .date-chip { flex-shrink: 0; width: 48px; text-align: center; border: 1px solid var(--line-2); border-radius: 8px; padding: 3px 0; background: var(--bg-2); }
.mini-list .date-chip b { display: block; font-family: var(--display); font-size: 18px; line-height: 1.1; color: var(--price); }
.mini-list .date-chip span { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.mini-list .grow { flex: 1; min-width: 0; }
.mini-list .grow .cell-title, .mini-list .grow .cell-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-list .right { text-align: right; flex-shrink: 0; }
.chart { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding: 10px 4px 0; }
.chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; min-width: 0; }
.chart .bar { width: 100%; max-width: 56px; border-radius: 6px 6px 2px 2px; background: var(--chart-bar); min-height: 2px; position: relative; display: flex; flex-direction: column-reverse; overflow: hidden; transition: height .3s var(--ease); }
.chart .bar .seg-ret { background: var(--chart-seg); }
.chart .bar-col.current .bar { box-shadow: 0 0 0 2px var(--hl-line); }
.chart .bar-val { font-size: 11px; color: var(--muted); white-space: nowrap; }
.chart .bar-lab { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); padding: 0 16px 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend .lg-bar { background: var(--accent); }
.legend .lg-seg { background: var(--chart-seg); }

/* ---------- Pipeline / kanban ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(210px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x proximity; min-height: 60vh; }
.col { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 200px; scroll-snap-align: start; }
.col-head { padding: 12px 12px 10px; border-bottom: 1px solid var(--line); position: relative; }
.col-head::before { content: ""; position: absolute; left: 12px; right: 12px; top: 0; height: 3px; border-radius: 2px; background: var(--stage, var(--accent)); }
.col-head .t { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; color: var(--heading); }
.col-head .n { color: var(--muted); font-weight: 500; font-size: 12px; }
.col-head .sum { color: var(--price); font-size: 12px; font-variant-numeric: tabular-nums; }
.col-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; flex: 1; transition: background .18s ease, outline-color .18s ease; border-radius: 0 0 var(--radius) var(--radius); outline: 1px dashed transparent; outline-offset: -4px; }
.col-body.drop-hover { background: var(--hl-soft); outline-color: var(--hl-line); }
.card { background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 10px 10px 12px; cursor: grab; position: relative; user-select: none; -webkit-user-select: none; touch-action: pan-y; transition: transform .18s ease, box-shadow .18s ease, border-color .18s, opacity .18s; }
.card:hover { border-color: var(--hl-border); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.card .c-title { font-weight: 600; padding-right: 22px; color: var(--text); }
.card .c-client { color: var(--muted); font-size: 12px; }
.card .c-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); align-items: center; }
.card .c-price { color: var(--price); font-variant-numeric: tabular-nums; font-weight: 600; }
.card .grip { position: absolute; right: 4px; top: 4px; width: 28px; height: 28px; display: grid; place-items: center; color: var(--dim); cursor: grab; touch-action: none; border-radius: 6px; }
.card .grip:hover { color: var(--hl); background: var(--hl-soft); }
.card .progress { height: 3px; background: var(--line); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.card .progress i { display: block; height: 100%; background: var(--accent); }
.card.dragging { opacity: .35; transform: scale(.97); box-shadow: none; }
.card.just-moved { animation: landed .32s var(--ease); }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; box-shadow: var(--shadow); border-color: var(--hl-line) !important; opacity: .96; transition: none !important; will-change: transform; }

/* ---------- Path (stage chevrons) ---------- */
.path { display: flex; gap: 3px; overflow-x: auto; margin: 4px 0 16px; scrollbar-width: none; }
.path::-webkit-scrollbar { display: none; }
.path button { flex: 1; min-width: 96px; border: 0; background: var(--panel-2); color: var(--muted); padding: 9px 14px 9px 20px; cursor: pointer; font-size: 13px; white-space: nowrap; clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%); transition: background .2s ease, color .2s ease; }
.path button:first-child { clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); border-radius: 8px 0 0 8px; padding-left: 14px; }
.path button:last-child { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 10px 50%); border-radius: 0 8px 8px 0; }
.path button.done { background: var(--path-done-bg); color: var(--path-done-text); }
.path button.current { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: var(--on-accent); font-weight: 600; }
.path button:hover:not(.current) { background: var(--hl-soft); color: var(--hl); }

/* ---------- Record page ---------- */
.record-head { padding: 16px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.record-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--hl-soft); color: var(--hl); font-family: var(--display); font-size: 20px; border: 1px solid var(--hl-border); flex-shrink: 0; }
.record-head h1 { font-family: var(--display); font-weight: 500; font-size: 24px; }
.record-head .eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .18em; color: var(--hl); }
.record-head .spacer { flex: 1; }
.record-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.highlights { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px 20px; width: 100%; padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--line); }
.highlights .h-label { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .1em; }
.highlights .h-val { overflow-wrap: anywhere; }
.record-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.fields .f { padding: 10px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.fields .f.full { grid-column: 1 / -1; }
.fields .f-label { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .1em; }
.fields .f-val { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 21px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---------- Checklist ---------- */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist label { display: flex; align-items: center; gap: 12px; padding: 11px 16px; cursor: pointer; }
.checklist input { appearance: none; -webkit-appearance: none; width: 20px; height: 20px; border: 1.5px solid var(--line-2); border-radius: 6px; display: grid; place-items: center; flex-shrink: 0; cursor: pointer; background: var(--bg-2); margin: 0; transition: background .15s, border-color .15s; }
.checklist input:checked { background: var(--accent); border-color: var(--accent); }
.checklist input:checked::after { content: ""; width: 5px; height: 10px; border: solid var(--on-accent); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translate(-1px, -1px); }
.checklist input:checked + span { color: var(--muted); text-decoration: line-through; }
.check-progress { font-size: 12px; color: var(--hl); }

/* ---------- Retainers ---------- */
.ret-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.ret-card { padding: 16px; display: flex; flex-direction: column; gap: 12px; transition: transform .18s ease, box-shadow .18s ease; }
.ret-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.ret-card .top { display: flex; align-items: flex-start; gap: 10px; }
.ret-card .top .grow { flex: 1; min-width: 0; }
.ret-card .price { font-family: var(--display); font-size: 22px; white-space: nowrap; font-weight: 500; }
.ret-card .price small { font-family: var(--font); font-size: 12px; color: var(--muted); }
.ret-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: 12px; }
.ret-stats div { background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.ret-stats b { display: block; font-size: 13px; color: var(--text); font-weight: 500; }
.ret-stats span { color: var(--dim); text-transform: uppercase; letter-spacing: .08em; font-size: 10px; }
.meter { display: flex; align-items: center; gap: 10px; }
.meter .track { flex: 1; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.meter .fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; transition: width .3s var(--ease); }
.meter .fill.full { background: var(--green); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 9px; overflow: hidden; }
.stepper button { width: 34px; height: 32px; border: 0; background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 16px; transition: background .15s; }
.stepper button:hover { background: var(--hl-soft); color: var(--hl); }
.stepper output { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.months { display: flex; gap: 6px; flex-wrap: wrap; }
.months .m { flex: 1; min-width: 44px; text-align: center; font-size: 11px; padding: 4px 2px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg-2); color: var(--muted); cursor: pointer; transition: transform .15s; }
.months .m:hover { transform: translateY(-1px); }
.months .m b { display: block; font-size: 13px; color: var(--text); }
.months .m.ok { border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.months .m.ok b { color: var(--green); }
.months .m.short { border-color: color-mix(in srgb, var(--red) 45%, transparent); }
.months .m.short b { color: var(--red); }
.months .m.cur { box-shadow: 0 0 0 1px var(--hl-line); }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-head h2 { font-family: var(--display); font-weight: 500; font-size: 22px; min-width: 190px; }
.cal-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-left: auto; flex-wrap: wrap; }
.cal-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.cal-legend .lg-shoot { background: var(--ev-shoot-line); }
.cal-legend .lg-due { background: var(--ev-due-line); }
.cal-legend .lg-review { background: var(--ev-rev-line); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); gap: 1px; }
.cal-dow { background: var(--panel); padding: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--dim); text-align: center; }
.cal-day { background: var(--bg-2); min-height: 112px; padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 0; cursor: pointer; transition: background .15s; }
[data-theme="light"] .cal-day { background: var(--panel); }
.cal-day:hover { background: var(--row-hover); }
.cal-day.other, [data-theme="light"] .cal-day.other { background: var(--cal-other); }
.cal-day.other .dnum { color: var(--dim); opacity: .5; }
.cal-day.today { background: linear-gradient(180deg, var(--hl-soft), transparent); }
.cal-day.today .dnum { background: var(--today-bg); color: var(--today-text); }
.cal-day.picked { box-shadow: inset 0 0 0 1px var(--hl-line); }
.cal-day .dnum { font-size: 12px; color: var(--muted); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; }
.ev { font-size: 12px; padding: 2px 6px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; border-left: 3px solid; transition: filter .15s, transform .15s; }
.ev.shoot { background: var(--ev-shoot-bg); border-color: var(--ev-shoot-line); color: var(--ev-shoot-text); }
.ev.due { background: var(--ev-due-bg); border-color: var(--ev-due-line); color: var(--ev-due-text); }
.ev.review { background: var(--ev-rev-bg); border-color: var(--ev-rev-line); color: var(--ev-rev-text); }
.ev:hover { filter: brightness(1.15); transform: translateX(1px); }
.cal-agenda { margin-top: 16px; }

/* ---------- Forms (modal) ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: var(--backdrop); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fadeIn .2s ease both; }
.modal-panel { position: relative; width: 100%; max-width: 720px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--panel); color: var(--text); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); animation: popIn .24s var(--ease) both; }
.modal-panel.wide { max-width: 900px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-family: var(--display); font-weight: 500; font-size: 20px; }
.modal-body { padding: 16px 18px; overflow: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; }
.form-grid label .req { color: var(--hl); }
.form-section { grid-column: 1 / -1; font-size: 11px; text-transform: uppercase; letter-spacing: .15em; color: var(--hl); margin-top: 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.date-field { display: flex; gap: 6px; }
.date-field input { flex: 1; }
.date-field button { flex-shrink: 0; width: 38px; height: 38px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.form-actions .left { margin-right: auto; }
.inline-checks { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 6px 12px; }
.inline-checks label { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
.inline-checks input { width: 16px; height: 16px; }
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice-list button { text-align: left; padding: 12px 14px; height: auto; justify-content: flex-start; flex-direction: column; align-items: flex-start; }
.choice-list small { display: block; color: var(--muted); font-weight: 400; }
.readonly-val { min-height: 38px; display: flex; align-items: center; padding: 0 10px; border-radius: 9px; background: var(--panel-2); color: var(--text); font-weight: 600; }

/* Line-item / batch editors (Keli Vault) */
.rows-editor { display: flex; flex-direction: column; gap: 8px; }
.rows-editor .row { display: grid; gap: 8px; align-items: center; animation: fadeUp .18s var(--ease) both; }
.rows-editor .row.items { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.2fr) 70px 100px 90px 36px; }
.rows-editor .row.batches { grid-template-columns: minmax(0, 1.4fr) 90px minmax(0, 1.4fr) 36px; }
.rows-editor .row.parts { grid-template-columns: minmax(0, 3fr) 90px 36px; }
.rows-editor .row-head { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); animation: none; }
.rows-editor .line-total { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--price); }
.rows-editor .icon-btn { width: 36px; height: 36px; }
.totals-box { display: grid; grid-template-columns: auto auto; justify-content: end; gap: 4px 18px; font-variant-numeric: tabular-nums; margin-top: 4px; }
.totals-box .t-label { color: var(--muted); text-align: right; }
.totals-box .t-val { text-align: right; min-width: 90px; }
.totals-box .grand { font-size: 17px; font-weight: 700; color: var(--price); }
.stock-pill { display: inline-flex; align-items: center; gap: 6px; }
.track-link { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--panel-2); border: 1px solid var(--hl-line); color: var(--text); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s var(--ease); z-index: 90; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Motion ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes landed { 0% { transform: scale(1.04); box-shadow: 0 0 0 2px var(--hl-line); } 100% { transform: none; box-shadow: none; } }
@keyframes spinIn { from { transform: rotate(-90deg) scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.view.enter > * { animation: fadeUp .24s var(--ease) both; }
.view.enter > *:nth-child(2) { animation-delay: .03s; }
.view.enter > *:nth-child(3) { animation-delay: .06s; }
.view.enter > *:nth-child(n+4) { animation-delay: .09s; }
.view.enter .card { animation: fadeUp .22s var(--ease) both; }
html.theme-fade, html.theme-fade *, html.theme-fade *::before, html.theme-fade *::after {
  transition: background-color .25s ease, border-color .25s ease, color .25s ease, fill .25s ease, box-shadow .25s ease !important;
}

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .dash-grid, .record-grid { grid-template-columns: minmax(0, 1fr); }
  .biz-switch .long { display: none; }
}
@media (max-width: 720px) {
  body { font-size: 15px; }
  .topbar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand actions" "biz search"; gap: 8px 10px; padding: 8px 12px; }
  .brand { grid-area: brand; }
  .top-actions { grid-area: actions; }
  .biz-switch { grid-area: biz; }
  .search-wrap { grid-area: search; max-width: none; margin: 0; }
  .brand-text { flex-direction: column; gap: 0; align-items: flex-start; }
  .brand-name { font-size: 17px; line-height: 1.15; }
  .brand-dot { display: none; }
  .brand-biz { font-size: 12.5px; line-height: 1.2; }
  .biz-switch button { padding: 0 10px; }
  .tabs { padding: 0 6px; }
  .tabs a { padding: 9px 11px 10px; }
  .view { padding: 14px 12px 40px; }
  .page-head h1 { font-size: 22px; }
  .toolbar input[type=search], .toolbar select { max-width: none; flex: 1 1 140px; min-width: 0; }
  .fields, .form-grid { grid-template-columns: 1fr; }
  .inline-checks { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .modal { padding: 0; align-items: flex-end; }
  .modal-panel { max-height: 92vh; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr { border-bottom: 1px solid var(--line); padding: 10px 14px; }
  table.list td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.list td::before { content: attr(data-label); color: var(--dim); font-size: 12px; text-align: left; flex-shrink: 0; }
  table.list td.primary { display: block; text-align: left; padding-bottom: 6px; }
  table.list td.primary::before { display: none; }
  .board { grid-auto-columns: 82%; }
  .cal-day { min-height: 64px; padding: 3px; }
  .cal-day .ev { font-size: 0; padding: 0; height: 6px; border-left-width: 0; border-radius: 3px; background: var(--ev-shoot-line); }
  .cal-day .ev.due { background: var(--ev-due-line); }
  .cal-day .ev.review { background: var(--ev-rev-line); }
  .cal-dow { padding: 6px 2px; font-size: 10px; letter-spacing: .05em; }
  .cal-legend { margin-left: 0; width: 100%; }
  .ret-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .value { font-size: 23px; }
  .rows-editor .row.items { grid-template-columns: 1fr 1fr 64px; }
  .rows-editor .row-head { display: none; }
  .rows-editor .row.batches { grid-template-columns: 1fr 80px 36px; }
  .rows-editor .row.batches .date-field { grid-column: 1 / 3; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .card:hover, .btn:hover, .kpi[data-href]:hover, .ret-card:hover, .icon-btn:hover { transform: none; }
}
