/* CrewDesk demo for Greenway Lawn & Garden. Built by Atomic Helm. */

:root {
  --forest-950: #0D2117;
  --forest-900: #143222;
  --forest-800: #1A412C;
  --forest-700: #22573A;
  --forest-600: #2C6B48;
  --forest-100: #E2EFE5;
  --lime-400: #B5E354;
  --lime-500: #9CCB36;
  --lime-200: #DDF2AE;
  --lime-100: #F0F9DC;
  --cream: #FAF8F2;
  --sand-50: #FFFEFB;
  --sand-100: #F4F0E6;
  --sand-200: #EAE4D6;
  --line: #E3DCCB;
  --line-strong: #D3CAB4;
  --ink: #1B241F;
  --ink-2: #3F4B44;
  --muted: #5B665F;
  --blue: #2B63A6;  --blue-bg: #E4EEF9;
  --amber: #9A5A00; --amber-bg: #FCEFD6;
  --red: #B0322A;   --red-bg: #FBE5E1;
  --green: #22693F; --green-bg: #E1F1E4;
  --gray: #545B56;  --gray-bg: #ECEAE3;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(20, 50, 34, .06), 0 1px 1px rgba(20, 50, 34, .04);
  --shadow: 0 1px 2px rgba(20, 50, 34, .05), 0 6px 18px -6px rgba(20, 50, 34, .12);
  --shadow-lg: 0 24px 60px -12px rgba(13, 33, 23, .35), 0 4px 12px rgba(13, 33, 23, .1);
  --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sidebar-w: 248px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'tnum' 0;
}
body.modal-open { overflow: hidden; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
h1, h2, h3, p { margin: 0; }
a { color: var(--forest-700); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--forest-900); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.ico { width: 18px; height: 18px; flex: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.up { color: var(--green); font-weight: 600; }
.down { color: var(--red); font-weight: 600; }
.warn-text { color: var(--amber); font-weight: 600; }
.danger-text { color: var(--red) !important; }
kbd { font-family: var(--font); font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--sand-50); color: var(--muted); }

/* Focus */
:focus { outline: none; }
:focus-visible { outline: 2.5px solid var(--forest-700); outline-offset: 2px; box-shadow: 0 0 0 5px rgba(181, 227, 84, .55); border-radius: 6px; }
.sidebar :focus-visible { outline-color: var(--lime-400); box-shadow: none; }
h1:focus-visible, main:focus-visible { outline: none; box-shadow: none; }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  background: var(--forest-900); color: #fff; border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 600;
}
.skip-link:focus { top: 12px; }

/* ---------- Demo banner ---------- */
.demo-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 16px; min-height: 38px;
  background: var(--forest-950); color: #E8F2E4; font-size: 13.5px;
  border-bottom: 1px solid rgba(181, 227, 84, .25);
  position: relative; z-index: 40;
}
.demo-banner[hidden] { display: none; }
.demo-banner p { flex: 1; min-width: 0; }
.demo-banner strong { color: var(--lime-400); }
.banner-ico { color: var(--lime-400); display: inline-flex; }
.banner-link { background: none; border: 0; color: #E8F2E4; text-decoration: underline; text-underline-offset: 2px; padding: 4px 6px; font-size: 13px; white-space: nowrap; }
.banner-link:hover { color: var(--lime-400); }
.banner-x { background: none; border: 0; color: #E8F2E4; width: 32px; height: 32px; border-radius: 8px; display: inline-grid; place-items: center; flex: none; }
.banner-x:hover { background: rgba(255, 255, 255, .1); }
.demo-banner :focus-visible { outline-color: var(--lime-400); box-shadow: none; }

/* ---------- Shell ---------- */
.shell { 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: linear-gradient(180deg, var(--forest-900), var(--forest-950));
  color: #DCE9DF; display: flex; flex-direction: column; padding: 18px 14px;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; }
.brand-logo { display: inline-flex; }
.logo-mark { width: 36px; height: 36px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-family: var(--serif); font-weight: 600; font-size: 20px; letter-spacing: -.01em; color: #fff; }
.brand-co { font-size: 12px; color: #A9C2AF; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: #CFE0D3; text-decoration: none; font-weight: 500; position: relative;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-link[aria-current="page"] { background: rgba(181, 227, 84, .14); color: #fff; }
.nav-link[aria-current="page"]::before { content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--lime-400); }
.nav-link[aria-current="page"] .ico { color: var(--lime-400); }
.nav-count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px; font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; background: rgba(255, 255, 255, .14); color: #fff; }
.nav-count.warn { background: #F2B544; color: #2A1A00; }
.nav-count.danger { background: #F0806F; color: #2B0703; }
.sidebar-foot { margin-top: auto; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, .1); display: flex; flex-direction: column; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.me-text { display: flex; flex-direction: column; line-height: 1.2; font-size: 13.5px; }
.me-text strong { color: #fff; font-weight: 600; }
.me-text span { color: #A9C2AF; font-size: 12px; }
.side-reset { display: flex; align-items: center; gap: 10px; background: transparent; border: 1px solid rgba(255, 255, 255, .16); color: #DCE9DF; border-radius: 10px; padding: 8px 12px; font-size: 13.5px; font-weight: 500; }
.side-reset:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.side-reset span { display: inline-flex; }
.built-by { font-size: 11.5px; color: #8FAA96; padding: 0 6px; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 32px; background: rgba(250, 248, 242, .88);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.menu-btn, .topbar-brand { display: none; }
.search-trigger {
  flex: 1; max-width: 520px; display: flex; align-items: center; gap: 10px;
  background: var(--sand-50); border: 1px solid var(--line); border-radius: 11px; padding: 8px 10px 8px 12px; color: var(--muted); text-align: left; min-height: 40px;
  box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s;
}
.search-trigger:hover { border-color: var(--line-strong); }
.search-trigger > span:first-child { display: inline-flex; }
.search-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.new-btn { margin-left: auto; }
.new-btn > span:first-child { display: inline-flex; }
main { flex: 1; }
.view { padding: 28px 32px 64px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* ---------- Page head ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head > div:first-child { min-width: 0; }
.eyebrow { font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--forest-600); margin-bottom: 4px; }
.eyebrow a { color: inherit; }
h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(26px, 3vw, 34px); line-height: 1.12; letter-spacing: -.015em; color: var(--forest-900); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.h1-sub { font-family: var(--font); font-size: 15px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.sub { color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; text-decoration: none; margin-bottom: 10px; color: var(--forest-600); }
.back-link .ico { width: 16px; height: 16px; }
.show-mobile { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--sand-50); color: var(--ink);
  font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap;
  box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.btn:hover { background: #fff; border-color: #BFB59C; color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn .ico { width: 17px; height: 17px; }
.btn-primary { background: var(--forest-800); border-color: var(--forest-800); color: #fff; }
.btn-primary:hover { background: var(--forest-700); border-color: var(--forest-700); color: #fff; }
.btn-accent { background: var(--lime-400); border-color: #9BC93C; color: var(--forest-950); }
.btn-accent:hover { background: #C3EC69; border-color: #8EBB30; color: var(--forest-950); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #962820; border-color: #962820; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--forest-700); }
.btn-ghost:hover { background: var(--sand-100); border-color: transparent; }
.btn-sm { min-height: 34px; padding: 5px 11px; font-size: 13.5px; border-radius: 9px; }
.btn-sm .ico { width: 15px; height: 15px; }
.btn-block { width: 100%; }
.btn-icon-text { padding: 8px 10px; }
.btn[aria-pressed="true"] { background: var(--forest-100); border-color: var(--forest-600); color: var(--forest-900); }
.btn-step { background: var(--forest-800); border-color: var(--forest-800); color: #fff; }
.btn-step:hover { background: var(--forest-700); color: #fff; }
.btn-icon {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--ink-2);
}
.btn-icon:hover { background: var(--sand-100); color: var(--ink); }
.btn-icon.bordered { border-color: var(--line-strong); background: var(--sand-50); width: 40px; height: 40px; }

/* ---------- Cards, badges ---------- */
.card { background: var(--sand-50); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-title { font-size: 16.5px; font-weight: 700; color: var(--forest-900); letter-spacing: -.005em; }
.card-title { margin-bottom: 14px; }
.card-sub { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.link-more { display: inline-flex; align-items: center; gap: 4px; font-size: 13.5px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.link-more .ico { width: 15px; height: 15px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; white-space: nowrap; line-height: 1.6; border: 1px solid transparent;
  font-family: var(--font); letter-spacing: 0;
}
.badge .ico { width: 13px; height: 13px; stroke-width: 2.6; }
.b-scheduled, .b-draft { background: var(--gray-bg); color: var(--gray); }
.b-enroute, .b-sent { background: var(--blue-bg); color: var(--blue); }
.b-inprogress, .b-unpaid { background: var(--amber-bg); color: var(--amber); }
.b-done, .b-paid, .b-accepted { background: var(--green-bg); color: var(--green); }
.b-declined, .b-overdue { background: var(--red-bg); color: var(--red); }
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; display: inline-grid; place-items: center; background: var(--lime-200); color: var(--forest-900); font-weight: 700; font-size: 13px; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar.lg { width: 56px; height: 56px; font-size: 19px; background: var(--forest-800); color: var(--lime-400); }
.sidebar .avatar { background: var(--lime-400); color: var(--forest-950); }
.crew-tag { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.crew-tag::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--crew); }
.plan-tag { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--sand-100); color: var(--ink-2); white-space: nowrap; }
.p-weekly { background: var(--lime-100); color: var(--forest-700); }
.p-biweekly { background: var(--blue-bg); color: var(--blue); }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 28px 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-ico { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--lime-100); color: var(--forest-600); margin-bottom: 6px; }
.empty-ico .ico { width: 24px; height: 24px; }
.empty-title { font-weight: 700; color: var(--forest-900); }
.empty-text { color: var(--muted); font-size: 14px; max-width: 34ch; }
.empty .btn { margin-top: 8px; }

/* ---------- Dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  position: relative; display: flex; flex-direction: column; gap: 2px; padding: 18px 18px 16px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--sand-50); box-shadow: var(--shadow);
  text-decoration: none; color: var(--ink); overflow: hidden; transition: transform .15s var(--ease), box-shadow .15s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: 0 10px 26px -10px rgba(20, 50, 34, .25); color: var(--ink); }
.kpi::after { content: ''; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--k, var(--forest-600)); }
.k-green { --k: var(--forest-600); }
.k-lime { --k: var(--lime-500); }
.k-sand { --k: #C9B98F; }
.k-red { --k: var(--red); }
.kpi-ico { position: absolute; right: 16px; top: 18px; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--sand-100); color: var(--forest-700); }
.kpi-label { font-size: 13.5px; font-weight: 600; color: var(--muted); }
.kpi-value { font-size: 30px; font-weight: 800; letter-spacing: -.02em; color: var(--forest-900); font-variant-numeric: tabular-nums; margin-top: 4px; }
.kpi-sub { font-size: 13px; color: var(--muted); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.lg-past { background: var(--forest-700); }
.lg-cur { background: var(--lime-500); }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart .bar rect { fill: var(--forest-700); transition: fill .15s; }
.chart .bar.current rect { fill: var(--lime-500); }
.chart .bar:hover rect, .chart .bar:focus rect { fill: var(--forest-600); }
.chart .bar.current:hover rect, .chart .bar.current:focus rect { fill: #8BBB27; }
.chart .bar:focus { outline: none; }
.chart .bar:focus-visible rect { stroke: var(--forest-950); stroke-width: 2.5; }
.chart .bar-val { fill: var(--ink-2); font-size: 12px; font-weight: 700; font-family: var(--font); }

.route-list { list-style: none; margin: 0; padding: 0; position: relative; }
.route-item { display: grid; grid-template-columns: 70px 14px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.route-item:last-child { border-bottom: 0; }
.route-time { font-size: 13px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.route-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--crew); box-shadow: 0 0 0 3px color-mix(in srgb, var(--crew) 20%, transparent); }
.route-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.route-main a { font-weight: 600; text-decoration: none; color: var(--ink); }
.route-main a:hover { text-decoration: underline; }
.route-main .muted { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.route-item.is-done .route-main a { color: var(--muted); }

.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.mini-list li:last-child { border-bottom: 0; }
.mini-list li > div:first-child { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.mini-list li > div:first-child a { font-weight: 600; text-decoration: none; color: var(--ink); }
.mini-list li > div:first-child a:hover { text-decoration: underline; }
.mini-list .muted { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.mini-right { display: flex; align-items: center; gap: 10px; flex: none; font-variant-numeric: tabular-nums; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed-item { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 10px 0; }
.feed-item + .feed-item { border-top: 1px solid var(--line); }
.feed-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--sand-100); color: var(--forest-700); }
.feed-ico .ico { width: 16px; height: 16px; }
.f-done .feed-ico, .f-pay .feed-ico { background: var(--green-bg); color: var(--green); }
.f-alert .feed-ico { background: var(--red-bg); color: var(--red); }
.f-send .feed-ico, .f-quote .feed-ico { background: var(--blue-bg); color: var(--blue); }
.f-job .feed-ico { background: var(--amber-bg); color: var(--amber); }
.feed-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.feed-main a, .feed-main strong { font-weight: 600; color: var(--ink); text-decoration: none; }
.feed-main a:hover { text-decoration: underline; }
.feed-main .muted { font-size: 13px; }
.feed-time { font-size: 12.5px; color: var(--muted); white-space: nowrap; padding-top: 2px; }

/* ---------- Dispatch ---------- */
.date-switch .input { min-height: 40px; width: auto; }
.board-tip { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); margin: -8px 0 14px; }
.board-tip .ico { width: 16px; height: 16px; color: var(--forest-600); }
.tip-touch { display: none; }
@media (pointer: coarse) { .tip-touch { display: inline; } .tip-desktop { display: none; } }
.crew-jump { display: none; }
.board { display: grid; grid-template-columns: repeat(4, minmax(252px, 1fr)); gap: 14px; align-items: start; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.col { background: var(--sand-100); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; scroll-snap-align: start; scroll-margin-top: 76px; }
.col-head { padding: 14px 14px 12px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, color-mix(in srgb, var(--crew) 10%, var(--sand-50)), var(--sand-50)); border-radius: var(--radius) var(--radius) 0 0; border-top: 4px solid var(--crew); }
.col-unassigned .col-head { border-top-style: dashed; }
.col-title { display: flex; align-items: center; gap: 8px; }
.col-title h2 { font-size: 15.5px; font-weight: 700; }
.col-title .dot, .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--crew); flex: none; }
.count { margin-left: auto; font-size: 12.5px; font-weight: 700; background: var(--sand-50); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; color: var(--ink-2); }
.col-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.progress { height: 7px; border-radius: 999px; background: var(--sand-200); margin-top: 10px; overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: inherit; background: var(--crew); transition: width .4s var(--ease); }
.progress-label { font-size: 12px; font-weight: 600; color: var(--ink-2); margin-top: 5px; }
.col-body { padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 120px; border-radius: 0 0 var(--radius) var(--radius); transition: background .15s, box-shadow .15s; }
.col-body.drop-over { background: color-mix(in srgb, var(--crew) 12%, var(--sand-100)); box-shadow: inset 0 0 0 2px var(--crew); }
.col-empty { border: 1.5px dashed var(--line-strong); border-radius: 11px; padding: 22px 12px; text-align: center; color: var(--muted); font-size: 13.5px; }

.jcard {
  position: relative; background: var(--sand-50); border: 1px solid var(--line); border-left: 4px solid var(--crew);
  border-radius: 12px; padding: 11px 12px 12px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 4px;
  transition: box-shadow .15s, transform .15s var(--ease), opacity .15s;
}
.jcard:hover { box-shadow: var(--shadow); }
@media (pointer: fine) { .jcard { cursor: grab; } .jcard a, .jcard button { cursor: pointer; } }
.jcard.s-done { background: color-mix(in srgb, var(--green-bg) 45%, var(--sand-50)); }
.jcard.s-done .jcard-title a { color: var(--ink-2); }
.jcard.dragging { opacity: .35; transform: scale(.98); }
.jcard.ghost { position: fixed; left: 0; top: 0; z-index: 300; pointer-events: none; box-shadow: var(--shadow-lg); opacity: .96; margin: 0; }
.jcard-top { display: flex; align-items: center; gap: 6px; }
.drag-handle {
  display: inline-grid; place-items: center; width: 28px; height: 30px; margin: -4px 0 -4px -6px; border-radius: 7px;
  color: #8E978F; cursor: grab; touch-action: none; flex: none;
}
.drag-handle:hover { background: var(--sand-100); color: var(--ink-2); }
.drag-handle .ico { width: 16px; height: 16px; }
.jtime { font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.jdur { font-size: 12.5px; color: var(--muted); }
.jcard-top .badge { margin-left: auto; }
.jcard-title { font-size: 15.5px; font-weight: 700; line-height: 1.25; margin-top: 2px; }
.jcard-title a { color: var(--ink); text-decoration: none; }
.jcard-title a:hover { text-decoration: underline; }
.jcard-addr { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.jcard-addr .ico { width: 14px; height: 14px; }
.jcard-svc { font-size: 13px; color: var(--ink-2); }
.flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.flag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 7px; background: var(--sand-100); color: var(--ink-2); }
.flag .ico { width: 13px; height: 13px; }
.flag-dog { background: var(--amber-bg); color: var(--amber); }
.stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 6px 0 2px; }
.stepper span { height: 4px; border-radius: 4px; background: var(--sand-200); }
.stepper span.on { background: var(--crew); }
.jcard-actions { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.jcard-actions .btn-icon { margin-left: auto; width: 34px; height: 34px; }
.billed-note { font-size: 12.5px; color: var(--muted); font-weight: 600; }

/* ---------- Status track (job detail) ---------- */
.status-track { list-style: none; margin: 0 0 18px; padding: 14px 18px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; background: var(--sand-50); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.status-track li { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14px; color: var(--muted); position: relative; }
.st-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--sand-100); border: 1.5px solid var(--line-strong); color: var(--muted); flex: none; }
.st-dot .ico { width: 15px; height: 15px; stroke-width: 2.6; }
.status-track li.past { color: var(--forest-700); }
.status-track li.past .st-dot { background: var(--forest-700); border-color: var(--forest-700); color: #fff; }
.status-track li.current { color: var(--forest-900); }
.status-track li.current .st-dot { background: var(--lime-400); border-color: var(--forest-700); color: var(--forest-950); box-shadow: 0 0 0 4px rgba(181, 227, 84, .35); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.billing-line { margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: var(--sand-100); font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.props { margin: 0; display: grid; gap: 12px; }
.props > div { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 10px; align-items: start; }
.props dt { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.props dt .ico { width: 15px; height: 15px; color: var(--forest-600); }
.props dd { margin: 0; font-size: 14.5px; }
.props .prop-warn dd { color: var(--amber); font-weight: 600; }
.props .prop-warn dt .ico { color: var(--amber); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 4px; background: var(--sand-100); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; width: fit-content; max-width: 100%; }
.tab { border: 0; background: transparent; padding: 7px 12px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 7px; min-height: 36px; }
.tab:hover { background: rgba(255, 255, 255, .6); }
.tab[aria-pressed="true"] { background: var(--sand-50); color: var(--forest-900); box-shadow: var(--shadow-sm); }
.tab-count { font-size: 12px; font-weight: 700; padding: 0 7px; border-radius: 999px; background: var(--sand-200); color: var(--ink-2); }
.tab[aria-pressed="true"] .tab-count { background: var(--forest-800); color: #fff; }

/* ---------- Tables ---------- */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 11px 14px; background: var(--sand-100); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: rgba(244, 240, 230, .55); }
.table tfoot th, .table tfoot td { background: transparent; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink); border-top: 1px solid var(--line); border-bottom: 0; }
.card > .table-wrap .table th:first-child, .card > .table-wrap .table td:first-child { padding-left: 18px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.table .act { text-align: right; white-space: nowrap; }
.clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strong-link { font-weight: 700; text-decoration: none; }
.strong-link:hover { text-decoration: underline; }
.row-link { cursor: pointer; }
.table-foot { padding: 12px 18px; font-size: 13px; border-top: 1px solid var(--line); }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--sand-50); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); }
.stat span { font-size: 13px; font-weight: 600; color: var(--muted); }
.stat strong { font-size: 22px; font-weight: 800; color: var(--forest-900); font-variant-numeric: tabular-nums; }
.stat-danger strong { color: var(--red); }
.stat-good strong { color: var(--green); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.input {
  width: 100%; min-height: 40px; padding: 8px 11px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: #fff; color: var(--ink); font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
.input:hover { border-color: #BFB59C; }
.input:focus { border-color: var(--forest-600); box-shadow: 0 0 0 3px rgba(181, 227, 84, .55); outline: none; }
.input:disabled { background: var(--sand-100); color: var(--ink-2); }
.input[aria-invalid="true"] { border-color: var(--red); }
textarea.input { resize: vertical; min-height: 70px; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 34px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235B665F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 16px; }
.input.num { text-align: right; font-variant-numeric: tabular-nums; }
.input-sm { min-height: 34px; padding: 5px 8px; width: 90px; }
.input-prefix { position: relative; display: flex; align-items: center; }
.input-prefix > span { position: absolute; left: 10px; color: var(--muted); font-size: 14px; pointer-events: none; }
.input-prefix .input { padding-left: 22px; }
.form-grid { display: grid; gap: 14px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.tight { gap: 10px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.field-error { color: var(--red); font-weight: 600; font-size: 14px; }
.hint { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-top: 12px; }
.hint .ico { width: 14px; height: 14px; color: var(--forest-600); }
.dirty { font-size: 12.5px; font-weight: 700; color: var(--amber); background: var(--amber-bg); padding: 1px 8px; border-radius: 999px; }
.dirty[hidden] { display: none; }
.total-line { display: flex; justify-content: flex-end; align-items: baseline; gap: 12px; font-weight: 600; color: var(--ink-2); }
.total-line strong { font-size: 20px; color: var(--forest-900); }

/* line editor */
.line-editor .table { font-size: 14px; }
.line-editor .table td { padding: 8px 8px; }
.line-editor .table th { padding: 9px 8px; }
.lines td:first-child { min-width: 220px; }
.lines td:nth-child(2) { width: 96px; }
.lines td:nth-child(3) { width: 130px; }
.lines td:nth-child(4) { width: 110px; font-weight: 600; }
.lines td.act { width: 44px; }
.unit-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; padding-left: 2px; }
.empty-row td { text-align: center; color: var(--muted); padding: 22px 10px !important; font-size: 14px; }
.add-line { display: block; margin-top: 12px; }
.add-line select { border-style: dashed; background-color: var(--sand-50); font-weight: 600; color: var(--forest-700); }

/* ---------- Quote builder ---------- */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.builder-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.builder-side { position: sticky; top: 84px; }
.sum { margin: 0 0 16px; display: grid; gap: 10px; }
.sum > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; }
.sum dt { color: var(--ink-2); font-size: 14px; }
.sum dd { margin: 0; font-weight: 600; }
.sum-total { border-top: 1px solid var(--line); padding-top: 12px; }
.sum-total dt { font-weight: 700; color: var(--forest-900); font-size: 15px; }
.sum-total dd { font-size: 26px; font-weight: 800; color: var(--forest-900); letter-spacing: -.02em; }
.side-actions { display: flex; flex-direction: column; gap: 8px; }
.cust-strip { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 10px 12px; background: var(--sand-100); border-radius: 10px; }
.cust-strip > div { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.cust-strip .muted { font-size: 13px; }

/* ---------- Schedule ---------- */
.cal-legend { margin: -6px 0 14px; }
.cal-legend i { width: 12px; height: 12px; border-radius: 4px; }
.cal-card { padding: 0; overflow: hidden; }
.cal-scroll { overflow-x: auto; }
.cal { width: 100%; min-width: 920px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.cal th, .cal td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); vertical-align: top; }
.cal th:last-child, .cal td:last-child { border-right: 0; }
.cal tbody tr:last-child th, .cal tbody tr:last-child td { border-bottom: 0; }
.cal thead th { background: var(--sand-100); padding: 10px 8px; text-align: left; font-weight: 600; }
.cal-corner { width: 150px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); vertical-align: middle !important; }
.cal-day { display: flex; align-items: baseline; gap: 6px; text-decoration: none; color: var(--ink); border-radius: 6px; }
.cal-day span { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.cal-day b { font-size: 20px; font-weight: 800; }
.cal-day:hover b { color: var(--forest-600); text-decoration: underline; }
.cal-count { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.cal thead th.is-today { background: var(--lime-100); box-shadow: inset 0 3px 0 var(--lime-500); }
.cal thead th.is-today .cal-day b { color: var(--forest-700); }
.cal td.is-today { background: rgba(240, 249, 220, .5); }
.cal td { padding: 6px; height: 88px; }
.cal-crew { padding: 12px 10px; text-align: left; font-weight: 400; background: var(--sand-50); }
.cal-crew { display: table-cell; }
.cal-crew > span:last-child { display: flex; flex-direction: column; line-height: 1.25; font-size: 13px; }
.cal-crew b { font-size: 14px; }
.cal-crew .dot { display: inline-block; margin-bottom: 6px; }
.cal-chip {
  display: flex; flex-direction: column; gap: 0; text-decoration: none; color: var(--ink);
  background: color-mix(in srgb, var(--crew) 13%, #fff); border-left: 3px solid var(--crew);
  border-radius: 7px; padding: 5px 7px; margin-bottom: 5px; font-size: 12.5px; line-height: 1.3;
  transition: background .15s, transform .1s;
}
.cal-chip:hover { background: color-mix(in srgb, var(--crew) 24%, #fff); color: var(--ink); }
.cal-chip.s-done { opacity: .62; }
.cal-time { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-size: 11.5px; color: color-mix(in srgb, var(--crew) 75%, #000); }
.cal-time .ico { width: 12px; height: 12px; stroke-width: 2.8; }
.cal-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-svc { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; }
.agenda { display: none; }
.today-pill { font-size: 11px; font-weight: 700; background: var(--lime-400); color: var(--forest-950); padding: 1px 8px; border-radius: 999px; vertical-align: middle; font-family: var(--font); }

/* ---------- Customers ---------- */
.split { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; align-items: start; }
.list-panel { padding: 14px; position: sticky; top: 84px; max-height: calc(100vh - 104px); display: flex; flex-direction: column; }
.list-tools { display: flex; flex-direction: column; gap: 10px; }
.list-tools .tabs { margin-bottom: 0; width: 100%; }
.list-tools .tab { flex: 1; justify-content: center; padding: 6px 8px; font-size: 13px; }
.search-field { position: relative; display: block; }
.search-field > .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 17px; height: 17px; pointer-events: none; }
.search-field .input { padding-left: 36px; }
.list-count { margin: 10px 2px 6px; }
.cust-list { list-style: none; margin: 0 -6px; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.cust-item { display: flex; align-items: center; gap: 11px; padding: 9px 8px; border-radius: 10px; text-decoration: none; color: var(--ink); margin: 0 4px; }
.cust-item:hover { background: var(--sand-100); color: var(--ink); }
.cust-item[aria-current="true"] { background: var(--forest-100); box-shadow: inset 3px 0 0 var(--forest-700); }
.ci-main { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.ci-main strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-main .muted { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: none; font-variant-numeric: tabular-nums; }
.list-empty .empty { padding: 20px 8px; }
.detail-panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.detail-empty { min-height: 320px; display: grid; place-items: center; }
.cust-head { display: flex; flex-direction: column; gap: 16px; }
.cust-id { display: flex; align-items: center; gap: 14px; }
.cust-name { font-family: var(--serif); font-size: 26px; font-weight: 600; color: var(--forest-900); line-height: 1.15; }
.cust-id .muted { font-size: 14px; margin-top: 3px; }
.cust-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mini-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.mini-stats > div { background: var(--sand-100); border-radius: 11px; padding: 11px 13px; display: flex; flex-direction: column; }
.mini-stats span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.mini-stats strong { font-size: 19px; font-weight: 800; color: var(--forest-900); font-variant-numeric: tabular-nums; }
.mini-stats strong.down { color: var(--red); }
.detail-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.sub-h { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 6px 0 2px; }
.pad { padding: 6px 0; }
.prop-card .props > div { grid-template-columns: 130px minmax(0, 1fr); }

/* ---------- Invoice document ---------- */
.invoice-doc {
  position: relative; max-width: 860px; margin: 0 auto; background: #fff; border: 1px solid var(--line);
  border-radius: 6px; box-shadow: var(--shadow); padding: 44px 48px; overflow: hidden;
}
.inv-head { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-bottom: 24px; border-bottom: 3px solid var(--forest-800); }
.inv-brand { display: flex; gap: 14px; align-items: flex-start; }
.inv-brand .logo-mark { width: 48px; height: 48px; }
.inv-brand > div { display: flex; flex-direction: column; font-size: 13.5px; color: var(--ink-2); line-height: 1.45; }
.inv-co { font-family: var(--serif); font-size: 22px; color: var(--forest-900); font-weight: 600; margin-bottom: 2px; }
.inv-title { font-family: var(--serif); font-size: 30px; font-weight: 600; color: var(--forest-900); text-align: right; text-transform: uppercase; letter-spacing: .08em; }
.inv-meta dl { margin: 6px 0 0; display: grid; gap: 2px; }
.inv-meta dl > div { display: flex; justify-content: flex-end; gap: 14px; font-size: 14px; }
.inv-meta dt { color: var(--muted); }
.inv-meta dd { margin: 0; font-weight: 600; min-width: 96px; text-align: right; }
.stamp { position: absolute; right: 48px; top: 160px; transform: rotate(-8deg); font-weight: 800; font-size: 26px; letter-spacing: .14em; text-transform: uppercase; border: 3px solid; border-radius: 10px; padding: 4px 14px; opacity: .85; }
.stamp-paid { color: var(--green); }
.stamp-overdue { color: var(--red); }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 24px 0; }
.inv-parties h2, .inv-payments h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.inv-parties p { font-size: 14.5px; line-height: 1.55; }
.inv-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.inv-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 8px; border-bottom: 2px solid var(--ink); }
.inv-table td { padding: 11px 8px; border-bottom: 1px solid var(--line); }
.inv-totals { display: flex; justify-content: flex-end; margin-top: 16px; }
.inv-totals dl { margin: 0; min-width: 290px; display: grid; gap: 6px; }
.inv-totals dl > div { display: flex; justify-content: space-between; gap: 20px; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.inv-totals dd { margin: 0; }
.inv-grand { border-top: 1px solid var(--line); padding-top: 8px; font-weight: 700; }
.inv-due { background: var(--forest-900); color: #fff; padding: 10px 12px; border-radius: 8px; font-weight: 700; font-size: 16px !important; margin-top: 4px; }
.inv-payments { margin-top: 24px; }
.inv-payments ul { list-style: none; margin: 0; padding: 0; }
.inv-payments li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.inv-foot { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--ink-2); display: grid; gap: 4px; }

/* ---------- Settings ---------- */
.settings { display: flex; flex-direction: column; gap: 16px; max-width: 920px; }
.crew-edit { display: grid; gap: 12px; }
.crew-row { display: grid; grid-template-columns: 14px 1fr 1fr; gap: 12px; align-items: end; }
.crew-row .dot { width: 14px; height: 14px; margin-bottom: 13px; }
.catalog td { padding: 8px 10px; }
.catalog td:first-child { min-width: 240px; }
.catalog td:nth-child(2) { width: 140px; }
.catalog td:nth-child(3) { width: 150px; }
.form-end { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.danger-zone { max-width: 920px; margin-top: 16px; border-color: #EBC9C3; }
.danger-zone .card-head { margin-bottom: 0; align-items: center; flex-wrap: wrap; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(13, 33, 23, .48); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  animation: fade .15s ease-out;
}
.modal {
  width: 100%; max-width: 560px; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); display: flex; flex-direction: column;
  background: var(--sand-50); border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--line);
  animation: pop .18s var(--ease);
}
.modal.sm { max-width: 440px; }
.modal.lg { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 12px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 18px; font-weight: 700; color: var(--forest-900); }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-desc { color: var(--muted); margin-bottom: 14px; font-size: 14.5px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--sand-100); border-radius: 0 0 16px 16px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* Command palette */
.modal-backdrop:has(.modal-palette) { align-items: flex-start; padding-top: 12vh; }
.modal.modal-palette { max-width: 620px; }
.modal-palette .modal-head { padding: 10px 12px 8px 18px; border-bottom: 0; }
.modal-palette .modal-head h2 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.modal-palette .modal-body { padding: 0; display: flex; flex-direction: column; min-height: 0; }
.palette { display: flex; flex-direction: column; min-height: 0; }
.pal-input { position: relative; padding: 0 14px 12px; border-bottom: 1px solid var(--line); }
.pal-input .ico { position: absolute; left: 28px; top: 13px; color: var(--muted); }
.pal-input .input { padding-left: 42px; min-height: 46px; font-size: 16.5px; }
.pal-list { list-style: none; margin: 0; padding: 6px 8px; max-height: 52vh; overflow-y: auto; }
.pal-group { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 10px 10px 4px; }
.pal-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.pal-item[aria-selected="true"] { background: var(--forest-100); box-shadow: inset 3px 0 0 var(--forest-700); }
.pal-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--sand-100); color: var(--forest-700); flex: none; }
.pal-ico .ico { width: 16px; height: 16px; }
.pal-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; flex: 1; }
.pal-text strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-text span { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-enter { color: var(--muted); opacity: 0; }
.pal-item[aria-selected="true"] .pal-enter { opacity: 1; }
.pal-empty { padding: 24px 14px; color: var(--muted); text-align: center; }
.pal-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); background: var(--sand-100); border-radius: 0 0 16px 16px; flex-wrap: wrap; }
.pal-foot kbd { margin-right: 3px; }

/* ---------- Popover menu ---------- */
.menu {
  position: fixed; z-index: 150; min-width: 220px; max-width: calc(100vw - 16px); padding: 6px;
  background: var(--sand-50); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-lg);
  animation: pop .12s var(--ease);
}
.menu-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; background: none; border-radius: 8px; text-align: left; font-size: 14px; font-weight: 500; min-height: 40px; color: var(--ink); }
.menu-item:hover, .menu-item:focus { background: var(--forest-100); outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--forest-700); }
.menu-item .ico { width: 16px; height: 16px; color: var(--forest-600); }
.menu-item.danger { color: var(--red); }
.menu-item[disabled] { opacity: .5; cursor: not-allowed; }
.menu-item > span:not(.swatch):not(.menu-check) { flex: 1; }
.menu-check { color: var(--forest-700); display: inline-flex; }
.swatch { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-heading { font-size: 12px; font-weight: 700; color: var(--muted); padding: 6px 10px 2px; }

/* ---------- Toasts ---------- */
.toast-region { position: fixed; z-index: 250; top: 72px; right: 16px; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 11px 10px 11px 14px;
  background: var(--forest-950); color: #EEF6EC; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px;
  animation: slide .2s var(--ease); border: 1px solid rgba(181, 227, 84, .18);
}
.toast.leaving { opacity: 0; transform: translateX(10px); transition: opacity .18s, transform .18s; }
.toast-ico { display: inline-flex; color: var(--lime-400); }
.toast-info .toast-ico { color: #F2C46B; }
.toast-demo { background: #22303F; border-color: rgba(160, 196, 255, .25); }
.toast-demo .toast-ico { color: #A9C8FF; }
.toast-msg { flex: 1; min-width: 0; }
.toast-action { flex: none; background: var(--lime-400); color: var(--forest-950); border: 0; border-radius: 8px; padding: 6px 10px; font-weight: 700; font-size: 13px; white-space: nowrap; }
.toast-action:hover { background: #C8EF74; }
.toast-close { flex: none; background: none; border: 0; color: #B8CDBE; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.toast-close:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.toast :focus-visible { outline-color: var(--lime-400); box-shadow: none; }
@keyframes slide { from { opacity: 0; transform: translateY(-6px); } }

.noscript { padding: 24px; text-align: center; }

/* ======================================================================
   Responsive
   ====================================================================== */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .dash-grid, .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .builder { grid-template-columns: minmax(0, 1fr) 290px; }
  .split { grid-template-columns: 310px minmax(0, 1fr); }
  .detail-cols { grid-template-columns: minmax(0, 1fr); }
  .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 899px) {
  :root { --sidebar-w: 280px; }
  html { scroll-padding-top: 70px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); max-width: 86vw; height: auto;
    transform: translateX(-100%); visibility: hidden; z-index: 90; padding-bottom: 110px;
    transition: transform .22s var(--ease), visibility 0s linear .22s; box-shadow: var(--shadow-lg);
  }
  .drawer-open .sidebar { transform: none; visibility: visible; transition: transform .22s var(--ease), visibility 0s; }
  .scrim { position: fixed; inset: 0; z-index: 80; background: rgba(13, 33, 23, .45); }
  .scrim[hidden] { display: none; }
  .topbar { padding: 10px 16px; gap: 8px; }
  .menu-btn { display: inline-grid; width: 42px; height: 42px; border: 1px solid var(--line-strong); background: var(--sand-50); }
  .topbar-brand { display: inline-flex; }
  .topbar-brand .brand-name { color: var(--forest-900); font-size: 19px; }
  .search-trigger { min-height: 42px; }
  .search-trigger .search-label, .search-trigger kbd { display: none; }
  .search-trigger { flex: none; margin-left: auto; width: 42px; padding: 0; justify-content: center; }
  .new-btn { margin-left: 0; min-height: 42px; padding: 8px 12px; }
  .view { padding: 20px 16px 120px; }
  .toast-region { top: 68px; right: 12px; left: 12px; width: auto; }

  .stat-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .stat { flex-direction: row; justify-content: space-between; align-items: center; }
  .stat strong { font-size: 19px; }

  /* Dispatch: stacked columns on phones/tablets */
  .board { grid-template-columns: minmax(0, 1fr); overflow: visible; }
  .crew-jump { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -16px 4px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
  .crew-jump::-webkit-scrollbar { display: none; }
  .chip { display: inline-flex; align-items: center; gap: 7px; flex: none; border: 1px solid var(--line-strong); background: var(--sand-50); border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 13.5px; min-height: 38px; }
  .chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--crew); }
  .chip b { font-size: 12px; background: var(--sand-100); padding: 0 7px; border-radius: 999px; }
  .col-body { min-height: 80px; }
  .drag-handle { width: 36px; height: 36px; margin: -6px 0 -6px -6px; }

  .builder { grid-template-columns: minmax(0, 1fr); }
  .builder-side { position: static; }

  .split { grid-template-columns: minmax(0, 1fr); }
  .list-panel { position: static; max-height: none; }
  .cust-list { overflow: visible; }
  .split.has-detail .list-panel { display: none; }
  .page-head.hide-mobile .head-actions, .page-head.hide-mobile .sub, .page-head.hide-mobile .eyebrow { display: none; }
  .page-head.hide-mobile { margin-bottom: 4px; }
  .sr-only-mobile { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .show-mobile { display: inline-flex; }

  .cal-card, .cal-legend { display: none; }
  .agenda { display: flex; flex-direction: column; gap: 12px; }
  .agenda-day { background: var(--sand-50); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm); }
  .agenda-day.is-today { border-color: var(--lime-500); box-shadow: 0 0 0 2px var(--lime-200); }
  .agenda-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
  .agenda-head h2 { font-size: 15.5px; font-weight: 700; color: var(--forest-900); }
  .agenda .cal-chip { font-size: 13.5px; padding: 8px 10px; }
  .agenda .cal-time { font-size: 12.5px; }
  .agenda .cal-svc { font-size: 12.5px; white-space: normal; }
  .agenda-empty { font-size: 13.5px; }

  .modal-backdrop { align-items: flex-start; padding: 16px 12px 110px; }
  .modal { max-height: calc(100vh - 130px); max-height: calc(100dvh - 130px); }
  .modal-backdrop:has(.modal-palette) { padding-top: 16px; }
}

@media (max-width: 640px) {
  body { font-size: 15px; }
  .kpis { gap: 10px; }
  .kpi { padding: 14px 14px 12px; }
  .kpi-value { font-size: 24px; }
  .kpi-ico { width: 32px; height: 32px; right: 12px; top: 14px; }
  .kpi-ico .ico { width: 16px; height: 16px; }
  .kpi-sub { font-size: 12.5px; }
  .card { padding: 16px; }
  .page-head { margin-bottom: 16px; align-items: flex-start; }
  .page-head .head-actions { width: 100%; }
  .page-head .head-actions > .btn:only-child { flex: 1; }
  .date-switch { display: grid !important; grid-template-columns: auto 1fr auto; }
  .date-switch .date-pick { grid-column: 1 / -1; }
  .date-switch .input { width: 100%; }
  .h1-sub { width: 100%; }
  .new-label { display: none; }
  .new-btn { width: 42px; padding: 0; }
  .demo-banner { font-size: 12.5px; padding: 6px 8px 6px 12px; gap: 8px; }
  .banner-ico { display: none; }
  .banner-link { display: none; }

  .route-item { grid-template-columns: 62px 12px minmax(0, 1fr); }
  .route-item .badge { grid-column: 3; justify-self: start; margin-top: -2px; }
  .mini-list li { flex-wrap: wrap; }
  .mini-right { width: 100%; justify-content: space-between; }
  .feed-item { grid-template-columns: 30px minmax(0, 1fr); }
  .feed-time { grid-column: 2; padding-top: 0; }
  .feed-ico { width: 30px; height: 30px; }

  .tabs { width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; }
  .list-tools .tab { flex: 1 0 auto; }

  /* Responsive tables become stacked cards */
  .table.responsive thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .table.responsive tbody tr:last-child { border-bottom: 0; }
  .table.responsive td { border: 0; padding: 4px 0 !important; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; min-height: 30px; }
  .table.responsive td::before { content: attr(data-label); font-size: 12.5px; font-weight: 600; color: var(--muted); text-align: left; flex: none; }
  .table.responsive td.act { justify-content: flex-end; padding-top: 8px !important; }
  .table.responsive td.act::before { content: none; }
  .table.responsive .clip { max-width: none; white-space: normal; }
  .table.responsive tfoot { display: block; }
  .table.responsive tfoot tr { display: flex; justify-content: space-between; padding: 10px 14px; }
  .table.responsive tfoot th, .table.responsive tfoot td { padding: 0; border: 0; }
  .table tbody tr:hover td { background: transparent; }
  .lines td:first-child, .lines td:nth-child(n) { width: 100%; min-width: 0; }
  .lines td[data-label="Service"] { flex-direction: column; align-items: stretch; text-align: left; }
  .lines td[data-label="Service"]::before { margin-bottom: 2px; }
  .lines .input.num, .lines .input-prefix { max-width: 150px; }
  .lines tr { background: var(--sand-100); border-radius: 10px; margin-bottom: 8px; border: 0 !important; }
  .line-editor .table-wrap { overflow: visible; }
  .catalog td:first-child, .catalog td:nth-child(n) { width: 100%; min-width: 0; }
  .catalog .input, .catalog .input-prefix { max-width: 220px; }

  .form-grid.cols-2, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .crew-row { grid-template-columns: 14px minmax(0, 1fr); }
  .crew-row .field:last-child { grid-column: 2; }
  .props > div, .prop-card .props > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .mini-stats strong { font-size: 17px; }
  .cust-name { font-size: 22px; }
  .cust-id { align-items: flex-start; }
  .avatar.lg { width: 46px; height: 46px; font-size: 16px; }

  .status-track { grid-template-columns: repeat(2, 1fr); padding: 12px; }
  .status-track li { font-size: 13px; }

  .invoice-doc { padding: 22px 18px; }
  .inv-title { text-align: left; }
  .inv-meta dl > div { justify-content: flex-start; }
  .inv-meta dd { text-align: left; }
  .inv-parties { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .inv-table { font-size: 13.5px; }
  .inv-table th, .inv-table td { padding: 8px 4px; }
  .inv-totals dl { min-width: 0; width: 100%; }
  .stamp { top: 22px; right: 16px; font-size: 18px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ---------- Print (invoice) ---------- */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; font-size: 12pt; }
  .demo-banner, .sidebar, .topbar, .toast-region, .no-print, .skip-link, .scrim, .modal-backdrop, .menu { display: none !important; }
  .shell { display: block; }
  .view { padding: 0; max-width: none; }
  .invoice-doc { box-shadow: none; border: 0; padding: 0; max-width: none; border-radius: 0; }
  .inv-due { background: #fff !important; color: #000 !important; border: 2px solid #000; }
  .stamp { opacity: .7; }
  a { color: inherit; text-decoration: none; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
