:root {
  --bg: #f5f6f8; --panel: #ffffff; --ink: #1c2330; --muted: #677285; --line: #dde1e8;
  --accent: #1f5fbf; --accent-ink: #fff; --accent-soft: #e6eefb;
  --err: #b42318; --err-soft: #fdecea; --warn: #9a6700; --warn-soft: #fff6dd; --ok: #1a7f37; --ok-soft: #e6f4ea;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1b2029; --ink: #e5e8ee; --muted: #98a2b3; --line: #2c3340;
    --accent: #5b9bff; --accent-ink: #0b1220; --accent-soft: #1d2a40;
    --err: #ff8a80; --err-soft: #3a1c1c; --warn: #f2c14e; --warn-soft: #3a2f12; --ok: #6fd38b; --ok-soft: #173322;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.4 system-ui, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 600; font-size: 16px; }
.logo { background: var(--accent); color: var(--accent-ink); padding: 2px 7px; border-radius: 5px; margin-right: 6px; font-family: var(--mono); }
.who { font-size: 12px; color: var(--muted); }
.shell { display: flex; min-height: calc(100vh - 49px); }
.side { width: 190px; flex: none; padding: 12px 8px; border-right: 1px solid var(--line); background: var(--panel); }
.side a { display: block; padding: 8px 12px; border-radius: 6px; color: var(--ink); text-decoration: none; margin-bottom: 2px; }
.side a:hover { background: var(--accent-soft); }
.side a.on { background: var(--accent); color: var(--accent-ink); }
main { flex: 1; padding: 18px 22px 60px; min-width: 0; }
h1 { font-size: 20px; margin: 0 0 14px; } h2 { font-size: 15px; margin: 18px 0 8px; } h3 { font-size: 13px; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: var(--mono); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
button, .btn { font: inherit; padding: 7px 13px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
button:hover { border-color: var(--accent); }
.btn { display: inline-block; text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
[hidden] { display: none !important; }
fieldset:disabled input, fieldset:disabled select { opacity: .75; }
button.danger { color: var(--err); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }
input, select, textarea { font: inherit; width: 100%; padding: 6px 8px; border-radius: 5px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input:disabled, select:disabled, textarea:disabled { opacity: .75; }
textarea { min-height: 70px; resize: vertical; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--accent-soft); }
.chip { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.chip.draft { background: var(--line); color: var(--ink); }
.chip.sent { background: var(--accent-soft); color: var(--accent); }
.chip.confirmed { background: var(--ok-soft); color: var(--ok); }
.chip.rejected, .chip.no-facilities { background: var(--err-soft); color: var(--err); }
.chip.cancelled, .chip.partial-cancel { background: var(--warn-soft); color: var(--warn); }
.badge { background: var(--err); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; margin-left: 4px; }

/* editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 14px; }
.tabs button.on { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
.tabs .cnt { font-size: 11px; color: var(--err); margin-left: 4px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 14px; }
.fld { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fld.w2 { grid-column: span 2; } .fld.full { grid-column: 1 / -1; }
.fld label { font-size: 12px; display: flex; gap: 6px; align-items: baseline; }
.fld label b { font-family: var(--mono); font-size: 11.5px; }
.fld label .nm { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fld .req { font-size: 10px; font-weight: 700; padding: 0 4px; border-radius: 3px; background: var(--line); }
.fld .req.R { background: var(--err-soft); color: var(--err); }
.fld .meta { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.fld.bad input, .fld.bad select, .fld.bad textarea { border-color: var(--err); background: var(--err-soft); }
.fld.warn input, .fld.warn select { border-color: var(--warn); }
.fld .emsg { font-size: 11px; color: var(--err); }
.auto { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.auto b { color: var(--ink); font-family: var(--mono); }
.sdcard { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 12px; background: var(--panel); }
.sdcard .sdhead { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sdcard .num { font-family: var(--mono); font-weight: 700; background: var(--accent); color: var(--accent-ink); border-radius: 5px; padding: 1px 7px; }
details > summary { cursor: pointer; color: var(--muted); font-size: 12px; margin: 8px 0; }
.issues { position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow: auto; }
.issue { display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--err); background: var(--err-soft); margin-bottom: 6px; padding: 6px 8px; border-radius: 0 5px 5px 0; font-size: 12px; }
.issue.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.issue b { font-family: var(--mono); }
.allgood { color: var(--ok); background: var(--ok-soft); padding: 8px 10px; border-radius: 6px; font-size: 13px; }
.banner { padding: 10px 14px; border-radius: 6px; background: var(--accent-soft); margin-bottom: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner.err { background: var(--err-soft); }
.preview { font-family: var(--mono); font-size: 12px; white-space: pre; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px; max-height: 420px; }
.preview span.f { border-bottom: 1px dotted var(--muted); }
.preview span.f:hover { background: var(--accent-soft); }
.preview span.fill { color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; font-size: 13px; }
.kv dt { font-family: var(--mono); color: var(--muted); font-size: 12px; } .kv dd { margin: 0; }
.drop { border: 2px dashed var(--line); border-radius: 8px; padding: 18px; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 20; }
.toast { background: var(--ink); color: var(--panel); padding: 9px 14px; border-radius: 6px; max-width: 420px; box-shadow: 0 4px 14px #0003; }
.toast.error { background: var(--err); color: #fff; }
dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); width: min(720px, 94vw); padding: 18px; }
dialog::backdrop { background: #0006; }
@media (max-width: 900px) {
  .shell { flex-direction: column; } .side { width: auto; display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .side a { white-space: nowrap; } .editor { grid-template-columns: 1fr; } .issues { position: static; max-height: none; }
  main { padding: 14px 16px 60px; } .fld.w2 { grid-column: auto; }
}
