/* OpsPilot — prototype styles. Brief §12 (mobile-first, simple for frontline staff). */

/* ---------- Design tokens ---------- */
:root {
  color-scheme: light;
  --font: "Inter", "Noto Sans Devanagari", "Nirmala UI", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --surface-3: #e3e8ee;
  --border: #dde3ea;
  --border-strong: #c6ced9;
  --text: #121a2b;
  --text-2: #3d4757;
  --text-3: #5a6474;
  --ink: #073569;
  --accent: #13ab5b;
  --accent-strong: #0a7a3f;
  --accent-soft: #e3f5ea;
  --primary-bg: #073569;
  --primary-fg: #ffffff;
  --primary-hover: #0b4687;
  --focus: #2a6df4;
  --good: #17804a;   --good-bg: #e2f3e9;
  --warn: #8f5500;   --warn-bg: #fcefd6;
  --serious: #ad420c; --serious-bg: #fde5d8;
  --crit: #bb2129;   --crit-bg: #fce2e2;
  --info: #2459b8;   --info-bg: #e2ebfb;
  --neutral-bg: #ebe9e2;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
  --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95;
  --grid: #e8e5dd;
  --overlay: rgba(12, 16, 32, 0.45);
  --shadow-1: 0 1px 2px rgba(20, 24, 40, 0.06), 0 1px 1px rgba(20, 24, 40, 0.04);
  --shadow-2: 0 10px 30px rgba(20, 24, 40, 0.12), 0 2px 6px rgba(20, 24, 40, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  /* WhatsApp-style chat surface (inside the phone only) */
  --wa-header: #008069; --wa-header-fg: #ffffff;
  --wa-bg: #efeae2; --wa-dot: rgba(0, 0, 0, 0.04);
  --wa-in: #ffffff; --wa-out: #d9fdd3; --wa-text: #111b21; --wa-meta: #667781;
  --wa-btn: #00749e; --wa-tick: #2f9fd6; --wa-composer: #f0f2f5; --wa-input: #ffffff;
  --wa-system: #fff5c4;
  --phone-frame: #141a2c;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #08111f; --surface: #101b2d; --surface-2: #16233a; --surface-3: #1f2e48;
    --border: #23324d; --border-strong: #34476a;
    --text: #eef0f6; --text-2: #bcc2d2; --text-3: #959cb0;
    --ink: #eef0f6; --accent: #2fc874; --accent-strong: #5fdc95; --accent-soft: #10301f;
    --primary-bg: #2fc874; --primary-fg: #06231a; --primary-hover: #5fdc95; --focus: #8fb4ff;
    --good: #55c98b; --good-bg: #11301f; --warn: #e9b553; --warn-bg: #33270e;
    --serious: #f2915e; --serious-bg: #3a1f12; --crit: #ff8080; --crit-bg: #3d1519;
    --info: #86adff; --info-bg: #152443; --neutral-bg: #232b42;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
    --seq-1: #1a2a48; --seq-2: #184f95; --seq-3: #1c5cab; --seq-4: #2a78d6; --seq-5: #5598e7; --seq-6: #86b6ef;
    --grid: #252d44; --overlay: rgba(0, 0, 0, 0.6);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4); --shadow-2: 0 12px 34px rgba(0, 0, 0, 0.5);
    --wa-header: #1f2c34; --wa-header-fg: #e9edef; --wa-bg: #0b141a; --wa-dot: rgba(255, 255, 255, 0.025);
    --wa-in: #202c33; --wa-out: #005c4b; --wa-text: #e9edef; --wa-meta: #8696a0;
    --wa-btn: #53bdeb; --wa-tick: #53bdeb; --wa-composer: #1f2c34; --wa-input: #2a3942; --wa-system: #182229;
    --phone-frame: #05070d;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08111f; --surface: #101b2d; --surface-2: #16233a; --surface-3: #1f2e48;
  --border: #23324d; --border-strong: #34476a;
  --text: #eef0f6; --text-2: #bcc2d2; --text-3: #959cb0;
  --ink: #eef0f6; --accent: #2fc874; --accent-strong: #5fdc95; --accent-soft: #10301f;
  --primary-bg: #2fc874; --primary-fg: #06231a; --primary-hover: #5fdc95; --focus: #8fb4ff;
  --good: #55c98b; --good-bg: #11301f; --warn: #e9b553; --warn-bg: #33270e;
  --serious: #f2915e; --serious-bg: #3a1f12; --crit: #ff8080; --crit-bg: #3d1519;
  --info: #86adff; --info-bg: #152443; --neutral-bg: #232b42;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  --seq-1: #1a2a48; --seq-2: #184f95; --seq-3: #1c5cab; --seq-4: #2a78d6; --seq-5: #5598e7; --seq-6: #86b6ef;
  --grid: #252d44; --overlay: rgba(0, 0, 0, 0.6);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4); --shadow-2: 0 12px 34px rgba(0, 0, 0, 0.5);
  --wa-header: #1f2c34; --wa-header-fg: #e9edef; --wa-bg: #0b141a; --wa-dot: rgba(255, 255, 255, 0.025);
  --wa-in: #202c33; --wa-out: #005c4b; --wa-text: #e9edef; --wa-meta: #8696a0;
  --wa-btn: #53bdeb; --wa-tick: #53bdeb; --wa-composer: #1f2c34; --wa-input: #2a3942; --wa-system: #182229;
  --phone-frame: #05070d;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--text); }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0; }
a { color: var(--info); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; border-radius: 8px; }
.skip:focus { left: 8px; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }
svg.i.lg { width: 22px; height: 22px; }

/* ---------- Buttons & controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 6px 14px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary-bg); color: var(--primary-fg); border-color: transparent; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--crit); }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.select, .input, .textarea {
  min-height: 36px; padding: 6px 10px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); max-width: 100%;
}
.textarea { min-height: 72px; resize: vertical; width: 100%; }
.input { width: 100%; }
label.field { display: block; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; font-weight: 550; color: var(--text-2); min-height: 30px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 36px; height: 20px; border-radius: 20px; background: var(--border-strong); position: relative; transition: background 0.15s; flex: none; }
.switch .track::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .track { background: var(--good); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--neutral-bg); color: var(--text-2); white-space: nowrap; }
.chip.brass { background: var(--accent-soft); color: var(--accent-strong); }
.chip.phase2 { background: var(--info-bg); color: var(--info); }
.chip button { border: 0; background: none; padding: 0; cursor: pointer; color: inherit; display: inline-grid; }

/* Status pills — always icon + word (never colour alone) */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill svg.i { width: 13px; height: 13px; stroke-width: 2.2; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.serious { background: var(--serious-bg); color: var(--serious); }
.pill.crit { background: var(--crit-bg); color: var(--crit); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.neutral { background: var(--neutral-bg); color: var(--text-2); }

/* ---------- App shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: 60px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-width: 0; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-weight: 800; font-size: 11px; letter-spacing: 0.04em; flex: none; }


.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text b { font-size: 14px; letter-spacing: 0.01em; white-space: nowrap; }
.brand-text span { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.demo-badge { font-size: 11px; font-weight: 700; color: var(--accent-strong); background: var(--accent-soft); border-radius: 6px; padding: 2px 7px; white-space: nowrap; }
.clock {
  display: flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
}
.clock-time { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; }
.clock-date { font-size: 12px; color: var(--text-3); margin-right: 4px; }
.role-select { min-width: 0; max-width: 230px; }
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr) 392px; min-height: calc(100vh - 60px); }
.sidebar { border-right: 1px solid var(--border); background: var(--surface); padding: 14px 10px 120px; position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; }
.nav-group { margin-bottom: 14px; }
.nav-label { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; padding: 6px 10px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--text-2); text-decoration: none; font-weight: 550; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }
.nav a .count { margin-left: auto; font-size: 11px; font-weight: 700; padding: 0 7px; border-radius: 999px; background: var(--crit-bg); color: var(--crit); }
.nav a .chip { margin-left: auto; font-size: 10px; padding: 1px 6px; }
.scope-card { margin: 4px 4px 14px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; }
.scope-card b { display: block; font-size: 13px; }
.main { min-width: 0; padding: 22px 24px 140px; }
.dock { border-left: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 60px; height: calc(100vh - 60px); padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.dock-head { display: flex; align-items: center; gap: 8px; }
.dock-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); }
.dock-close { display: none; }
.phone-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.phone-tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 9px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--text-2); font-size: 11px; font-weight: 600; line-height: 1.2; }
.phone-tab:hover { background: var(--surface); }
.phone-tab[aria-selected="true"] { background: var(--surface); border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-1); }
.phone-tab .who { font-size: 10px; font-weight: 500; color: var(--text-3); }
.phone-tab .dot { position: absolute; top: 3px; right: 10px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--good); color: #fff; font-size: 10px; display: grid; place-items: center; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; flex: none; }
.phone-fab { display: none; }

/* ---------- Page layout pieces ---------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-3); margin-top: 4px; max-width: 720px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px 0; flex-wrap: wrap; }
.card-head .hint { color: var(--text-3); font-size: 12px; }
.card-body { padding: 14px 18px 16px; }
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filters .select { font-size: 13px; }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 13px; }
.banner.info { background: var(--info-bg); color: var(--info); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.brass { background: var(--accent-soft); color: var(--accent-strong); }
.banner b { color: inherit; }

/* Stat tiles */
.stat { padding: 14px 16px; }
.stat .label { font-size: 12.5px; color: var(--text-3); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat .foot { font-size: 12px; color: var(--text-3); margin-top: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.stat.clickable { cursor: pointer; text-align: left; width: 100%; font: inherit; color: inherit; }
.stat.clickable:hover { border-color: var(--border-strong); }
.hero { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.hero-num { font-size: 56px; font-weight: 750; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.hero-num small { font-size: 26px; font-weight: 650; color: var(--text-3); }
.delta { font-size: 12.5px; font-weight: 650; display: inline-flex; align-items: center; gap: 3px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--crit); }
.meter { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--good); }
.meter.warn > span { background: var(--warn); }
.meter.crit > span { background: var(--crit); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); font-weight: 650; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.clickable { cursor: pointer; }
table.t tr.clickable:hover td { background: var(--surface-2); }
table.t tr.live td { background: var(--accent-soft); }
table.t td.r, table.t th.r { text-align: right; }
.live-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em; color: var(--accent-strong); }
.live-tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--crit); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.ticks { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.ticks.read { color: var(--info); }
.ticks.fail { color: var(--crit); }

/* Department bars */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 70px; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { position: relative; height: 18px; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--series-1); border-radius: 0 4px 4px 0; max-height: 18px; }
.bar-target { position: absolute; top: -3px; bottom: -3px; width: 0; border-left: 1.5px dashed var(--text-3); }
.bar-row .val { font-weight: 650; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.bar-row .val svg.i { width: 14px; height: 14px; color: var(--warn); }
.bar-row.nodata .val { color: var(--text-3); font-weight: 500; }

/* Heatmap */
.heat { width: 100%; border-collapse: separate; border-spacing: 2px; font-size: 12px; }
.heat th { font-weight: 600; color: var(--text-3); padding: 4px 6px; text-align: left; white-space: nowrap; }
.heat th.col { text-align: center; font-size: 11px; }
.heat td { text-align: center; padding: 0; height: 34px; border-radius: 4px; font-weight: 650; font-variant-numeric: tabular-nums; min-width: 46px; }
.heat td.na { background: var(--surface-2); color: var(--text-3); font-weight: 400; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); align-items: center; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend .ln { width: 16px; height: 0; border-top: 2.5px solid; display: inline-block; border-radius: 2px; }
.legend .dash { width: 16px; height: 0; border-top: 1.5px dashed var(--text-3); display: inline-block; }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .band { fill: var(--good-bg); }
.chart .hairline { stroke: var(--text-3); stroke-width: 1; }
.chart .endlabel { fill: var(--text-2); font-size: 11.5px; font-weight: 600; font-family: var(--font); }
.tooltip { position: fixed; z-index: 90; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 9px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow-2); min-width: 140px; opacity: 0; transition: opacity 0.1s; }
.tooltip.show { opacity: 1; }
.tooltip .tt-title { font-weight: 700; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.tooltip .tt-row span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }

/* Kanban (corrective actions) */
.board { display: grid; grid-template-columns: repeat(6, minmax(190px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px; min-height: 160px; }
.col-head { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; padding: 2px 4px 10px; color: var(--text-2); }
.col-head .n { margin-left: auto; font-size: 11px; color: var(--text-3); }
.ca { display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 11px; margin-bottom: 8px; cursor: pointer; color: var(--text); box-shadow: var(--shadow-1); }
.ca:hover { border-color: var(--border-strong); }
.ca.is-new { border-color: var(--crit); box-shadow: 0 0 0 3px var(--crit-bg); }
.ca .id { font-size: 11px; color: var(--text-3); font-weight: 650; }
.ca .title { font-weight: 600; margin: 3px 0 6px; font-size: 13px; line-height: 1.35; }
.ca .meta { font-size: 11.5px; color: var(--text-3); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.steps { display: flex; gap: 4px; flex-wrap: wrap; }
.step { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }
.step.done { background: var(--good-bg); color: var(--good); border-color: transparent; }
.step.now { background: var(--primary-bg); color: var(--primary-fg); border-color: transparent; }

/* Drawer & modal */
.backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 60; animation: fade 0.15s ease; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 61; box-shadow: var(--shadow-2); display: flex; flex-direction: column; animation: slide 0.2s ease; }
.drawer-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px 24px; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.modal { position: fixed; z-index: 61; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow-y: auto; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-2); animation: fade 0.15s ease; }
.modal-head { padding: 18px 20px 6px; }
.modal-body { padding: 10px 20px 8px; }
.modal-foot { padding: 12px 20px 18px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
dl.kv { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px 12px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--text-3); }
dl.kv dd { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 14px 22px; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline li::after { content: ""; position: absolute; left: 8.5px; top: 16px; bottom: 0; width: 1px; background: var(--border-strong); }
.timeline li:last-child::after { display: none; }
.timeline .t-time { font-size: 11.5px; color: var(--text-3); }

/* Toast */
.toasts { position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-2); font-size: 13px; display: flex; gap: 8px; align-items: center; animation: fade 0.2s ease; }
:root[data-theme="dark"] .toast { background: var(--surface-3); color: var(--text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast { background: var(--surface-3); color: var(--text); } }

/* ---------- Tour ---------- */
.tour { position: fixed; left: 248px; right: 408px; bottom: 16px; z-index: 40; display: none; }
.tour.show { display: block; }
.tour-card { background: var(--ink); color: var(--bg); border-radius: 16px; box-shadow: var(--shadow-2); padding: 14px 16px; display: grid; gap: 10px; }
:root[data-theme="dark"] .tour-card { background: #fbf7ee; color: #141a2c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tour-card { background: #fbf7ee; color: #141a2c; } }
.tour-top { display: flex; align-items: center; gap: 10px; }
.tour-stage { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.75; }
.tour-title { font-size: 17px; font-weight: 700; }
.tour-text { font-size: 13.5px; opacity: 0.92; line-height: 1.5; }
.tour-text b { color: inherit; }
.tour-dots { display: flex; gap: 4px; }
.tour-dots button { width: 26px; height: 6px; border-radius: 6px; border: 0; background: currentColor; opacity: 0.25; cursor: pointer; padding: 0; }
.tour-dots button[aria-current="step"] { opacity: 1; }
.tour-dots button.seen { opacity: 0.55; }
.tour-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tour-card .btn { border-color: rgba(255, 255, 255, 0.25); background: transparent; color: inherit; }
.tour-card .btn:hover { background: rgba(255, 255, 255, 0.1); }
.tour-card .btn.primary { background: var(--accent); color: #06231a; border-color: transparent; }
.tour-card .btn.primary:hover { filter: brightness(1.08); }
:root[data-theme="dark"] .tour-card .btn { border-color: rgba(20, 26, 44, 0.25); }
:root[data-theme="dark"] .tour-card .btn:hover { background: rgba(20, 26, 44, 0.08); }
:root[data-theme="dark"] .tour-card .btn.primary { background: #141a2c; color: #fbf7ee; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tour-card .btn { border-color: rgba(20, 26, 44, 0.25); }
  :root:not([data-theme="light"]) .tour-card .btn:hover { background: rgba(20, 26, 44, 0.08); }
  :root:not([data-theme="light"]) .tour-card .btn.primary { background: #141a2c; color: #fbf7ee; }
}
.tour-card .icon-btn { color: inherit; }
.tour-card .icon-btn:hover { background: rgba(127, 127, 127, 0.18); color: inherit; }
.tour-mini { display: none; }
.highlight { outline: 3px solid var(--accent) !important; outline-offset: 3px; border-radius: 10px; transition: outline-color 0.3s; }

/* ---------- Welcome ---------- */
.welcome { width: min(760px, calc(100vw - 32px)); }
.welcome-hero { padding: 26px 26px 8px; }
.welcome-hero .eyebrow { font-size: 11.5px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-strong); }
.welcome-hero h1 { font-size: 28px; margin: 8px 0 6px; letter-spacing: -0.02em; }
.welcome-hero p { color: var(--text-2); font-size: 15px; max-width: 600px; }
.journey { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 16px 26px 6px; counter-reset: j; }
.journey div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 11px; font-size: 12.5px; color: var(--text-2); }
.journey b { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; margin-bottom: 2px; }
.journey b::before { counter-increment: j; content: counter(j); width: 20px; height: 20px; border-radius: 50%; background: var(--primary-bg); color: var(--primary-fg); font-size: 11px; display: inline-grid; place-items: center; flex: none; }
.welcome-foot { padding: 16px 26px 24px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- Phone + WhatsApp-style chat ---------- */
.phone {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  border-radius: 34px; border: 9px solid var(--phone-frame); background: var(--phone-frame);
  overflow: hidden; box-shadow: var(--shadow-2); max-width: 360px; width: 100%; margin: 0 auto; position: relative;
}
.p-status { display: flex; align-items: center; justify-content: space-between; padding: 6px 18px 4px; font-size: 12px; font-weight: 650; background: var(--wa-header); color: var(--wa-header-fg); font-variant-numeric: tabular-nums; }
.p-status .notch { width: 70px; height: 18px; border-radius: 12px; background: var(--phone-frame); }
.p-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px 10px; background: var(--wa-header); color: var(--wa-header-fg); }
.p-head .mark { width: 36px; height: 36px; border-radius: 50%; background: #fff; flex: none; }
.p-head .name { font-weight: 650; font-size: 14.5px; line-height: 1.2; }
.p-head .sub { font-size: 11.5px; opacity: 0.85; }
.chat {
  flex: 1; overflow-y: auto; padding: 10px 10px 8px; background-color: var(--wa-bg);
  background-image: radial-gradient(var(--wa-dot) 1.2px, transparent 1.2px); background-size: 14px 14px;
  display: flex; flex-direction: column; gap: 6px; scroll-behavior: smooth;
}
.day-sep { align-self: center; font-size: 11.5px; background: var(--wa-in); color: var(--wa-meta); padding: 3px 10px; border-radius: 8px; box-shadow: var(--shadow-1); margin: 4px 0; }
.sys-note { align-self: center; text-align: center; font-size: 11.5px; background: var(--wa-system); color: var(--wa-text); padding: 5px 10px; border-radius: 8px; max-width: 92%; }
.msg { max-width: 86%; display: flex; flex-direction: column; gap: 2px; }
.msg.new { animation: pop 0.18s ease; }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; }
.bubble { position: relative; padding: 6px 9px 18px; border-radius: 10px; font-size: 13.5px; line-height: 1.42; color: var(--wa-text); box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13); white-space: pre-wrap; word-wrap: break-word; min-width: 84px; }
.msg.in .bubble { background: var(--wa-in); border-top-left-radius: 3px; }
.msg.out .bubble { background: var(--wa-out); border-top-right-radius: 3px; }
.bubble b { font-weight: 700; color: inherit; }
.bubble .meta { position: absolute; right: 8px; bottom: 3px; font-size: 10.5px; color: var(--wa-meta); display: flex; align-items: center; gap: 3px; }
.bubble .meta svg.i { width: 15px; height: 15px; stroke-width: 2; }
.bubble .meta .tk { color: var(--wa-tick); display: inline-flex; }
.bubble .tag { display: block; font-size: 10.5px; color: var(--wa-meta); margin-top: 4px; }
.bubble.flag { box-shadow: inset 3px 0 0 var(--crit), 0 1px 0.5px rgba(0, 0, 0, 0.13); }
.bubble .tpl-head { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.bubble .tpl-foot { display: block; font-size: 11.5px; color: var(--wa-meta); margin-top: 6px; }
.wa-btns { display: grid; gap: 2px; }
.wa-btn { background: var(--wa-in); color: var(--wa-btn); border: 0; border-radius: 8px; padding: 9px 8px; font-weight: 600; font-size: 13.5px; cursor: pointer; box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13); display: flex; align-items: center; justify-content: center; gap: 6px; }
.wa-btn:hover:not([disabled]) { filter: brightness(0.97); }
.wa-btn[disabled] { cursor: default; color: var(--wa-meta); }
.wa-btn.chosen { color: var(--wa-btn); }
.wa-btn.chosen::after { content: "✓"; font-weight: 800; }
.photo-bubble { padding: 3px 3px 18px; }
.photo { position: relative; width: 210px; height: 150px; border-radius: 8px; overflow: hidden; display: block; }
.photo .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 5px; font-size: 10.5px; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, 0.55)); text-align: left; }
.photo svg { width: 100%; height: 100%; display: block; }
.photo-bubble .caption { padding: 4px 6px 0; font-size: 13px; white-space: pre-wrap; }
.link-card { display: block; margin: 6px 0 2px; border-radius: 8px; overflow: hidden; background: rgba(127, 127, 127, 0.12); text-decoration: none; color: var(--wa-text); }
.link-card .lc-body { padding: 8px 10px; font-size: 12px; }
.link-card .lc-body b { font-size: 13px; display: block; }
.link-card .lc-body span { color: var(--wa-meta); }
.typing { align-self: flex-start; background: var(--wa-in); border-radius: 10px; padding: 9px 12px; display: flex; gap: 4px; box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13); }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--wa-meta); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }
.p-demo { display: flex; gap: 6px; padding: 6px 8px; background: var(--wa-composer); border-top: 1px solid rgba(127, 127, 127, 0.15); overflow-x: auto; }
.p-demo .lbl { font-size: 10.5px; font-weight: 700; color: var(--wa-meta); align-self: center; white-space: nowrap; text-transform: uppercase; letter-spacing: 0.05em; }
.p-demo button { flex: none; border: 1px dashed var(--wa-meta); background: transparent; color: var(--wa-text); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.p-demo button:hover:not([disabled]) { background: rgba(127, 127, 127, 0.12); }
.p-demo button[disabled] { opacity: 0.45; cursor: not-allowed; }
.composer { display: flex; align-items: center; gap: 6px; padding: 6px 8px 10px; background: var(--wa-composer); }
.composer .c-input { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; background: var(--wa-input); border-radius: 22px; padding: 0 6px 0 4px; }
.composer input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 9px 4px; color: var(--wa-text); outline: none; font-size: 14px; }
.composer input::placeholder { color: var(--wa-meta); }
.composer .c-icon { border: 0; background: transparent; color: var(--wa-meta); cursor: pointer; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; }
.composer .c-send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: #00a884; color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.composer .c-send svg.i, .composer .c-icon svg.i { width: 20px; height: 20px; }
.composer .c-input:focus-within { box-shadow: 0 0 0 2px var(--focus); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; background: var(--wa-in); color: var(--wa-text); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.25); padding: 12px 12px 16px; z-index: 5; animation: up 0.18s ease; max-height: 80%; overflow-y: auto; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h4 { color: var(--wa-text); font-size: 14px; margin-bottom: 8px; display: flex; align-items: center; }
.sheet .gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.sheet .gallery button { border: 0; padding: 0; cursor: pointer; border-radius: 6px; overflow: hidden; height: 74px; position: relative; }
.sheet .gallery button svg { width: 100%; height: 100%; display: block; }
.sheet .gallery button span { position: absolute; left: 0; right: 0; bottom: 0; font-size: 9.5px; color: #fff; background: rgba(0, 0, 0, 0.5); padding: 2px 4px; text-align: left; }
.sheet .note { font-size: 11px; color: var(--wa-meta); margin-top: 8px; }
.sheet .list-opt { display: flex; width: 100%; align-items: center; justify-content: space-between; padding: 11px 6px; border: 0; border-bottom: 1px solid rgba(127, 127, 127, 0.2); background: none; color: var(--wa-text); cursor: pointer; font-size: 14px; text-align: left; }
.webview { position: absolute; inset: 0; z-index: 6; background: var(--surface); color: var(--text); display: flex; flex-direction: column; animation: up 0.2s ease; }
.wv-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 12px; }
.wv-bar .url { flex: 1; min-width: 0; display: flex; align-items: center; gap: 5px; background: var(--surface); border-radius: 8px; padding: 5px 8px; color: var(--text-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.wv-bar .url svg.i { color: var(--good); width: 14px; height: 14px; }
.wv-body { flex: 1; overflow-y: auto; }
.phone-empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--wa-meta); padding: 20px; font-size: 13px; }

/* ---------- Report (mobile report page & PDF) ---------- */
.report { padding: 16px; font-size: 13px; }
.report.wide { padding: 0; }
.r-head { display: flex; gap: 10px; align-items: flex-start; }
.r-head .logo { width: 30px; height: 30px; border-radius: 8px; flex: none; }
.r-title { font-size: 17px; font-weight: 700; line-height: 1.25; }
.r-sub { color: var(--text-3); font-size: 12px; }
.r-score { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.r-score div { background: var(--surface-2); border-radius: 10px; padding: 9px 10px; }
.r-score b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.r-score span { font-size: 11.5px; color: var(--text-3); }
.r-section { margin-top: 16px; }
.r-section > h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); margin-bottom: 6px; }
.r-item { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--border); align-items: start; }
.r-item:last-child { border-bottom: 0; }
.r-item .ic { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; }
.r-item .ic svg.i { width: 13px; height: 13px; stroke-width: 2.6; }
.r-item .ic.ok { background: var(--good-bg); color: var(--good); }
.r-item .ic.bad { background: var(--crit-bg); color: var(--crit); }
.r-item .ic.na { background: var(--neutral-bg); color: var(--text-3); }
.r-item .q { font-weight: 600; }
.r-item .a { color: var(--text-2); font-size: 12.5px; }
.r-item .time { font-size: 11.5px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.r-photos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.r-photos .photo { width: 92px; height: 68px; border-radius: 6px; }
.r-photos .photo .cap { font-size: 8.5px; padding: 8px 4px 3px; }
.r-meta { font-size: 11.5px; color: var(--text-3); border-top: 1px solid var(--border); margin-top: 16px; padding-top: 10px; line-height: 1.6; }
.r-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.dept-mini { display: grid; gap: 7px; }
.dept-mini .bar-row { grid-template-columns: 110px minmax(0, 1fr) 50px; font-size: 12px; }

/* ---------- SOP builder ---------- */
.builder { display: grid; grid-template-columns: 230px minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.sop-list { display: grid; gap: 2px; }
.sop-list .dept { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; padding: 10px 8px 4px; }
.sop-list button { text-align: left; border: 0; background: transparent; padding: 7px 8px; border-radius: 8px; cursor: pointer; color: var(--text-2); font-weight: 550; font-size: 13px; display: flex; justify-content: space-between; gap: 6px; }
.sop-list button:hover { background: var(--surface-2); }
.sop-list button[aria-current="true"] { background: var(--accent-soft); color: var(--accent-strong); }
.q-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; margin-bottom: 6px; width: 100%; text-align: left; color: var(--text); }
.q-row:hover { border-color: var(--border-strong); }
.q-row[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.q-row .n { width: 24px; height: 24px; border-radius: 7px; background: var(--surface-2); display: grid; place-items: center; font-size: 11.5px; font-weight: 700; color: var(--text-2); }
.q-row .qt { font-weight: 600; }
.q-row .qs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.q-edit { border: 1px solid var(--accent); border-radius: 10px; padding: 14px; margin: -2px 0 10px; background: var(--surface); display: grid; gap: 12px; }
.q-edit .g-2 { gap: 10px; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.type-grid button { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 7px 9px; cursor: pointer; font-size: 12.5px; color: var(--text-2); text-align: left; }
.type-grid button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); font-weight: 650; }
.preview-phone { border-radius: 24px; border: 7px solid var(--phone-frame); overflow: hidden; position: sticky; top: 76px; }
.preview-phone .chat { min-height: 340px; max-height: 480px; }

/* Schedules */
.ladder { display: grid; gap: 0; }
.ladder-step { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; position: relative; }
.ladder-step .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); z-index: 1; }
.ladder-step.crit .dot { background: var(--crit-bg); color: var(--crit); border-color: transparent; }
.ladder-step::before { content: ""; position: absolute; left: 15px; top: 0; bottom: 0; width: 1px; background: var(--border-strong); }
.ladder-step:first-child::before { top: 50%; }
.ladder-step:last-child::before { bottom: 50%; }
.ladder-step input { width: 64px; text-align: right; }
.weekday { display: flex; gap: 4px; flex-wrap: wrap; }
.weekday button { width: 38px; height: 34px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 12px; color: var(--text-2); }
.weekday button[aria-pressed="true"] { background: var(--primary-bg); color: var(--primary-fg); border-color: transparent; }

/* Setup tree */
.tree { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.tree ul { list-style: none; margin: 0; padding-left: 16px; border-left: 1px solid var(--border); margin-left: 9px; }
.tree li { margin: 2px 0; }
.tree button { display: flex; align-items: center; gap: 6px; width: 100%; text-align: left; border: 0; background: transparent; padding: 5px 8px; border-radius: 7px; cursor: pointer; color: var(--text-2); }
.tree button:hover { background: var(--surface-2); }
.tree button[aria-current="true"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 650; }
.lock-note { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--text-3); }

/* Photo placeholders grid */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.photo-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.photo-card .photo { width: 100%; height: 120px; border-radius: 0; }
.photo-card .pc-body { padding: 8px 10px; font-size: 12px; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty svg.i { width: 32px; height: 32px; margin-bottom: 8px; }

/* Print: the PDF export only prints the report */
#print-root { display: none; }
@media print {
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block; }
  body.printing { background: #fff; color: #000; }
  #print-root .report { padding: 0; }
  #print-root .r-actions { display: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .shell { grid-template-columns: 210px minmax(0, 1fr) 372px; }
  .tour { left: 226px; right: 388px; }
}
@media (max-width: 1080px) {
  .shell { grid-template-columns: 200px minmax(0, 1fr); }
  .dock { display: none; position: fixed; inset: 0; z-index: 50; height: auto; top: 0; border: 0; padding: 12px 12px 16px; background: var(--surface-2); }
  .dock.open { display: flex; }
  .dock-close { display: inline-grid; margin-left: auto; }
  .phone { max-width: 400px; }
  .phone-fab { display: inline-flex; position: fixed; right: 16px; bottom: 16px; z-index: 45; box-shadow: var(--shadow-2); border-radius: 999px; min-height: 48px; padding: 0 18px; }
  .phone-fab .dot { min-width: 18px; height: 18px; border-radius: 999px; background: var(--good); color: #fff; font-size: 11px; display: grid; place-items: center; padding: 0 5px; }
  .tour { left: 216px; right: 16px; bottom: 76px; }
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .topbar { gap: 8px; padding: 0 12px; }
  .brand-text span, .clock-date, .demo-badge { display: none; }
  .topbar .menu-btn { display: inline-grid !important; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; position: fixed; inset: 60px 0 0 0; z-index: 35; height: auto; width: min(300px, 86vw); box-shadow: var(--shadow-2); }
  .sidebar.open { display: block; }
  .main { padding: 16px 16px 200px; }
  .tour { left: 12px; right: 12px; bottom: 74px; }
  .g-2, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .journey { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 14px 18px 4px; }
  .welcome-hero { padding: 20px 18px 4px; }
  .welcome-hero h1 { font-size: 23px; }
  .welcome-foot { padding: 14px 18px 20px; }
  .bar-row { grid-template-columns: 110px minmax(0, 1fr) 60px; }
  dl.kv { grid-template-columns: 110px minmax(0, 1fr); }
  .hero-num { font-size: 48px; }
  .role-select { max-width: 150px; }
  .tour-text { font-size: 13px; }
  .tour-card { padding: 12px 14px; }
}
@media (max-width: 480px) {
  .clock .btn-label { display: none; }
  .role-select { max-width: 112px; font-size: 12px; }
  .g-4 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .stat .value { font-size: 23px; }
  .page-head .actions { margin-left: 0; }
  .tour-collapsible.collapsed .tour-text, .tour-collapsible.collapsed .tour-dots { display: none; }
}
.menu-btn { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ---------- Additions: heatmap steps, 4th series, tour over the phone on small screens ---------- */
:root { --series-4: #eda100; --heat-ink-light: #151824; --heat-ink-dark: #ffffff; }
:root[data-theme="dark"] { --series-4: #c98500; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --series-4: #c98500; } }
.heat td.h1 { background: var(--seq-1); color: var(--heat-ink-light); }
.heat td.h2 { background: var(--seq-2); color: var(--heat-ink-light); }
.heat td.h3 { background: var(--seq-3); color: var(--heat-ink-light); }
.heat td.h4 { background: var(--seq-4); color: var(--heat-ink-dark); }
.heat td.h5 { background: var(--seq-5); color: var(--heat-ink-dark); }
.heat td.h6 { background: var(--seq-6); color: var(--heat-ink-dark); }
:root[data-theme="dark"] .heat td.h1, :root[data-theme="dark"] .heat td.h2, :root[data-theme="dark"] .heat td.h3, :root[data-theme="dark"] .heat td.h4 { color: #ffffff; }
:root[data-theme="dark"] .heat td.h5, :root[data-theme="dark"] .heat td.h6 { color: #0c1020; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .heat td.h1, :root:not([data-theme="light"]) .heat td.h2, :root:not([data-theme="light"]) .heat td.h3, :root:not([data-theme="light"]) .heat td.h4 { color: #ffffff; }
  :root:not([data-theme="light"]) .heat td.h5, :root:not([data-theme="light"]) .heat td.h6 { color: #0c1020; }
}
.tour { z-index: 55; }
@media (max-width: 1080px) {
  body.dock-open .tour { top: 8px; bottom: auto; left: 12px; right: 12px; }
  body.dock-open .tour .tour-text { max-height: 96px; overflow-y: auto; }
  body.dock-open .phone-fab { display: none; }
}
@media (max-width: 820px) {
  #setup-grid { grid-template-columns: minmax(0, 1fr) !important; }
  #dash-top { grid-template-columns: minmax(0, 1fr) !important; }
}
.q-row .qt { overflow-wrap: anywhere; }

/* ---------- Layout follows the content column width (phone dock takes space on desktop) ---------- */
.main { container-type: inline-size; container-name: main; }
.sop-pick { display: none; width: 100%; margin-bottom: 12px; }
@container main (max-width: 1100px) {
  .builder { grid-template-columns: minmax(0, 1fr) 280px; }
  .builder > nav.sop-list { display: none; }
  .sop-pick { display: block; }
  .sched-bottom { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sched-bottom > :first-child { grid-row: span 2; }
}
@container main (max-width: 960px) {
  .g-main { grid-template-columns: minmax(0, 1fr); }
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container main (max-width: 720px) {
  .builder { grid-template-columns: minmax(0, 1fr); }
  .preview-phone { position: static; max-width: 340px; }
  .g-2, .g-3, .sched-bottom { grid-template-columns: minmax(0, 1fr); }
  .sched-bottom > :first-child { grid-row: auto; }
  #setup-grid, #dash-top { grid-template-columns: minmax(0, 1fr) !important; }
}
/* Needs-attention items */
.att { display: block; width: 100%; text-align: left; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 10px 12px; margin-bottom: 8px; cursor: pointer; color: var(--text); font: inherit; }
.att:hover { border-color: var(--border-strong); }
.att .t { display: block; font-weight: 600; margin: 6px 0 2px; }
.att .m { display: block; font-size: 12px; color: var(--text-3); }
/* Desktop: presenter can hide the phone to give screens more room */
.dock-close { display: inline-grid; margin-left: auto; }
@media (min-width: 1081px) {
  body.dock-collapsed .shell { grid-template-columns: 232px minmax(0, 1fr); }
  body.dock-collapsed .dock { display: none; }
  body.dock-collapsed .phone-fab { display: inline-flex; position: fixed; right: 16px; bottom: 16px; z-index: 45; box-shadow: var(--shadow-2); border-radius: 999px; min-height: 48px; padding: 0 18px; }
  body.dock-collapsed .phone-fab .dot { min-width: 18px; height: 18px; border-radius: 999px; background: var(--good); color: #fff; font-size: 11px; display: grid; place-items: center; padding: 0 5px; }
  body.dock-collapsed .tour { right: 200px; }
}

/* ---------- Phone-width top bar: two rows ---------- */
@media (max-width: 600px) {
  .topbar { height: auto; min-height: 60px; flex-wrap: wrap; padding: 8px 12px; row-gap: 8px; }
  .topbar > .spacer { display: none; }
  .brand { flex: 1 1 auto; }
  .brand-text span { display: none; }
  .clock { order: 10; flex: 1 1 auto; justify-content: space-between; }
  .role-select { order: 11; flex: 1 1 150px; max-width: none !important; }
  .topbar .btn-label { display: none; }
  .sidebar { inset: 104px 0 0 0; }
}
@media (max-width: 400px) { .brand-text { display: none; } }

@container main (max-width: 1100px) { #setup-grid { grid-template-columns: 200px minmax(0, 1fr) !important; } }
#setup-grid table.t { min-width: 620px; }
@container main (max-width: 720px) { #setup-grid { grid-template-columns: minmax(0, 1fr) !important; } }

/* ---------- OpsPilot brand ---------- */
.brand-logo { height: 26px; width: auto; display: block; flex: none; }
.brand-mark-img { display: none; width: 34px; height: 34px; border-radius: 9px; flex: none; }
.brand-text span { line-height: 1.25; border-left: 1px solid var(--border); padding-left: 10px; }
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: block; }
}
.welcome-logo { height: 64px; width: auto; margin-bottom: 14px; }
@media (max-width: 600px) {
  .brand-logo { display: none !important; }
  .brand-mark-img { display: block; }
  .welcome-logo { height: 46px; }
}
@media (max-width: 1280px) { .brand-text { display: none; } }

/* Staff language switch (phone demo bar) */
.lang-seg { display: inline-flex; flex: none; border: 1px solid var(--wa-meta); border-radius: 999px; overflow: hidden; }
.p-demo .lang-seg button { border: 0; border-radius: 0; padding: 4px 9px; font-size: 12px; }
.p-demo .lang-seg button[aria-pressed="true"] { background: var(--wa-header); color: var(--wa-header-fg); }
.p-demo { flex-wrap: wrap; row-gap: 4px; }
[lang="hi"], .hi-text { font-family: "Noto Sans Devanagari", "Nirmala UI", var(--font); }

.seg.nowrap { flex-wrap: nowrap; }
.seg.nowrap button { padding: 4px 10px; min-height: 28px; }
.chip.crit { background: var(--crit-bg); color: var(--crit); }

/* Real evidence photos */
.photo img, .sheet .gallery button img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Corrections, property-specific limits */
.corr { font-size: 12.5px; color: var(--warn); background: var(--warn-bg); border-radius: 6px; padding: 5px 8px; margin-top: 5px; line-height: 1.45; }
.ov-t td, .ov-t th { padding: 6px 8px; }
.ov-t input { min-width: 72px; min-height: 32px; }
