:root {
  --side: #0f2a44; --side-2: #17395a; --side-ink: #c9d6e3; --side-ink-dim: #7f97ae; --side-active: #37b6a0;
  --bg: #eef1f5; --card: #ffffff; --line: #dde3ea; --line-2: #eef1f4; --ink: #15202b; --ink-2: #4a5866; --ink-3: #7b8794;
  --primary: #1f6fd1; --primary-ink: #ffffff; --primary-soft: #e6f0fc; --accent: #2a9d8a;
  --good: #0ca30c; --good-ink: #0b7a0b; --good-soft: #e5f5e5;
  --warn: #fab219; --warn-ink: #8a5a00; --warn-soft: #fff4dc;
  --serious: #ec835a; --serious-ink: #a8431b; --serious-soft: #fdece4;
  --crit: #d03b3b; --crit-ink: #b02a2a; --crit-soft: #fbe7e7;
  --info-ink: #1b5aa6; --info-soft: #e6f0fc; --muted-soft: #eef0f3;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --grid: #e8eaee; --axis: #c3c2b7;
  --radius: 8px; --shadow: 0 1px 2px rgba(16,32,48,.06), 0 1px 1px rgba(16,32,48,.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.side { width: 232px; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex: none; z-index: 30; }
.brand { display: flex; gap: 10px; align-items: center; padding: 16px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-name { color: #fff; font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--side-ink-dim); text-transform: uppercase; letter-spacing: .8px; }
.nav { flex: 1; overflow-y: auto; padding: 8px 0 12px; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--side-ink-dim); padding: 14px 18px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 18px; color: var(--side-ink); border-left: 3px solid transparent; font-size: 13.5px; }
.nav a:hover { background: rgba(255,255,255,.05); text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-2); color: #fff; border-left-color: var(--side-active); font-weight: 600; }
.nav a .badge { margin-left: auto; }
.side-foot { padding: 12px 18px; font-size: 11.5px; color: var(--side-ink-dim); border-top: 1px solid rgba(255,255,255,.07); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { height: 58px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 0 20px; position: sticky; top: 0; z-index: 20; }
.menu-btn { display: none; }
.search-wrap { position: relative; flex: 1; max-width: 460px; }
.search-wrap input { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 18px; padding: 0 14px 0 36px; background: #f6f8fa; }
.search-wrap input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-soft); }
.search-ico { position: absolute; left: 11px; top: 9px; color: var(--ink-3); }
.search-results { position: absolute; top: 42px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(16,32,48,.14); max-height: 380px; overflow: auto; }
.search-results a { display: flex; gap: 10px; padding: 9px 12px; color: var(--ink); border-bottom: 1px solid var(--line-2); align-items: center; }
.search-results a:hover, .search-results a.on { background: var(--primary-soft); text-decoration: none; }
.search-results .kind { font-size: 10.5px; text-transform: uppercase; color: var(--ink-3); width: 54px; flex: none; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.top-select { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); }
.top-select select { height: 32px; border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; background: #fff; color: var(--ink); max-width: 170px; }
.view { padding: 20px 24px 40px; outline: none; }

/* ---------- page parts ---------- */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
.page-head .sub { color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 12.5px; color: var(--ink-3); margin-bottom: 4px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.card-h h2, .card-h h3 { margin: 0; font-size: 14px; font-weight: 650; }
.card-h .muted { font-size: 12px; }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-b { padding: 14px 16px; }
.card-b.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g-main { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
.mt { margin-top: 16px; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.right-align { text-align: right; }
.nowrap { white-space: nowrap; }
.empty { padding: 28px 16px; text-align: center; color: var(--ink-3); }
.empty svg.i { width: 28px; height: 28px; display: block; margin: 0 auto 8px; opacity: .6; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 11px; box-shadow: var(--shadow); position: relative; cursor: default; }
.kpi.link { cursor: pointer; } .kpi.link:hover { border-color: #b9c6d4; }
.kpi .lbl { font-size: 11.5px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.kpi .val { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.5px; }
.kpi .val small { font-size: 14px; font-weight: 600; color: var(--ink-3); margin-left: 2px; }
.kpi .foot { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; display: flex; gap: 6px; align-items: center; }
.kpi .bar { position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; }
.delta { font-weight: 600; } .delta.good { color: var(--good-ink); } .delta.bad { color: var(--crit-ink); } .delta.flat { color: var(--ink-3); }
.meter { height: 6px; background: var(--muted-soft); border-radius: 3px; margin-top: 7px; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 3px; }

/* ---------- pills & badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 11px; font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 18px; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-open { background: var(--info-soft); color: var(--info-ink); }
.st-in_progress { background: #e8f6f3; color: #11705f; }
.st-on_hold { background: var(--warn-soft); color: var(--warn-ink); }
.st-completed { background: var(--good-soft); color: var(--good-ink); }
.st-cancelled { background: var(--muted-soft); color: var(--ink-3); }
.st-new { background: var(--info-soft); color: var(--info-ink); }
.st-converted, .st-received, .st-operational, .st-approved { background: var(--good-soft); color: var(--good-ink); }
.st-rejected, .st-down { background: var(--crit-soft); color: var(--crit-ink); }
.st-draft, .st-retired { background: var(--muted-soft); color: var(--ink-2); }
.st-submitted { background: var(--warn-soft); color: var(--warn-ink); }
.pr { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; }
.pr svg { width: 12px; height: 12px; }
.pr-urgent { color: var(--crit-ink); font-weight: 650; } .pr-high { color: var(--serious-ink); font-weight: 600; } .pr-normal { color: var(--ink-2); } .pr-low { color: var(--ink-3); }
.badge { background: var(--crit); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 9px; padding: 0 6px; line-height: 17px; min-width: 18px; text-align: center; }
.badge.soft { background: rgba(255,255,255,.14); color: #fff; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 4px; background: var(--muted-soft); color: var(--ink-2); font-weight: 600; text-transform: capitalize; }
.overdue-flag { color: var(--crit-ink); font-weight: 650; display: inline-flex; gap: 4px; align-items: center; }
.overdue-flag svg.i { width: 13px; height: 13px; }
.crit-high { color: var(--crit-ink); font-weight: 600; } .crit-medium { color: var(--ink-2); } .crit-low { color: var(--ink-3); }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; font-weight: 600; font-size: 13px; white-space: nowrap; }
.btn:hover { background: #f5f7f9; text-decoration: none; }
.btn svg.i { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; } .btn.primary:hover { background: #1a5fb5; }
.btn.good { background: #11805f; border-color: #11805f; color: #fff; } .btn.good:hover { background: #0d6c50; }
.btn.danger { color: var(--crit-ink); } .btn.danger:hover { background: var(--crit-soft); }
.btn.danger.solid { background: var(--crit); color: #fff; border-color: var(--crit); }
.btn.ghost { border-color: transparent; background: transparent; } .btn.ghost:hover { background: var(--muted-soft); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { border: none; background: transparent; width: 32px; height: 32px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--muted-soft); color: var(--ink); }
.form { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px 16px; }
.form .full { grid-column: 1 / -1; }
.form.g3f { grid-template-columns: repeat(3, minmax(0,1fr)); }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field label .req { color: var(--crit-ink); }
.field input, .field select, .field textarea, .inp { width: 100%; height: 36px; border: 1px solid #cfd7e0; border-radius: 6px; padding: 0 10px; background: #fff; }
.field textarea { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .inp:focus, .filters select:focus, .filters input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field .hint { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- toolbar / filters / tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 0; padding: 0 12px; background: #fff; border-radius: var(--radius) var(--radius) 0 0; overflow-x: auto; }
.tabs a { padding: 11px 14px 10px; color: var(--ink-2); font-weight: 600; font-size: 13px; border-bottom: 2px solid transparent; display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .count { font-size: 11px; background: var(--muted-soft); color: var(--ink-2); border-radius: 9px; padding: 0 7px; }
.tabs a.on .count { background: var(--primary-soft); color: var(--primary); }
.filters { display: flex; gap: 8px; padding: 10px 12px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--line-2); background: #fafbfc; }
.filters select, .filters input { height: 32px; border: 1px solid #cfd7e0; border-radius: 6px; padding: 0 8px; background: #fff; font-size: 13px; }
.filters input[type=search] { width: 220px; }
.filters .spacer { flex: 1; }
.bulkbar { display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: var(--primary-soft); border-bottom: 1px solid #c9dcf5; font-size: 13px; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-2); font-weight: 650; padding: 9px 12px; background: #f7f9fb; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; }
.tbl th.sort { cursor: pointer; user-select: none; } .tbl th.sort:hover { color: var(--ink); }
.tbl th .arr { opacity: .7; margin-left: 3px; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: #f6f9fd; }
.tbl tr.sel td { background: #eef5fe; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .code { font-weight: 650; color: var(--primary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl .title-cell { font-weight: 550; max-width: 340px; }
.tbl .sub { font-size: 12px; color: var(--ink-3); }
.tbl input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--primary); }
.tbl tfoot td { font-weight: 650; background: #f7f9fb; }
.tbl.compact td { padding: 7px 12px; }
.tbl-foot { padding: 9px 12px; font-size: 12px; color: var(--ink-3); }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.list li:last-child { border-bottom: none; }
.list li.click { cursor: pointer; } .list li.click:hover { background: #f6f9fd; }
.list .grow { flex: 1; min-width: 0; }
.list .t { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .s { font-size: 12px; color: var(--ink-3); }

/* ---------- detail pages ---------- */
.detail-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; flex-wrap: wrap; }
.detail-head h1 { margin: 0; font-size: 21px; }
.detail-head .meta { display: flex; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.detail-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.dl { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px 18px; }
.dl > div > .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-3); font-weight: 600; }
.dl > div > .v { margin-top: 2px; font-size: 13.5px; }
.desc { white-space: pre-wrap; font-size: 13.5px; }
.cost-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.cost-row:last-child { border-bottom: none; font-weight: 700; font-size: 14px; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.checklist li.done span { text-decoration: line-through; color: var(--ink-3); }
.checklist input { width: 17px; height: 17px; accent-color: var(--good); }
.progress-txt { font-size: 12px; color: var(--ink-3); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.timeline .av { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex: none; }
.timeline .av.sys { background: var(--muted-soft); color: var(--ink-3); }
.timeline .who { font-weight: 600; } .timeline .when { color: var(--ink-3); font-size: 12px; margin-left: 6px; }
.timeline .body { white-space: pre-wrap; margin-top: 1px; }
.timeline li.k-comment .body { background: #f6f8fa; border: 1px solid var(--line-2); padding: 7px 10px; border-radius: 6px; margin-top: 4px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line-2); background: #fafbfc; }
.inline-form .field { margin: 0; }
.inline-form .field input, .inline-form .field select { height: 32px; }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-family: var(--font); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend i.line { height: 2px; width: 14px; border-radius: 1px; }
.hbars .row { display: grid; grid-template-columns: 110px 1fr 40px; gap: 10px; align-items: center; padding: 5px 0; font-size: 12.5px; cursor: default; }
.hbars .row.click { cursor: pointer; } .hbars .row.click:hover .lab { color: var(--primary); }
.hbars .lab { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbars .track { height: 14px; position: relative; }
.hbars .fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbars .n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.tip { position: fixed; z-index: 100; background: #15202b; color: #fff; font-size: 12px; padding: 7px 10px; border-radius: 6px; pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,.2); max-width: 260px; line-height: 1.5; }
.tip b { font-weight: 650; }
.tip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,30,45,.45); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; animation: fade .12s; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 680px; box-shadow: 0 20px 50px rgba(0,0,0,.25); animation: pop .14s; }
.modal.wide { max-width: 900px; } .modal.narrow { max-width: 460px; }
.modal-h { display: flex; align-items: center; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.modal-h h2 { margin: 0; font-size: 17px; }
.modal-h .icon-btn { margin-left: auto; }
.modal-b { padding: 18px 20px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: #fafbfc; border-radius: 0 0 10px 10px; }
.modal-f .left { margin-right: auto; }
.err { background: var(--crit-soft); color: var(--crit-ink); padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; font-size: 13px; }
@keyframes fade { from { opacity: 0 } }
@keyframes pop { from { transform: translateY(8px); opacity: 0 } }
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #15202b; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.2); animation: pop .15s; display: flex; gap: 8px; align-items: center; }
.toast.error { background: var(--crit); }
.lines-tbl input, .lines-tbl select { height: 32px; border: 1px solid #cfd7e0; border-radius: 6px; padding: 0 8px; width: 100%; background: #fff; }
.notice { display: flex; gap: 10px; padding: 11px 14px; border-radius: 8px; background: var(--info-soft); color: var(--info-ink); font-size: 13px; margin-bottom: 16px; align-items: center; }
.notice.warn { background: var(--warn-soft); color: var(--warn-ink); }
.notice .btn { margin-left: auto; }
.loading { padding: 60px; text-align: center; color: var(--ink-3); }
.scorecard { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); }
.scorecard > div { padding: 14px 16px; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); }
.scorecard .k { font-size: 11.5px; text-transform: uppercase; color: var(--ink-3); font-weight: 600; letter-spacing: .4px; }
.scorecard .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.scorecard .d { font-size: 11.5px; color: var(--ink-3); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; }
.seg button { border: none; background: transparent; padding: 0 12px; height: 30px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--primary); color: #fff; }

/* ---------- print ---------- */
.print-only { display: none; }
@media print {
  body { background: #fff; }
  .side, .top, .no-print, .actions, .inline-form, .toasts, .filters, .tabs, .bulkbar { display: none !important; }
  .view { padding: 0; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .print-only { display: block; }
  .grid.g-main, .grid.g2, .grid.g3 { grid-template-columns: 1fr; }
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) { .kpis { grid-template-columns: repeat(3, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); } .scorecard { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 980px) {
  .g-main, .g2, .g3 { grid-template-columns: minmax(0,1fr); }
  .dl { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .scorecard { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 820px) {
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .side { position: fixed; left: -250px; transition: left .18s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .shell.nav-open .side { left: 0; }
  .menu-btn { display: inline-flex; }
  .top { padding: 0 12px; gap: 8px; }
  .top-select span { display: none; }
  #siteFilter { display: none; }
  .view { padding: 16px 16px 40px; }
  .form, .form.g3f { grid-template-columns: minmax(0,1fr); }
  #newWoBtn .lbl { display: none; }
}

/* ---------- v2: login, account, safety, tips, photos, skills ---------- */
[hidden] { display: none !important; }
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, var(--side) 0%, var(--side-2) 60%, #1d4b6e 100%); }
.login-card { background: var(--card); border-radius: 12px; padding: 26px 26px 20px; width: 100%; max-width: 400px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.login-brand .brand-name { font-size: 19px; }
.login-tabs { display: flex; width: 100%; margin-bottom: 14px; }
.login-tabs button { flex: 1; }
.login .form { display: grid; gap: 12px; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pinpad button { height: 54px; font-size: 20px; font-weight: 600; border: 1px solid var(--line); background: #f7f9fb; border-radius: 10px; cursor: pointer; }
.pinpad button:active { background: var(--primary-soft); }
.user-btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px; }
.user-btn .lbl { display: flex; flex-direction: column; line-height: 1.1; text-align: left; font-size: 13px; }
.user-btn small { color: var(--ink-3); font-size: 11px; }
.av-sm { width: 28px; height: 28px; border-radius: 50%; background: var(--side-2); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
@media (max-width: 760px) { .user-btn .lbl { display: none; } }
.btn.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn-ink); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; background: #f4f6f8; border: 1px dashed var(--line); padding: 12px 14px; border-radius: 8px; user-select: all; line-height: 1.7; }
.notice.good { background: var(--good-soft); color: var(--good-ink); }
.card.safety { border-left: 4px solid var(--crit); }
.card.safety.ok { border-left-color: var(--good); }
.card.safety .card-h h2 { color: var(--crit-ink); }
.card.safety.ok .card-h h2 { color: var(--good-ink); }
.tipcard { border-left: 4px solid var(--warn); }
.tips { list-style: none; margin: 0; padding: 0; }
.tips li { padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.tips li:last-child { border-bottom: 0; }
.tips li.pinned .body { font-weight: 600; }
.tips li.inactive { opacity: .5; }
.tips .s { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photos figure { margin: 0; }
.photos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #f4f6f8; }
.photos figcaption { font-size: 12px; margin-top: 3px; }
.qrbox { display: flex; gap: 14px; align-items: flex-start; }
.qrbox img { flex: none; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.matrix th.rot { height: 120px; vertical-align: bottom; padding: 4px 2px; }
.matrix th.rot span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-size: 12px; }
.matrix td.lv { text-align: center; font-weight: 700; cursor: pointer; width: 34px; min-width: 34px; border-left: 1px solid #fff; }
.matrix td.lv:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
.lv0 { background: #f1f3f5; color: #f1f3f5; } .lv1 { background: #fde9cf; color: #8a5a00; } .lv2 { background: #fbe3a0; color: #6d4b00; }
.lv3 { background: #bfe6c7; color: #135f1f; } .lv4 { background: #4caf65; color: #fff; }
.legend i.lv0, .legend i.lv1, .legend i.lv2, .legend i.lv3, .legend i.lv4 { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-right: 4px; vertical-align: -2px; }
@media print { .login { display: none !important; } }
