:root {
  --bg: #f6f5f0; --panel: #ffffff; --panel-2: #fbfaf6; --ink: #1d2a30; --ink-2: #4a5a62; --muted: #7b8a91; --line: #e3e0d6; --line-2: #eeebe3;
  --brand: #0f4c5c; --brand-2: #16697a; --brand-ink: #ffffff; --accent: #e9c46a; --accent-ink: #3d2f00;
  --ok: #2a9d8f; --ok-bg: #e3f4f1; --warn: #c27c0e; --warn-bg: #fdf1dc; --bad: #c0392b; --bad-bg: #fbe6e3; --info: #2f6db5; --info-bg: #e5eef9; --gray-bg: #eeede8;
  --radius: 10px; --shadow: 0 1px 2px rgba(20, 30, 35, .06), 0 4px 14px rgba(20, 30, 35, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11181b; --panel: #182226; --panel-2: #1c272c; --ink: #e6ecee; --ink-2: #b4c1c6; --muted: #8597a0; --line: #2a383e; --line-2: #233035;
    --brand: #4fb3bf; --brand-2: #6cc4cf; --brand-ink: #0b1a1e; --accent: #e9c46a; --accent-ink: #2a2000;
    --ok-bg: #173430; --warn-bg: #3a2c12; --bad-bg: #3d1d1a; --info-bg: #182c45; --gray-bg: #243035; --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 14px 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: var(--mono); font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.grow { flex: 1; } .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .col { display: flex; flex-direction: column; gap: 10px; }
.hidden { display: none !important; }

/* layout */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--brand); color: #e8f1f2; padding: 14px 10px 30px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
@media (prefers-color-scheme: dark) { .side { background: #0d1417; border-right: 1px solid var(--line); } }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-weight: 700; font-size: 16px; color: #fff; }
.brand img { width: 30px; height: 30px; border-radius: 7px; object-fit: contain; background: #fff2; }
.nav-group { margin-top: 12px; }
.nav-group > .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .55; padding: 4px 10px; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 7px; color: #dce9eb; font-size: 13.5px; }
.nav a:hover { background: #ffffff14; text-decoration: none; }
.nav a.active { background: #ffffff24; color: #fff; font-weight: 600; }
.nav .badge { margin-left: auto; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 10px; padding: 10px 22px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top .menu-btn { display: none; }
.content { padding: 20px 22px 60px; max-width: 1500px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; z-index: 50; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px #0006; }
  .top .menu-btn { display: inline-flex; }
  .content { padding: 14px 12px 60px; }
}

/* components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 14px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; }
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } }
.stat { padding: 14px 16px; }
.stat .v { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.stat.link { cursor: pointer; } .stat.link:hover { border-color: var(--brand-2); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--brand-2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.danger.solid { background: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.lg { padding: 12px 20px; font-size: 16px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-group { display: inline-flex; } .btn-group .btn { border-radius: 0; } .btn-group .btn:first-child { border-radius: 8px 0 0 8px; } .btn-group .btn:last-child { border-radius: 0 8px 8px 0; } .btn-group .btn + .btn { margin-left: -1px; }
.btn-group .btn.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); position: relative; }

input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand-2) 35%, transparent); border-color: var(--brand-2); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--brand); }
input[type=color] { padding: 2px; height: 34px; width: 60px; }
textarea { min-height: 80px; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
label.f.check { flex-direction: row; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink); }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
.ro { padding: 7px 0; color: var(--ink); min-height: 34px; }
.req::after { content: ' *'; color: var(--bad); }
.search { max-width: 280px; }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); position: sticky; top: 0; cursor: default; }
table.t th.sortable { cursor: pointer; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--panel-2); }
table.t tfoot td { font-weight: 600; background: var(--panel-2); }
.table-wrap { overflow-x: auto; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 12px; color: var(--muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--gray-bg); color: var(--ink-2); white-space: nowrap; }
.badge.ok, .badge.completed, .badge.paid, .badge.approved, .badge.accepted, .badge.active, .badge.resolved, .badge.clear, .badge.won, .badge.online, .badge.hired, .badge.complete, .badge.verified { background: var(--ok-bg); color: var(--ok); }
.badge.warn, .badge.pending, .badge.partial, .badge.sent, .badge.en_route, .badge.in_progress, .badge.reviewing, .badge.interview, .badge.contacted, .badge.quoted, .badge.checked_out, .badge.running, .badge.on_leave { background: var(--warn-bg); color: var(--warn); }
.badge.bad, .badge.cancelled, .badge.overdue, .badge.denied, .badge.rejected, .badge.declined, .badge.no_access, .badge.void, .badge.open, .badge.flagged, .badge.lost, .badge.failed, .badge.terminated, .badge.expired, .badge.blocked { background: var(--bad-bg); color: var(--bad); }
.badge.info, .badge.scheduled, .badge.new, .badge.draft, .badge.lead, .badge.in_office, .badge.waiting { background: var(--info-bg); color: var(--info); }
.badge.n { background: var(--accent); color: var(--accent-ink); min-width: 18px; text-align: center; padding: 1px 6px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 18px 0 12px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 9px 12px; font: inherit; color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--brand-2); border-bottom-color: var(--brand-2); font-weight: 600; }

.empty { padding: 30px; text-align: center; color: var(--muted); }
.alert { padding: 10px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); margin: 8px 0; }
.alert.bad { background: var(--bad-bg); color: var(--bad); } .alert.ok { background: var(--ok-bg); color: var(--ok); } .alert.info { background: var(--info-bg); color: var(--info); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; background: var(--gray-bg); font-size: 12.5px; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0; font-size: 14px; line-height: 1; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

/* combobox */
.combo { position: relative; }
.combo .list { position: absolute; z-index: 60; left: 0; right: 0; top: 100%; margin-top: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; }
.combo .list div { padding: 7px 10px; cursor: pointer; } .combo .list div:hover, .combo .list div.hl { background: var(--panel-2); }
.combo .clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; }

/* modal & toast */
.modal-bg { position: fixed; inset: 0; background: #0b141880; display: flex; align-items: flex-start; justify-content: center; padding: 50px 14px; z-index: 100; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px #0005; }
.modal.wide { max-width: 860px; }
.modal-h { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 16px; display: flex; align-items: center; }
.modal-h .x { margin-left: auto; border: 0; background: none; font-size: 20px; color: var(--muted); cursor: pointer; }
.modal-b { padding: 16px 18px; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--ink); color: var(--panel); padding: 10px 14px; border-radius: 9px; box-shadow: var(--shadow); max-width: 380px; }
.toast.bad { background: var(--bad); color: #fff; } .toast.ok { background: var(--ok); color: #fff; }

/* calendar */
.cal-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.cal-week { display: grid; grid-template-columns: 56px repeat(7, minmax(110px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: auto; max-height: 76vh; }
.cal-day-view { display: grid; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: auto; max-height: 76vh; }
.cal-head { position: sticky; top: 0; z-index: 5; background: var(--panel-2); border-bottom: 1px solid var(--line); padding: 7px; font-weight: 600; font-size: 12.5px; text-align: center; }
.cal-head.today { color: var(--brand-2); }
.cal-col { position: relative; border-left: 1px solid var(--line-2); }
.cal-hours { position: relative; }
.cal-hour { height: 48px; border-bottom: 1px solid var(--line-2); font-size: 11px; color: var(--muted); padding: 2px 4px; }
.cal-slot { height: 48px; border-bottom: 1px solid var(--line-2); }
.cal-slot.drop { background: color-mix(in srgb, var(--brand-2) 15%, transparent); }
.cal-ev { position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 3px 6px; font-size: 11.5px; line-height: 1.25; overflow: hidden; cursor: pointer; background: var(--info-bg); border-left: 4px solid var(--info); color: var(--ink); box-shadow: 0 1px 2px #0002; }
.cal-ev.completed { opacity: .7; } .cal-ev.pending { outline: 2px dashed var(--warn); }
.cal-ev.unassigned { border-left-color: var(--bad) !important; }
.cal-ev b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.cal-month .cell { min-height: 110px; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); padding: 4px; font-size: 12px; }
.cal-month .cell.other { background: var(--panel-2); color: var(--muted); }
.cal-month .cell .d { font-weight: 600; margin-bottom: 3px; }
.cal-month .mev { padding: 2px 5px; border-radius: 4px; margin-bottom: 2px; background: var(--info-bg); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--info); }
.timeoff-band { font-size: 11px; background: var(--warn-bg); color: var(--warn); padding: 2px 5px; margin: 2px; border-radius: 4px; }

/* dispatch */
.lanes { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: auto; }
.lane-row { display: grid; grid-template-columns: 170px 1fr; border-bottom: 1px solid var(--line-2); min-height: 62px; }
.lane-name { padding: 8px 10px; border-right: 1px solid var(--line); font-size: 13px; background: var(--panel-2); }
.lane-track { position: relative; min-height: 62px; }
.lane-track.drop { background: color-mix(in srgb, var(--brand-2) 12%, transparent); }
.lane-ev { position: absolute; top: 6px; bottom: 6px; border-radius: 6px; padding: 3px 6px; font-size: 11.5px; overflow: hidden; cursor: grab; background: var(--info-bg); border-left: 4px solid var(--info); line-height: 1.25; }
.lane-scale { display: grid; grid-template-columns: 170px 1fr; position: sticky; top: 0; z-index: 3; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.lane-scale .ticks { position: relative; height: 26px; }
.lane-scale .tick { position: absolute; top: 5px; font-size: 11px; color: var(--muted); transform: translateX(-50%); }
.queue .qitem { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; cursor: grab; background: var(--panel); }
.queue .qitem:hover { border-color: var(--brand-2); }

/* map */
.map { width: 100%; height: 560px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--panel-2); position: relative; }
.map .notice { position: absolute; z-index: 5; left: 10px; top: 10px; right: 10px; }
.mk { width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2px solid #fff; box-shadow: 0 1px 4px #0006; display: flex; align-items: center; justify-content: center; }
.mk span { transform: rotate(45deg); color: #fff; font-size: 11px; font-weight: 700; }
.mk-site { width: 14px; height: 14px; border-radius: 3px; background: #fff; border: 3px solid var(--brand); box-shadow: 0 1px 3px #0005; }
.mk-emp { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 5px #0007; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 11px; }

/* employee & customer portals */
.portal-wrap { max-width: 900px; margin: 0 auto; }
.clock-card { text-align: center; padding: 24px 16px; }
.clock-card .big { font-size: 40px; font-weight: 800; letter-spacing: -.03em; }
.job-tile { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); margin-bottom: 8px; color: var(--ink); }
.job-tile:hover { border-color: var(--brand-2); text-decoration: none; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line-2); font-size: 15px; }
.check-row input { width: 22px; height: 22px; }
.check-row.done span { text-decoration: line-through; color: var(--muted); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.photos figure { margin: 0; } .photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.photos figcaption { font-size: 11px; color: var(--muted); }
.stars { display: inline-flex; gap: 2px; } .stars button { border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--line); padding: 0 2px; } .stars button.on { color: var(--accent); }
.sig { border: 1px dashed var(--muted); border-radius: 8px; background: #fff; touch-action: none; width: 100%; height: 160px; display: block; }
.thread { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; padding: 4px; }
.msg { max-width: 75%; padding: 8px 11px; border-radius: 11px; background: var(--gray-bg); white-space: pre-wrap; }
.msg.me { align-self: flex-end; background: var(--brand); color: var(--brand-ink); }
.msg .meta { font-size: 11px; opacity: .7; margin-bottom: 2px; }
.bar { height: 8px; border-radius: 4px; background: var(--gray-bg); overflow: hidden; } .bar > div { height: 100%; background: var(--brand-2); }
.chart { width: 100%; }
.perm-table td, .perm-table th { padding: 6px 10px; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, var(--brand), #08303a); }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { color: var(--ink); padding: 0 0 16px; justify-content: center; font-size: 20px; }
.login-card .brand img { background: none; }
pre.code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.qr { background: #fff; padding: 8px; border-radius: 8px; display: inline-block; }
.qr img, .qr svg { display: block; width: 240px; height: 240px; }
.files-path { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.drop-zone { border: 2px dashed var(--line); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); }
.drop-zone.over { border-color: var(--brand-2); background: var(--panel-2); }
@media print { .side, .top, .no-print { display: none !important; } .shell { display: block; } .content { padding: 0; } .card { box-shadow: none; } }
@media (max-width: 1000px) { .dispatch-grid, .content .grid[style*="380px"] { grid-template-columns: 1fr !important; } }
details.card > summary { list-style: none; } details.card > summary::-webkit-details-marker { display: none; }
details.card[open] > summary { margin-bottom: 6px; }
.grid > .card + .card, .grid > .card { margin-top: 0; }
