/* Safetylink Command Centre design system. Ported from reference/mock/css/styles.css (the approved mock). Keep the tokens and components identical; additions for the live app are at the end. */
:root {
  --ink: #1F2328; --muted: #6B7280; --line: #E5E7EB; --surface: #FFFFFF; --canvas: #F6F7F9;
  --accent: #C8102E; --accent-soft: #FBE9EC;
  --ok: #1F8A5B; --ok-soft: #E6F4EC; --warn: #C27C0E; --warn-soft: #FBF1DF; --bad: #C8102E; --bad-soft: #FBE9EC; --idle: #9CA3AF; --idle-soft: #F1F2F4;
  --info: #2563EB; --info-soft: #E8EFFD;
  --sidebar: 232px; --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-lg: 0 10px 30px rgba(16,24,40,.16);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; font-size: 14px; line-height: 1.45; color: var(--ink); background: var(--canvas); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14px; } h4 { font-size: 13px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; } .mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.grow { flex: 1; }

/* ---------- app frame ---------- */
#app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #E6E8EB; padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 8px; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand .name { font-weight: 600; font-size: 14px; color: #fff; line-height: 1.2; }
.brand .sub { font-size: 11px; color: #9CA3AF; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #8B929C; padding: 12px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #D1D5DB; text-decoration: none; font-size: 13.5px; }
.nav a svg { width: 17px; height: 17px; color: #9CA3AF; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--accent); color: #fff; }
.nav a.active svg { color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .foot { font-size: 11px; color: #8B929C; padding: 10px 10px 0; border-top: 1px solid rgba(255,255,255,.08); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); padding: 0 28px; height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px; position: sticky; top: 0; z-index: 20; }
.topbar .title { display: flex; align-items: center; gap: 12px; }
.topbar .crumbs { color: var(--muted); font-size: 13px; }
.topbar .crumbs a { color: var(--muted); text-decoration: none; }
.topbar .crumbs a:hover { text-decoration: underline; }
.content { padding: 24px 28px 40px; max-width: 1440px; width: 100%; margin: 0 auto; }
.footer { padding: 14px 28px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); background: var(--surface); margin-top: auto; }

.demo-tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; background: var(--canvas); }
.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; font-size: 13px; color: var(--muted); }
.seg button.active { background: var(--ink); color: #fff; }
.role-switch { position: relative; }
.role-btn { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px 4px 4px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.role-btn .who { text-align: left; line-height: 1.15; }
.role-btn .who b { display: block; font-size: 13px; font-weight: 600; }
.role-btn .who span { font-size: 11px; color: var(--muted); }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); min-width: 300px; padding: 6px; z-index: 50; }
.menu .menu-h { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 10px 4px; }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 8px; }
.menu button:hover { background: var(--canvas); }
.menu button.active { background: var(--accent-soft); }
.menu button .who b { display: block; font-size: 13px; font-weight: 600; } .menu button .who span { font-size: 11.5px; color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* ---------- cards, tiles ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card.tight { padding: 14px 16px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-h h2 { font-size: 15px; }
.card-h .hint { color: var(--muted); font-size: 12.5px; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.c6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid.main-side { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.grid.side-main { grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
@media (max-width: 1200px) { .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.c6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid.main-side { grid-template-columns: 1fr; } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-height: 96px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.kpi .label { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kpi .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.kpi .value .metric { font-size: inherit; font-weight: inherit; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.compact .value { font-size: 20px; }
.tile-link { display: block; text-decoration: none; color: inherit; }
.tile-link:hover .card { border-color: #C9CDD3; box-shadow: var(--shadow); }

/* ---------- metric button ---------- */
.metric { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; text-decoration: none; border-bottom: 1px solid transparent; border-radius: 2px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.metric:hover, .metric:focus-visible { border-bottom-color: var(--accent); color: var(--accent); outline: none; }
.metric.bad { color: var(--bad); } .metric.ok { color: var(--ok); } .metric.warn { color: var(--warn); }
.audit-bad { outline: 2px solid var(--bad) !important; outline-offset: 1px; background: #FFF0F2; }

/* ---------- status pill ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; line-height: 1.5; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.idle { background: var(--idle-soft); color: #5B6472; }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.plain::before { display: none; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 500; line-height: 1.2; white-space: nowrap; }
.btn:hover { background: var(--canvas); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #A80D26; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--canvas); color: var(--ink); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.ok { color: var(--ok); border-color: #BFE3CF; } .btn.ok:hover { background: var(--ok-soft); }
.btn.danger { color: var(--bad); border-color: #F1C2CA; } .btn.danger:hover { background: var(--bad-soft); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--canvas); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: 13.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .count { display: inline-block; margin-left: 6px; font-size: 11px; color: var(--muted); background: var(--canvas); border-radius: 999px; padding: 0 6px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: bottom; user-select: none; }
table.data th.sortable { cursor: pointer; } table.data th.sortable:hover { color: var(--ink); }
table.data td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover td { background: var(--canvas); }
table.data tr.total td { font-weight: 600; border-top: 2px solid var(--line); background: var(--canvas); }
table.data .sub { display: block; color: var(--muted); font-size: 11.5px; }
.table-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.table-tools input, .table-tools select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; background: var(--surface); }
.table-tools input { min-width: 200px; }
.view-all { margin-top: 8px; }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); font-size: 13px; }

/* ---------- chips ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--muted); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip:hover { border-color: #C9CDD3; }

/* ---------- drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(17,24,39,.28); z-index: 90; opacity: 0; pointer-events: none; transition: opacity .15s; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 640px; max-width: 100vw; background: var(--surface); box-shadow: var(--shadow-lg); z-index: 100; transform: translateX(100%); transition: transform .18s ease-out; display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
.drawer-h { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.drawer-h .bc { font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.drawer-h .bc button { border: 0; background: none; padding: 0; color: var(--muted); text-decoration: underline; font-size: 12px; }
.drawer-h .bc button:hover { color: var(--ink); }
.drawer-h h2 { font-size: 16px; margin-top: 4px; }
.drawer-body { padding: 16px 20px 24px; overflow-y: auto; flex: 1; }
.drawer .total { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.drawer .how { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.drawer-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.section-h { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
.linked { display: flex; flex-direction: column; gap: 6px; }
.linked button { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.linked button:hover { background: var(--canvas); }
.linked .lk-type { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.audit-list { font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; }
.audit-list .a { display: grid; grid-template-columns: 120px 1fr; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.audit-list .a .ts { color: var(--muted); }

/* ---------- modal, toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(17,24,39,.4); z-index: 200; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: 560px; max-width: 100%; max-height: 90vh; overflow: auto; }
.modal.wide { width: 860px; }
.modal-h { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-b { padding: 18px 20px; }
.modal-f { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center; animation: toastin .2s ease-out; pointer-events: auto; max-width: 560px; }
.toast.ok { border-left: 3px solid #4ADE80; } .toast.bad { border-left: 3px solid #F87171; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12.5px; color: var(--muted); }
.field input, .field select, .field textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 14px; background: var(--surface); width: 100%; }
.field textarea { min-height: 72px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(200,16,46,.25); border-color: var(--accent); }

/* ---------- alert / flag cards ---------- */
.flag { border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: 10px; padding: 12px 14px; background: var(--surface); display: flex; flex-direction: column; gap: 6px; }
.flag.high { border-left-color: var(--bad); } .flag.low { border-left-color: var(--idle); }
.flag .f-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.flag .f-tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.flag .f-title { font-weight: 600; font-size: 13.5px; }
.flag .f-reason { font-size: 13px; color: #3B4149; }
.flag .f-meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 12px; color: var(--muted); }
.flag .f-meta b { color: var(--ink); font-weight: 500; }
.flag .f-actions { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }

/* ---------- thread strip ---------- */
.thread { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding: 4px 0; }
.thread .step { flex: 1; min-width: 120px; position: relative; padding: 10px 12px 10px 20px; background: var(--canvas); border: 1px solid var(--line); border-right: 0; font-size: 12px; cursor: pointer; }
.thread .step:first-child { border-radius: 8px 0 0 8px; padding-left: 12px; }
.thread .step:last-child { border-right: 1px solid var(--line); border-radius: 0 8px 8px 0; }
.thread .step::after { content: ''; position: absolute; right: -9px; top: 50%; width: 16px; height: 16px; background: inherit; border-top: 1px solid var(--line); border-right: 1px solid var(--line); transform: translateY(-50%) rotate(45deg); z-index: 1; }
.thread .step:last-child::after { display: none; }
.thread .step.done { background: var(--ok-soft); } .thread .step.done .s-name { color: var(--ok); }
.thread .step.bad { background: var(--bad-soft); } .thread .step.bad .s-name { color: var(--bad); }
.thread .step.now { background: var(--warn-soft); } .thread .step.now .s-name { color: var(--warn); }
.thread .step .s-name { font-weight: 600; display: block; }
.thread .step .s-date { color: var(--muted); display: block; }
.thread .step:hover { filter: brightness(.97); }

/* ---------- board ---------- */
.board { display: grid; grid-template-columns: repeat(7, minmax(160px, 1fr)); gap: 10px; overflow-x: auto; align-items: start; }
.board.c4 { grid-template-columns: repeat(4, minmax(180px, 1fr)); }
.board.c5 { grid-template-columns: repeat(5, minmax(180px, 1fr)); }
.col { background: var(--canvas); border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-height: 120px; }
.col-h { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; padding: 0 2px; }
.jcard { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; font-size: 12.5px; cursor: pointer; }
.jcard:hover { border-color: #C9CDD3; box-shadow: var(--shadow); }
.jcard .j-id { font-size: 11px; color: var(--muted); }
.jcard .j-title { font-weight: 600; margin: 2px 0; }
.jcard .j-meta { color: var(--muted); display: flex; justify-content: space-between; gap: 6px; margin-top: 6px; }

/* ---------- gantt & charts ---------- */
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 300px; } .chart-box.short { height: 180px; }
.gantt { font-size: 12px; }
.gantt .g-row { display: grid; grid-template-columns: 230px 1fr; gap: 10px; align-items: center; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.gantt .g-track { position: relative; height: 18px; background: var(--canvas); border-radius: 4px; }
.gantt .g-bar { position: absolute; top: 2px; height: 6px; border-radius: 3px; background: #C9CDD3; }
.gantt .g-bar.actual { top: 10px; background: var(--ok); }
.gantt .g-bar.actual.late { background: var(--bad); }
.gantt .g-today { position: absolute; top: -2px; bottom: -2px; width: 1px; background: var(--accent); }
.bar { height: 8px; background: var(--canvas); border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ok); }
.bar.warn > span { background: var(--warn); } .bar.bad > span { background: var(--bad); } .bar.idle > span { background: var(--idle); }
.spark { width: 90px; height: 24px; }

/* ---------- org chart, calendar ---------- */
.org { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.org .person { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; gap: 10px; align-items: center; background: var(--surface); }
.org .person.empty-role { border-style: dashed; background: var(--warn-soft); }
.org .person .r { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { font-size: 11px; color: var(--muted); text-align: center; padding: 4px 0; text-transform: uppercase; }
.cal .day { min-height: 86px; border: 1px solid var(--line); border-radius: 6px; padding: 4px; font-size: 11px; background: var(--surface); }
.cal .day.off { background: var(--canvas); }
.cal .day.today { border-color: var(--accent); }
.cal .day .dn { color: var(--muted); font-size: 11px; margin-bottom: 2px; }
.cal .visit { display: block; border-radius: 4px; padding: 2px 5px; margin-top: 2px; font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; border: 0; width: 100%; text-align: left; background: var(--idle-soft); color: #4B5563; }
.cal .visit.done { background: var(--ok-soft); color: var(--ok); } .cal .visit.due { background: var(--warn-soft); color: var(--warn); } .cal .visit.overdue { background: var(--bad-soft); color: var(--bad); } .cal .visit.scheduled { background: var(--info-soft); color: var(--info); }
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 14px; }
.week-strip .wd { border: 1px solid var(--line); border-radius: 8px; padding: 8px; text-align: center; font-size: 12px; background: var(--surface); }
.week-strip .wd.today { border-color: var(--accent); }
.week-strip .wd b { display: block; font-size: 18px; font-weight: 600; }

/* ---------- document preview ---------- */
.doc { background: #fff; border: 1px solid var(--line); padding: 36px 40px; font-size: 13px; color: var(--ink); min-height: 560px; box-shadow: var(--shadow); }
.doc .doc-h { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--ink); padding-bottom: 14px; margin-bottom: 18px; }
.doc .doc-h h2 { font-size: 20px; letter-spacing: .02em; }
.doc .doc-co { font-size: 12px; color: var(--muted); line-height: 1.4; }
.doc table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.doc th, .doc td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; font-size: 12.5px; }
.doc th { background: var(--canvas); font-weight: 600; }
.doc .doc-stamp { margin-top: 28px; display: flex; justify-content: space-between; gap: 20px; font-size: 12px; color: var(--muted); }
.doc .doc-stamp div { border-top: 1px solid var(--ink); padding-top: 6px; width: 200px; }
.doc .watermark { position: absolute; right: 24px; top: 24px; border: 2px solid var(--idle); color: var(--idle); border-radius: 6px; padding: 4px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; transform: rotate(6deg); }

/* ---------- AI assistant ---------- */
.ai-q { display: flex; gap: 8px; flex-wrap: wrap; }
.ai-q button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.ai-q button:hover, .ai-q button.active { border-color: var(--ink); background: var(--ink); color: #fff; }
.ai-a { background: var(--canvas); border-radius: 10px; padding: 14px 16px; font-size: 13.5px; line-height: 1.6; margin-top: 12px; }
.ai-a ul { margin: 6px 0 0; padding-left: 18px; }
.ai-a .disclaimer { color: var(--muted); font-size: 12px; margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.ai-input { display: flex; gap: 8px; margin-top: 12px; }
.ai-input input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: var(--canvas); }

/* ---------- phone frame ---------- */
.phone-wrap { display: flex; justify-content: center; padding: 20px 0; }
.phone { width: 390px; height: 820px; border: 10px solid #111; border-radius: 44px; background: #fff; overflow: hidden; position: relative; box-shadow: 0 30px 60px rgba(0,0,0,.25); display: flex; flex-direction: column; }
.phone .notch { height: 30px; background: #fff; display: flex; justify-content: center; align-items: flex-start; }
.phone .notch span { width: 120px; height: 24px; background: #111; border-radius: 0 0 16px 16px; }
.phone .ph-h { padding: 8px 18px 12px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.phone .ph-h b { font-size: 16px; }
.phone .ph-body { flex: 1; overflow-y: auto; padding: 16px 18px 24px; }
.big-btn { display: flex; align-items: center; gap: 14px; width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 18px 16px; font-size: 16px; font-weight: 600; text-align: left; margin-bottom: 12px; }
.big-btn svg { width: 26px; height: 26px; color: var(--accent); flex: none; }
.site-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.site-item:last-child { border-bottom: 0; }
.big-btn small { display: block; font-weight: 400; font-size: 12.5px; color: var(--muted); }
.big-btn:hover { background: var(--canvas); }
.phone .field input, .phone .field select, .phone .field textarea { font-size: 16px; padding: 12px; border-radius: 10px; }
.phone .btn.primary.full { width: 100%; justify-content: center; padding: 14px; font-size: 16px; border-radius: 12px; }
.photo-ph { border: 1px dashed var(--line); border-radius: 10px; padding: 16px; text-align: center; color: var(--muted); font-size: 13px; background: var(--canvas); }
.stepper { display: flex; gap: 8px; align-items: center; }
.stepper button { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 20px; }
.stepper input { width: 80px; text-align: center; }
.done-check { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: flex; align-items: center; justify-content: center; margin: 20px auto; }
.done-check svg { width: 32px; height: 32px; }
.updated { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-top: 8px; display: flex; gap: 10px; align-items: flex-start; }
.updated svg { width: 16px; height: 16px; color: var(--ok); flex: none; margin-top: 2px; }

/* ---------- misc ---------- */
.tour { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; border-radius: 14px; padding: 14px 18px; z-index: 400; width: 720px; max-width: calc(100vw - 40px); box-shadow: var(--shadow-lg); display: flex; gap: 14px; align-items: center; }
.tour .t-step { font-size: 11px; color: #9CA3AF; text-transform: uppercase; letter-spacing: .06em; }
.tour .t-cap { font-size: 14px; margin-top: 2px; }
.tour .btn { border-color: rgba(255,255,255,.25); background: transparent; color: #fff; } .tour .btn:hover { background: rgba(255,255,255,.1); }
.tour .btn.primary { background: var(--accent); border-color: var(--accent); }
.hl { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; transition: outline-color .3s; }
.styleguide section { margin-bottom: 28px; }
.score { font-size: 28px; font-weight: 600; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.notice { background: var(--warn-soft); border: 1px solid #EBD9B4; color: #7A4F06; padding: 10px 14px; border-radius: 8px; font-size: 13px; }
.notice.bad { background: var(--bad-soft); border-color: #F1C2CA; color: #8B0A20; }
.notice.ok { background: var(--ok-soft); border-color: #BFE3CF; color: #166042; }
.notice.info { background: var(--info-soft); border-color: #C7D7F7; color: #1E3A8A; }
.queue-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.queue-item:last-child { border-bottom: 0; }
.queue-item .q-type { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; width: 110px; flex: none; }
.queue-item .q-main { flex: 1; min-width: 0; }
.queue-item .q-main b { display: block; }
.queue-item .q-main span { color: var(--muted); font-size: 12px; }
@media (max-width: 1100px) { #app { grid-template-columns: 200px 1fr; } .content { padding: 18px; } .topbar { padding: 0 18px; } .org { grid-template-columns: repeat(2, 1fr); } }
@media print { .sidebar, .topbar, .footer { display: none; } #app { grid-template-columns: 1fr; } }

/* ======================================================================
   Additions for the live app (not in the mock)
   ====================================================================== */
.env-bar { background: #FBF1DF; color: #7A4F06; border-bottom: 1px solid #EBD9B4; font-size: 12px; font-weight: 600; text-align: center; padding: 4px 12px; letter-spacing: .02em; position: sticky; top: 0; z-index: 30; }
body.auth { background: var(--canvas); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); width: 420px; max-width: 100%; padding: 28px 28px 24px; }
.auth-card h1 { font-size: 20px; margin-bottom: 6px; }
.auth-brand { border-bottom: 0; padding: 0 0 18px; margin: 0; color: var(--ink); }
.auth-brand .name { color: var(--ink); } .auth-brand .sub { color: var(--muted); }
.auth-foot { font-size: 12px; color: var(--muted); margin-top: 16px; }
.btn.full { width: 100%; justify-content: center; padding: 10px; font-size: 14px; }
.totp-secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--canvas); padding: 4px 8px; border-radius: 6px; display: inline-block; margin-top: 6px; letter-spacing: .04em; }
.menu a.menu-item, .menu form button { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: inherit; font: inherit; cursor: pointer; }
.menu a.menu-item:hover, .menu form button:hover { background: var(--canvas); }
.menu svg { width: 16px; height: 16px; color: var(--muted); }
.seg a { padding: 6px 12px; font-size: 13px; color: var(--muted); text-decoration: none; } .seg a.active { background: var(--ink); color: #fff; }
.field.span2 { grid-column: span 2; }
.field .req { color: var(--accent); }
.field-error { color: var(--bad); font-size: 12px; }
.field input[aria-invalid="true"] { border-color: var(--bad); }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); cursor: pointer; padding: 6px 0; }
label.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.role-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 16px; }
.count-tag { font-size: 12px; color: var(--muted); background: var(--canvas); border-radius: 999px; padding: 1px 8px; font-weight: 500; margin-left: 6px; vertical-align: 2px; }
.team-row { display: grid; grid-template-columns: 150px 1fr auto auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.team-row .r { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.team-row select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px; background: var(--surface); min-width: 0; }
.status-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.status-row:last-child { border-bottom: 0; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--idle); }
.status-dot.ok { background: var(--ok); } .status-dot.warn { background: var(--warn); } .status-dot.failed { background: var(--bad); }
.plain-list { margin: 0; padding-left: 18px; line-height: 1.9; }
.linked a.linked-a { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 12px; font-size: 13px; text-decoration: none; }
.linked a.linked-a:hover { background: var(--canvas); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--canvas); padding: 1px 5px; border-radius: 4px; }
tr[data-href] { cursor: pointer; } tr[data-href]:hover td { background: var(--canvas); }
.audit-banner { margin-bottom: 16px; }
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 240px; transform: translateX(-100%); transition: transform .18s; z-index: 60; }
  .sidebar.open { transform: none; }
  .topbar { padding: 0 14px; }
  .content { padding: 14px; }
  .grid, .grid.c2, .grid.c3, .grid.c4, .grid.c6, .grid.main-side, .grid.side-main { grid-template-columns: minmax(0, 1fr); }
  .card, .kpi { min-width: 0; }
  .topbar h1 { font-size: 17px; }
  .field.span2 { grid-column: auto; }
  .role-btn .who { display: none; }
  .phone-wrap { padding: 0; } .phone { width: 100%; height: auto; min-height: calc(100vh - 140px); border: 0; border-radius: 0; box-shadow: none; } .phone .notch { display: none; }
  .drawer { width: 100vw; }
  .team-row { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-flex; }
}
.menu-toggle { display: none; }
.card { min-width: 0; }
.sidebar-backdrop { display: none; } @media (max-width: 760px) { .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(17,24,39,.28); z-index: 55; } }

.mrf-lines input, .mrf-lines select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px; width: 100%; background: var(--surface); }
.mrf-lines td { padding: 6px; }
tr.focus td { background: var(--accent-soft); }
.phone .ph-h a.icon-btn { text-decoration: none; }
.phone a.big-btn { text-decoration: none; color: inherit; }
.mrf-lines .rm-label { display: none; }
.phone .mrf-lines thead { display: none; }
.phone .mrf-lines, .phone .mrf-lines tbody { display: block; }
.phone .mrf-lines tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.phone .mrf-lines td { padding: 0; border: 0; min-width: 0; }
.phone .mrf-lines td:first-child { grid-column: 1 / -1; }
.phone .mrf-lines td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.phone .mrf-lines td input, .phone .mrf-lines td select { width: 100% !important; font-size: 16px; padding: 10px; }
.phone .mrf-lines td.rm { grid-column: 1 / -1; text-align: right; }
.phone .mrf-lines td.rm .icon-btn { width: auto; padding: 4px 8px; gap: 4px; display: inline-flex; align-items: center; font-size: 13px; color: var(--muted); }
.phone .mrf-lines td.rm .rm-label { display: inline; }
@media (max-width: 760px) {
  .mrf-lines thead { display: none; }
  .mrf-lines, .mrf-lines tbody { display: block; }
  .mrf-lines tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .mrf-lines td { padding: 0; border: 0; min-width: 0; }
  .mrf-lines td:first-child { grid-column: 1 / -1; }
  .mrf-lines td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
  .mrf-lines td input, .mrf-lines td select { width: 100% !important; font-size: 16px; padding: 10px; }
  .mrf-lines td.rm { grid-column: 1 / -1; text-align: right; }
  .mrf-lines td.rm .icon-btn { width: auto; padding: 4px 8px; gap: 4px; display: inline-flex; align-items: center; font-size: 13px; color: var(--muted); }
  .mrf-lines td.rm .rm-label { display: inline; }
  .week-strip { grid-template-columns: repeat(4, 1fr); }
}
