/* Z3 FieldOps — design tokens & components
   Palette: petrol teal accent on cool mineral neutrals; dark petrol sidebar; semantic status colours kept separate.
   Type: Barlow Semi Condensed (titles, nameplates), IBM Plex Sans (UI), IBM Plex Sans Arabic, IBM Plex Mono (IDs, timers). */
:root {
  color-scheme: light;
  --bg: #eef2f1; --surface: #ffffff; --surface-2: #f5f8f7; --surface-3: #eaf0ee; --line: #d6dfdc; --line-2: #e5ebe9;
  --ink: #13232b; --ink-2: #3b4d55; --muted: #66787e; --faint: #93a3a7;
  --accent: #0b6e6e; --accent-2: #085757; --accent-ink: #ffffff; --accent-soft: #dcefec; --accent-line: #9fcfca;
  --ok: #1d7a44; --ok-bg: #e0f2e6; --warn: #8f5500; --warn-bg: #fcefd3; --warn-dot: #d98a00; --crit: #b3261e; --crit-bg: #fbe2df; --info: #245aa6; --info-bg: #e2ebf8;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4;
  --st-good: #0ca30c; --st-warn: #fab219; --st-serious: #ec835a; --st-crit: #d03b3b;
  --grid: #e4eae8; --axis: #7a8a8e; --base: #c3cdca;
  --side-bg: #0f2a30; --side-2: #163a41; --side-ink: #d6e6e3; --side-muted: #8fb0ac; --side-line: #1f4148;
  --shadow: 0 1px 2px rgba(19, 35, 43, .06), 0 6px 18px rgba(19, 35, 43, .07);
  --shadow-lg: 0 12px 48px rgba(10, 25, 30, .22);
  --r: 10px; --r-sm: 7px;
  --f-ui: 'IBM Plex Sans', 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --f-ar: 'IBM Plex Sans Arabic', 'IBM Plex Sans', 'Segoe UI', Tahoma, sans-serif;
  --f-disp: 'Barlow Semi Condensed', 'IBM Plex Sans', 'Arial Narrow', sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a1315; --surface: #111c1f; --surface-2: #142227; --surface-3: #1a2b30; --line: #24373c; --line-2: #1c2d32;
    --ink: #e2ebe9; --ink-2: #b5c5c4; --muted: #8499a0; --faint: #5f7479;
    --accent: #3db4ae; --accent-2: #5ccbc5; --accent-ink: #04201f; --accent-soft: #11363a; --accent-line: #2a6c6b;
    --ok: #52c885; --ok-bg: #12301f; --warn: #f2b653; --warn-bg: #362710; --warn-dot: #f2b653; --crit: #ff8077; --crit-bg: #3a1614; --info: #86b4f3; --info-bg: #13253b;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
    --grid: #1f3035; --axis: #7f9398; --base: #34494e;
    --side-bg: #071012; --side-2: #10262b; --side-ink: #d0e2df; --side-muted: #7fa19d; --side-line: #173237;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a1315; --surface: #111c1f; --surface-2: #142227; --surface-3: #1a2b30; --line: #24373c; --line-2: #1c2d32;
  --ink: #e2ebe9; --ink-2: #b5c5c4; --muted: #8499a0; --faint: #5f7479;
  --accent: #3db4ae; --accent-2: #5ccbc5; --accent-ink: #04201f; --accent-soft: #11363a; --accent-line: #2a6c6b;
  --ok: #52c885; --ok-bg: #12301f; --warn: #f2b653; --warn-bg: #362710; --warn-dot: #f2b653; --crit: #ff8077; --crit-bg: #3a1614; --info: #86b4f3; --info-bg: #13253b;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
  --grid: #1f3035; --axis: #7f9398; --base: #34494e;
  --side-bg: #071012; --side-2: #10262b; --side-ink: #d0e2df; --side-muted: #7fa19d; --side-line: #173237;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--f-ui); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body.has-modal { overflow: hidden; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font: 700 26px/1.1 var(--f-disp); letter-spacing: .2px; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { flex: none; vertical-align: middle; }
.mono, .id { font-family: var(--f-mono); font-size: .92em; letter-spacing: -.1px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.xs { font-size: 11.5px; }
.b { font-weight: 600; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nowrap { white-space: nowrap; }
.ar { font-family: var(--f-ar); }
[dir="rtl"] { font-family: var(--f-ar); }
.hide-sm { }
@media (max-width: 700px) { .hide-sm { display: none !important; } }

/* ---------- Layout primitives ---------- */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.nowrap-row { flex-wrap: nowrap; }
.row.top { align-items: flex-start; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.stack { display: grid; gap: 16px; align-content: start; }
.stack-sm { display: grid; gap: 8px; align-content: start; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-side { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
@media (max-width: 1180px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main, .g-side { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) { .g3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) { .g2, .g4 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100%; }
.sidebar { background: var(--side-bg); color: var(--side-ink); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; border-right: 1px solid var(--side-line); z-index: 30; }
.brand { padding: 16px 16px 12px; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--side-line); }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg, #1aa39c, #0b6e6e 60%, #084f52); display: grid; place-items: center; font: 700 17px var(--f-disp); color: #fff; letter-spacing: .5px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.brand-t { font: 700 18px/1 var(--f-disp); letter-spacing: .3px; }
.brand-s { font-size: 11.5px; color: var(--side-muted); margin-top: 3px; }
.nav { padding: 8px 8px 16px; display: grid; gap: 1px; }
.nav-g { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.1px; color: var(--side-muted); padding: 14px 10px 5px; display: flex; align-items: center; gap: 6px; }
.nav-g .step { font-family: var(--f-mono); font-size: 10px; opacity: .8; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--side-ink); text-decoration: none; font-size: 13.5px; }
.nav a:hover { background: var(--side-2); }
.nav a.active { background: var(--side-2); box-shadow: inset 2px 0 0 #3db4ae; color: #fff; }
.nav a .ic { opacity: .85; }
.nav .badge { margin-left: auto; background: #3db4ae; color: #04201f; font: 600 11px/1 var(--f-ui); padding: 3px 6px; border-radius: 10px; }
.nav .badge.crit { background: #ff8a80; color: #2b0705; }
.side-foot { margin-top: auto; padding: 12px 14px; border-top: 1px solid var(--side-line); font-size: 11.5px; color: var(--side-muted); display: grid; gap: 6px; }
.side-foot b { color: var(--side-ink); font-weight: 600; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; padding: 10px 20px; min-height: 58px; }
.topbar .crumb { font-size: 12px; color: var(--muted); }
.topbar .title { font: 700 20px/1.1 var(--f-disp); letter-spacing: .2px; }
.menu-btn { display: none; }
.content { padding: 20px 24px 48px; width: 100%; max-width: 1480px; margin: 0 auto; }
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; }
  .menu-btn { display: inline-grid; }
  .content { padding: 16px 16px 40px; }
  .topbar { padding: 8px 16px; }
}
.gsearch { position: relative; flex: 1; max-width: 420px; }
.gsearch input { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 12px 0 34px; }
.gsearch .ic { position: absolute; left: 10px; top: 9px; color: var(--muted); }
.gs-results { position: absolute; top: 40px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 420px; overflow: auto; z-index: 50; padding: 6px; }
.gs-item { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.gs-item:hover, .gs-item.sel { background: var(--surface-3); }
.gs-kind { font-size: 11px; color: var(--muted); min-width: 64px; }
@media (max-width: 700px) { .gsearch { display: none; } }

.top-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; font-size: 13px; white-space: nowrap; }
.chip-btn:hover { border-color: var(--accent-line); }
.chip-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn-dot); }
.bell { position: relative; }
.bell .count { position: absolute; top: -5px; right: -5px; background: var(--crit); color: #fff; border-radius: 9px; font: 600 10.5px/1 var(--f-ui); padding: 3px 5px; min-width: 18px; text-align: center; }
.userchip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 22px; padding: 3px 10px 3px 3px; cursor: pointer; max-width: 260px; }
.userchip .u-n { font-weight: 600; font-size: 13px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userchip .u-r { font-size: 11px; color: var(--muted); line-height: 1.1; white-space: nowrap; }
@media (max-width: 700px) { .userchip .u-txt { display: none; } .userchip { padding: 3px; } }

.banner { display: flex; gap: 10px; align-items: center; padding: 8px 20px; font-size: 13px; border-bottom: 1px solid var(--line); }
.banner.heat { background: var(--warn-bg); color: var(--warn); }
.banner.demo { background: var(--accent-soft); color: var(--accent-2); }
.banner button { margin-left: auto; }

/* ---------- Page head ---------- */
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .ph-t { display: grid; gap: 4px; min-width: 0; }
.page-head .ph-sub { color: var(--muted); font-size: 13px; max-width: 72ch; }
.page-head .ph-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.card-h h2 { font-size: 14.5px; }
.card-h .sub { color: var(--muted); font-size: 12.5px; }
.card-h .right { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card-b { padding: 14px 16px; }
.card-b.flush { padding: 0; }
.card-f { padding: 10px 16px; border-top: 1px solid var(--line-2); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.panel { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 12px; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 4px; box-shadow: var(--shadow); position: relative; min-width: 0; }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { border-color: var(--accent-line); }
.kpi-l { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.kpi-v { font-size: 26px; font-weight: 600; letter-spacing: -.4px; line-height: 1.1; }
.kpi-d { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kpi-d .up { color: var(--ok); } .kpi-d .down { color: var(--crit); }
.kpi .spark { display: block; margin-top: 2px; }
.kpi.k-crit { border-color: color-mix(in srgb, var(--crit) 40%, var(--line)); }
.kpi.k-crit .kpi-v { color: var(--crit); }
.kpi.k-warn .kpi-v { color: var(--warn); }

/* ---------- Workflow spine ---------- */
.spine { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.spine-s { padding: 10px 12px 12px; border-right: 1px solid var(--line-2); cursor: pointer; position: relative; min-width: 0; }
.spine-s:last-child { border-right: 0; }
.spine-s:hover { background: var(--surface-2); }
.spine-n { font: 500 10.5px var(--f-mono); color: var(--muted); }
.spine-t { font-size: 12.5px; font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spine-v { font-size: 22px; font-weight: 600; margin-top: 4px; letter-spacing: -.3px; }
.spine-d { font-size: 11.5px; color: var(--muted); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.spine-s.alert .spine-d { color: var(--crit); }
.spine-s::after { content: ''; position: absolute; right: -6px; top: 50%; width: 10px; height: 10px; background: var(--surface); border-top: 1px solid var(--line-2); border-right: 1px solid var(--line-2); transform: translateY(-50%) rotate(45deg); z-index: 1; }
.spine-s:last-child::after { display: none; }
@media (max-width: 1180px) { .spine { grid-template-columns: repeat(3, minmax(0, 1fr)); } .spine-s { border-bottom: 1px solid var(--line-2); } .spine-s::after { display: none; } }
@media (max-width: 520px) { .spine { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; font-size: 13.5px; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--accent-line); background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--accent-ink); }
.btn-danger { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn-danger:hover { filter: brightness(1.05); background: var(--crit); color: #fff; }
.btn-warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12.5px; gap: 5px; border-radius: 7px; }
.btn-lg { height: 44px; padding: 0 18px; font-size: 15px; border-radius: 10px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--ink-2); }
.btn-icon:hover { background: var(--surface-3); }
.lnk { color: var(--accent); text-decoration: none; font-weight: 500; }
.lnk:hover { text-decoration: underline; }

/* ---------- Pills, priority, SLA ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap; border: 1px solid transparent; line-height: 1.5; }
.p-ok { background: var(--ok-bg); color: var(--ok); }
.p-ok-soft { background: var(--surface-3); color: var(--ok); }
.p-warn { background: var(--warn-bg); color: var(--warn); }
.p-crit { background: var(--crit-bg); color: var(--crit); }
.p-info { background: var(--info-bg); color: var(--info); }
.p-accent { background: var(--accent-soft); color: var(--accent-2); }
.p-muted { background: var(--surface-3); color: var(--muted); }
.p-outline { background: transparent; border-color: var(--line); color: var(--ink-2); }
.prio { display: inline-grid; place-items: center; min-width: 28px; height: 20px; padding: 0 5px; border-radius: 5px; font: 600 11.5px/1 var(--f-mono); }
.prio-P1 { background: var(--crit); color: #fff; }
.prio-P2 { background: var(--warn-dot); color: #2b1a00; }
.prio-P3 { background: var(--info-bg); color: var(--info); }
.prio-P4 { background: var(--surface-3); color: var(--muted); }
.sla { display: inline-flex; align-items: center; gap: 4px; font: 500 12px/1.4 var(--f-mono); padding: 1px 7px; border-radius: 6px; white-space: nowrap; background: var(--surface-3); color: var(--ink-2); }
.sla-met { background: var(--ok-bg); color: var(--ok); }
.sla-live { background: var(--info-bg); color: var(--info); }
.sla-risk { background: var(--warn-bg); color: var(--warn); }
.sla-breached { background: var(--crit-bg); color: var(--crit); }
.sla-paused { background: var(--surface-3); color: var(--muted); }
.sla-na { background: transparent; color: var(--faint); }
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font: 600 11.5px/1 var(--f-ui); color: #fff; background: hsl(var(--h) 38% 40%); flex: none; letter-spacing: .3px; }
.av-sm { width: 24px; height: 24px; font-size: 10px; }
.av-lg { width: 44px; height: 44px; font-size: 15px; }
.stars { color: var(--faint); letter-spacing: 1px; white-space: nowrap; }
.stars .on { color: #e3a008; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.cat { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); white-space: nowrap; }
.tag { display: inline-flex; align-items: center; gap: 4px; font: 500 11.5px var(--f-mono); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.nameplate { display: inline-flex; flex-direction: column; font-family: var(--f-mono); border: 1.5px solid var(--ink-2); border-radius: 4px; padding: 5px 9px; background: linear-gradient(180deg, var(--surface-2), var(--surface-3)); box-shadow: inset 0 1px 0 rgba(255,255,255,.5); }
.nameplate b { font: 700 15px var(--f-disp); letter-spacing: .6px; }
.nameplate span { font-size: 10.5px; color: var(--muted); }

/* ---------- Tables ---------- */
.tbl-wrap { width: 100%; overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; letter-spacing: .2px; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl.dense td, .tbl.dense th { padding: 6px 10px; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: var(--surface-2); }
.tbl tr.row-crit td:first-child { box-shadow: inset 3px 0 0 var(--crit); }
.tbl tr.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn-dot); }
.tbl tr.row-muted td { color: var(--muted); }
.tbl .a-right { text-align: right; }
.tbl .a-center { text-align: center; }
.tbl tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line); }
.cell-t { font-weight: 500; color: var(--ink); }
.cell-s { font-size: 12px; color: var(--muted); margin-top: 1px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 12px; font-size: 12.5px; color: var(--muted); }
.searchbox { position: relative; display: inline-flex; align-items: center; }
.searchbox .ic { position: absolute; left: 9px; color: var(--muted); }
.searchbox input { height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 10px 0 32px; width: 260px; max-width: 100%; }
.sel select { height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 28px 0 10px; max-width: 220px; }
@media (max-width: 640px) { .searchbox, .searchbox input { width: 100%; } .toolbar > * { flex: 1 1 auto; } }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 9px 12px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent-2); border-bottom-color: var(--accent); }
.tab-n { background: var(--surface-3); color: var(--ink-2); border-radius: 10px; font-size: 11px; padding: 1px 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; font-size: 13px; color: var(--muted); }
.seg button.active { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid.one { grid-template-columns: minmax(0, 1fr); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .form-grid, .form-grid.three { grid-template-columns: minmax(0, 1fr); } }
.field { display: grid; gap: 5px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field.full { grid-column: 1 / -1; }
.field label, .field legend { font-size: 12.5px; font-weight: 500; color: var(--ink-2); padding: 0; }
.req { color: var(--crit); margin-left: 2px; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 8px 10px; min-height: 36px; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); outline-offset: 0; }
.field .invalid, .invalid { border-color: var(--crit) !important; background: color-mix(in srgb, var(--crit-bg) 40%, var(--surface)); }
.hint { font-size: 12px; color: var(--muted); }
.check, .radio { display: inline-flex; gap: 7px; align-items: center; cursor: pointer; font-size: 13.5px; }
.check input, .radio input { width: 16px; height: 16px; accent-color: var(--accent); }
.checks, .radios { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.inline-input { height: 30px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); padding: 0 8px; width: 100%; min-width: 60px; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(8, 18, 21, .52); display: grid; place-items: center; padding: 20px 16px; z-index: 100; animation: fade .14s ease; }
.modal { background: var(--surface); border-radius: 14px; width: min(640px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); border: 1px solid var(--line); animation: pop .16s ease; }
.modal-sm { width: min(460px, 100%); }
.modal-lg { width: min(880px, 100%); }
.modal-xl { width: min(1120px, 100%); }
.modal-head { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px 12px; border-bottom: 1px solid var(--line-2); }
.modal-head h2 { font: 700 19px/1.15 var(--f-disp); letter-spacing: .2px; }
.modal-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.modal-head .btn-icon { margin-left: auto; }
.modal-body { padding: 16px; overflow: auto; display: grid; gap: 14px; align-content: start; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--line-2); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.confirm-msg { color: var(--ink-2); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .modal-back, .modal { animation: none; } .sidebar { transition: none; } }

/* ---------- Toasts & tooltip ---------- */
.toasts { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 200; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); font-size: 13.5px; animation: pop .16s ease; }
.toast b { display: block; }
.toast.out { opacity: 0; transform: translateY(6px); transition: all .2s; }
.toast .ic { margin-top: 1px; }
.t-ok .ic { color: var(--ok); } .t-warn .ic { color: var(--warn-dot); } .t-crit .ic { color: var(--crit); } .t-info .ic { color: var(--info); }
.t-crit { border-color: color-mix(in srgb, var(--crit) 40%, var(--line)); }
.toast-x { margin-left: auto; border: 0; background: none; cursor: pointer; color: var(--muted); padding: 2px; }
.tip { position: fixed; z-index: 300; pointer-events: none; background: var(--ink); color: var(--surface); padding: 6px 9px; border-radius: 7px; font-size: 12px; line-height: 1.45; max-width: 280px; box-shadow: var(--shadow-lg); display: none; font-variant-numeric: tabular-nums; }

/* ---------- Misc blocks ---------- */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 16px; margin: 0; }
.kv > div { min-width: 0; }
.kv dt { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.kv.cols-1 { grid-template-columns: minmax(0, 1fr); }
.kv.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.empty { display: grid; place-items: center; gap: 6px; padding: 28px 16px; text-align: center; color: var(--muted); }
.empty-t { font-weight: 600; color: var(--ink-2); }
.empty-d { font-size: 13px; max-width: 46ch; }
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 9px; font-size: 13px; border: 1px solid transparent; }
.callout b { display: block; margin-bottom: 1px; }
.c-ok { background: var(--ok-bg); color: var(--ok); }
.c-warn { background: var(--warn-bg); color: var(--warn); }
.c-crit { background: var(--crit-bg); color: var(--crit); }
.c-info { background: var(--info-bg); color: var(--info); }
.c-accent { background: var(--accent-soft); color: var(--accent-2); }
.callout > div { color: var(--ink); } .callout b { color: inherit; }
.c-ok > div > b { color: var(--ok); } .c-warn > div > b { color: var(--warn); } .c-crit > div > b { color: var(--crit); } .c-info > div > b { color: var(--info); } .c-accent > div > b { color: var(--accent-2); }
.meter { height: 8px; border-radius: 6px; background: var(--surface-3); overflow: hidden; min-width: 60px; }
.meter > span { display: block; height: 100%; border-radius: 6px; }
.m-ok > span { background: var(--st-good); } .m-warn > span { background: var(--st-warn); } .m-crit > span { background: var(--st-crit); } .m-accent > span { background: var(--accent); }
.divider { height: 1px; background: var(--line-2); margin: 4px 0; }
.list { display: grid; }
.li { display: flex; gap: 10px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line-2); min-width: 0; }
.li:last-child { border-bottom: 0; }
.li.clickable { cursor: pointer; }
.li.clickable:hover { background: var(--surface-2); }
.li-main { min-width: 0; flex: 1; }
.li-t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-s { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-r { display: flex; gap: 6px; align-items: center; flex: none; }
.note { background: var(--surface-2); border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--ink-2); }

/* ---------- Timeline ---------- */
.timeline { display: grid; gap: 0; position: relative; }
.tl { display: grid; grid-template-columns: 74px 22px minmax(0, 1fr); gap: 0 8px; position: relative; padding-bottom: 12px; }
.tl-time { font: 500 11.5px/1.3 var(--f-mono); color: var(--muted); text-align: right; padding-top: 2px; }
.tl-dot { width: 22px; display: grid; justify-items: center; position: relative; }
.tl-dot::before { content: ''; position: absolute; top: 18px; bottom: -12px; width: 2px; background: var(--line); }
.tl:last-child .tl-dot::before { display: none; }
.tl-dot i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--surface); background: var(--faint); box-shadow: 0 0 0 1px var(--line); margin-top: 3px; }
.tl-body { min-width: 0; font-size: 13px; }
.tl-by { font-size: 11.5px; color: var(--muted); }
.tl.e-created i, .tl.e-triage i { background: var(--info); }
.tl.e-assigned i, .tl.e-reassigned i, .tl.e-vendor i, .tl.e-accepted i { background: var(--series-1); }
.tl.e-travel i, .tl.e-arrived i, .tl.e-started i { background: var(--accent); }
.tl.e-hold i, .tl.e-escalated i, .tl.e-hse i { background: var(--warn-dot); }
.tl.e-completed i, .tl.e-verified i, .tl.e-rated i { background: var(--st-good); }
.tl.e-sla i, .tl.e-rejected i, .tl.e-reopened i, .tl.e-cancelled i { background: var(--st-crit); }
.tl .flag { color: var(--crit); font-weight: 600; }
.tl .offline-tag { font-size: 11px; color: var(--warn); }

/* ---------- Photos ---------- */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface-2); position: relative; }
.photo img { display: block; width: 100%; aspect-ratio: 16/10; object-fit: cover; max-width: 100%; }
.photo .cap { font-size: 11.5px; padding: 5px 7px; color: var(--ink-2); display: flex; gap: 6px; align-items: center; }
.photo .stage { position: absolute; left: 6px; top: 6px; }
.photo .rm { position: absolute; right: 4px; top: 4px; background: rgba(0,0,0,.55); color: #fff; border: 0; border-radius: 6px; width: 24px; height: 24px; display: grid; place-items: center; cursor: pointer; }

/* ---------- Checklist ---------- */
.checklist { display: grid; gap: 6px; }
.ck { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); }
.ck.done { background: var(--ok-bg); border-color: transparent; }
.ck .ck-t { flex: 1; min-width: 0; font-size: 13px; }
.ck input[type=text], .ck input[type=number] { width: 110px; height: 30px; border: 1px solid var(--line); border-radius: 7px; padding: 0 8px; background: var(--surface); }
.ck-box { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--line); display: grid; place-items: center; background: var(--surface); cursor: pointer; flex: none; }
.ck.done .ck-box { background: var(--ok); border-color: var(--ok); color: #fff; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--base); stroke-width: 1; }
.chart .target { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 0; opacity: .7; }
.chart .axis { fill: var(--muted); font-size: calc(11px * var(--k, 1)); font-family: var(--f-ui); font-variant-numeric: tabular-nums; }
.chart .val { fill: var(--ink); font-size: calc(11.5px * var(--k, 1)); font-weight: 600; font-family: var(--f-ui); }
.chart rect[data-tip]:hover, .chart .hot:hover { fill: color-mix(in srgb, var(--ink) 5%, transparent); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 36%) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar[data-action] { cursor: pointer; }
.hbar-l { display: flex; gap: 6px; align-items: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.hbar-track { height: 10px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.hbar-v { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12.5px; min-width: 42px; text-align: right; }
.stackbar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; gap: 2px; background: var(--surface); margin: 6px 0 8px; }
.stackbar span { display: block; height: 100%; }
.stackbar span:first-child { border-radius: 7px 0 0 7px; } .stackbar span:last-child { border-radius: 0 7px 7px 0; }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); background: var(--bg); }
.login-hero { background: var(--side-bg); color: var(--side-ink); padding: 40px 44px; display: flex; flex-direction: column; gap: 22px; position: relative; overflow: hidden; }
.login-hero::after { content: ''; position: absolute; inset: auto -120px -160px auto; width: 480px; height: 480px; border-radius: 50%; border: 1px solid var(--side-line); box-shadow: 0 0 0 60px rgba(61,180,174,.04), 0 0 0 120px rgba(61,180,174,.03); pointer-events: none; }
.login-hero h1 { font: 700 44px/1.02 var(--f-disp); color: #fff; max-width: 14ch; letter-spacing: .2px; }
.login-hero p { color: var(--side-muted); max-width: 52ch; font-size: 15px; }
.flow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font: 500 12px var(--f-mono); color: var(--side-ink); }
.flow span { border: 1px solid var(--side-line); border-radius: 6px; padding: 4px 8px; background: rgba(255,255,255,.03); }
.flow i { color: var(--side-muted); font-style: normal; }
.login-roles { padding: 32px 36px; overflow: auto; display: grid; gap: 14px; align-content: start; }
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.role-card { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px; cursor: pointer; display: grid; gap: 6px; box-shadow: var(--shadow); }
.role-card:hover { border-color: var(--accent); }
.role-card .rc-top { display: flex; gap: 8px; align-items: center; }
.role-card .rc-r { font: 600 11px var(--f-ui); color: var(--accent-2); text-transform: uppercase; letter-spacing: .8px; }
.role-card .rc-n { font-weight: 600; }
.role-card .rc-d { font-size: 12.5px; color: var(--muted); }
@media (max-width: 900px) { .login { grid-template-columns: minmax(0, 1fr); } .login-hero { padding: 28px 20px; } .login-hero h1 { font-size: 34px; } .login-roles { padding: 20px 16px; } }

/* ---------- Access denied ---------- */
.denied { max-width: 560px; margin: 40px auto; text-align: center; display: grid; gap: 12px; justify-items: center; }
.denied .ic { color: var(--crit); }

/* ---------- Dispatch board ---------- */
.dispatch { display: grid; grid-template-columns: 350px minmax(0, 1fr); gap: 14px; align-items: start; }
.dispatch > .stack { min-width: 0; }
.sugg-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
@media (max-width: 1000px) { .dispatch { grid-template-columns: minmax(0, 1fr); } }
.queue { display: grid; gap: 8px; max-height: 62vh; overflow: auto; padding: 10px; }
@media (max-width: 900px) { .queue { max-height: none; } }
.jobcard { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--surface); display: grid; gap: 6px; cursor: pointer; position: relative; }
.jobcard:hover { border-color: var(--accent-line); }
.jobcard.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.jobcard.p1 { box-shadow: inset 3px 0 0 var(--crit); }
.jobcard.p2 { box-shadow: inset 3px 0 0 var(--warn-dot); }
.jobcard .jc-t { font-weight: 600; font-size: 13px; }
.jobcard .jc-s { font-size: 12px; color: var(--muted); }
.map-wrap { position: relative; border-radius: var(--r); overflow: hidden; background: var(--surface-2); }
.map { width: 100%; height: auto; display: block; }
.map .sea { fill: color-mix(in srgb, var(--info) 14%, var(--surface)); }
.map .land { fill: var(--surface); }
.map .road { stroke: var(--line); stroke-width: 3; fill: none; stroke-linecap: round; }
.map .road.major { stroke: color-mix(in srgb, var(--warn-dot) 35%, var(--line)); stroke-width: 4; }
.map .creek { stroke: color-mix(in srgb, var(--info) 30%, var(--surface)); stroke-width: 6; fill: none; stroke-linecap: round; }
.map .zone { fill: none; stroke-dasharray: 4 5; stroke-width: 1.2; opacity: .8; }
.map .zlabel { font: 600 calc(10px * var(--k, 1)) var(--f-ui); fill: var(--muted); letter-spacing: .6px; text-transform: uppercase; }
.map .alabel { font: 500 calc(10px * var(--k, 1)) var(--f-ui); fill: var(--ink-2); opacity: .7; }
.map .site circle { fill: var(--surface); stroke: var(--ink-2); stroke-width: 1.5; }
.map .site text { font: 500 calc(9px * var(--k, 1)) var(--f-ui); fill: var(--ink-2); }
.map .tech circle.halo { opacity: .22; }
.map .tech text { font: 700 8.5px var(--f-ui); fill: #fff; pointer-events: none; }
.map .job path { stroke: var(--surface); stroke-width: 1.5; }
.map .route { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 5 4; fill: none; }
.map [data-tip] { cursor: pointer; }
.map-legend { position: absolute; left: 10px; bottom: 10px; background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 11.5px; display: flex; gap: 10px; flex-wrap: wrap; }
.techrow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line-2); }
.techrow:last-child { border-bottom: 0; }
.techrow.pick { cursor: pointer; }
.techrow.pick:hover { background: var(--surface-2); }
.sugg { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 6px; background: var(--surface); }
.sugg.best { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.sugg .why { font-size: 12px; color: var(--muted); }
.sugg .flags { display: flex; flex-wrap: wrap; gap: 4px; }
.score { font: 600 12px var(--f-mono); background: var(--surface-3); border-radius: 6px; padding: 2px 6px; }
.gantt { display: grid; grid-template-columns: 170px minmax(0, 1fr); font-size: 12px; }
.gantt .g-h { position: relative; height: 24px; border-bottom: 1px solid var(--line); }
.gantt .g-h span { position: absolute; top: 4px; transform: translateX(-50%); color: var(--muted); font: 500 10.5px var(--f-mono); }
.gantt .g-name { padding: 6px 8px; border-bottom: 1px solid var(--line-2); display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; }
.gantt .g-row { position: relative; border-bottom: 1px solid var(--line-2); height: 36px; background-image: linear-gradient(90deg, var(--line-2) 1px, transparent 1px); background-size: calc(100% / 16) 100%; }
.gantt .g-blk { position: absolute; top: 5px; height: 26px; border-radius: 6px; padding: 3px 6px; font-size: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--ink); background: var(--info-bg); border: 1px solid color-mix(in srgb, var(--info) 30%, transparent); cursor: pointer; }
.gantt .g-blk.p1 { background: var(--crit-bg); border-color: color-mix(in srgb, var(--crit) 35%, transparent); }
.gantt .g-blk.ppm { background: var(--accent-soft); border-color: var(--accent-line); }
.gantt .g-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--crit); opacity: .7; }
.gantt .g-heat { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--warn-dot) 16%, transparent) 0 6px, transparent 6px 12px); }

/* ---------- Technician phone ---------- */
.phone-stage { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 24px; align-items: start; padding: 24px 20px 40px; background: radial-gradient(circle at 50% 0%, var(--surface-3), var(--bg) 60%); }
.phone-side { max-width: 320px; justify-self: end; display: grid; gap: 12px; padding-top: 30px; }
.phone-side.right { justify-self: start; }
.phone { width: 390px; height: min(844px, calc(100vh - 48px)); border-radius: 44px; border: 11px solid #0d1a1d; background: var(--bg); box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(255,255,255,.04); overflow: hidden; display: flex; flex-direction: column; position: relative; }
.phone::before { content: ''; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 110px; height: 28px; background: #0d1a1d; border-radius: 16px; z-index: 5; }
.ph-status { height: 44px; flex: none; display: flex; align-items: flex-end; justify-content: space-between; padding: 0 26px 4px; font: 600 12.5px var(--f-ui); color: var(--ink); background: var(--surface); }
.ph-head { flex: none; background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 14px 10px; display: grid; gap: 6px; }
.ph-head .row { flex-wrap: nowrap; }
.ph-title { font: 700 19px/1.1 var(--f-disp); }
.ph-scroll { flex: 1; overflow: auto; padding: 12px; display: grid; gap: 10px; align-content: start; }
.ph-tabs { flex: none; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); background: var(--surface); padding-bottom: 14px; }
.ph-tabs button { border: 0; background: none; padding: 8px 4px 4px; display: grid; justify-items: center; gap: 2px; font-size: 11px; color: var(--muted); cursor: pointer; position: relative; }
.ph-tabs button.active { color: var(--accent); font-weight: 600; }
.ph-tabs .count { position: absolute; top: 4px; right: 22%; background: var(--crit); color: #fff; border-radius: 8px; font-size: 10px; padding: 1px 5px; }
.tcard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 8px; }
.tcard.p1 { border-color: color-mix(in srgb, var(--crit) 50%, var(--line)); box-shadow: inset 4px 0 0 var(--crit); }
.tcard.active-job { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.bigbtn { height: 50px; border-radius: 12px; font-size: 15.5px; font-weight: 600; width: 100%; justify-content: center; }
.ph-offline { background: var(--warn-bg); color: var(--warn); font-size: 12.5px; padding: 8px 12px; display: flex; gap: 8px; align-items: center; }
.sigpad { width: 100%; height: 150px; border: 1.5px dashed var(--line); border-radius: 10px; background: #fff; touch-action: none; display: block; }
.steps { display: flex; gap: 4px; }
.steps span { flex: 1; height: 4px; border-radius: 3px; background: var(--surface-3); }
.steps span.on { background: var(--accent); }
@media (max-width: 1100px) { .phone-stage { grid-template-columns: minmax(0, 1fr); justify-items: center; } .phone-side { justify-self: center; max-width: 390px; width: 100%; padding-top: 0; } .phone-side.left { order: 2; } .phone-side.right { order: 3; } }
@media (max-width: 520px) {
  .phone-stage { padding: 0; gap: 0; background: var(--bg); display: block; }
  .phone { width: 100%; height: 100vh; height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
  .phone::before { display: none; }
  .ph-status { display: none; }
  .phone-side { display: none; }
}

/* ---------- Portal / vendor / tenant ---------- */
.portal { min-height: 100%; display: flex; flex-direction: column; }
.portal-top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; }
.portal-bar { max-width: 1180px; margin: 0 auto; padding: 10px 20px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.portal-brand { display: flex; gap: 10px; align-items: center; min-width: 0; }
.portal-brand .pb-n { font: 700 18px/1.1 var(--f-disp); }
.portal-brand .pb-s { font-size: 11.5px; color: var(--muted); }
.portal-nav { max-width: 1180px; margin: 0 auto; padding: 0 20px; display: flex; gap: 2px; overflow-x: auto; }
.portal-nav a { padding: 9px 12px; text-decoration: none; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.portal-nav a.active { color: var(--accent-2); border-bottom-color: var(--accent); }
.portal-main { max-width: 1180px; width: 100%; margin: 0 auto; padding: 20px 20px 48px; }
@media (max-width: 640px) { .portal-bar, .portal-nav, .portal-main { padding-left: 16px; padding-right: 16px; } }
.tenant { max-width: 560px; margin: 0 auto; padding: 16px 16px 48px; display: grid; gap: 14px; }

/* ---------- Tracking page ---------- */
.track { max-width: 620px; margin: 0 auto; padding: 20px 16px 48px; display: grid; gap: 14px; }
.track-hero { background: var(--side-bg); color: var(--side-ink); border-radius: 16px; padding: 18px; display: grid; gap: 10px; }
.track-hero h1 { color: #fff; font-size: 24px; }
.track-steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.track-steps div { display: grid; gap: 5px; font-size: 11.5px; color: var(--side-muted); }
.track-steps div i { height: 5px; border-radius: 3px; background: var(--side-line); }
.track-steps div.on { color: #fff; }
.track-steps div.on i { background: #3db4ae; }

/* ---------- WhatsApp ---------- */
.wa { display: grid; grid-template-columns: 300px minmax(0, 1fr) 330px; gap: 14px; align-items: start; }
@media (max-width: 1280px) { .wa { grid-template-columns: 280px minmax(0, 1fr); } .wa .wa-ai { grid-column: 1 / -1; } }
@media (max-width: 820px) { .wa { grid-template-columns: minmax(0, 1fr); } }
.wa-chat { display: flex; flex-direction: column; height: min(640px, calc(100vh - 200px)); min-height: 420px; }
.wa-msgs { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: color-mix(in srgb, var(--surface-3) 70%, var(--surface)); }
.bubble { max-width: 78%; padding: 7px 10px 5px; border-radius: 10px; font-size: 13.5px; box-shadow: 0 1px 1px rgba(0,0,0,.06); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.in { align-self: flex-start; background: var(--surface); border-top-left-radius: 3px; }
.bubble.out { align-self: flex-end; background: color-mix(in srgb, #25d366 18%, var(--surface)); border-top-right-radius: 3px; }
.bubble.out.agent { background: color-mix(in srgb, var(--info) 16%, var(--surface)); }
.bubble .meta { font-size: 10.5px; color: var(--muted); text-align: right; margin-top: 2px; display: flex; gap: 6px; justify-content: flex-end; }
.bubble img { border-radius: 7px; margin-bottom: 4px; max-width: 220px; display: block; }
.bubble .who { font-size: 10.5px; font-weight: 600; color: var(--accent-2); margin-bottom: 2px; }
.wa-compose { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.wa-compose input[type=text] { flex: 1; min-width: 160px; height: 38px; border: 1px solid var(--line); border-radius: 20px; padding: 0 14px; background: var(--surface-2); }
.samples { display: flex; gap: 6px; flex-wrap: wrap; }
.samples button { border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 4px 10px; font-size: 12px; cursor: pointer; text-align: left; }
.samples button:hover { border-color: var(--accent-line); }

/* ---------- Documents (job report, invoice) ---------- */
.doc { background: #fff; color: #111; border-radius: 6px; padding: 28px 32px; box-shadow: var(--shadow); border: 1px solid var(--line); font-size: 12.5px; max-width: 880px; margin: 0 auto; }
.doc h1 { font: 700 24px var(--f-disp); color: #111; }
.doc .muted { color: #666; }
.doc table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.doc th { text-align: left; font-size: 11px; color: #555; border-bottom: 1.5px solid #222; padding: 6px 4px; }
.doc td { border-bottom: 1px solid #ddd; padding: 6px 4px; vertical-align: top; }
.doc .tot td { border: 0; padding: 3px 4px; }
.doc .tot tr:last-child td { font-weight: 700; font-size: 14px; border-top: 1.5px solid #222; }
.doc .doc-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; border-bottom: 2px solid #0b6e6e; padding-bottom: 12px; margin-bottom: 14px; }
.doc .doc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; }
.doc .doc-box { border: 1px solid #ddd; border-radius: 6px; padding: 10px; }
.doc .photos { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.doc .photo { border-color: #ddd; background: #f6f6f6; }
.doc .photo .cap { color: #333; }
.doc .stamp { display: inline-block; border: 2px solid #1d7a44; color: #1d7a44; border-radius: 6px; padding: 4px 10px; font: 700 13px var(--f-disp); letter-spacing: 1px; transform: rotate(-3deg); }
.doc-wrap { overflow-x: auto; }
@media (max-width: 640px) { .doc { padding: 18px 16px; } .doc .doc-grid { grid-template-columns: 1fr; } }
pre.code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; font: 12px/1.5 var(--f-mono); max-height: 420px; white-space: pre; }

/* ---------- Permission matrix ---------- */
.matrix { border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.matrix th, .matrix td { padding: 6px 8px; border-bottom: 1px solid var(--line-2); text-align: center; white-space: nowrap; }
.matrix th:first-child, .matrix td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.matrix thead th { background: var(--surface-2); position: sticky; top: 0; z-index: 2; }
.pm { width: 22px; height: 22px; border-radius: 5px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: inline-grid; place-items: center; color: transparent; padding: 0; }
.pm.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pm:disabled { cursor: not-allowed; opacity: .6; }

/* ---------- Calendar (PPM) ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--line-2); gap: 1px; }
.cal-h { background: var(--surface-2); padding: 6px 8px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.cal-d { background: var(--surface); min-height: 92px; padding: 6px; display: grid; gap: 3px; align-content: start; min-width: 0; }
.cal-d.other { background: var(--surface-2); }
.cal-d.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-n { font: 500 11.5px var(--f-mono); color: var(--muted); }
.cal-e { font-size: 11px; border-radius: 5px; padding: 2px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; background: var(--surface-3); }
.cal-e.Done { background: var(--ok-bg); color: var(--ok); }
.cal-e.Missed { background: var(--crit-bg); color: var(--crit); }
.cal-e.Released { background: var(--info-bg); color: var(--info); }
@media (max-width: 760px) { .cal-d { min-height: 64px; } .cal-e { font-size: 10px; } }

/* ---------- Scenario lab ---------- */
.scen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.scen { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 8px; align-content: start; box-shadow: var(--shadow); }
.scen .q { font-weight: 600; font-size: 14px; }
.scen ul { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 13px; display: grid; gap: 3px; }
.scen .scen-f { display: flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.scen .ask { font-size: 12.5px; color: var(--muted); font-style: italic; }

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .banner, .no-print, .toasts, .portal-top, .ph-tabs, .modal-foot, .modal-head .btn-icon { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  body, .modal-back { background: #fff !important; }
  .modal-back { position: static; padding: 0; display: block; }
  .modal { box-shadow: none; border: 0; max-height: none; width: 100% !important; }
  .doc { box-shadow: none; border: 0; }
  body.has-modal .app, body.has-modal .portal { display: none; }
}
