:root {
  --brand: #0f766e;
  --brand-600: #0d5f59;
  --brand-100: #d7f0ec;
  --brand-50: #eef8f6;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f4f6f8;
  --card: #ffffff;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --info: #1d4ed8;
  --info-bg: #dbeafe;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .06);
  --nav-h: 64px;
  --header-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  font-size: 15px; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 600; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
svg.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- App shell ---------- */
#app { min-height: 100%; }
.shell { display: grid; grid-template-rows: var(--header-h) 1fr; min-height: 100vh; min-height: 100dvh; }
.topbar {
  height: var(--header-h); background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 0 14px; position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; font-size: 17px; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), #14b8a6); display: grid; place-items: center; color: #fff; }
.brand-mark svg { width: 18px; height: 18px; }
.topbar .spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.2; white-space: nowrap; }
.pill svg { width: 14px; height: 14px; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.neutral { background: #e2e8f0; color: var(--ink-2); }
.pill.brand { background: var(--brand-100); color: var(--brand-600); }
.persona-btn { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); }
.persona-btn:hover { background: var(--bg); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr); }
.main { min-width: 0; }
.sidenav { display: none; }
.main { padding: 16px 14px calc(var(--nav-h) + var(--safe-b) + 16px); max-width: 1400px; width: 100%; margin: 0 auto; }
.main.full { max-width: none; padding: 0 0 calc(var(--nav-h) + var(--safe-b)); }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--card); border-top: 1px solid var(--line); display: flex; z-index: 30;
}
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); position: relative; }
.bottomnav a.active { color: var(--brand); }
.bottomnav a svg { width: 22px; height: 22px; }
.navbadge { position: absolute; top: 6px; left: calc(50% + 6px); background: var(--bad); color: #fff; font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px; display: grid; place-items: center; padding: 0 4px; }

@media (min-width: 900px) {
  .layout { grid-template-columns: 224px minmax(0, 1fr); }
  .sidenav { display: flex; flex-direction: column; gap: 4px; padding: 14px 10px; border-right: 1px solid var(--line); background: var(--card); position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); height: calc(100dvh - var(--header-h)); }
  .sidenav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 600; font-size: 14px; position: relative; }
  .sidenav a:hover { background: var(--bg); }
  .sidenav a.active { background: var(--brand-50); color: var(--brand-600); }
  .sidenav .navbadge { position: static; margin-left: auto; }
  .sidenav .foot { margin-top: auto; padding: 10px 12px; font-size: 12px; color: var(--muted); }
  .bottomnav { display: none; }
  .main { padding: 22px 24px 32px; }
  .main.full { padding: 0; }
}

/* ---------- Components ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.card.pad0 { padding: 0; }
.card.click { cursor: pointer; transition: transform .08s, box-shadow .08s; }
.card.click:active { transform: scale(.995); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 10px; }
.section-title h2 { font-size: 16px; }
.grid { display: grid; gap: 12px; }
.grid.tiles { grid-template-columns: repeat(2, 1fr); }
.grid.cards { grid-template-columns: 1fr; }
@media (min-width: 700px) { .grid.tiles { grid-template-columns: repeat(3, 1fr); } .grid.cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .grid.tiles { grid-template-columns: repeat(6, 1fr); } .grid.cards { grid-template-columns: repeat(3, 1fr); } }
.tile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.tile .n { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.tile .l { font-size: 12px; color: var(--muted); font-weight: 600; }
.tile.warn .n { color: var(--warn); } .tile.bad .n { color: var(--bad); } .tile.ok .n { color: var(--ok); } .tile.info .n { color: var(--info); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 11px; font-weight: 600; font-size: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); min-height: 42px; white-space: nowrap; }
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-600); }
.btn.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg); }
.btn.sm { padding: 6px 10px; min-height: 32px; font-size: 13px; border-radius: 9px; }
.btn.lg { padding: 14px 20px; min-height: 54px; font-size: 16px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn.icon { padding: 8px; min-height: 36px; min-width: 36px; }
.btn svg { width: 18px; height: 18px; }

.input, select.input, textarea.input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); min-height: 42px; }
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { outline: 2px solid var(--brand-100); border-color: var(--brand); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex: none; letter-spacing: .02em; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: #fff; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.scheduled { background: #94a3b8; } .dot.in_progress { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.25); } .dot.done { background: var(--ok); }

.tabs { display: flex; gap: 4px; background: #e9eef3; padding: 4px; border-radius: 12px; }
.tabs button { flex: 1; padding: 8px 10px; border-radius: 9px; font-weight: 600; font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tabs button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.tabs .navbadge { position: static; }

.list { display: flex; flex-direction: column; }
.list > .item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > .item:last-child { border-bottom: 0; }
.list > .item.click { cursor: pointer; }
.list > .item.click:hover { background: var(--bg); margin: 0 -14px; padding-left: 14px; padding-right: 14px; }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; font-size: 14px; }
.empty svg { width: 36px; height: 36px; opacity: .4; margin-bottom: 8px; }

.alert { border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; }
.alert svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert.warn { background: var(--warn-bg); color: #78350f; }
.alert.bad { background: var(--bad-bg); color: #7f1d1d; }
.alert.info { background: var(--info-bg); color: #1e3a8a; }
.alert.ok { background: var(--ok-bg); color: #14532d; }
.alert .actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- Sheet / modal ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 100; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--card); width: 100%; max-height: 92vh; max-height: 92dvh; border-radius: 20px 20px 0 0; display: flex; flex-direction: column; animation: up .2s; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { flex: 1; font-size: 17px; }
.sheet-body { overflow: auto; padding: 14px 16px calc(16px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 10px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); display: flex; gap: 10px; }
.sheet-foot .btn { flex: 1; }
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; padding: 20px; }
  .sheet { max-width: 640px; border-radius: 18px; max-height: 88vh; }
  .sheet.wide { max-width: 860px; }
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes up { from { transform: translateY(30px); opacity: 0 } to { transform: none; opacity: 1 } }

.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b) + 12px); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 200; pointer-events: none; }
@media (min-width: 900px) { .toast-wrap { bottom: 24px; } }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow); animation: up .2s; max-width: 92vw; display: flex; gap: 8px; align-items: center; }
.toast.ok { background: var(--ok); } .toast.warn { background: var(--warn); } .toast.bad { background: var(--bad); }
.toast svg { width: 16px; height: 16px; }

/* ---------- Job cards (board) ---------- */
.jobcard { background: var(--card); border-radius: 10px; border: 1px solid var(--line); border-left: 4px solid var(--type, var(--brand)); padding: 8px 10px; margin-bottom: 6px; cursor: grab; box-shadow: 0 1px 2px rgba(15,23,42,.05); user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.jobcard:active { cursor: grabbing; }
.jobcard .t { font-weight: 700; font-size: 13px; line-height: 1.25; }
.jobcard .s { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 3px; }
.jobcard .meta { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-size: 11px; color: var(--muted); }
.jobcard .meta svg { width: 13px; height: 13px; }
.jobcard.done { opacity: .72; }
.jobcard.done .t { text-decoration: none; }
.jobcard.needs-cover { border-color: var(--bad); background: #fff7f7; }
.sortable-ghost { opacity: .35; }
.sortable-chosen { box-shadow: 0 8px 22px rgba(15,23,42,.18); }
.sortable-drag { opacity: .95; }

.board-wrap { overflow: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.board { display: grid; grid-template-columns: 170px repeat(7, minmax(168px, 1fr)); min-width: 1300px; }
.board .hd { position: sticky; top: 0; z-index: 3; background: var(--card); border-bottom: 1px solid var(--line); padding: 10px; font-size: 13px; font-weight: 700; }
.board .hd.today { color: var(--brand); }
.board .hd .cnt { font-weight: 500; color: var(--muted); font-size: 12px; }
.board .rh { position: sticky; left: 0; z-index: 2; background: var(--card); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px; display: flex; align-items: center; gap: 8px; }
.board .rh.corner { z-index: 4; top: 0; }
.board .rh .nm { font-weight: 700; font-size: 13px; line-height: 1.2; }
.board .rh .hrs { font-size: 11px; color: var(--muted); }
.board .cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; min-height: 64px; background: var(--bg); position: relative; }
.board .cell.today { background: #f0faf8; }
.board .cell.off { background: repeating-linear-gradient(135deg, #f1f5f9 0 8px, #e9edf2 8px 16px); }
.board .cell.off::before { content: attr(data-off); position: absolute; top: 6px; right: 8px; font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.board .cell.over { color: var(--bad); }
.board .cell .cap { font-size: 10px; color: var(--muted); text-align: right; padding: 2px 2px 0; }
.board .cell .cap.over { color: var(--bad); font-weight: 700; }
.board .cell .drop { min-height: 40px; }
.board .row-unassigned .rh, .board .row-unassigned .cell { background: #fffbeb; }
.board .row-unassigned .cell { border-bottom: 2px solid #fcd34d; }
.board .row-unassigned .rh { border-bottom: 2px solid #fcd34d; }

.dayview .daycol { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; margin-bottom: 12px; }
.dayview .daycol .drop { min-height: 48px; border-radius: 10px; }
.dayview .daycol.off { background: repeating-linear-gradient(135deg, #f8fafc 0 8px, #f1f5f9 8px 16px); }
.dayview .daycol.unassigned { background: #fffbeb; border: 1px dashed #fcd34d; }
.daychips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.daychips::-webkit-scrollbar { display: none; }
.daychips button { flex: none; padding: 8px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); font-size: 13px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 62px; }
.daychips button .d { font-size: 11px; color: var(--muted); font-weight: 600; }
.daychips button .n { font-size: 15px; }
.daychips button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.daychips button.active .d { color: rgba(255,255,255,.8); }
.daychips button.today:not(.active) { border-color: var(--brand); color: var(--brand); }

/* ---------- Cleaner today ---------- */
.hero { background: linear-gradient(135deg, var(--brand), #0e9488); color: #fff; border-radius: 18px; padding: 18px; box-shadow: var(--shadow); }
.hero h1 { color: #fff; }
.hero .muted { color: rgba(255,255,255,.8); }
.jobrow { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: flex; gap: 12px; align-items: flex-start; border-left: 5px solid var(--type, var(--brand)); }
.jobrow .time { font-weight: 800; font-size: 15px; min-width: 52px; line-height: 1.2; }
.jobrow .time .dur { font-size: 11px; color: var(--muted); font-weight: 600; }
.jobrow.done { opacity: .75; }
.jobrow.active { border-left-color: #f59e0b; box-shadow: 0 0 0 2px #fde68a, var(--shadow); }
.progress { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 4px; transition: width .2s; }
.checklist { display: flex; flex-direction: column; }
.checklist label { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 15px; }
.checklist label:last-child { border-bottom: 0; }
.checklist input { width: 22px; height: 22px; accent-color: var(--brand); flex: none; }
.checklist label.checked { color: var(--muted); text-decoration: line-through; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photos .ph { aspect-ratio: 4/3; border-radius: 10px; overflow: hidden; background: #e2e8f0; position: relative; }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .ph .cap { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.45); color: #fff; font-size: 11px; padding: 3px 6px; }
.photos .add { aspect-ratio: 4/3; border-radius: 10px; border: 2px dashed var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 600; background: var(--bg); }
.photos .add svg { width: 22px; height: 22px; }

/* NFC sheet */
.nfc-anim { position: relative; width: 160px; height: 160px; margin: 10px auto; display: grid; place-items: center; }
.nfc-anim .ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--brand); opacity: 0; animation: ring 2s infinite; }
.nfc-anim .ring:nth-child(2) { animation-delay: .6s; } .nfc-anim .ring:nth-child(3) { animation-delay: 1.2s; }
.nfc-anim .core { width: 76px; height: 76px; border-radius: 50%; background: var(--brand-100); color: var(--brand); display: grid; place-items: center; }
.nfc-anim .core svg { width: 36px; height: 36px; }
@keyframes ring { 0% { transform: scale(.5); opacity: .7 } 100% { transform: scale(1.1); opacity: 0 } }
.nfc-success { width: 96px; height: 96px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; margin: 16px auto; animation: pop .3s; }
.nfc-success svg { width: 48px; height: 48px; stroke-width: 3; }
@keyframes pop { from { transform: scale(.5); opacity: 0 } to { transform: none; opacity: 1 } }

/* ---------- Map ---------- */
.mapwrap { position: relative; height: calc(100vh - var(--header-h) - var(--nav-h) - var(--safe-b)); height: calc(100dvh - var(--header-h) - var(--nav-h) - var(--safe-b)); display: grid; grid-template-rows: 1fr auto; }
@media (min-width: 900px) { .mapwrap { height: calc(100vh - var(--header-h)); height: calc(100dvh - var(--header-h)); grid-template-columns: 1fr 340px; grid-template-rows: 1fr; } }
#map { width: 100%; height: 100%; min-height: 240px; background: #dbe7ee; }
.mappanel { background: var(--card); border-top: 1px solid var(--line); max-height: 42vh; overflow: auto; display: flex; flex-direction: column; }
@media (min-width: 900px) { .mappanel { border-top: 0; border-left: 1px solid var(--line); max-height: none; } }
.mappanel .ctl { padding: 10px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 2; }
.mappanel .plist { padding: 6px 14px; }
.mappanel .plist .item { padding: 9px 0; }
.mappanel .plist .item.sel { background: var(--brand-50); margin: 0 -14px; padding: 9px 14px; }
input[type=range] { width: 100%; accent-color: var(--brand); }
.cl-marker { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 800; position: relative; }
.cl-marker.onsite::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid #f59e0b; animation: ring 1.6s infinite; }
.cl-marker.home { opacity: .55; }
.pr-marker { width: 12px; height: 12px; border-radius: 3px; background: #475569; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); transform: rotate(45deg); }
.pr-marker.active { background: var(--brand); width: 14px; height: 14px; }
.leaflet-popup-content { font-size: 13px; margin: 10px 12px; }
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline .ev { position: relative; padding: 4px 0 10px; font-size: 13px; }
.timeline .ev::before { content: ''; position: absolute; left: -17px; top: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.timeline .ev.out::before { background: var(--ok); }
.timeline .ev.future::before { background: #cbd5e1; }

/* ---------- Messages ---------- */
.msgs { display: grid; grid-template-columns: 1fr; height: calc(100vh - var(--header-h) - var(--nav-h) - var(--safe-b)); height: calc(100dvh - var(--header-h) - var(--nav-h) - var(--safe-b)); }
@media (min-width: 900px) { .msgs { grid-template-columns: 300px 1fr; height: calc(100vh - var(--header-h)); height: calc(100dvh - var(--header-h)); } }
.threads { overflow: auto; border-right: 1px solid var(--line); background: var(--card); }
.threads .th { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.threads .th:hover, .threads .th.sel { background: var(--brand-50); }
.threads .th .nm { font-weight: 700; font-size: 14px; }
.threads .th .pv { font-size: 12px; color: var(--muted); }
.threads .th.unread .nm { color: var(--ink); }
.threads .th.unread .pv { color: var(--ink); font-weight: 600; }
.convo { display: flex; flex-direction: column; background: #eef2f5; min-height: 0; }
.convo .chead { padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.convo .cbody { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 78%; padding: 9px 12px; border-radius: 16px; background: var(--card); font-size: 14px; line-height: 1.35; box-shadow: 0 1px 1px rgba(15,23,42,.06); align-self: flex-start; }
.bubble.me { background: var(--brand); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.them { border-bottom-left-radius: 4px; }
.bubble .who { font-size: 11px; font-weight: 700; margin-bottom: 2px; color: var(--brand-600); }
.bubble .when { font-size: 10px; opacity: .7; margin-top: 3px; text-align: right; }
.daysep { align-self: center; font-size: 11px; color: var(--muted); font-weight: 600; margin: 6px 0; }
.composer { padding: 10px 12px calc(10px + var(--safe-b)); background: var(--card); border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; min-height: 42px; max-height: 120px; }
.quick { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px 0; background: var(--card); scrollbar-width: none; }
.quick button { flex: none; font-size: 12px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); font-weight: 600; }
@media (max-width: 899px) { .msgs.in-thread .threads { display: none; } .msgs:not(.in-thread) .convo { display: none; } }

/* ---------- Reports ---------- */
.bars { display: flex; flex-direction: column; gap: 6px; }
.bars .b { display: grid; grid-template-columns: 120px 1fr 48px; align-items: center; gap: 10px; font-size: 13px; }
.bars .b .bar { height: 14px; background: var(--brand-100); border-radius: 7px; overflow: hidden; }
.bars .b .bar > i { display: block; height: 100%; background: var(--brand); border-radius: 7px; }
.bars .b .v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tblwrap { overflow-x: auto; }

/* ---------- Absence calendar ---------- */
.abscal { display: grid; font-size: 11px; min-width: 900px; }
.abscal .c { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); height: 30px; display: grid; place-items: center; }
.abscal .c.name { position: sticky; left: 0; background: var(--card); justify-items: start; padding-left: 8px; font-weight: 600; font-size: 12px; z-index: 1; }
.abscal .c.hd { font-weight: 700; color: var(--muted); background: var(--card); position: sticky; top: 0; }
.abscal .c.hd.wkend { background: #f1f5f9; }
.abscal .c.hd.today { color: var(--brand); }
.abscal .c.holiday { background: #bfdbfe; } .abscal .c.sick { background: #fecaca; } .abscal .c.pending { background: repeating-linear-gradient(45deg, #bfdbfe 0 4px, #fff 4px 8px); } .abscal .c.dayoff { background: #f1f5f9; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 20% -10%, #d7f0ec, transparent), radial-gradient(900px 500px at 110% 110%, #dbeafe, transparent), var(--bg); }
.login .box { width: 100%; max-width: 440px; }
.login .choice { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); cursor: pointer; width: 100%; text-align: left; }
.login .choice:hover { border-color: var(--brand); background: var(--brand-50); }
.login .choice svg.icon.arrow { margin-left: auto; color: var(--muted); }
.offline-banner { background: var(--warn-bg); color: #78350f; font-size: 13px; font-weight: 600; padding: 8px 14px; text-align: center; }
