:root {
  --bg: #eef0f3;
  --panel: #ffffff;
  --ink: #1d2330;
  --muted: #5b6475;
  --line: #d5dae2;
  --accent: #1f5fbf;
  --accent-soft: #e3ecfb;
  --done: #1d8a3a;
  --warn: #b85c00;
  --danger: #c0262d;
  --stage: #7d8591;
  --btn-h: 46px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--bg); overflow: hidden;
}
#view-review { height: 100%; display: grid; grid-template-rows: 60px 1fr 66px; }
#view-list { height: 100%; overflow-y: auto; }
[hidden] { display: none !important; }
.grow { flex: 1 1 auto; }

.btn {
  min-height: var(--btn-h); min-width: 44px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.small { min-height: 44px; padding: 0 10px; font-size: 14px; }
.btn.square { width: 46px; padding: 0; font-size: 22px; }
.btn.done { background: var(--done); border-color: var(--done); color: #fff; min-width: 130px; font-size: 17px; }
.btn.done:hover:not(:disabled) { background: #176f2f; border-color: #176f2f; }
.btn.warn { color: var(--warn); border-color: #e2b98e; }
.btn.warn.confirm { background: var(--warn); color: #fff; }
.btn.danger { color: var(--danger); border-color: #e7a9ac; }
.btn.primary-soft { background: var(--accent-soft); border-color: #a9c1ea; color: var(--accent); min-width: 140px; }
.btn.toggle { width: 100%; justify-content: space-between; margin-bottom: 6px; }
.btn.toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

header#top {
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0;
}
.h-info { min-width: 0; }
.h-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-sub { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; margin-top: 3px; }
.h-right { text-align: right; font-size: 14px; color: var(--muted); }
.h-progress { font-weight: 600; color: var(--ink); white-space: nowrap; }
.h-user { white-space: nowrap; }
.pill { padding: 1px 9px; border-radius: 10px; font-weight: 700; font-size: 13px; background: #e7e9ee; color: var(--muted); }
.pill.done { background: #d8f0de; color: var(--done); }
.pill.unusable { background: #fbe5d0; color: var(--warn); }
.pill.draft { background: var(--accent-soft); color: var(--accent); }
.save { font-size: 13px; }
.save.failed { color: var(--danger); font-weight: 700; }

main { display: grid; grid-template-columns: 284px 1fr 236px; min-height: 0; }
aside { background: var(--panel); overflow-y: auto; padding: 8px 10px; min-height: 0; }
#left { border-right: 1px solid var(--line); }
#right { border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.sect-head {
  display: flex; align-items: center; justify-content: space-between; min-height: 32px;
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}

.palette { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.prow { display: flex; gap: 4px; }
.prow.hidden .cls { opacity: .45; }
.cls {
  flex: 1 1 auto; min-width: 0; min-height: var(--btn-h); padding: 0 8px; justify-content: flex-start;
  border-width: 2px;
}
.cls .swatch { flex: 0 0 auto; }
.cls { white-space: normal; }
.cls .name { flex: 1 1 auto; min-width: 0; text-align: left; line-height: 1.12; font-size: 14.5px; hyphens: auto; overflow-wrap: anywhere; }
.cls .count { color: var(--muted); font-weight: 600; font-size: 13px; }
.cls.armed { box-shadow: inset 0 0 0 3px var(--ink); }
.cls.current { background: var(--accent-soft); }
.swatch { flex: 0 0 auto; width: 18px; height: 18px; border-radius: 4px; border: 2px solid rgba(0,0,0,.25); display: inline-block; }
.eye, .solo { flex: 0 0 44px; width: 44px; padding: 0; }
.solo { font-size: 13px; }
.eye svg { width: 24px; height: 24px; }
.eye[aria-pressed="false"] { color: var(--muted); background: #eceef2; }
.solo[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

#stage { position: relative; overflow: hidden; background: var(--stage); touch-action: none; user-select: none; }
#page-img {
  position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; max-height: none;
  pointer-events: none; background: #fff; box-shadow: 0 2px 14px rgba(0,0,0,.35); visibility: hidden;
}
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.tag {
  position: absolute; pointer-events: none; padding: 3px 8px; border-radius: 5px; font-weight: 700; font-size: 14px;
  white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.35); z-index: 3;
}
.tag.selected { outline: 2px solid #fff; }
#banner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 16px;
  background: var(--ink); color: #fff; border-radius: 10px; font-size: 17px; font-weight: 700;
  box-shadow: 0 3px 14px rgba(0,0,0,.4);
}
#banner { pointer-events: none; }
#banner .btn { background: #fff; color: var(--ink); min-width: 90px; pointer-events: auto; }
.errors {
  position: fixed; left: 300px; right: 250px; bottom: 76px; z-index: 6; padding: 10px 14px;
  background: #fff4f4; border: 2px solid var(--danger); border-radius: 8px; color: var(--danger); font-size: 14px;
}
.overlay-msg {
  position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; background: rgba(125,133,145,.85); color: #fff;
  font-size: 19px; font-weight: 700; text-align: center; padding: 20px;
}
.spinner {
  width: 46px; height: 46px; border-radius: 50%; border: 5px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#minimap { width: 100%; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; touch-action: none; background: #fff; }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fafbfc; }
.sel-title { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.sel-help { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.changes { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.change-item { flex: 0 0 auto; display: flex; flex-direction: column; gap: 4px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.change-item.undone .change { opacity: .65; }
.change-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding-left: 4px; }
.undone-mark { color: var(--done); font-weight: 700; font-size: 14px; white-space: nowrap; }
.value-only { font-size: 13px; padding: 4px 0; }
.change {
  flex: 0 0 auto; min-height: 44px; text-align: left; justify-content: flex-start; font-weight: 500; white-space: normal;
  padding: 6px 8px; line-height: 1.25;
}
.change .num {
  flex: 0 0 auto; min-width: 26px; height: 26px; border-radius: 13px; color: #fff; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px;
}
.change .verb { font-weight: 700; }
.muted { color: var(--muted); font-size: 14px; }

footer#bottom {
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--panel); border-top: 1px solid var(--line);
}
.sep { width: 1px; height: 36px; background: var(--line); margin: 0 4px; }
.area-label { color: var(--muted); font-size: 14px; white-space: nowrap; min-width: 84px; }

.hint {
  position: fixed; z-index: 20; max-width: 300px; padding: 8px 12px; border-radius: 8px;
  background: var(--ink); color: #fff; font-size: 14px; pointer-events: none; box-shadow: 0 3px 12px rgba(0,0,0,.35);
}

.menu {
  position: fixed; z-index: 30; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.35); padding: 8px; width: 440px;
}
.menu-head { font-weight: 700; padding: 2px 4px 8px; display: flex; align-items: center; gap: 8px; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.menu .btn { min-height: 50px; justify-content: flex-start; padding: 4px 10px; white-space: normal; text-align: left; line-height: 1.15; }
.menu .btn.current { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.menu-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.menu-actions .btn { justify-content: center; }

.lang { display: flex; gap: 2px; }
.lang-btn { min-width: 46px; padding: 0 8px; font-size: 14px; }
.lang-btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.change-actions .btn { white-space: normal; text-align: left; line-height: 1.2; }
.toast {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 7; max-width: 80%;
  padding: 12px 18px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 16px; font-weight: 600;
  box-shadow: 0 3px 14px rgba(0,0,0,.4); pointer-events: none; text-align: center;
}
.done-big { font-size: 30px; }
.menu-changes { display: flex; flex-direction: column; gap: 6px; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.menu-change { display: flex; align-items: center; gap: 8px; }
.menu-change .txt { flex: 1 1 auto; font-size: 14px; }
.num {
  flex: 0 0 auto; min-width: 26px; height: 26px; border-radius: 13px; color: #fff; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px;
}

.list-top {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 14px; height: 64px; padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.list-title { font-weight: 700; font-size: 19px; }
.list-body { max-width: 1120px; margin: 0 auto; padding: 18px 16px 40px; display: flex; flex-direction: column; gap: 12px; }
.list-h { font-size: 22px; margin: 4px 0 6px; }
.batch { display: flex; gap: 10px; align-items: stretch; }
.batch-open {
  flex: 1 1 auto; min-height: 96px; padding: 12px 18px; justify-content: space-between; align-items: center;
  text-align: left; white-space: normal; gap: 18px; font-weight: 500;
}
.batch-main, .batch-side { display: flex; flex-direction: column; gap: 4px; }
.batch-side { align-items: flex-end; text-align: right; flex: 0 0 auto; }
.batch-name { font-size: 20px; font-weight: 700; }
.batch-desc, .batch-meta { color: var(--muted); font-size: 14px; }
.batch-counts { font-size: 15px; font-weight: 700; }
.batch.finished .batch-open { background: #f1f2f4; opacity: .6; }
.batch.finished .batch-name { color: var(--done); }
.bar { display: flex; width: 240px; height: 9px; border-radius: 5px; background: #e1e4e9; overflow: hidden; }
.bar .d { background: var(--done); }
.bar .u { background: #e2a35c; }
.batch-export {
  flex: 0 0 150px; display: inline-flex; align-items: center; justify-content: center; text-align: center;
  font-size: 13px; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; padding: 6px;
}
.list-row-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn { min-width: 110px; }
.chip-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.big { min-height: 54px; font-size: 18px; padding: 0 22px; }
.rows { display: flex; flex-direction: column; gap: 6px; }
.page-row { min-height: 60px; justify-content: flex-start; gap: 18px; padding: 8px 18px; font-weight: 500; text-align: left; }
.page-row .pnum { min-width: 40px; color: var(--muted); font-weight: 700; }
.page-row .who { min-width: 140px; font-weight: 700; }
.page-row .when { min-width: 170px; color: var(--muted); }
.page-row .nch { flex: 1 1 auto; color: var(--muted); }
.muted.big { font-size: 17px; padding: 20px 0; }

.account { position: relative; }
.account-btn { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.account-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; display: flex; flex-direction: column; gap: 6px;
  min-width: 200px; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.3);
}
.account-menu .btn { justify-content: flex-start; text-decoration: none; }
a.btn { text-decoration: none; }

body.page { overflow: auto; height: auto; min-height: 100%; }
.page-body { max-width: 1200px; margin: 0 auto; padding: 18px 16px 48px; display: flex; flex-direction: column; gap: 14px; }
.page-body.narrow { max-width: 560px; }
.page-body.wide { max-width: 1360px; }
.page-body h1 { font-size: 24px; margin: 0 0 4px; }
.page-body h2 { font-size: 18px; margin: 8px 0 0; }
.card.form { display: flex; flex-direction: column; gap: 12px; padding: 18px; background: var(--panel); }
.form label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 14px; color: var(--muted); }
.form input, .form select, .cell-input, td select {
  min-height: 46px; padding: 8px 12px; border: 1px solid #b9c0cc; border-radius: 8px; font: inherit; font-size: 17px;
  color: var(--ink); background: #fff;
}
td select, .cell-input { min-height: 40px; font-size: 15px; }
.form input:focus, .form select:focus, .cell-input:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.form-error { color: var(--danger); font-weight: 700; padding: 10px 12px; background: #fff4f4; border-radius: 8px; }
.form-msg { padding: 10px 14px; border-radius: 8px; background: #e6f4ea; color: var(--done); font-weight: 600; }
.form-msg.bad { background: #fff4f4; color: var(--danger); }
.hint-line { color: var(--muted); font-size: 13.5px; }
.who { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.once-card, .once { padding: 14px 16px; border: 2px solid var(--done); border-radius: 10px; background: #f3fbf5; }
.once-title { font-weight: 700; margin-bottom: 8px; }
.pw { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; font: 700 26px/1.2 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; letter-spacing: .04em; }
.copied { color: var(--done); font-weight: 700; }
.table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 10px; overflow: hidden; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.table.small td { font-size: 13.5px; padding: 6px 10px; }
.table tr.inactive td { color: var(--muted); background: #f6f7f9; }
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.num-cell { text-align: right; }
.login { margin-top: 40px; }

/* spaces: QA batches look like test data at a glance */
.space-pill {
  margin-left: 10px; vertical-align: middle; color: #5c3b00; border: 1px solid #c58b00; letter-spacing: .03em;
  background: repeating-linear-gradient(135deg, #ffd65a 0 6px, #ffe9a3 6px 12px);
}
#h-space:empty { display: none; }
#h-space .space-pill { margin-left: 0; }
.batch[data-space="qa"] .batch-open { border-left: 7px solid #e0a400; }
.space-h { font-size: 18px; margin: 14px 0 2px; padding-bottom: 4px; border-bottom: 2px solid var(--line); }
.space-h.space-qa { border-bottom-color: #e0a400; }
.space-checks { display: flex; gap: 8px; flex-wrap: wrap; }
.space-check {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border: 1px solid #b9c0cc;
  border-radius: 8px; background: #fff; cursor: pointer; font-weight: 600; color: var(--ink); font-size: 14px;
}
.form .space-check { flex-direction: row; }
.space-check input { width: 20px; height: 20px; margin: 0; }
td.spaces { min-width: 190px; }
.table-wrap { overflow-x: auto; border-radius: 10px; }
#users .cell-input { width: 150px; }
#users .actions .btn { padding: 0 9px; }
td.spaces .space-check { white-space: nowrap; }
.spaces-all { color: var(--muted); font-style: italic; }
.field { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 14px; color: var(--muted); }

/* training and settings (admins) */
.space-switch { display: flex; gap: 12px; flex-wrap: wrap; }
.btn.space-btn { flex: 1 1 260px; min-height: 64px; font-size: 20px; }
.btn.space-btn[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: #fff; }
body[data-space="qa"] .training-card { border-left: 7px solid #e0a400; }
.threshold-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.threshold-space, .size-space { min-width: 150px; font-size: 16px; color: var(--ink); }
.training-card {
  display: flex; flex-wrap: wrap; gap: 20px 32px; align-items: center; justify-content: space-between;
  padding: 20px 24px; background: var(--panel);
}
.counter { flex: 1 1 440px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.counter-label { font-size: 18px; font-weight: 600; color: var(--muted); }
.counter-value { font-size: 44px; font-weight: 800; line-height: 1.05; }
.counter-value .of { font-size: 30px; font-weight: 600; color: var(--muted); }
.counter.ready .counter-value b { color: var(--done); }
.bar.big-bar { width: 100%; height: 14px; border-radius: 7px; }
.settings-link { margin-top: 4px; }
.launch { flex: 0 0 340px; display: flex; flex-direction: column; gap: 10px; }
.btn.launch-btn { min-height: 76px; font-size: 21px; white-space: normal; text-align: center; line-height: 1.2; }
.btn.done.confirm { background: #0e5021; border-color: #0e5021; box-shadow: 0 0 0 4px #bfe5c9; }
.launch-reason { min-height: 20px; color: var(--muted); font-size: 15px; font-weight: 600; text-align: center; }
.btn.warn.confirm:hover:not(:disabled) { background: #9a4d00; border-color: #9a4d00; }
.warn-card {
  padding: 12px 16px; border: 2px solid #e2b98e; background: #fff7ee; color: #6b3600; font-weight: 600; font-size: 15px;
}
.active-card { display: flex; flex-direction: column; gap: 14px; padding: 18px 24px; background: var(--panel); }
.active-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.active-head h2 { margin: 0; font-size: 20px; }
.active-card .waiting { color: var(--muted); font-size: 15px; font-weight: 600; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 24px; }
.fact .k { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.fact .v { font-size: 18px; font-weight: 700; margin-top: 3px; }
.fact .progress { display: flex; flex-direction: column; gap: 6px; }
.fact .progress .bar { width: 100%; max-width: 220px; }
.pill.training-requested, .pill.training-starting, .pill.training-running { background: var(--accent-soft); color: var(--accent); }
.pill.training-finished { background: #d8f0de; color: var(--done); }
.pill.training-failed { background: #fbe0e1; color: var(--danger); }
.pill.training-cancelled { background: #e7e9ee; color: var(--muted); }
.pill.dry-run { margin-left: 6px; background: #fff1c7; color: #6b5000; }
#history td { vertical-align: top; }
#history td.status { min-width: 150px; }
.error-line { font-size: 13px; margin-top: 4px; max-width: 280px; overflow-wrap: anywhere; }
.gate.ok b { color: var(--done); }
.gate.bad b { color: var(--danger); }
.gate .muted { font-size: 13px; margin-top: 2px; }
.pull-card h2 { margin: 0; font-size: 22px; }
.pull-explain { font-size: 16px; color: var(--muted); }
.pull-card > .active-card, .pull-card > .table-wrap { flex: 1 1 100%; }
#pull-history tbody tr:last-child td { border-bottom: 0; }
.space-head { display: flex; align-items: center; gap: 12px; }
.space-head .space-h { flex: 1 1 auto; }
.stepper { display: flex; gap: 8px; align-items: stretch; }
.stepper .btn { width: 72px; min-height: 60px; font-size: 30px; padding: 0; }
.form .stepper input { width: 150px; min-height: 60px; text-align: center; font-size: 26px; font-weight: 700; }

@media (max-width: 1400px) {
  main { grid-template-columns: 270px 1fr 220px; }
  .btn { padding: 0 11px; }
  .btn.done { min-width: 116px; }
  .btn.primary-soft { min-width: 124px; }
}
