:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1b2430;
  --muted: #6b7684;
  --faint: #9aa4b0;
  --line: #e5e8ec;
  --line-soft: #eef0f3;
  --brand: #2486cf;
  --brand-dark: #1a6fb0;
  --brand-soft: #e6f1fb;
  --sidebar: #10161f;
  --sidebar-ink: #c4ccd6;
  --sidebar-active: #1c2632;
  --ok: #1a6fb0; --ok-bg: #e6f1fb;
  --warn: #9a6700; --warn-bg: #fbf1dd;
  --busy: #1f6a9c; --busy-bg: #e3eff8;
  --err: #b42318; --err-bg: #fbeceb;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.08);
  --shadow-lg: 0 10px 30px rgba(16,24,40,.14);
  --radius: 12px;
  /* surface tokens that were previously hardcoded light values */
  --input-bg: #ffffff;
  --hover: #fafbfc;
  --track: #eef1f4;
  --neutral-bg: #f0f1f3;
  --toast-bg: #1b2430;
  --search-icon: %236b7684;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1217;
  --card: #161c24;
  --ink: #e7ebf0;
  --muted: #9aa6b3;
  --faint: #6c7783;
  --line: #273039;
  --line-soft: #1f272f;
  --brand: #56aef0;
  --brand-dark: #3f97dd;
  --brand-soft: #12314a;
  --sidebar: #0b0e13;
  --sidebar-ink: #c4ccd6;
  --sidebar-active: #1a222c;
  --ok: #6bb8f2; --ok-bg: rgba(70,150,220,.16);
  --warn: #e2b24d; --warn-bg: rgba(200,150,40,.15);
  --busy: #5fb0e8; --busy-bg: rgba(70,140,210,.16);
  --err: #f0776c; --err-bg: rgba(210,70,60,.18);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 3px rgba(0,0,0,.5);
  --shadow-lg: 0 12px 30px rgba(0,0,0,.55);
  --input-bg: #1b222b;
  --hover: #1d252e;
  --track: #232c35;
  --neutral-bg: #232c35;
  --toast-bg: #2a3543;
  --search-icon: %239aa6b3;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }

.app { display: grid; grid-template-columns: 248px 1fr; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar { background: var(--sidebar); color: var(--sidebar-ink); display: flex; flex-direction: column;
  padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 20px; }
.brand-mark { width: 40px; height: 40px; flex: none; }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { color: #fff; font-size: 16px; letter-spacing: -.01em; }
.brand-text span { color: #7d8794; font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.nav a { color: var(--sidebar-ink); padding: 10px 12px; border-radius: 9px; font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 11px; transition: .12s; }
.nav a .ico { opacity: .7; width: 16px; text-align: center; }
.nav a:hover { background: #182029; color: #fff; }
.nav a.active { background: var(--sidebar-active); color: #fff; }
.nav a.active .ico { opacity: 1; color: var(--brand); }
.theme-toggle { display: flex; align-items: center; gap: 11px; width: 100%;
  background: transparent; border: 0; cursor: pointer; color: var(--sidebar-ink);
  font: inherit; font-weight: 600; font-size: 14px; padding: 10px 12px; border-radius: 9px; transition: .12s; }
/* Only the first bottom button absorbs the free space, so the toggle + sign-out
   sit together at the bottom (two auto margins would split the gap between them). */
#theme-toggle { margin-top: auto; }
.theme-toggle:hover { background: #182029; color: #fff; }
.theme-toggle svg { width: 16px; height: 16px; opacity: .8; }
.sidebar-foot { padding: 14px 10px 4px; margin-top: 12px; border-top: 1px solid #1e2732; }
.foot-company { color: #aeb7c2; font-size: 12px; font-weight: 600; }
.foot-sub { color: #6b7580; font-size: 11px; margin-top: 2px; }

/* Main */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; overflow: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 22px 32px; border-bottom: 1px solid var(--line); background: var(--card); }
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.page-sub { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.page-actions { display: flex; gap: 10px; align-items: center; }
/* `.page-actions` prefix keeps these winning over the generic input[type=text]
   rule (which otherwise overrides padding/background on higher specificity). */
.page-actions .search { width: 240px; max-width: 42vw; padding: 9px 12px 9px 34px; border: 1px solid var(--line);
  border-radius: 9px; font: inherit; color: var(--ink); background-color: var(--input-bg);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7684' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.35-4.35'/></svg>");
  background-repeat: no-repeat; background-position: 11px center; }
:root[data-theme="dark"] .search {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239aa6b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.35-4.35'/></svg>"); }
.search:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
/* The content area (not the header) is the scroll container, and reserves the
   scrollbar gutter on BOTH edges so a visible scrollbar keeps the left/right
   margins equal. The topbar stays full-bleed above it. */
.view { padding: 26px 32px; width: 100%; flex: 1 1 auto; min-height: 0;
  overflow-y: auto; scrollbar-gutter: stable both-edges; }

/* Buttons */
.btn { font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; border-radius: 9px;
  padding: 9px 15px; border: 1px solid var(--line); background: var(--input-bg); color: var(--ink);
  display: inline-flex; align-items: center; gap: 7px; transition: .12s; white-space: nowrap; }
.btn:hover { border-color: var(--faint); background: var(--hover); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--neutral-bg); color: var(--ink); }
.btn.danger:hover { color: var(--err); border-color: var(--err); background: var(--err-bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 6px 10px; font-size: 13px; }

/* Cards & grid */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); overflow: hidden;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.stat::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; opacity: 0; transition: opacity .16s;
  background: linear-gradient(90deg, var(--brand), #4aa8ea); }
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--faint); }
.stat:hover::after { opacity: 1; }
.stat-head { display: flex; align-items: center; gap: 10px; }
.stat-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.stat-ico svg { width: 18px; height: 18px; }
.stat-ico.green { background: linear-gradient(135deg, #3a97e0, #1a6fb0); color: #fff;
  box-shadow: 0 5px 14px rgba(36,134,207,.4); }
.stat-ico.slate { background: linear-gradient(135deg, #f0f2f5, #e1e6ea); color: #566370; }
:root[data-theme="dark"] .stat-ico.slate { background: #232c35; color: #aab4bf; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat .value { font-size: 32px; font-weight: 850; letter-spacing: -.02em; margin-top: 14px; line-height: 1.05;
  font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--faint); font-size: 12px; margin-top: 5px; }
.stat .value.accent { background: linear-gradient(120deg, #1a6fb0, #4aa8ea); -webkit-background-clip: text;
  background-clip: text; -webkit-text-fill-color: transparent; }

/* Hero band */
.hero { position: relative; overflow: hidden; border-radius: 18px; padding: 30px 34px; margin-bottom: 22px;
  color: #fff; background: linear-gradient(135deg, #0f4c78 0%, #2486cf 48%, #4aa8ea 100%);
  box-shadow: 0 16px 40px rgba(20,90,150,.32); display: flex; justify-content: space-between;
  align-items: center; gap: 26px; }
.hero::before { content: ""; position: absolute; right: -70px; top: -110px; width: 360px; height: 360px;
  border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.20), transparent 70%); pointer-events: none; }
.hero::after { content: ""; position: absolute; left: -80px; bottom: -140px; width: 300px; height: 300px;
  border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.10), transparent 70%); pointer-events: none; }
.hero-left { position: relative; z-index: 1; }
.hero .greeting { font-size: 14px; font-weight: 600; opacity: .9; letter-spacing: .01em; }
.hero-main { display: flex; gap: 44px; align-items: flex-end; margin-top: 16px; }
.hero-num .n { font-size: 42px; font-weight: 850; letter-spacing: -.02em; line-height: 1;
  font-variant-numeric: tabular-nums; }
.hero-num .l { font-size: 13px; opacity: .82; margin-top: 7px; }
.hero-num.sec .n { font-size: 27px; opacity: .95; }
.gauge { position: relative; width: 140px; height: 140px; flex: none; z-index: 1; }
.gauge svg { transform: rotate(-90deg); }
.gauge .g-arc { transition: stroke-dashoffset 1.1s cubic-bezier(.22,1,.36,1); }
.gauge .g-label { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; line-height: 1.1; }
.gauge .g-label .p { font-size: 30px; font-weight: 850; font-variant-numeric: tabular-nums; }
.gauge .g-label .t { font-size: 11px; opacity: .85; text-transform: uppercase; letter-spacing: .06em; }
@media (max-width: 760px) { .hero { flex-direction: column; align-items: flex-start; } }

/* Pipeline funnel */
.funnel { padding: 14px 18px 20px; display: flex; flex-direction: column; gap: 16px; }
.stage { display: grid; grid-template-columns: minmax(150px, 210px) 1fr auto; align-items: center; gap: 16px; }
.stage .s-label { font-size: 14px; color: var(--ink); font-weight: 600; }
.stage .s-track { background: var(--track); border-radius: 999px; height: 15px; overflow: hidden; }
.stage .s-track > i { display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, #4aa8ea, #1a6fb0); box-shadow: 0 0 12px rgba(36,134,207,.35);
  transition: width .9s cubic-bezier(.22,1,.36,1); }
.stage .s-count { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--ink); min-width: 28px; text-align: right; }
.stage .s-pct { color: var(--faint); font-size: 12px; font-weight: 500; margin-left: 6px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-top: 22px; }
.panel > .panel-head { display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 15px; }
.panel-head .hint { color: var(--muted); font-size: 13px; font-weight: 400; }
.panel-body { padding: 6px 0; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  font-weight: 700; margin: 4px 0 12px; }

/* Job / list rows */
.rowlist { display: flex; flex-direction: column; }
.rowlist .row { display: flex; align-items: center; gap: 14px; padding: 13px 18px; border-bottom: 1px solid var(--line-soft); }
.rowlist .row:last-child { border-bottom: 0; }
.rowlist .row.is-last { border-bottom: 0; }         /* last VISIBLE row while filtering */
.rowlist .row:hover { background: var(--hover); }
.row .title { font-weight: 600; }
.row .meta { color: var(--muted); font-size: 13px; }
.row .grow { flex: 1; min-width: 0; }
.row .trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clickable { cursor: pointer; }

/* Badges */
.badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; }
.badge.done { color: var(--ok); background: var(--ok-bg); }
.badge.queued { color: var(--warn); background: var(--warn-bg); }
.badge.processing, .badge.uploading, .badge.generating { color: var(--busy); background: var(--busy-bg); }
.badge.error { color: var(--err); background: var(--err-bg); }
.badge.cancelled { color: var(--muted); background: var(--neutral-bg); }
.badge.none { color: var(--faint); background: var(--neutral-bg); }
.pill { font-size: 12px; color: var(--muted); background: var(--neutral-bg); border-radius: 999px; padding: 2px 9px; }

/* Spinner */
.spin { display: inline-block; width: 11px; height: 11px; border: 2px solid currentColor;
  border-right-color: transparent; border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* Tables */
table.grid { width: 100%; border-collapse: collapse; }
table.grid th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 700; padding: 11px 14px; border-bottom: 1px solid var(--line); }
table.grid th.num { text-align: right; }   /* numeric headers align over their right-aligned cells */
table.grid td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr.is-last td { border-bottom: 0; }      /* last VISIBLE row while filtering */
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.money { font-variant-numeric: tabular-nums; }

/* Inputs */
label.fld { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=url],
input[type=search], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font: inherit;
  color: inherit; background-color: var(--input-bg); }   /* not `background` shorthand — it clobbers .search's icon */
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
input.cell, select.cell { padding: 7px 9px; border-radius: 7px; }
input.num-cell { text-align: right; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.help { color: var(--muted); font-size: 12px; margin-top: 6px; }
.err-text { color: var(--err); font-size: 13px; }

/* Estimate editor */
.est-line-desc { min-width: 240px; }
.approval-banner { margin: 12px 18px 4px; padding: 10px 14px; border-radius: 9px;
  background: var(--ok-bg); color: var(--ok); font-size: 13px; font-weight: 600; }
.line-status { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 6px;
  padding: 1px 7px; margin-bottom: 5px; }
.line-status.ok { color: var(--ok); background: var(--ok-bg); }
.line-status.no { color: var(--muted); background: var(--neutral-bg); }
.est-row.declined { opacity: .55; }
.est-row.declined .money { text-decoration: line-through; }
.est-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 18px;
  border-top: 1px solid var(--line); }
.est-controls .grow { flex: 1; }
.rate-inline { display: flex; align-items: center; gap: 8px; }
.rate-inline label { font-size: 13px; color: var(--muted); font-weight: 600; }
.rate-inline input { width: 84px; }
.totals-box { display: flex; justify-content: flex-end; padding: 16px 18px; border-top: 1px solid var(--line); }
.totals-box table { border-collapse: collapse; min-width: 280px; }
.totals-box td { padding: 6px 4px; }
.totals-box td.lbl { color: var(--muted); }
.totals-box td.v { text-align: right; font-variant-numeric: tabular-nums; }
.totals-box tr.grand td { border-top: 2px solid var(--ink); padding-top: 11px; font-size: 20px; font-weight: 800; }
.dirty-note { color: var(--warn); font-size: 13px; font-weight: 600; }

/* Empty state */
.empty { text-align: center; color: var(--muted); padding: 46px 20px; }
.empty .big { font-size: 16px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }

/* Log */
.log { background: #0f1720; color: #cbd5e1; border-radius: 10px; padding: 12px 14px; margin: 0 18px 16px;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; max-height: 220px; overflow: auto;
  white-space: pre-wrap; word-break: break-word; }
.log.err { color: #fca5a5; }

/* Detail header */
.detail-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.detail-meta { color: var(--muted); font-size: 14px; margin-top: 6px; }
.detail-meta span::after { content: "·"; margin: 0 8px; color: var(--faint); }
.detail-meta span:last-child::after { content: ""; margin: 0; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,22,31,.5); display: grid; place-items: center;
  z-index: 50; padding: 20px; }
.modal { background: var(--card); border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 520px;
  max-height: 90vh; overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 15px; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.x { cursor: pointer; color: var(--faint); font-size: 22px; line-height: 1; border: 0; background: none; }

/* Dropzone */
.drop { border: 1.5px dashed var(--faint); border-radius: 11px; padding: 26px 16px; text-align: center;
  color: var(--muted); cursor: pointer; transition: .15s; background: var(--hover); }
.drop.drag { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }
.drop.has-file { border-style: solid; border-color: var(--brand); background: var(--brand-soft); color: var(--ink); }
.drop strong { display: block; color: var(--ink); font-size: 14px; margin-bottom: 3px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 500; }
.check input { width: auto; }
.skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 14px; margin-top: 2px; }
table.grid tr.mat-section td { background: var(--brand-soft); color: var(--brand); font-size: 12px;
  font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 11px 14px;
  border-top: 1px solid var(--line); box-shadow: inset 4px 0 0 var(--brand); }
.mat-price { font-size: 12px; line-height: 1.4; }
.mat-price .q-line { white-space: nowrap; color: var(--muted); }
.mat-price .q-line.best { color: var(--ink); font-weight: 700; }
.mat-price .q-line a { color: inherit; text-decoration: none; }
.mat-price .q-line a:hover { text-decoration: underline; }
.mat-price .m-use { margin-top: 4px; }
.stk.ok { color: var(--ok); font-weight: 600; }
.stk.no { color: var(--err); font-weight: 600; }
.progress { height: 7px; background: var(--line); border-radius: 5px; overflow: hidden; display: none; }
.progress.show { display: block; }
.progress > i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--toast-bg);
  color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-lg);
  z-index: 60; opacity: 0; transition: opacity .2s; }
.toast.show { opacity: 1; }
.toast.err { background: var(--err); }

/* Login overlay (desktop admin) */
#login-overlay { position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 28px 26px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .brand-mark { width: 44px; height: 44px; flex: none; }
.login-brand .brand-mark svg { width: 100%; height: 100%; }
.login-brand strong { display: block; font-size: 18px; color: var(--ink); }
.login-brand span { display: block; color: var(--muted); font-size: 13px; }
.login-card .fld { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 0 5px; }
.login-card input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; color: var(--ink); background: var(--input-bg); }
.login-card input:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.login-card .btn.primary { margin-top: 20px; }

/* ---------- scheduling ---------- */
.sched-actions { display: flex; gap: 8px; }

/* Scope + suggest + shared bits (also used in the schedule modal) */
.sched-scope { font-size: 14px; color: var(--ink); background: var(--hover); border: 1px solid var(--line-soft);
  border-radius: 10px; padding: 10px 14px; }
.sched-suggest-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sched-suggest-row .help { margin-top: 0; flex: 1; min-width: 180px; }
.ai-rationale { font-size: 13px; color: var(--ink); background: var(--brand-soft); border: 1px solid var(--brand);
  border-radius: 10px; padding: 10px 12px; line-height: 1.45; }
.ai-tag { display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: #fff; background: var(--brand); border-radius: 5px; padding: 1px 6px; margin-right: 6px; vertical-align: 1px; }
.cap-hint { font-size: 13px; color: var(--muted); }
.cap-hint.ok { color: var(--ok); }
.cap-hint.under { color: var(--warn); }
.cap-hint .warn { color: var(--warn); font-weight: 600; }
.conflict-box { border: 1px solid var(--err); background: var(--err-bg); border-radius: 10px; padding: 10px 12px; }
.conflict-head { font-size: 13px; font-weight: 700; color: var(--err); }
.conflict-head.sub { color: var(--ink); margin-top: 8px; font-weight: 600; }
.conflict-list, .fix-list { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink);
  display: flex; flex-direction: column; gap: 3px; }
.fix-list { color: var(--muted); }
.ok-note { font-size: 13px; color: var(--ok); font-weight: 600; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.warn:hover { filter: brightness(.95); background: var(--warn); }

/* Schedule modal: quick-fill + per-day rows + staff chips */
.modal.modal-xl { max-width: 820px; }
.quick-fill { border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px 14px; background: var(--hover); }
.qf-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.qf-title { font-weight: 700; font-size: 13px; color: var(--ink); }
.qf-f { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.qf-f input { width: auto; }
.qf-f input[type=number] { width: 62px; }
.check.inline { display: inline-flex; }
.qf-crewlabel { font-size: 12px; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
.qf-crew, .dr-crew { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-toggle { font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--card);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; cursor: pointer; transition: .12s; }
.chip-toggle:hover { border-color: var(--faint); color: var(--ink); }
.chip-toggle.match { border-color: var(--brand); color: var(--brand); }
.chip-toggle.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip-toggle.busy { border-color: var(--warn); color: var(--warn); }
.chip-toggle.busy.on { background: var(--warn); border-color: var(--warn); color: #fff; }
.days-head { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.days-head .fld { margin: 0; }
#day-rows { display: flex; flex-direction: column; gap: 8px; }
.day-row { border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px 12px; }
.day-row.weekend { background: var(--warn-bg); border-color: transparent; }
.dr-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dr-top input { width: auto; }
.dr-dow { font-size: 12px; color: var(--muted); font-weight: 600; min-width: 34px; }
.wknd-tag { color: var(--warn); font-weight: 700; }
.dr-times { display: inline-flex; align-items: center; gap: 6px; }
.dr-dash { color: var(--faint); }
.dr-top .dr-del { margin-left: auto; }
.dr-crew { margin-top: 9px; }

/* Calendar view */
.cal-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-title { font-weight: 700; font-size: 15px; color: var(--ink); margin: 0 4px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn { border: 0; background: var(--card); color: var(--muted); font-weight: 600; font-size: 13px;
  padding: 6px 14px; cursor: pointer; }
.seg-btn.on { background: var(--brand); color: #fff; }
.cal-panel { padding: 0; overflow: hidden; }
.cal-conflict-note { background: var(--err-bg); color: var(--err); font-weight: 600; font-size: 13px;
  padding: 10px 16px; border-bottom: 1px solid var(--line-soft); }
.cal-wrap { overflow: auto; max-height: calc(100vh - 210px); }
.cal-headrow { display: grid; position: sticky; top: 0; z-index: 3; background: var(--card); border-bottom: 1px solid var(--line); }
.cal-gutter-head { border-right: 1px solid var(--line-soft); }
.cal-dayhead { text-align: center; padding: 8px 4px; font-size: 12px; font-weight: 600; color: var(--muted);
  border-left: 1px solid var(--line-soft); }
.cal-dayhead span { display: block; font-size: 15px; font-weight: 700; color: var(--ink); }
.cal-dayhead.weekend { background: var(--hover); }
.cal-dayhead.today { color: var(--brand); }
.cal-dayhead.today span { color: var(--brand); }
.cal-body { display: grid; }
.cal-gutter { position: relative; border-right: 1px solid var(--line-soft); }
.cal-hour { position: relative; }
.cal-hour span { position: absolute; top: -7px; right: 7px; font-size: 11px; color: var(--faint); white-space: nowrap; }
.cal-col { position: relative; border-left: 1px solid var(--line-soft);
  background-image: linear-gradient(to bottom, var(--line-soft) 1px, transparent 1px); background-repeat: repeat-y; }
.cal-col.weekend { background-color: color-mix(in srgb, var(--warn-bg) 45%, transparent); }
.cal-col.today { background-color: color-mix(in srgb, var(--brand-soft) 50%, transparent); }
.cal-event { position: absolute; border-radius: 7px; padding: 3px 7px; overflow: hidden; cursor: pointer;
  border-left: 3px solid currentColor; box-shadow: 0 1px 2px rgba(16,24,40,.14); font-size: 11.5px; line-height: 1.25; }
.cal-event:hover { filter: brightness(.97); box-shadow: var(--shadow-lg); z-index: 2; }
.ce-time { font-weight: 600; opacity: .85; font-size: 10.5px; }
.ce-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ce-crew { opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event.conflict { box-shadow: 0 0 0 2px var(--err); z-index: 2; }

/* Event colors (job-stable palette; soft fill + readable ink, both themes) */
.ev-0 { background: #e3eff8; color: #1f5a86; }
.ev-1 { background: #e7f3ec; color: #1c7a4f; }
.ev-2 { background: #f3ecfa; color: #6b3fa0; }
.ev-3 { background: #fdeede; color: #9a5b17; }
.ev-4 { background: #fbe9ec; color: #a23545; }
.ev-5 { background: #e6f1f0; color: #1c7d78; }
:root[data-theme="dark"] .ev-0 { background: #17303f; color: #8fc4e8; }
:root[data-theme="dark"] .ev-1 { background: #163227; color: #6fd3a0; }
:root[data-theme="dark"] .ev-2 { background: #2a2140; color: #c0a3e8; }
:root[data-theme="dark"] .ev-3 { background: #33280f; color: #e2b874; }
:root[data-theme="dark"] .ev-4 { background: #3a1c22; color: #f09aa6; }
:root[data-theme="dark"] .ev-5 { background: #14302e; color: #6fd0c9; }

@media (max-width: 720px) {

  .app { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .main { height: auto; overflow: visible; }
  .view { overflow: visible; scrollbar-gutter: auto; min-height: 0; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 12px 16px; }
  .nav { flex-direction: row; margin: 0 auto; }
  .brand, .sidebar-foot { display: none; }
  .view, .topbar { padding-left: 18px; padding-right: 18px; }
}
