:root {
  --bg: #f6f6f3;
  --panel: #ffffff;
  --ink: #1d2327;
  --muted: #69737a;
  --line: #e2e3df;
  --line-strong: #c9cbc5;
  --accent: #1e6b5c;
  --accent-ink: #ffffff;
  --ok: #2f7d4f;
  --warn: #b7791f;
  --breach: #c0392b;
  --review: #3d5a99;
  --unfilled: #8a9094;
  --weekend: #f0efe9;
  --ph: #fbf1e3;
  --row-h: 58px;
  --label-w: 220px;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.disclaimer {
  background: #fff7e0; border-bottom: 1px solid #ecd9a4; padding: 6px 16px; font-size: 13px;
}
.disclaimer a { color: var(--accent); }

.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; font-size: 16px; }
.brand .muted { font-weight: 400; font-size: 13px; margin-left: 6px; }
.roster-meta, .controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.controls { margin-left: auto; }
.name-input { border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; min-width: 220px; font-weight: 600; background: transparent; }
.name-input:hover, .name-input:focus { border-color: var(--line-strong); background: #fff; }
.week input { border: 1px solid var(--line-strong); border-radius: 6px; padding: 3px 6px; }

.btn { border: 1px solid var(--line-strong); background: #fff; border-radius: 6px; padding: 5px 10px; cursor: pointer; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.icon { width: 30px; padding: 5px 0; }
.btn.danger { color: var(--breach); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 5px 12px; cursor: pointer; }
.seg button.on { background: var(--ink); color: #fff; }

.pill { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 12px; border: 1px solid var(--line-strong); background: #fff; }
.pill.published { border-color: var(--ok); color: var(--ok); }

.summary { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 10px 16px; align-items: baseline; }
.stat b { font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); margin-left: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border-radius: 999px; padding: 1px 9px; font-size: 12px; border: 1px solid; cursor: default; }
.st-complete { color: var(--ok); border-color: var(--ok); }
.st-warnings { color: var(--warn); border-color: var(--warn); }
.st-breach { color: var(--breach); border-color: var(--breach); }
.st-legal_review, .st-instrument_unresolved, .st-manual_classification, .st-no_rate { color: var(--review); border-color: var(--review); }
.st-unfilled { color: var(--unfilled); border-color: var(--unfilled); }
.roster-flags { width: 100%; font-size: 13px; }

.layout { display: flex; align-items: stretch; min-height: 0; }
.board-wrap { flex: 1; overflow: auto; background: var(--panel); border-top: 1px solid var(--line); max-height: calc(100vh - 180px); }
.board { position: relative; }
.row { display: flex; border-bottom: 1px solid var(--line); min-height: var(--row-h); }
.row.head { position: sticky; top: 0; z-index: 3; background: var(--panel); min-height: 44px; }
.label {
  position: sticky; left: 0; z-index: 2; width: var(--label-w); flex: none; background: var(--panel);
  border-right: 1px solid var(--line); padding: 6px 10px; cursor: pointer;
}
.label:hover { background: #fafaf7; }
.label .who { font-weight: 600; }
.label .what { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label .tot { font-size: 12px; font-variant-numeric: tabular-nums; }
.label .tot .warn { color: var(--breach); }
.lane { position: relative; flex: none; }
.day-bg { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line); }
.day-bg.weekend { background: var(--weekend); }
.day-bg.ph { background: var(--ph); }
.day-head { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line); padding: 4px 6px; font-size: 12px; }
.day-head b { font-size: 13px; }
.day-head .phn { color: var(--warn); }
.tick { position: absolute; bottom: 2px; font-size: 10px; color: var(--muted); transform: translateX(-50%); }

.shift {
  position: absolute; height: 44px; border-radius: 6px; background: #fff; border: 1px solid var(--line-strong);
  border-left: 4px solid var(--ok); padding: 2px 6px; font-size: 11.5px; line-height: 1.3; overflow: hidden;
  cursor: grab; user-select: none; touch-action: none; box-shadow: 0 1px 0 rgba(0,0,0,.04);
}
.shift:hover { border-color: var(--ink); }
.shift.sel { outline: 2px solid var(--accent); outline-offset: 1px; }
.shift.dragging { opacity: .75; cursor: grabbing; z-index: 5; }
.shift .t { font-weight: 600; white-space: nowrap; }
.shift .c { white-space: nowrap; color: var(--muted); }
.shift .m { font-variant-numeric: tabular-nums; white-space: nowrap; }
.shift.s-warnings { border-left-color: var(--warn); }
.shift.s-breach { border-left-color: var(--breach); background: #fdf3f1; }
.shift.s-legal_review, .shift.s-instrument_unresolved, .shift.s-manual_classification, .shift.s-no_rate { border-left-color: var(--review); background: #f2f4fa; }
.shift.s-unfilled { border-style: dashed; border-left-style: solid; border-left-color: var(--unfilled); background: #f7f7f5; }
.shift.cancelled { background: repeating-linear-gradient(135deg, #fff, #fff 6px, #f1f1ee 6px, #f1f1ee 12px); }
.shift.cancelled .t { text-decoration: line-through; }
.shift .so { position: absolute; top: 0; bottom: 0; background: rgba(30,107,92,.08); border-left: 1px dashed var(--accent); border-right: 1px dashed var(--accent); pointer-events: none; }
.shift .act { position: absolute; bottom: 0; height: 5px; background: var(--warn); pointer-events: none; }

.drawer {
  width: 460px; flex: none; background: var(--panel); border-left: 1px solid var(--line); border-top: 1px solid var(--line);
  overflow: auto; max-height: calc(100vh - 180px); padding: 12px 16px 40px;
}
.drawer h2 { font-size: 16px; margin: 0 0 2px; }
.drawer h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 6px; }
.drawer-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.big { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.form label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; }
.form label.full { grid-column: 1 / -1; }
.form label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); font-size: 13px; }
.form input, .form select { border: 1px solid var(--line-strong); border-radius: 6px; padding: 4px 6px; color: var(--ink); background: #fff; font-size: 13px; }
.lines { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.lines td { border-top: 1px solid var(--line); padding: 6px 4px; vertical-align: top; }
.lines td.amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.lines .lbl { font-weight: 600; }
.lines .maths { font-variant-numeric: tabular-nums; color: var(--ink); }
.lines .why { color: var(--muted); margin-top: 2px; }
.lines .src { font-size: 11px; color: var(--review); margin-top: 2px; }
.lines tr.total td { border-top: 2px solid var(--ink); font-weight: 700; }
.flags { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.flags li { border-left: 3px solid; padding: 4px 8px; background: #fafaf7; font-size: 12.5px; }
.flags .breach { border-color: var(--breach); }
.flags .warning { border-color: var(--warn); }
.flags .review { border-color: var(--review); }
.flags .info { border-color: var(--line-strong); }
.flags .sev { font-weight: 700; text-transform: uppercase; font-size: 10.5px; letter-spacing: .04em; margin-right: 6px; }
.flags .clause { display: block; font-size: 11px; color: var(--review); }
.rules { list-style: none; padding: 0; margin: 0; font-size: 12px; display: grid; gap: 6px; }
.rules li { background: #fafaf7; padding: 5px 8px; border-radius: 4px; }
.rules .note { color: var(--muted); }
.empty { color: var(--muted); font-style: italic; }

dialog { border: 1px solid var(--line-strong); border-radius: 10px; max-width: 860px; width: calc(100% - 32px); padding: 16px 20px; }
dialog::backdrop { background: rgba(0,0,0,.3); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; font-size: 18px; }
.rule-card { border-top: 1px solid var(--line); padding: 10px 0; font-size: 13px; }
.rule-card code { font-size: 12px; background: #f1f1ee; padding: 0 4px; border-radius: 3px; }
.rule-card table { border-collapse: collapse; margin-top: 4px; font-size: 12px; }
.rule-card td, .rule-card th { border: 1px solid var(--line); padding: 3px 6px; text-align: left; vertical-align: top; }

@media (max-width: 900px) {
  :root { --label-w: 130px; }
  .layout { flex-direction: column; }
  .drawer { width: 100%; max-height: none; border-left: 0; }
  .board-wrap { max-height: 60vh; }
  .controls { margin-left: 0; }
  .name-input { min-width: 0; width: 100%; }
}
