:root {
  --bg: #F6F7F9; --surface: #FFFFFF; --border: #E3E6EA;
  --text: #1B1F24; --text-muted: #5B636E;
  --accent: #1F4FD8; --accent-hover: #1A43B8; --accent-bg: #EAF0FD;
  --danger: #C62828; --danger-bg: #FDECEC;
  --warning: #B26A00; --warning-bg: #FFF4E0;
  --ok: #2E7D32; --ok-bg: #EAF5EB;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r: 6px; --fast: 150ms;
  --font: -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); font-variant-numeric: tabular-nums; }
button { font: inherit; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Shell */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: var(--s5) var(--s4); display: flex; flex-direction: column; gap: var(--s5); }
.brand { font-size: 16px; font-weight: 600; padding: 0 var(--s2); }
.brand small { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: var(--s2) var(--s3); border-radius: var(--r); color: var(--text); min-height: 36px; transition: background var(--fast); }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.on { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.nav a.off { color: var(--text-muted); pointer-events: none; }
.nav a.off span { font-size: 12px; }
.side-foot { margin-top: auto; font-size: 12px; color: var(--text-muted); padding: 0 var(--s2); }

.main { padding: var(--s6); min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: var(--s5); gap: var(--s4); }
.crumb { font-size: 12px; color: var(--text-muted); margin-bottom: var(--s1); }
h1 { font-size: 24px; font-weight: 600; }
h2 { font-size: 16px; font-weight: 600; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }

/* Buttons */
.btn { min-height: 32px; padding: 0 var(--s3); border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 500; transition: background var(--fast), border-color var(--fast); display: inline-flex; align-items: center; gap: var(--s2); white-space: nowrap; }
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0 var(--s1); }

/* Badges: icon + word, never colour only */
.badge { display: inline-flex; align-items: center; gap: var(--s1); font-size: 12px; font-weight: 600; padding: 2px var(--s2); border-radius: 999px; white-space: nowrap; }
.badge.danger { color: var(--danger); background: var(--danger-bg); }
.badge.warning { color: var(--warning); background: var(--warning-bg); }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.neutral { color: var(--text-muted); background: var(--bg); }
.badge.info { color: var(--accent); background: var(--accent-bg); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.section { margin-top: var(--s6); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--s3); }

/* S1: totals strip */
.totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s4); margin-bottom: var(--s5); }
.total { padding: var(--s4); }
.total b { display: block; font-size: 24px; font-weight: 600; }
.total.danger b { color: var(--danger); }

/* S1: line grid, 5 x 4 */
.lines { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--s4); }
.tile { display: block; padding: var(--s4); color: var(--text); border-left-width: 4px; transition: border-color var(--fast), box-shadow var(--fast); }
.tile:hover { text-decoration: none; border-color: #C9CED6; }
.tile.danger { border-left-color: var(--danger); }
.tile.warning { border-left-color: var(--warning); }
.tile.ok { border-left-color: var(--border); }
.tile-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s2); }
.tile-num { font-size: 24px; font-weight: 600; }
.tile-num span { font-size: 14px; font-weight: 400; color: var(--text-muted); }
.tile.danger .tile-num { color: var(--danger); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-muted); padding: var(--s2) var(--s4); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 0 var(--s4); height: 44px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: var(--s2); }
tr.done td { color: var(--text-muted); }
.chk { width: 16px; height: 16px; accent-color: var(--accent); }

/* S2: line detail */
.line-summary { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1.4fr; gap: var(--s4); margin-bottom: var(--s5); }
.line-summary .card { padding: var(--s4); }
.line-summary b { display: block; font-size: 24px; font-weight: 600; }
.gaps { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }
.bar { display: flex; justify-content: space-between; align-items: center; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); gap: var(--s4); }
.phone-missing { color: var(--danger); font-size: 12px; }

/* S3: drawer */
.scrim { position: fixed; inset: 0; background: rgba(27, 31, 36, .32); z-index: 10; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 560px; background: var(--surface); box-shadow: -8px 0 24px rgba(27, 31, 36, .12); z-index: 11; display: flex; flex-direction: column; }
.drawer-head { padding: var(--s5); border-bottom: 1px solid var(--border); }
.drawer-head .row { display: flex; justify-content: space-between; align-items: flex-start; }
.drawer-body { padding: var(--s4) var(--s5); overflow: auto; flex: 1; }
.cand { display: flex; justify-content: space-between; align-items: center; padding: var(--s3) 0; border-bottom: 1px solid var(--border); gap: var(--s3); }
.cand.nomatch { opacity: .55; }
.skills { display: flex; flex-wrap: wrap; gap: var(--s1); margin-top: var(--s1); }
.drawer-foot { padding: var(--s4) var(--s5); border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }
.filter { display: flex; align-items: center; gap: var(--s2); font-size: 12px; color: var(--text-muted); margin: var(--s2) 0 var(--s3); }

/* S4: worker profile */
.profile { display: grid; grid-template-columns: 360px 1fr; gap: var(--s5); align-items: start; }
.who { padding: var(--s5); }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--accent-bg); color: var(--accent); display: grid; place-items: center; font-size: 16px; font-weight: 600; margin-bottom: var(--s3); }
.facts { margin-top: var(--s4); display: grid; grid-template-columns: auto 1fr; gap: var(--s2) var(--s4); font-size: 14px; }
.facts dt { color: var(--text-muted); }
.strike { padding: var(--s5); }
.strike-row { display: flex; align-items: center; gap: var(--s4); margin: var(--s3) 0; }
.pips { display: flex; gap: var(--s1); }
.pip { width: 28px; height: 8px; border-radius: 4px; background: var(--border); }
.pip.on { background: var(--warning); }
.pips.over .pip.on { background: var(--danger); }
.balance { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s4); padding: var(--s4); }
.balance b { display: block; font-size: 24px; font-weight: 600; }
.upload { display: none; align-items: center; gap: var(--s2); }
.upload.show { display: inline-flex; }

/* Toast */
.toast { position: fixed; bottom: var(--s5); left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: var(--s3) var(--s4); border-radius: var(--r); z-index: 20; font-size: 14px; display: flex; gap: var(--s3); align-items: center; }
.empty { padding: var(--s6); text-align: center; color: var(--text-muted); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Fixes after heuristic evaluation */
.toast-undo { background: none; border: 1px solid rgba(255,255,255,.4); color: #fff; border-radius: var(--r); min-height: 28px; padding: 0 var(--s3); font-weight: 600; }
.toast-undo:hover { background: rgba(255,255,255,.12); }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 480px; padding: var(--s5); z-index: 12; box-shadow: 0 8px 24px rgba(27,31,36,.16); }
.modal p { margin: var(--s3) 0 var(--s5); color: var(--text-muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--s2); }
/* S3: decision info at 14px, HR reads it to choose who to move */
.drawer .small, .drawer .filter, .drawer-body > p { font-size: 14px; }
.drawer .badge { font-size: 14px; padding: 2px 10px; }
