:root {
  --ink: #1b1f24;
  --muted: #5c6670;
  --line: #d9dee3;
  --bg: #f3f5f7;
  --card: #fff;
  --accent: #0b5cad;
  --accent-ink: #fff;
  --danger: #b3261e;
  --ok: #1e7d34;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.4;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: .2rem 0 .8rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
h2 { font-size: 1.2rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: .8rem 0 .4rem; }
h3:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.center { text-align: center; }

/* Header */
header.top { display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; background: #13202e; color: #fff; flex-wrap: wrap; position: sticky; top: 0; z-index: 10; }
header.top a { color: #fff; }
.brand { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.search { flex: 1; min-width: 180px; max-width: 420px; }
.search input { width: 100%; padding: .45rem .7rem; border-radius: 8px; border: 0; font-size: 1rem; }
.menu { display: flex; align-items: center; gap: 1rem; margin-left: auto; font-size: .95rem; }
.linklike { background: none; border: 0; color: #cfe0f2; cursor: pointer; font: inherit; padding: 0; }

main { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.crumbs { font-size: .9rem; margin-bottom: .5rem; display: flex; gap: .4rem; flex-wrap: wrap; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.card.narrow { max-width: 440px; margin: 2rem auto; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.cols > .card { margin-bottom: 0; }
.cols + * { margin-top: 1rem; }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }

.titlebar { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; flex-wrap: wrap; }
.titlebar h1, .titlebar h2 { margin-bottom: .4rem; }
.sub { margin: -.4rem 0 .6rem; color: var(--muted); }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: .25rem; color: var(--ink); }
.tile:hover { border-color: var(--accent); text-decoration: none; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.tile span { color: var(--muted); font-size: .9rem; }

/* Buttons & forms */
button, .btn { display: inline-flex; align-items: center; gap: .3rem; padding: .5rem .9rem; border-radius: 8px; border: 1px solid #b9c2cb; background: #fff; color: var(--ink); font: inherit; font-size: .95rem; cursor: pointer; text-decoration: none; min-height: 40px; }
button:hover, .btn:hover { background: #eef2f6; text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover, .btn.primary:hover { background: #094d91; }
button.danger { color: var(--danger); border-color: #e3b4b0; }
button.danger:hover { background: #fdecea; }
.small.btn, button.small { padding: .3rem .6rem; min-height: 32px; font-size: .85rem; }
label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .9rem; }
label small { font-weight: 400; color: var(--muted); }
label.check { flex-direction: row; align-items: center; font-weight: 500; gap: .5rem; }
label.compact { flex-direction: row; align-items: center; gap: .4rem; font-weight: 500; }
input, select, textarea { font: inherit; font-size: 1rem; padding: .5rem .6rem; border: 1px solid #b9c2cb; border-radius: 7px; background: #fff; color: var(--ink); min-height: 40px; width: 100%; }
input[type=checkbox] { width: 1.15rem; height: 1.15rem; min-height: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #8bb8e8; border-color: var(--accent); }
input:disabled, select:disabled { background: #f1f3f5; color: #8a939c; }
form.inline { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
form.inline input:not([type=checkbox]) { width: auto; flex: 1; min-width: 160px; }
form + form { margin-top: .6rem; }
.card form label { margin-bottom: .2rem; }
.form-grid fieldset { border: 0; border-top: 1px solid var(--line); margin: 0 0 1rem; padding: .8rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem 1rem; }
.form-grid fieldset:first-of-type { border-top: 0; padding-top: 0; }
.form-grid legend { font-weight: 700; font-size: 1.05rem; padding: 0 0 .4rem; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid .ats-pair { display: contents; }
.form-grid .ats-pair[hidden] { display: none; }
.form-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.form-actions.sticky { position: sticky; bottom: 0; background: #fff; padding: .7rem 0; border-top: 1px solid var(--line); margin-top: .5rem; }
[hidden] { display: none !important; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: #e8f0fb; border: 1px solid #c4d7f2; }
.flash.ok { background: #e7f5ea; border-color: #b9dfc2; }
.flash.error { background: #fdecea; border-color: #f3c1bc; color: #7d1a14; }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; letter-spacing: .02em; vertical-align: middle; white-space: nowrap; }
h1 .badge { font-size: .8rem; }
.tag { display: inline-block; padding: .05rem .4rem; border-radius: 4px; background: #eef1f4; border: 1px solid #dde2e7; font-size: .75rem; color: #3b444d; white-space: nowrap; }
.tag.strong { background: #13202e; color: #fff; border-color: #13202e; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; }
table.list th, table.list td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.list th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8f9fa; }
table.list tr.inactive td { color: #999; }
table.list td.num { font-weight: 700; white-space: nowrap; }
@media (max-width: 640px) { .hide-sm { display: none; } }

dl.info { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
dl.info dt { color: var(--muted); font-size: .9rem; }
dl.info dd { margin: 0; font-weight: 500; }
.notes { margin-top: .8rem; padding-top: .6rem; border-top: 1px solid var(--line); }
.notes p { white-space: pre-wrap; margin: .3rem 0 0; }
ul.feedlist { list-style: none; padding: 0; margin: 0 0 .5rem; }
ul.feedlist li { padding: .3rem 0; border-bottom: 1px dashed var(--line); }
ul.feedlist li:last-child { border-bottom: 0; }

/* Panel schedule */
table.schedule { font-size: .88rem; }
table.schedule th { background: #f0f2f4; font-size: .72rem; text-transform: uppercase; color: var(--muted); padding: .35rem .3rem; border: 1px solid var(--line); }
table.schedule td { border: 1px solid var(--line); padding: .3rem .35rem; vertical-align: top; }
table.schedule td.num { text-align: center; font-weight: 700; background: #fafbfc; width: 2.4rem; }
table.schedule td.brk, table.schedule td.va { white-space: nowrap; text-align: right; width: 4.2rem; }
table.schedule td.ph { text-align: center; width: 2rem; color: var(--muted); }
table.schedule td.desc { min-width: 9rem; }
table.schedule td.split { border-left: 3px solid #7b8691; }
td.desc.spare, td.desc.space, .desc.spare, .desc.space { color: var(--muted); }
td.cont { color: #8a939c; font-size: .8rem; background: repeating-linear-gradient(45deg, #fafbfc, #fafbfc 6px, #f2f4f6 6px, #f2f4f6 12px); }
td.empty { background: #fcfcfd; }
a.add { font-size: .8rem; color: #8a939c; }
a.add:hover { color: var(--accent); }
a.feeds { font-size: .8rem; font-weight: 600; white-space: nowrap; }
.wire { color: var(--muted); font-size: .75rem; }
.wide-only { display: block; }
.narrow-only { display: none; }
@media (max-width: 820px) {
  .wide-only { display: none; }
  .narrow-only { display: block; }
}
ol.mobile-list { list-style: none; padding: 0; margin: 0; }
ol.mobile-list li { display: grid; grid-template-columns: 2.4rem 1fr; grid-template-rows: auto auto; padding: .45rem 0; border-bottom: 1px solid var(--line); }
ol.mobile-list .num { grid-row: span 2; font-weight: 700; color: var(--muted); }
ol.mobile-list .meta { font-size: .8rem; color: var(--muted); }
ol.mobile-list li.cont, ol.mobile-list li.empty { color: #8a939c; font-size: .85rem; }

.totals { margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.totals table { width: auto; min-width: 320px; font-size: .92rem; }
.totals th, .totals td { padding: .3rem .8rem .3rem 0; text-align: right; }
.totals thead th { color: var(--muted); font-size: .8rem; font-weight: 600; }
.totals tbody th { text-align: left; color: var(--muted); font-weight: 600; }
.pct { margin: .6rem 0 .2rem; }
.pct.warn b { color: #b45309; }

/* Bulk editor */
table.bulk-table { font-size: .88rem; }
table.bulk-table th { font-size: .72rem; text-transform: uppercase; color: var(--muted); text-align: left; padding: .3rem; white-space: nowrap; position: sticky; top: 0; background: #fff; }
table.bulk-table td { padding: .15rem .2rem; border-bottom: 1px solid #eef0f2; }
table.bulk-table td.num { font-weight: 700; text-align: center; width: 2.2rem; }
table.bulk-table input, table.bulk-table select { min-height: 34px; padding: .3rem .4rem; font-size: .9rem; }
table.bulk-table td:nth-child(2) { min-width: 14rem; }
table.bulk-table input.n { width: 5.5rem; }
table.bulk-table input.ph { width: 3.6rem; }
table.bulk-table input.w { width: 6.5rem; }
table.bulk-table td.c { text-align: center; }
table.bulk-table tr.covered { opacity: .45; }
table.bulk-table tr.covered td.num::after { content: " ↳"; }
table.bulk-table td.feeds { font-size: .8rem; white-space: nowrap; }

/* History */
table.history ul.changes { margin: 0; padding-left: 1rem; }
table.history s { color: #a33; }
.act { font-weight: 700; }
.act.create { color: var(--ok); }
.act.delete { color: var(--danger); }

/* Tree */
ul.tree { list-style: none; margin: 0; padding: 0; }
ul.tree li { padding: .35rem 0 .35rem calc(var(--d, 0) * 1.4rem + .2rem); border-left: 0; position: relative; }
ul.tree li::before { content: ""; position: absolute; left: calc(var(--d, 0) * 1.4rem - .6rem); top: 0; bottom: 50%; width: .5rem; border-left: 1px solid #b9c2cb; border-bottom: 1px solid #b9c2cb; }
ul.tree li[style*="--d:0"]::before { display: none; }
.card.this { border: 2px solid var(--accent); }

details.manage summary { cursor: pointer; color: var(--muted); font-weight: 600; margin-bottom: .4rem; }
details.manage[open] summary { margin-bottom: .8rem; }
.floor .manage { margin-top: .8rem; }

/* QR / stickers */
.sticker-preview { max-width: 100%; height: auto; }
ul.downloads { padding-left: 1.1rem; }
ul.downloads li { margin: .3rem 0; }
.pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .3rem 1rem; margin: .6rem 0; }
.sticker-sheet { display: flex; flex-wrap: wrap; gap: .25in; }
.sticker-sheet img { width: 2in; height: 2.6in; }
.temp-pw { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.5rem; padding: .6rem; background: #f3f5f7; border-radius: 8px; text-align: center; user-select: all; }

/* Public QR page */
.public { max-width: 640px; margin: 0 auto; }
.public h1 { font-size: 2rem; margin-top: .6rem; }
.public-list td.num { width: 5rem; }
.public-list td { font-size: 1.05rem; }

@media print {
  header.top, .no-print, .crumbs, .flash { display: none !important; }
  body, :root { background: #fff; }
  main { padding: 0; max-width: none; }
  .sticker-sheet { gap: .2in; }
  .sticker-sheet img { break-inside: avoid; }
  @page { size: letter; margin: .4in; }
}
