/* AV365 Signage CMS.
   A dashboard: the menu on the left, the page beside it; white cards with thin borders, calm tables.
   Colours are AV365's (avmarket.hu): red #d90012 / #b00012, ink #171a1f, slate #56616d, greys #f3f5f7 / #dce1e6.
   Red is kept for the brand, the primary action and the open menu entry; the rest is ink and grey, so a red
   state tag (offline, failed) still stands out.
   Light and dark theme: the system setting unless the user picked one (data-theme on <html>, "Saját fiók" page). */

:root {
  color-scheme: light;
  --page: #f3f5f7;
  --panel: #ffffff;
  --side: #ffffff;
  --fill: #f1f3f6;
  --hover: #f7f8fa;
  --line: #e8ebef;
  --edge: #d5dbe1;
  --text: #171a1f;
  --muted: #56616d;
  --faint: #8a94a0;
  --red: #d90012;
  --red-dark: #b00012;
  --red-soft: #fff1f2;
  --red-text: #b00012;
  --neutral: #dfe4e9;
  --ok: #17702f;
  --ok-bg: #e4f2e8;
  --warn: #7a4a00;
  --warn-bg: #fbefd2;
  --bad: #b00012;
  --bad-bg: #fde6e8;
  --focus: #171a1f;
  --shadow: 0 16px 40px rgb(23 26 31 / 22%);
  --stage: #0b0c0e;
  --series: #d90012;
  --series-wash: rgb(217 0 18 / 10%);
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0f1114;
    --panel: #181b20;
    --side: #14171b;
    --fill: #22262c;
    --hover: #1d2126;
    --line: #262b31;
    --edge: #343a42;
    --text: #e6e9ec;
    --muted: #9aa4ae;
    --faint: #6f7a85;
    --red-soft: #32171b;
    --red-text: #ff8a92;
    --neutral: #333a42;
    --ok: #5cc98a;
    --ok-bg: #15281c;
    --warn: #e8b84a;
    --warn-bg: #2d2412;
    --bad: #ff6b75;
    --bad-bg: #331a1e;
    --focus: #e6e9ec;
    --shadow: 0 16px 40px rgb(0 0 0 / 55%);
    --series: #ff5c67;
    --series-wash: rgb(255 92 103 / 14%);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0f1114;
  --panel: #181b20;
  --side: #14171b;
  --fill: #22262c;
  --hover: #1d2126;
  --line: #262b31;
  --edge: #343a42;
  --text: #e6e9ec;
  --muted: #9aa4ae;
  --faint: #6f7a85;
  --red-soft: #32171b;
  --red-text: #ff8a92;
  --neutral: #333a42;
  --ok: #5cc98a;
  --ok-bg: #15281c;
  --warn: #e8b84a;
  --warn-bg: #2d2412;
  --bad: #ff6b75;
  --bad-bg: #331a1e;
  --focus: #e6e9ec;
  --shadow: 0 16px 40px rgb(0 0 0 / 55%);
  --series: #ff5c67;
  --series-wash: rgb(255 92 103 / 14%);
}

/* --- base ------------------------------------------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--text); text-decoration: underline; text-decoration-thickness: 1px; text-decoration-color: var(--faint); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
h1 { font-size: 22px; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 15px; line-height: 1.35; font-weight: 600; margin: 0; }
p { margin: 0 0 8px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }
.break { overflow-wrap: anywhere; }
.right { text-align: right; }
ul.plain { list-style: none; margin: 4px 0 0; padding: 0; }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* --- the frame: menu on the left, page on the right -------------------------------------------------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow-y: auto;
  background: var(--side); border-right: 1px solid var(--edge); scrollbar-width: thin;
}
.side-brand { display: flex; align-items: center; flex: none; height: 60px; padding: 0 20px; color: var(--text); }
.side-brand, .side-brand:hover { text-decoration: none; }
/* The AV365 logo and the product's name beside it; the logo's "365" is drawn in the text colour (logo.svg). */
.logo { display: inline-flex; align-items: baseline; gap: 9px; color: var(--text); line-height: 1; white-space: nowrap; }
.logo-mark { display: block; flex: none; height: 28px; width: auto; }
.logo span { font-size: 15px; font-weight: 500; color: var(--muted); }
.side-org { flex: none; padding: 0 12px 12px; border-bottom: 1px solid var(--line); }
.side-org-name { display: block; padding: 0 8px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-nav { flex: 1; padding: 10px 12px 16px; }
.side-group + .side-group { margin-top: 14px; }
.side-label { padding: 6px 8px 4px; font-size: 12.5px; color: var(--faint); }
.side-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.side-link { text-decoration: none; display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 4px 8px; border-radius: 6px; color: var(--text); font-weight: 500; }
.side-link .icon { color: var(--muted); }
.side-link:hover { background: var(--fill); text-decoration: none; }
.side-link[aria-current="page"] { background: var(--red-soft); color: var(--red-text); font-weight: 600; }
.side-link[aria-current="page"] .icon { color: inherit; }
.side-link > #alert-badge, .side-link > .badge { margin-left: auto; }
.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--red); color: #ffffff; font-size: 11.5px; font-weight: 700; line-height: 20px; text-align: center;
}
.side-user { flex: none; display: flex; align-items: center; gap: 4px; padding: 10px 12px; border-top: 1px solid var(--line); }
.side-who { text-decoration: none; flex: 1; min-width: 0; display: grid; padding: 4px 8px; border-radius: 6px; color: var(--text); line-height: 1.35; }
.side-who:hover { background: var(--fill); text-decoration: none; }
.side-who strong, .side-who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-who strong { font-weight: 600; }
.side-who span { font-size: 12.5px; color: var(--muted); }
.side-user form { display: contents; }
.side-logout { flex: none; height: 30px; padding: 0 8px; border: 0; border-radius: 6px; background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.side-logout:hover { background: var(--fill); color: var(--text); }
.org-switch select { font-weight: 600; }
.main { min-width: 0; }
.topbar { display: none; }
.side-backdrop { display: none; }
.page { max-width: 1280px; margin: 0 auto; padding: 26px 32px 64px; }

/* --- page head -------------------------------------------------------------------------------------- */
.titlebar { display: flex; align-items: center; justify-content: space-between; gap: 10px 20px; flex-wrap: wrap; min-height: 34px; margin-bottom: 16px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }
.info { color: var(--muted); max-width: 92ch; margin: -8px 0 18px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dirty { color: var(--warn); font-size: 13px; font-weight: 600; margin-right: 4px; }

/* The pages of one thing (a display): tabs under its head, each a page of its own. */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; margin: -4px 0 18px; border-bottom: 1px solid var(--edge); }
.tabs a { margin-bottom: -1px; padding: 8px 12px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; text-decoration: none; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--red); }
/* A part of a page that refreshes itself keeps its distance like a card does. */
.page > [hx-get] { margin-bottom: 16px; }

/* --- panels ----------------------------------------------------------------------------------------- */
.panel { background: var(--panel); border: 1px solid var(--edge); border-radius: 6px; }
.panel + .panel, .panel + .note, .note + .panel { margin-top: 16px; }
.panel-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  min-height: 48px; padding: 8px 16px; border-bottom: 1px solid var(--line); font-size: 15px; font-weight: 600;
}
.panel > .panel-head:not(:first-child) { border-top: 1px solid var(--line); }
.panel-head .muted { font-weight: 400; font-size: 13px; }
.panel-head a { font-weight: 400; font-size: 13px; }
.page > form, .page > .panel, .page > section { margin-bottom: 16px; }
.page > form > .panel, .page > form > .msg { margin-bottom: 16px; }
.page > form > .actions { margin-top: 16px; }
.panel-body { padding: 16px; }
.panel-body > :last-child { margin-bottom: 0; }
.panel-body > p:first-child { margin-top: 0; }
.panel-body > h2 { margin: 16px 0 4px; }
.panel-body > p + .form, .panel-body > .msg + .form { margin-top: 14px; }
.panel-body > .actions { margin: 12px 0; }
.panel-body > .actions:last-child { margin-bottom: 0; }
.panel-body + table.grid, .panel-body + .scroll, .panel-body + div:not([class]) { border-top: 1px solid var(--line); }
table + .panel-body, .scroll + .panel-body { border-top: 1px solid var(--line); }
.panel-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); }
.note { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.empty { padding: 28px 16px; color: var(--muted); text-align: center; }
.narrow { max-width: 640px; }

/* --- buttons and fields ----------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 13px;
  border: 1px solid var(--edge); border-radius: 6px; background: var(--panel); color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 600; line-height: 1; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--fill); text-decoration: none; }
.btn:disabled { color: var(--faint); cursor: not-allowed; background: var(--fill); }
.btn-primary { background: var(--red); border-color: var(--red); color: #ffffff; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-primary:disabled { background: var(--red); color: #ffffff; opacity: .45; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); }
.btn-emergency { background: var(--red); border-color: var(--red); color: #ffffff; }
.btn-emergency:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-emergency:disabled { background: var(--red); color: #ffffff; opacity: .45; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--text); cursor: pointer; text-decoration: underline; text-decoration-thickness: 1px; text-decoration-color: var(--faint); text-underline-offset: 3px; }
.linkbtn:hover { text-decoration-color: currentColor; }

input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="email"],
input[type="date"], input[type="time"], input[type="datetime-local"], select, textarea {
  width: 100%; height: 34px; padding: 4px 10px; border: 1px solid var(--edge); border-radius: 6px;
  background: var(--panel); color: var(--text); font: inherit;
}
textarea { height: auto; min-height: 84px; }
input::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; margin: 0; accent-color: var(--red); vertical-align: -3px; }
.check { display: inline-flex; gap: 7px; align-items: center; white-space: nowrap; }
.choices { display: grid; gap: 8px; justify-items: start; }

/* A form: the label above its field. */
.form { display: grid; gap: 6px; }
.form > .label { margin-top: 10px; font-weight: 600; }
.form > .label:first-child { margin-top: 0; }
.form > .label:empty { display: none; }
.form > .label:empty + .control { margin-top: 10px; }
.form > .control { min-width: 0; }
.form > .buttons { display: flex; gap: 8px; margin-top: 14px; }
.help { color: var(--muted); font-size: 13px; margin-top: 4px; }
.errorlist { list-style: none; margin: 4px 0 0; padding: 0; color: var(--bad); font-size: 13px; }
.control > div > div > label { display: flex; gap: 7px; align-items: center; padding: 3px 0; }
.code-input { font-family: var(--mono) !important; font-size: 20px !important; height: 44px !important; letter-spacing: .12em; text-transform: uppercase; max-width: 220px; }

/* --- messages and tags ------------------------------------------------------------------------------ */
.messages { list-style: none; margin: 0 0 16px; padding: 0; }
.msg { border-left: 3px solid var(--faint); border-radius: 6px; background: var(--fill); padding: 10px 14px; margin: 0 0 12px; }
.msg-success { border-left-color: var(--ok); background: var(--ok-bg); }
.msg-warning { border-left-color: var(--warn); background: var(--warn-bg); }
.msg-error { border-left-color: var(--bad); background: var(--bad-bg); }
.msg ul { margin: 4px 0 0 18px; padding: 0; }
.tag {
  display: inline-block; padding: 1px 7px; border-radius: 4px; background: var(--fill); color: var(--muted);
  font-size: 12px; line-height: 18px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.tag::first-letter { text-transform: uppercase; }
a.tag:hover { text-decoration: none; filter: brightness(.96); }
.tag-ok { color: var(--ok); background: var(--ok-bg); }
.tag-warn { color: var(--warn); background: var(--warn-bg); }
.tag-bad { color: var(--bad); background: var(--bad-bg); }
.tag.tag-label { background: none; box-shadow: inset 0 0 0 1px var(--edge); font-weight: 500; }
.tag.tag-label::first-letter { text-transform: none; }

/* --- tables ----------------------------------------------------------------------------------------- */
.scroll { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { padding: 10px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.grid th { padding-top: 9px; padding-bottom: 9px; color: var(--muted); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: var(--hover); }
table.grid td.num { text-align: right; white-space: nowrap; }
table.grid td.fit { width: 1%; white-space: nowrap; }
table.grid td.mono { font-family: inherit; font-size: 13px; }
table.grid td strong { font-weight: 600; }
table.grid th.right { text-align: right; }
table.grid .btn { height: 28px; padding: 0 10px; font-size: 13px; }
table.grid td.empty { padding: 28px 16px; text-align: center; }
table.grid tbody tr:hover td.empty { background: none; }
/* A row opens what its first cell links to (cms.js). */
table.grid tbody tr:has(td:first-child > a:not(.tag)) { cursor: pointer; }
/* The name a row opens: heavier, and underlined only under the pointer. */
table.grid td:first-child > a:not(.tag) { font-weight: 600; text-decoration: none; }
table.grid td:first-child > a:not(.tag):hover { text-decoration: underline; }
/* A hovered last row would stick out of the card's round corners. */
.panel > table.grid:last-child tbody tr:last-child td:first-child,
.panel > .scroll:last-child > table.grid tbody tr:last-child td:first-child { border-bottom-left-radius: 5px; }
.panel > table.grid:last-child tbody tr:last-child td:last-child,
.panel > .scroll:last-child > table.grid tbody tr:last-child td:last-child { border-bottom-right-radius: 5px; }
/* The display list under locations and groups: a heading row for each, their displays under them. */
table.grid tr.place-row th { padding-top: 14px; background: var(--fill); color: var(--text); font-size: 14px; white-space: normal; }
table.grid tr.group-row th { padding-left: 16px; color: var(--text); font-size: 13.5px; white-space: normal; }
table.grid tr.group-row .place-head > a { font-weight: 600; text-decoration: none; }
table.grid tr.group-row .place-head > a:hover { text-decoration: underline; }
.place-name { font-weight: 700; }
.place-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; }
.place-actions { margin-left: auto; display: inline-flex; gap: 14px; font-size: 13px; font-weight: 400; }
table.grid tbody tr.place-row:hover th, table.grid tbody tr.group-row:hover th { background-color: inherit; }
table.grid tbody tr.place-row:hover th { background: var(--fill); }
/* Name and value pairs (a display's state, a media file's data). */
table.props { border-collapse: collapse; width: 100%; margin-bottom: 12px; }
table.props th, table.props td { padding: 9px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.props th { width: 128px; padding-right: 16px; color: var(--muted); font-weight: 400; white-space: nowrap; }
table.props tr:last-child th, table.props tr:last-child td { border-bottom: 0; }
table.props td { overflow-wrap: anywhere; }
table.props td.mono { font-family: inherit; font-size: inherit; }
table.props td .btn { margin-top: 6px; }

/* --- filters above a list --------------------------------------------------------------------------- */
.toolbar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar label:not(.check) { display: grid; gap: 4px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.toolbar label.check { height: 34px; }
.toolbar input, .toolbar select { width: auto; max-width: 240px; font-size: 14px; font-weight: 400; color: var(--text); }
.toolbar input[type="search"] { width: 280px; max-width: none; }
.toolbar-end { margin-left: auto; }
/* The periods of the report as quiet links under its filters. */
.periods { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: -4px 0 16px; color: var(--muted); font-size: 13px; }
.periods a[aria-current] { font-weight: 600; text-decoration-color: currentColor; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; max-width: 100%; padding: 3px; border-radius: 8px; background: var(--fill); }
.segmented .btn { height: 28px; border-color: transparent; background: none; color: var(--muted); }
.segmented .btn:hover { color: var(--text); }
.segmented .btn.active, .segmented .btn-primary, .segmented .btn-primary:hover {
  background: var(--panel); border-color: var(--edge); color: var(--text);
}
/* A choice of a few, drawn like the segmented buttons (the theme on the account page). */
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice span { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border: 1px solid transparent; border-radius: 6px; color: var(--muted); font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.choice span:hover { color: var(--text); }
.choice input:checked + span { background: var(--panel); border-color: var(--edge); color: var(--text); }
.choice input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

/* --- settings: a card of rows, the text on the left, the control on the right ------------------------- */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; padding: 16px; }
.setting + .setting { border-top: 1px solid var(--line); }
.setting-text { flex: 1 1 300px; min-width: 0; }
.setting-text p { margin: 2px 0 0; color: var(--muted); }
.setting-text .tag { margin-left: 6px; vertical-align: 1px; }
.setting-control { flex: none; display: flex; align-items: center; gap: 8px; }
.setting-control form { display: contents; }
.setting-control select { width: auto; min-width: 150px; }

/* --- media library ---------------------------------------------------------------------------------- */
.upload { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; margin-bottom: 16px; border: 1px dashed var(--edge); border-radius: 6px; background: var(--panel); }
.upload.over { border-color: var(--red); background: var(--red-soft); }
.upload > .muted { flex: 1 1 320px; font-size: 13px; }
.upload-file { position: relative; overflow: hidden; }
.upload-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-owner { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.upload-owner select { width: auto; }
#uploads:empty { display: none; }
#uploads { margin-bottom: 16px; }
.upload-row { display: grid; grid-template-columns: minmax(0, 1fr) 180px 80px; gap: 12px; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.upload-row:last-child { border-bottom: 0; }
.upload-row progress { width: 100%; height: 8px; accent-color: var(--red); }
.upload-row.failed { grid-template-columns: minmax(0, 1fr) auto; color: var(--bad); background: var(--bad-bg); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.tile-cell { display: flex; min-width: 0; }
.tile {
  display: flex; flex-direction: column; width: 100%; padding: 0; overflow: hidden; text-align: left; cursor: pointer;
  border: 1px solid var(--edge); border-radius: 6px; background: var(--panel); color: inherit; font: inherit;
}
.tile:hover { border-color: var(--faint); }
.tile-img { display: block; position: relative; flex: none; width: 100%; aspect-ratio: 4 / 3; background: var(--stage); }
.tile-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.tile-img .none { position: absolute; inset: 0; display: grid; place-items: center; color: #8f99a4; font-size: 12px; }
.tile-text { display: block; width: 100%; min-width: 0; padding: 8px 10px 10px; }
.tile-name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-error { display: block; margin-top: 4px; color: var(--bad); font-size: 12.5px; line-height: 1.35; }
.tile .tag { margin-top: 4px; }
.tile.added { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok); }
.tile-waiting { cursor: default; }
/* Ticking media in the library: a box on the corner of each tile, and a bar of what to do with the ticked. */
.tile-cell { position: relative; }
.tile-pick { position: absolute; top: 6px; left: 6px; z-index: 1; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; background: var(--panel); box-shadow: 0 0 0 1px var(--edge); cursor: pointer; }
.tile-cell.picked > .tile { border-color: var(--red); box-shadow: 0 0 0 1px var(--red); }
.selection-bar {
  position: sticky; bottom: 16px; z-index: 5; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 16px; padding: 10px 14px; border: 1px solid var(--edge); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow);
}
.selection-bar > strong { margin-right: 4px; }
.usage { display: flex; align-items: center; gap: 10px; font-size: 13px; white-space: nowrap; }
.usage meter { width: 150px; height: 10px; }
.usage-high > span:first-child { color: var(--warn); font-weight: 600; }
.usage-full > span:first-child { color: var(--bad); font-weight: 600; }

/* --- dialog ----------------------------------------------------------------------------------------- */
dialog {
  padding: 0; border: 1px solid var(--edge); border-radius: 8px; background: var(--panel); color: var(--text);
  width: min(940px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(15 17 20 / 50%); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 52px; padding: 0 10px 0 18px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.close-btn { flex: none; width: 32px; height: 32px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.close-btn:hover { background: var(--fill); color: var(--text); }
/* An open dialog is a column: the head, the body that scrolls, and (the picker) a foot that stays in sight. */
dialog[open] { display: flex; flex-direction: column; }
.dialog-head { flex: none; }
.dialog-body { flex: 1 1 auto; min-height: 0; padding: 18px; overflow: auto; }
.dialog-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
dialog > .dialog-foot { flex: none; margin: 0; padding: 12px 18px; }
/* The question before something is deleted or cut off (cms.js askFirst). */
dialog.confirm { width: min(440px, calc(100vw - 32px)); padding: 22px; }
dialog.confirm p { margin: 0 0 20px; font-size: 15px; }
.confirm-buttons { display: flex; justify-content: flex-end; gap: 8px; }
dialog .upload { margin-top: 0; }
.detail { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.stage { display: grid; place-items: center; min-height: 240px; overflow: hidden; background: var(--stage); border-radius: 6px; }
.stage img, .stage video { display: block; max-width: 100%; max-height: 60vh; }
.stage .none { color: #8f99a4; }
/* M9 (tasks 9.2, 9.3): a document's pages, one under the other, as the displays show them. */
.stage .pages { display: grid; gap: 8px; width: 100%; max-height: 60vh; overflow: auto; padding: 8px; justify-items: center; }
.stage .pages img { max-height: none; height: auto; }
/* M9 (task 9.4): emergency content that is on. */
.emergency-on { border-color: var(--bad); }

/* --- playlist editor -------------------------------------------------------------------------------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.editor-side { position: sticky; top: 16px; }
.items-head, .item {
  display: grid; grid-template-columns: 20px 28px 72px minmax(0, 1fr) 116px 136px 28px; gap: 10px; align-items: center; padding: 8px 16px;
}
.items-head { border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12.5px; font-weight: 600; }
.items { list-style: none; margin: 0; padding: 0; }
.item { border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--hover); }
.item.selected { background: var(--fill); box-shadow: inset 3px 0 0 var(--red); }
.item.sortable-ghost { opacity: .35; }
.handle { cursor: grab; color: var(--faint); text-align: center; font-size: 16px; line-height: 1; user-select: none; touch-action: none; }
.item-no { font-size: 13px; color: var(--muted); text-align: right; }
.item-thumb { position: relative; width: 72px; height: 44px; overflow: hidden; background: var(--stage); border-radius: 4px; }
.item-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.item-info { min-width: 0; }
.item-name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { display: block; color: var(--muted); font-size: 12.5px; }
.item-duration { display: flex; align-items: center; gap: 6px; }
.item-duration input { width: 76px; text-align: right; }
.remove-btn { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--faint); font-size: 18px; line-height: 1; cursor: pointer; }
.remove-btn:hover { color: var(--bad); background: var(--bad-bg); }
.shape-warning { display: none; }
.item.mismatch .shape-warning { display: inline-block; }
.fields { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 14px; }
.fields .label { display: block; font-weight: 600; margin-bottom: 6px; }
.fields .help { color: var(--muted); font-size: 13px; margin-top: 4px; }
.frame-wrap { padding: 16px; border-bottom: 1px solid var(--line); }
.frame { display: grid; place-items: center; width: 100%; max-width: 210px; margin: 0 auto; aspect-ratio: 9 / 16; overflow: hidden; background: #000000; border: 5px solid #23272e; border-radius: 4px; }
.frame.landscape { max-width: 100%; aspect-ratio: 16 / 9; }
.frame img, .frame video { display: block; width: 100%; height: 100%; object-fit: contain; }
.frame.fit-cover img, .frame.fit-cover video { object-fit: cover; }
.frame .placeholder { padding: 10px; color: #8f99a4; font-size: 13px; text-align: center; }
.picker-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 12px; }

/* --- schedule editor ------------------------------------------------------------------------------- */
.schedule-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.rules-head, .rule {
  display: grid; grid-template-columns: 20px 28px minmax(120px, 1fr) auto 28px; gap: 10px; align-items: center; padding: 8px 16px;
}
/* When a rule applies: days, times, dates, priority. Fixed widths, so the head's labels stand over them. */
.rule-when { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; min-width: 0; }
.rule-when > .days { width: 228px; }
.rule-when > .times { width: 226px; }
.rule-when > .dates { width: 262px; }
.rule-when > .prio { width: 64px; }
.rules-head { border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12.5px; font-weight: 600; }
.rules { list-style: none; margin: 0; padding: 0; }
.rule { border-bottom: 1px solid var(--line); }
.rule:last-child { border-bottom: 0; }
.rule:hover { background: var(--hover); }
.rule.sortable-ghost { opacity: .35; }
.days { display: flex; gap: 3px; }
.day { position: relative; }
.day input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.day span { display: inline-block; width: 30px; padding: 6px 0; border: 1px solid var(--edge); border-radius: 6px; background: var(--panel); color: var(--muted); font-size: 12.5px; font-weight: 600; line-height: 20px; text-align: center; cursor: pointer; user-select: none; }
.day input:checked + span { background: var(--text); border-color: var(--text); color: var(--panel); }
.day input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }
.times, .dates { display: flex; align-items: center; gap: 4px; }
.times input, .dates input { padding: 4px 6px; }
.times input { width: 104px; }
.dates input { width: 122px; }
.rule .priority { width: 64px; text-align: right; }
/* The screen's on-windows in a display's settings: the same day buttons and time fields, one window per row. */
.windows > .label { font-weight: 600; margin: 4px 0 6px; }
.window-rows { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.window-rows:empty { margin: 0; }
.window-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.windows > .errorlist { margin: 0 0 8px; }
.at-field { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 13px; }
.at-field input { width: auto; min-width: 0; }
.at-result { margin: 0 0 12px; }
.week { display: grid; grid-template-columns: 24px repeat(7, minmax(0, 1fr)); gap: 4px; }
.week-axis, .week-day { display: grid; grid-template-rows: 20px 300px; gap: 4px; }
.week-head { font-size: 12.5px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; }
.week-hours { position: relative; }
.week-hours span { position: absolute; right: 2px; transform: translateY(-50%); color: var(--muted); font-size: 11.5px; }
.week-col { position: relative; background: var(--fill); border-radius: 4px; overflow: hidden; }
.segment { position: absolute; left: 0; right: 0; min-height: 2px; overflow: hidden; padding: 1px 5px; border-bottom: 1px solid var(--panel); font-size: 11.5px; line-height: 1.3; }
.week-now { position: absolute; left: 0; right: 0; height: 0; border-top: 2px dashed var(--text); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; margin: 12px 0 0; padding: 0; font-size: 13px; }
.swatch { display: inline-block; width: 12px; height: 12px; margin-right: 5px; vertical-align: -1px; border-radius: 3px; }
/* Playlist colours of the preview; .c0 is the default playlist. */
.c0 { background: var(--neutral); color: var(--text); }
.c1 { background: #d90012; color: #ffffff; }
.c2 { background: #2f64a3; color: #ffffff; }
.c3 { background: #1f7a4c; color: #ffffff; }
.c4 { background: #b36b00; color: #ffffff; }
.c5 { background: #6f4a9c; color: #ffffff; }
.c6 { background: #56616d; color: #ffffff; }

/* --- login and the other pages before the menu -------------------------------------------------------- */
.auth { display: grid; place-content: center; justify-items: center; gap: 16px; min-height: 100vh; padding: 24px 16px; }
.auth-card { width: min(380px, calc(100vw - 32px)); padding: 28px; background: var(--panel); border: 1px solid var(--edge); border-radius: 8px; }
.auth-wide .auth-card { width: min(540px, calc(100vw - 32px)); }
.auth-card .logo { margin-bottom: 24px; }
.auth-card .logo-mark { height: 38px; }
.auth-card .logo span { font-size: 18px; }
.auth-card h1 { font-size: 18px; letter-spacing: 0; margin-bottom: 14px; }
.auth-card .btn-primary { min-width: 120px; }
.auth-card .form > .buttons .btn-primary:only-child { width: 100%; height: 38px; }
.auth-foot { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--muted); }
.auth-foot form { display: contents; }
.auth-foot .linkbtn { color: var(--muted); text-decoration: none; }
.auth-foot .linkbtn:hover { color: var(--text); text-decoration: underline; }
.org-choices { display: grid; gap: 8px; }
.org-choices .btn { justify-content: flex-start; height: 40px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 14px; }
.qr { margin: 10px 0; width: 200px; background: #ffffff; padding: 6px; border-radius: 6px; }
.qr svg { display: block; width: 100%; height: auto; }
.secret { display: inline-block; font-family: var(--mono); font-size: 13px; letter-spacing: 1px; user-select: all; }
.codes { list-style: none; margin: 14px 0; padding: 0; display: grid; grid-template-columns: repeat(2, max-content); gap: 6px 28px; }
.codes code { font-family: var(--mono); font-size: 15px; letter-spacing: 1px; }

/* --- monitoring: a display's page, a release's rollout ------------------------------------------------ */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
/* Side by side in a grid, the stacked-panel gap (.panel + .panel) would push every second panel down. */
.detail-grid > .panel, .chart-grid > .panel { margin-top: 0; }
.rollout-summary { display: flex; gap: 8px 18px; flex-wrap: wrap; margin-bottom: 14px; }
/* The overview's counts: tiles that open the list they count. */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stats .stat { flex: 1 1 140px; max-width: 220px; color: inherit; text-decoration: none; }
.stats a.stat:hover { border-color: var(--faint); }
/* A report's sums: a line of plain figures, not chips that look like buttons. */
.rollout-summary > .tag { padding: 0; border-radius: 0; background: none; color: var(--text); font-size: 15px; line-height: 22px; }
.rollout-summary > .tag + .tag { padding-left: 18px; border-left: 1px solid var(--edge); }
.stat { display: flex; flex-direction: column; min-width: 108px; padding: 10px 16px; border: 1px solid var(--edge); border-radius: 6px; background: var(--panel); }
.stat strong { font-size: 26px; line-height: 1.15; font-weight: 700; }
.stat span { color: var(--muted); font-size: 13px; }
.stat-active strong { color: var(--ok); }
.stat-failed strong { color: var(--bad); }

/* Charts: the SVG is stretched to the plot, its strokes do not scale; labels are HTML (charts.py). */
.charts-section { margin-top: 24px; }
.charts-section h2 { font-size: 17px; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 12px; }
.chart { margin: 0; padding: 14px 16px 8px; }
.chart figcaption { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.chart figcaption strong { color: var(--text); font-size: 15px; white-space: nowrap; }
.chart-plot { position: relative; height: 110px; margin-left: 44px; touch-action: pan-y; }
.chart-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.chart-plot .grid-line { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-plot .threshold { stroke: var(--warn); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-plot .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart-plot .area { fill: var(--series-wash); stroke: none; }
.chart-plot .bar { fill: var(--series); }
.y-tick { position: absolute; right: calc(100% + 6px); transform: translateY(-50%); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.threshold-label { position: absolute; right: 2px; transform: translateY(-115%); font-size: 11.5px; color: var(--warn); }
.x-axis { position: relative; height: 20px; margin-left: 44px; }
.x-axis span { position: absolute; top: 4px; transform: translateX(-50%); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.chart-empty { height: 110px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
.crosshair { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--muted); pointer-events: none; }
.crosshair::after {
  content: ""; position: absolute; left: -5px; top: var(--dot-y, 50%); width: 8px; height: 8px; margin-top: -5px;
  border-radius: 50%; background: var(--series); border: 2px solid var(--panel);
}
.chart-tip {
  position: absolute; top: -6px; transform: translate(-50%, -100%); padding: 4px 8px; pointer-events: none; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 6px; box-shadow: 0 4px 12px rgb(23 26 31 / 14%); font-size: 12.5px; z-index: 2;
}
.chart-tip strong { display: block; font-size: 13.5px; }
.chart-table { margin-top: 12px; }
.chart-table summary { padding: 10px 16px; cursor: pointer; color: var(--muted); font-size: 13px; }

/* --- M7: service channel and web terminal (7.11) --------------------------------------------------------- */
.service-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.copyable { padding: 5px 10px; background: var(--fill); border-radius: 6px; font-size: 13px; user-select: all; }
/* The terminal is dark in both themes; it fills what is left of the window. */
.terminal-frame { height: calc(100vh - 200px); min-height: 320px; padding: 10px; background: #0b0c0e; border-radius: 6px; }
.terminal-frame #terminal { height: 100%; }
.terminal-frame .xterm-viewport { scrollbar-color: #454d57 #0b0c0e; }

/* --- narrower screens ------------------------------------------------------------------------------- */
@media (max-width: 1399px) {
  .page { padding-left: 24px; padding-right: 24px; }
}
/* A rule in two lines: the playlist, and under it when it applies. */
@media (max-width: 1343px) {
  .rules-head { display: none; }
  .rule { grid-template-columns: 20px 28px minmax(0, 1fr) 28px; }
  .rule > .rule-when { grid-column: 3 / 4; grid-row: 2; }
  .rule-when > .prio { display: flex; align-items: center; gap: 6px; width: auto; }
  .rule-when > .prio[data-label]::before { content: attr(data-label) ":"; color: var(--muted); font-size: 13px; }
}
@media (max-width: 1280px) {
  .editor { grid-template-columns: 1fr; }
  .editor-side { position: static; }
}
/* The menu becomes a drawer, opened from a bar on top (cms.js sets menu-open on <body>). */
@media (max-width: 900px) {
  .shell { display: block; }
  .topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; height: 52px; padding: 0 8px;
    background: var(--side); border-bottom: 1px solid var(--edge);
  }
  .topbar .side-brand { height: auto; padding: 0 8px; }
  .menu-btn { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 6px; background: none; color: var(--text); cursor: pointer; }
  .menu-btn:hover { background: var(--fill); }
  .menu-btn .icon { width: 18px; height: 18px; }
  .side { position: fixed; z-index: 40; left: 0; top: 0; width: min(280px, 86vw); transform: translateX(-100%); transition: transform .16s ease-out; }
  .menu-open .side { transform: none; box-shadow: var(--shadow); }
  .menu-open .side-backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: rgb(15 17 20 / 50%); }
  .page { padding: 18px 16px 48px; }
  .detail, .detail-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .side { transition: none; }
}
/* Phones: the wide tables turn into one card per row (task 4.4: no horizontal scrolling at 375 px). */
@media (max-width: 680px) {
  h1 { font-size: 20px; }
  .fields, .schedule-fields { grid-template-columns: 1fr; }
  .week-axis, .week-day { grid-template-rows: 20px 240px; }
  .toolbar label:not(.check) { width: 100%; }
  .toolbar input, .toolbar select, .toolbar input[type="search"] { width: 100%; max-width: none; }
  .titlebar .actions { width: 100%; }
  .rule { grid-template-columns: 20px minmax(0, 1fr) 28px; }
  .rule > .item-no { display: none; }
  .rule > .rule-when { grid-column: 1 / -1; }
  .items-head { display: none; }
  .item { grid-template-columns: 20px 72px minmax(0, 1fr) 28px; }
  .item .item-no { display: none; }
  .item .item-duration, .item .item-fit { grid-column: 2 / -1; }
  .item .remove-btn { grid-column: 4; grid-row: 1; }
  .upload-row { grid-template-columns: minmax(0, 1fr) 90px; }
  .upload-row .upload-note { display: none; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .auth-card { padding: 22px 18px; }
  table.grid.cards, table.grid.cards tbody, table.grid.cards tr, table.grid.cards td { display: block; width: auto; }
  table.grid.cards thead { display: none; }
  table.grid.cards tbody th { display: block; }
  table.grid.cards tr { border-bottom: 1px solid var(--line); padding: 10px 6px; }
  table.grid.cards tbody tr:last-child { border-bottom: 0; }
  table.grid.cards tr.place-row, table.grid.cards tr.group-row { padding: 0; }
  table.grid.cards tr.place-row th, table.grid.cards tr.group-row th { padding: 10px 16px; }
  table.grid.cards td { border: 0; padding: 2px 10px; white-space: normal; }
  table.grid.cards td.fit { width: auto; }
  table.grid.cards td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 13px; }
  table.grid.cards td.num { text-align: left; }
  table.grid.cards tbody tr:hover td { background: none; }
  table.props th { width: 96px; white-space: normal; }
}
