:root {
  --bg: #f6f6f4; --panel: #ffffff; --ink: #1d1d1b; --muted: #6b6b66; --line: #dcdcd6;
  --accent: #1f5fbf; --accent-ink: #ffffff; --ok: #2f7d3b; --warn: #a15c00; --warn-bg: #fff1d6;
  --bad: #b3261e; --bad-bg: #fde7e5; --start: #2f7d3b; --row: #f0f0ec; --sel: #e6eefb;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1b1a; --panel: #242423; --ink: #ecece8; --muted: #9a9a94; --line: #3a3a37;
    --accent: #6ea0f0; --accent-ink: #101010; --ok: #7bcf86; --warn: #f0b255; --warn-bg: #3b2c10;
    --bad: #f1857d; --bad-bg: #3d1c19; --start: #7bcf86; --row: #2c2c2a; --sel: #26354d;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.4 system-ui, "Segoe UI", sans-serif; }
h1 { font-size: 18px; margin: 0 0 10px; } h1 span { color: var(--muted); font-weight: 400; margin-left: 8px; font-size: 14px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 6px; }
.top, .arrangement, .parts, .preview { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.top { margin: 16px; padding: 14px 16px; }
.open { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); min-width: 160px; }
.field.grow, .grow { flex: 1 1 260px; }
.with-button { display: flex; gap: 6px; }
input[type=text], input[type=number], select {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 5px;
  padding: 5px 7px; min-width: 0; width: 100%;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 5px;
  padding: 5px 12px; cursor: pointer; white-space: nowrap;
}
button:hover { background: var(--row); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:disabled { opacity: .45; cursor: not-allowed; }
button.small { padding: 2px 6px; font-size: 12px; }
.progress { position: relative; height: 22px; margin-top: 12px; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
#bar { height: 100%; width: 0; background: var(--accent); opacity: .35; transition: width .3s; }
#progress-text { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; }
.banner { margin: 10px 0 0; padding: 8px 12px; border-radius: 6px; }
.banner.error { background: var(--bad-bg); color: var(--bad); }
main { margin: 0 16px; }
.arrangement { display: flex; gap: 14px; align-items: flex-end; padding: 12px 16px; flex-wrap: wrap; }
.arrangement .field { flex: 1 1 200px; }
.keyfield { flex: 0 1 250px; } .timefield { flex: 0 1 90px; min-width: 70px; }
.key-box { display: flex; gap: 8px; align-items: center; }
.key-svg { display: block; color: var(--ink); } .key-svg svg { display: block; height: 62px; width: auto; }
.key-box select { min-width: 150px; }
.sig-note { margin: 6px 4px 0; }
td.sig .bad { text-decoration: line-through; opacity: .55; }
.badge.mute { background: var(--row); color: var(--muted); }
td.sig { white-space: nowrap; color: var(--muted); font-size: 12px; padding-top: 9px; }
.summary { margin: 0; flex: 2 1 280px; color: var(--muted); }
.summary b { color: var(--ink); } .summary .bad { color: var(--bad); font-weight: 600; } .summary .warn { color: var(--warn); font-weight: 600; }
.columns { display: grid; grid-template-columns: minmax(0, 3.4fr) minmax(280px, 1fr); gap: 14px; margin: 14px 0 90px; align-items: start; }
@media (max-width: 1000px) { .columns { grid-template-columns: 1fr; } }
.parts { padding: 8px 12px 14px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 4px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
td { padding: 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.row { cursor: pointer; } tr.row:hover td { background: var(--row); } tr.row.selected td { background: var(--sel); }
tr.row.attention td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
tr.row.missing td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
td.num { color: var(--muted); text-align: right; width: 30px; }
td.pages input { width: 48px; padding: 5px 3px; text-align: center; } td.pages { white-space: nowrap; width: 112px; }
td.inst { min-width: 150px; } td.inst .label { margin-top: 3px; font-size: 12px; padding: 3px 6px; }
td.no select { width: 68px; } td.tr input { width: 54px; }
td.name { width: 38%; } td.name input { min-width: 300px; }
td.name input.locked { border-color: var(--accent); }
td.notes { min-width: 110px; } td.actions { white-space: nowrap; } td.actions button + button { margin-left: 3px; }
.badge { display: inline-block; padding: 1px 7px; margin: 0 4px 3px 0; border-radius: 10px; font-size: 11px; background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.good { background: transparent; color: var(--ok); }
.table-actions { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }
.strip { display: flex; flex-wrap: wrap; gap: 6px; }
.strip figure { margin: 0; text-align: center; font-size: 11px; color: var(--muted); cursor: pointer; }
.strip img { display: block; width: 72px; border: 3px solid var(--line); border-radius: 3px; background: #fff; }
.strip figure.start img { border-top-color: var(--start); }
.strip figure.unused img { border-color: var(--bad); opacity: .6; }
.strip.small img { width: 92px; }
.preview { padding: 10px 14px 14px; position: sticky; top: 12px; }
.preview h2 { margin-top: 4px; }
#header-img { width: 100%; border: 1px solid var(--line); border-radius: 4px; background: #fff; margin: 8px 0; min-height: 40px; }
.flags-list { margin: 6px 0; padding-left: 18px; color: var(--warn); font-size: 12px; }
.bottom { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 12px; align-items: center; padding: 10px 16px; background: var(--panel); border-top: 1px solid var(--line); }
dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); max-width: min(640px, 92vw); padding: 18px 22px; }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { margin-top: 0; }
.check { display: block; margin: 8px 0; }
.dialog-buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
#dialog-result { margin-top: 10px; font-size: 13px; max-height: 240px; overflow: auto; }
#dialog-result .ok { color: var(--ok); } #dialog-result .bad { color: var(--bad); } #dialog-result .warn { color: var(--warn); }
#zoom-img { max-width: 80vw; max-height: 82vh; display: block; margin-bottom: 10px; }

/* ---- web mode */
.jobs { margin: 0 16px 16px; padding: 4px 16px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.jobs table { width: 100%; border-collapse: collapse; }
.jobs td { padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.jobs td.name { word-break: break-word; }
.jobs td.act { text-align: right; white-space: nowrap; }
.jobs .state.error { color: var(--bad); }
.jobs .state.stale { color: var(--warn); }
a.button { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 5px;
  padding: 5px 12px; text-decoration: none; white-space: nowrap; }
@media (max-width: 700px) { .jobs { margin: 0 8px 12px; } .top { margin: 8px; } }
