@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --navy: #0f2a44;
  --navy-2: #163a5c;
  --sidebar: #142f4b;
  --teal: #1a8a8f;
  --teal-2: #13777b;
  --teal-soft: #e6f4f4;
  --bg: #f3f5f8;
  --card: #ffffff;
  --line: #e3e8ee;
  --line-2: #d4dbe3;
  --text: #0f2740;
  --muted: #66778a;
  --green: #1b7a3d;
  --green-soft: #e4f5ea;
  --amber: #b46a00;
  --amber-soft: #fdf1df;
  --red: #c0392b;
  --red-soft: #fdeceb;
  --blue: #2f7fd6;
  --blue-soft: #eaf3fd;
  --violet-soft: #eeeafd;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 39, 64, 0.06), 0 1px 1px rgba(15, 39, 64, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 39, 64, 0.16);
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--teal-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 30px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.space { justify-content: space-between; }
.gap16 { gap: 16px; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; } .mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #16324f 0%, #10273f 100%);
  color: #dbe6f1; padding: 22px 12px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; color: #fff; }
.brand-name { font-weight: 800; font-size: 19px; line-height: 1.05; }
.brand-name .teal { color: #5fd0cf; }
.brand-tag { font-size: 10.5px; color: #8fb3cf; margin-top: 3px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: #d2deea;
  font-weight: 500; font-size: 15px; text-decoration: none; margin-bottom: 2px;
}
.nav a svg { width: 20px; height: 20px; opacity: 0.9; }
.nav a:hover { background: rgba(255, 255, 255, 0.06); }
.nav a.active { background: #234c74; color: #fff; font-weight: 700; }
.sidebar-foot { margin-top: auto; padding: 8px; }
.quote { font-style: italic; color: #a9c0d6; font-size: 13.5px; white-space: pre-line; line-height: 1.5; margin-bottom: 14px; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; color: #fff; cursor: pointer; }
.me:hover { background: rgba(255, 255, 255, 0.06); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 18px 28px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .title { display: flex; flex-direction: column; }
.topbar .sub { font-size: 17px; color: var(--muted); margin-top: 2px; }
.topbar .sub b { color: var(--text); font-weight: 600; }
.content { padding: 24px 28px 48px; }
.search { position: relative; width: 300px; }
.search input { width: 100%; padding: 10px 12px 10px 36px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; }
.search svg { position: absolute; left: 11px; top: 11px; color: var(--muted); }
.search-results { position: absolute; top: 44px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 30; }
.search-results a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.search-results a:hover { background: var(--bg); text-decoration: none; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.avatar.light { background: #e8edf3; color: var(--navy); }
.lang-switch { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.lang-switch button { border: 0; background: #fff; padding: 6px 10px; cursor: pointer; font-weight: 600; font-size: 12px; color: var(--muted); }
.lang-switch button.on { background: var(--navy); color: #fff; }

/* ---------- primitives ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card.flat { box-shadow: none; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--line-2); background: #fff; cursor: pointer; font-weight: 600; color: var(--text); white-space: nowrap;
}
.btn:hover { background: #f7f9fb; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-2); }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.outline-teal { border-color: var(--teal); color: var(--teal-2); }
.btn.danger { color: var(--red); border-color: #f0c7c2; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 13px 20px; font-size: 16px; }
.btn.block { width: 100%; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: #f5f7fa; display: grid; place-items: center; cursor: pointer; color: var(--navy); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.b-green { background: var(--green-soft); color: var(--green); }
.b-amber { background: var(--amber-soft); color: var(--amber); }
.b-red { background: var(--red-soft); color: var(--red); }
.b-blue { background: var(--blue-soft); color: var(--blue); }
.b-gray { background: #eef1f5; color: #4d5d70; }
.b-teal { background: var(--teal-soft); color: var(--teal-2); }
.b-violet { background: var(--violet-soft); color: #5b43b5; }
.demo-pill { background: #e2f3f4; color: var(--teal-2); font-weight: 700; font-size: 12px; padding: 4px 10px; border-radius: 8px; letter-spacing: 0.04em; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.input, .field input, .field select, .field textarea {
  border: 1px solid var(--line-2); border-radius: 9px; padding: 9px 11px; background: #fff; width: 100%; min-width: 0;
}
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(26, 138, 143, 0.25); border-color: var(--teal); }
textarea { resize: vertical; min-height: 72px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 12px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; font-size: 15px; white-space: nowrap; }
.tabs button.on { color: var(--teal-2); border-bottom-color: var(--teal); }
.seg { display: inline-flex; background: #eef2f6; border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--navy-2); color: #fff; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); text-transform: uppercase; letter-spacing: 0.03em; }
table.t td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f8fafc; }
.kv { display: grid; grid-template-columns: 150px 1fr; row-gap: 0; }
.kv > div { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.stat .v { font-size: 26px; font-weight: 800; margin-top: 6px; }
.stat .l { color: var(--muted); font-size: 13px; font-weight: 500; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; background: #f1f4f8; color: #4b5c70; font-size: 13px; line-height: 1.45; }
.callout.green { background: var(--green-soft); color: var(--green); }
.callout.amber { background: var(--amber-soft); color: var(--amber); }
.callout.red { background: var(--red-soft); color: var(--red); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.chip-filter { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-filter button { border: 1px solid var(--line-2); background: #fff; border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); }
.chip-filter button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip-filter .n { opacity: 0.7; margin-left: 4px; }

/* ---------- modal / drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 39, 64, 0.35); z-index: 50; display: flex; justify-content: center; align-items: flex-start; padding: 60px 16px; overflow: auto; }
.modal { background: #fff; border-radius: 14px; width: min(560px, 100%); box-shadow: var(--shadow-lg); }
.modal.wide { width: min(820px, 100%); }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-b { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); }
.drawer-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(15, 39, 64, 0.25); }
.drawer { position: absolute; right: 0; top: 0; bottom: 0; width: min(600px, 100%); background: #fff; box-shadow: var(--shadow-lg); overflow-y: auto; padding: 24px 26px; }
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); max-width: 420px; }
.toast.err { background: var(--red); }

/* ---------- job page ---------- */
.breadcrumb { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.job-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.meta-line { color: var(--muted); font-size: 13px; margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; }
.route-v { position: relative; padding-left: 26px; }
.route-v .pt { position: relative; padding-bottom: 18px; }
.route-v .pt::before { content: ''; position: absolute; left: -22px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--teal); }
.route-v .pt.end::before { background: #fff; border: 3px solid var(--teal); width: 8px; height: 8px; }
.route-v .pt:not(:last-child)::after { content: ''; position: absolute; left: -17px; top: 20px; bottom: 0; border-left: 2px dashed var(--teal); }
.route-v .city { font-weight: 700; font-size: 15.5px; }
.addr-link { cursor: pointer; color: var(--muted); font-size: 13px; }
.addr-link:hover { color: var(--teal-2); text-decoration: underline; }
.facts .row { padding: 6px 0; font-size: 15px; }
.facts svg { color: var(--navy-2); }
table.calc { width: 100%; border-collapse: collapse; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.calc td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 15px; }
table.calc td:last-child { text-align: right; font-weight: 600; }
table.calc tr.total td { font-weight: 800; }
table.calc tr.paid td { background: var(--green-soft); color: var(--green); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.panel-side { position: sticky; top: 90px; }

/* ---------- address panel ---------- */
.map-frame { width: 100%; height: 360px; border: 0; border-radius: 12px; background: #e8edf2; }
.map-mini { width: 100%; height: 190px; border: 0; border-radius: 10px; }

/* ---------- dispatch ---------- */
.dispatch { display: grid; grid-template-columns: 270px minmax(0, 1fr) 380px; gap: 14px; align-items: start; }
.res-card { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; margin-bottom: 10px; cursor: grab; user-select: none; }
.res-card:active { cursor: grabbing; }
.res-card.busy { opacity: 0.75; }
.res-card.absent { opacity: 0.5; cursor: not-allowed; }
.res-card .grip { color: #a7b3c0; }
.res-card .face { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px; flex-shrink: 0; }
.truck-ico { width: 56px; height: 40px; border-radius: 8px; background: #fff2ef; display: grid; place-items: center; color: #d35400; flex-shrink: 0; }
.state { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.state::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #22a35a; }
.state.busy::before { background: #e6a23c; }
.state.absent::before { background: #c0392b; }
.timeline { position: relative; }
.tl-row { height: 62px; border-top: 1px solid var(--line); position: relative; }
.tl-row .h { position: absolute; left: 0; top: -9px; width: 54px; font-size: 13px; color: var(--muted); background: #fff; }
.tl-jobs { position: absolute; left: 62px; right: 0; top: 0; bottom: 0; }
.tl-job {
  position: absolute; border-radius: 10px; background: #fff; border: 1px solid var(--line-2); border-left: 4px solid var(--teal);
  padding: 10px 14px; cursor: pointer; overflow: hidden; box-shadow: var(--shadow); transition: box-shadow 0.1s;
}
.tl-job:hover { box-shadow: 0 4px 14px rgba(15, 39, 64, 0.12); }
.tl-job.sel { border-color: var(--blue); }
.tl-job.drop { background: var(--blue-soft); border: 2px dashed var(--blue); border-left: 4px solid var(--blue); }
.tl-job .num { font-weight: 700; color: #2f4864; }
.tl-job .who { font-size: 19px; font-weight: 800; margin: 3px 0 6px; }
.tl-job .ln { display: flex; align-items: center; gap: 8px; color: #3c4f64; font-size: 14px; margin: 3px 0; }
.drop-hint { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); text-align: center; color: #6f9fd3; font-size: 12px; width: 130px; }
.drop-hint .plus { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #9cc2ea; display: grid; place-items: center; margin: 0 auto 6px; font-size: 18px; }
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.week-day { background: #fafbfc; border: 1px solid var(--line); border-radius: 10px; min-height: 360px; padding: 8px; }
.week-day.today { border-color: var(--teal); }
.week-job { background: #fff; border: 1px solid var(--line-2); border-left: 4px solid var(--teal); border-radius: 8px; padding: 7px 8px; margin-top: 6px; font-size: 12.5px; cursor: pointer; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #f1f4f8; border-radius: 999px; padding: 3px 4px 3px 4px; font-size: 13px; }
.chip .x { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 6px; }

/* ---------- foreman (mobile) ---------- */
.m-app { max-width: 480px; margin: 0 auto; min-height: 100vh; background: #f4f6f9; display: flex; flex-direction: column; }
.m-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: #fff; position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--line); }
.m-body { padding: 12px; display: flex; flex-direction: column; gap: 12px; flex: 1; padding-bottom: 96px; }
.m-card { background: #fff; border-radius: 14px; padding: 14px 16px; border: 1px solid var(--line); }
.m-tabs { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: min(480px, 100%); background: #fff; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, 1fr); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 20; }
.m-tabs button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px; color: var(--muted); font-weight: 600; font-size: 13px; border-radius: 12px; cursor: pointer; }
.m-tabs button.on { color: var(--teal-2); background: var(--teal-soft); }
.m-tabs svg { width: 24px; height: 24px; }
.timer { font-size: 64px; font-weight: 800; text-align: center; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--navy); }
.status-box { display: flex; align-items: center; gap: 12px; background: #f1f4f8; border-radius: 12px; padding: 12px 14px; }
.stepper { display: flex; justify-content: space-between; position: relative; padding: 4px 8px; }
.stepper::before { content: ''; position: absolute; top: 17px; left: 40px; right: 40px; height: 3px; background: #dfe5eb; }
.stepper .s { position: relative; text-align: center; z-index: 1; flex: 1; }
.stepper .c { width: 28px; height: 28px; border-radius: 50%; background: #d7dee6; margin: 0 auto 6px; display: grid; place-items: center; color: #fff; border: 3px solid #fff; box-shadow: 0 0 0 1px #d7dee6; }
.stepper .s.done .c { background: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.stepper .s.cur .c { background: var(--teal); box-shadow: 0 0 0 5px rgba(26, 138, 143, 0.2); }
.stepper .s.todo { color: #9aa7b5; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; }
.qty button { width: 36px; height: 36px; border: 0; background: #f4f6f9; cursor: pointer; font-size: 18px; }
.qty span { width: 44px; text-align: center; font-weight: 700; }
.sig-box { border: 2px dashed var(--line-2); border-radius: 12px; height: 110px; display: grid; place-items: center; color: var(--muted); cursor: pointer; background: #fafbfc; text-align: center; }
.sig-box img { max-height: 100px; max-width: 100%; }
canvas.sig { width: 100%; height: 200px; border: 1px solid var(--line-2); border-radius: 12px; touch-action: none; background: #fff; }
.sync-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--green-soft); color: var(--green); padding: 5px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; }
.sync-pill.off { background: var(--amber-soft); color: var(--amber); }

/* ---------- client portal & login ---------- */
.portal { max-width: 720px; margin: 0 auto; padding: 24px 16px 60px; display: flex; flex-direction: column; gap: 16px; }
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-left { background: linear-gradient(160deg, #16324f, #0d2236); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-right { display: grid; place-items: center; padding: 24px; }
.login-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px; }
.demo-acc { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.demo-acc button { text-align: left; border: 1px solid var(--line-2); background: #fff; border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.demo-acc button:hover { border-color: var(--teal); }

/* ---------- calls ---------- */
.call-row { display: grid; grid-template-columns: 32px 1fr auto; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: start; }
.call-ico { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; }
audio { height: 34px; width: 100%; max-width: 360px; }
.note-edit textarea { min-height: 60px; }

/* ---------- kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: #eef2f6; border-radius: 12px; padding: 10px; min-height: 300px; }
.kcol.over { outline: 2px dashed var(--teal); }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 8px; cursor: pointer; box-shadow: var(--shadow); }

@media (max-width: 1280px) {
  .dispatch { grid-template-columns: 230px minmax(0, 1fr); }
  .dispatch > .detail-col { grid-column: 1 / -1; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 10px; }
  .sidebar .brand-tag, .sidebar-foot .quote, .nav a span { display: none; }
  .nav { display: flex; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .search { width: 100%; order: 3; }
  .content { padding: 16px; }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .dispatch { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-left { display: none; }
  h1 { font-size: 24px; }
  .kv { grid-template-columns: 120px 1fr; }
}

/* ---------- v0.2: softphone, mail, e-sign ---------- */
.softphone-pop { position: absolute; right: 0; top: 48px; width: 300px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 16px; z-index: 40; display: flex; flex-direction: column; gap: 6px; }
.mail { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 16px; align-items: start; }
.mail-list { padding: 0; max-height: calc(100vh - 210px); overflow-y: auto; }
.mail-item { padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.mail-item:hover { background: #f8fafc; }
.mail-item.sel { background: var(--teal-soft); }
.mail-item.unread .subj, .mail-item.unread .from { font-weight: 800; }
.mail-msg { border-bottom: 1px solid var(--line); padding: 14px 0; }
.mail-msg pre { white-space: pre-wrap; font-family: inherit; margin: 8px 0 0; }
.mail-html { width: 100%; min-height: 220px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.doc-body h3 { margin: 18px 0 8px; }
.doc-body p { line-height: 1.5; }
.tg-msg { background: #1f2c3b; color: #e9eef3; border-radius: 12px; padding: 10px 12px; white-space: pre-wrap; font-size: 13.5px; line-height: 1.45; }
.tg-msg a { color: #6ab2f2; }
.summary-box { background: #f4f1fd; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.summary-box ul { margin: 6px 0; padding-left: 18px; }
@media (max-width: 900px) { .mail { grid-template-columns: 1fr; } }

/* ---------- v0.3: SMS chat, media ---------- */
.chat { display: flex; flex-direction: column; }
.chat-scroll { max-height: calc(100vh - 380px); min-height: 220px; overflow-y: auto; padding: 8px 4px; background: #f6f8fb; border-radius: 10px; }
.bubble-row { display: flex; margin: 6px 0; }
.bubble-row.outbound { justify-content: flex-end; }
.bubble { max-width: 75%; padding: 9px 12px; border-radius: 14px; background: #fff; border: 1px solid var(--line); font-size: 14.5px; }
.bubble.outbound { background: var(--teal); color: #fff; border-color: var(--teal); }
.bubble-meta { font-size: 11px; opacity: 0.7; margin-top: 4px; display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.bubble-media { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chat-compose { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.thumb { position: relative; width: 110px; height: 90px; border: 0; padding: 0; border-radius: 10px; overflow: hidden; cursor: pointer; background: #dfe6ee; }
.gallery .thumb { width: 100%; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 26px; text-shadow: 0 2px 8px rgba(0,0,0,.5); }
.progress { height: 6px; background: #e3e8ee; border-radius: 4px; overflow: hidden; margin-top: 6px; }
.progress div { height: 100%; background: var(--teal); transition: width .2s; }

/* ---------- v0.5: financial module ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpis.hero { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.kpis.hero .kpi .v { font-size: 30px; }
.kpis.three { grid-template-columns: repeat(3, 1fr); }
.kpi { padding: 14px 16px; position: relative; }
.kpi .v { font-size: 22px; font-variant-numeric: tabular-nums; }
.kpi .h { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi.pos { border-top: 3px solid var(--green); }
.kpi.neg { border-top: 3px solid var(--red); }
.kpi.warn { border-top: 3px solid #e6a23c; }
.amt { font-variant-numeric: tabular-nums; }
.amt.neg, .neg { color: var(--red); }
.amt.pos, .pos { color: var(--green); }
.warn-t { color: var(--amber); }
.fin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.card-h.pad, .pad { padding: 16px 20px; }
.card-h.wrap { flex-wrap: wrap; }
.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.t tfoot td { border-top: 2px solid var(--line-2); padding-top: 10px; }
.t tr.voided td, .voided { opacity: 0.55; }
.t th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.t th.sortable.on { color: var(--teal-2); }
.profit-t tr.gain td:first-child { box-shadow: inset 4px 0 0 var(--green); }
.profit-t tr.loss td:first-child { box-shadow: inset 4px 0 0 var(--red); }
.profit-t tr.loss { background: #fff7f6; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 12.5px; }
.pill.pos { background: var(--green-soft); }
.pill.neg { background: var(--red-soft); }
.lines .line { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lines .line.total { border-bottom: 0; font-size: 15px; }
.link-btn { background: none; border: 0; padding: 2px 4px; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; gap: 2px; font: inherit; }
.link-btn:hover { color: var(--teal-2); }
.exp-actions { display: inline-flex; gap: 2px; align-items: center; margin-left: 6px; flex-wrap: wrap; }
.truck-box { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #fbfcfd; }
.money-in { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: 9px; background: #fff; padding-left: 10px; }
.money-in span { color: var(--muted); font-weight: 600; }
.money-in input { border: 0 !important; outline: none !important; width: 100%; padding: 9px 10px 9px 4px; font-variant-numeric: tabular-nums; background: transparent; }
.period { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.seg.scroll { overflow-x: auto; max-width: 100%; }
.seg.scroll button { white-space: nowrap; padding: 7px 12px; }
.seg.wrap { flex-wrap: wrap; }
.refetch { opacity: 0.55; transition: opacity 0.2s; }
.emp-card .emp-sums { display: flex; gap: 22px; }
.emp-card .emp-sums > div { display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
.chip { display: inline-block; background: #eef2f6; border-radius: 6px; padding: 2px 8px; margin: 2px 4px 2px 0; }
details > summary { cursor: pointer; }
/* charts */
.viz .legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.viz .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.viz-scroll { position: relative; overflow-x: auto; }
.viz-scroll svg { display: block; }
.viz-scroll .grid { stroke: #edf0f4; stroke-width: 1; }
.viz-scroll .base { stroke: #b9c3ce; stroke-width: 1; }
.viz-scroll .axis { font-size: 11px; fill: var(--muted); }
.viz-scroll .hit { cursor: default; outline: none; }
.viz-scroll .hit:hover path, .viz-scroll .hit:focus path { filter: brightness(1.12); }
.viz-tip { position: absolute; pointer-events: none; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-lg); border-radius: 8px; padding: 8px 10px; min-width: 140px; z-index: 5; }
.viz-tip .key { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 190px) 1fr auto 40px; gap: 10px; align-items: center; font-size: 13px; }
.hbar .track { height: 10px; background: #f0f3f6; border-radius: 4px; overflow: hidden; }
.hbar .track span { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.hbar .pct { text-align: right; }
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpis.hero { grid-template-columns: 1fr 1fr; }
  .kpis.hero .kpi .v { font-size: 22px; }
  .fin-grid { grid-template-columns: 1fr; }
  .emp-card .emp-sums { gap: 12px; width: 100%; justify-content: space-between; }
  .hbar { grid-template-columns: 100px 1fr auto; }
  .hbar .pct { display: none; }
  .kpis.three { grid-template-columns: 1fr 1fr 1fr; }
}
.access-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 8px; border-top: 1px dashed var(--line); }
.badge-btn { border: 0; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 600; }
.badge-btn:hover { filter: brightness(0.95); }
.travel-in { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar .title { min-width: 220px; }
.topbar .sub { white-space: nowrap; }
.m-tabs { grid-template-columns: repeat(4, 1fr); }
.crew-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.crew-grid > div { display: flex; flex-direction: column; background: #f6f8fb; border-radius: 8px; padding: 6px 8px; }
.crew-row.no_show { opacity: 0.6; }
.crew-row.working { border-left: 4px solid var(--blue); }
.crew-row.done { border-left: 4px solid var(--green); }
.sig-box { display: flex; align-items: center; gap: 10px; }
.sig-box img { height: 54px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.rate-req { border-left: 4px solid #e6a23c; }
.sig-box { display: flex; align-items: center; gap: 10px; }
.sig-box img { height: 54px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.rate-req { border-left: 4px solid #e6a23c; }
.claim { padding: 12px 0; border-bottom: 1px solid var(--line); }
.claim:last-child { border-bottom: 0; }
.claim-photo { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.stars { display: flex; gap: 6px; }
.stars button { font-size: 32px; background: none; border: 0; color: #d0d6de; cursor: pointer; }
.stars button.on { color: #e6a23c; }
.mb16 { margin-bottom: 16px; }
