/* Visual language modelled on the Infragistics blog: white header with a navy
   wordmark, a navy hero band per page, blue accent, flat cards with hairline
   borders, small-radius controls and uppercase eyebrow labels. */
:root {
  --bg: #fafafa; --card: #fff; --text: #101828; --muted: #4a5565; --line: #e5e7eb; --line-strong: #d1d5dc;
  --accent: #155dfc; --accent-hover: #1447e6; --accent-text: #fff; --accent-wash: #eff6ff;
  --brand: #27265f; --hero: #27265f; --hero-text: #fff; --hero-muted: #ffffffd9;
  --danger: #dc2638; --ok: #028a54; --warn: #b86e00;
  --chip: #f3f4f6; --chip-on: #dbeafe;
  --radius: 10px; --radius-sm: 4px;
  --shadow: 0 1px 2px rgb(16 24 40 / .04), 0 1px 3px rgb(16 24 40 / .06);
  --shadow-lg: 0 12px 32px rgb(16 24 40 / .14);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0b10; --card: #14161d; --text: #f3f4f6; --muted: #a3acb9; --line: #262a35; --line-strong: #353a47;
    --accent: #5b8cff; --accent-hover: #7ba2ff; --accent-text: #0a0b10; --accent-wash: #15203a;
    --brand: #fff; --hero: #1f1e55; --hero-text: #fff; --hero-muted: #ffffffcc;
    --danger: #ff4d5e; --ok: #3dbf85; --warn: #faa419;
    --chip: #1d2029; --chip-on: #1c2d52;
    --shadow: none; --shadow-lg: 0 12px 32px rgb(0 0 0 / .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.6 var(--font); background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 2rem; }
h3 { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  display: flex; align-items: center; gap: .5em; }
h3::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--accent); flex: none; }
code { font: .88em "JetBrains Mono", "Cascadia Code", Consolas, monospace; background: var(--chip);
  padding: .1em .35em; border-radius: var(--radius-sm); }
a { color: var(--accent); }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.warning { background: color-mix(in srgb, var(--warn) 10%, var(--card)); border-left: 4px solid var(--warn);
  padding: 1rem; margin: 0 0 1.5rem; color: var(--text); }

/* Header */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5em 2rem; padding: 0 clamp(16px, 3vw, 2rem);
  min-height: 4.25rem; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; }
.brand { font-size: 1.15rem; font-weight: 800; color: var(--brand); letter-spacing: -.02em; display: inline-flex;
  align-items: center; gap: .55em; }
.brand::before { content: ""; width: 1.5rem; height: 1.5rem; border-radius: 6px; flex: none;
  background: linear-gradient(135deg, var(--hero) 0 50%, var(--accent) 50% 100%); }
#nav { display: flex; flex-wrap: wrap; gap: 0 .25rem; flex: 1; align-self: stretch; }
#nav a { color: var(--text); text-decoration: none; padding: 0 .75rem; font-size: .92rem; font-weight: 500;
  display: flex; align-items: center; min-height: 4.25rem; border-bottom: 3px solid transparent;
  margin-bottom: -1px; transition: color .15s ease, border-color .15s ease; }
#nav a:hover { color: var(--accent); }
#nav a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.who { color: var(--muted); white-space: nowrap; font-size: .9rem; }
.who #who { color: var(--text); font-weight: 600; margin-right: .5em; }

/* Page layout */
main { max-width: 78rem; margin: 0 auto; padding: 0 clamp(16px, 3vw, 2rem) 4rem; }
.view { display: none; } .view.active { display: block; }

/* Navy full-bleed hero band built from each view's heading row */
.view > h2, .view > .row-between {
  background: var(--hero); color: var(--hero-text); padding: 2.75rem 0 2.25rem; margin: 0 0 2rem;
  box-shadow: 0 0 0 100vmax var(--hero); clip-path: inset(0 -100vmax); }
.view > .row-between { margin-bottom: 2rem; }
.view > .row-between h2 { margin: 0; }
.view > h2 + p.muted, .view > .row-between + p.muted {
  background: var(--hero); color: var(--hero-muted); font-size: 1.05rem; max-width: none;
  margin: -3.5rem 0 2rem; padding: 0 0 2.25rem;
  box-shadow: 0 0 0 100vmax var(--hero); clip-path: inset(0 -100vmax); }
.view > h2 + p.muted b, .view > .row-between + p.muted b,
.view > .row-between + p.muted em { color: var(--hero-text); }
/* Buttons sitting on the hero */
.view > .row-between button.primary { background: #fff; border-color: #fff; color: var(--hero); }
.view > .row-between button.primary:hover { background: #eef0ff; }
.view > .row-between button:not(.primary):not(.danger) { background: transparent; border-color: rgb(255 255 255 / .6);
  color: var(--hero-text); }
.view > .row-between button:not(.primary):not(.danger):hover { border-color: #fff; background: rgb(255 255 255 / .1); }
.view > .row-between button.danger { background: #fff; border-color: #fff; color: #c8102e;
  box-shadow: 0 2px 8px rgb(0 0 0 / .18); }
.view > .row-between button.danger.emergency { background: #c8102e; border-color: #fff; color: #fff; }
.view > .row-between button.danger:hover { filter: brightness(.95); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: var(--shadow); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 1.5rem;
  margin-bottom: 1.5rem; }
.grid2 > .card { margin-bottom: 0; }
.stack > * + * { margin-top: .75rem; } .stack { margin-bottom: 1.5rem; } .stack:empty { margin: 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1em; flex-wrap: wrap;
  margin-bottom: .75rem; }
.row-end { display: flex; justify-content: flex-end; gap: .5em; margin-top: 1.5rem; }
.inline { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; }

/* Forms */
label { display: block; margin-bottom: 1rem; font-size: .85rem; font-weight: 600; color: var(--text); }
.inline label { margin-bottom: 0; }
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  display: block; width: 100%; margin-top: .35rem; padding: 0 .75rem; min-height: 2.5rem; background: var(--card);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); color: var(--text); font-weight: 400;
  transition: border-color .15s ease, box-shadow .15s ease; }
textarea { padding: .6rem .75rem; resize: vertical; line-height: 1.5; }
input[type=file] { padding: .4rem .75rem !important; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.inline input:not([type=checkbox]), .inline select { width: auto; min-width: 7em; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }

/* Buttons */
button, a.button { display: inline-flex; align-items: center; justify-content: center; gap: .4em; min-height: 2.5rem;
  padding: 0 1.1rem; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--card);
  color: var(--text); font-weight: 600; font-size: .92rem; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, filter .15s ease; }
button:hover { border-color: var(--accent); color: var(--accent); }
a.button { text-decoration: none; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary, a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover, a.button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger:hover { filter: brightness(.92); color: #fff; }
button.big { font-size: 1rem; min-height: 3rem; padding: 0 1.5rem; font-weight: 700; }
button.link { background: none; border: none; color: var(--accent); padding: 0; min-height: 0; }
button.link:hover { text-decoration: underline; }
button.small { min-height: 2rem; padding: 0 .75rem; font-size: .82rem; }
button:disabled { opacity: .5; cursor: default; pointer-events: none; }

/* Target pickers */
.targets { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem 1rem; margin: 0 0 1.25rem;
  background: var(--bg); }
.targets legend { padding: 0 .4em; color: var(--muted); font-size: .7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .35rem 0 .6rem; }
.chip { display: inline-flex; align-items: center; gap: .4em; padding: .3em .8em; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line-strong); cursor: pointer; font-size: .85rem; font-weight: 500;
  color: var(--text); margin: 0; user-select: none; transition: border-color .15s ease, background .15s ease; }
.chip:hover { border-color: var(--accent); }
.chip input { margin: 0; }
.chip:has(input:checked) { background: var(--accent-wash); border-color: var(--accent); color: var(--accent); }
.chip .dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--muted); flex: none; }
.dot.online { background: var(--ok); } .dot.offline { background: var(--danger); } .dot.authfail { background: var(--warn); }
.sub { font-size: .8rem; color: var(--muted); margin-top: .35em; }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; display: block; overflow-x: auto; box-shadow: var(--shadow);
  margin-bottom: 1.5rem; }
.table thead, .table tbody { display: table; width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.table th { font-size: .7rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  background: var(--bg); }
.table td.actions { white-space: nowrap; text-align: right; }
.table td.actions button + button { margin-left: .35rem; }
.table audio { height: 32px; max-width: 220px; vertical-align: middle; }

ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: .65rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .75em;
  justify-content: space-between; align-items: center; font-size: .93rem; }
ul.plain li:first-child { padding-top: 0; }
ul.plain li:last-child { border-bottom: none; padding-bottom: 0; }

/* Now-playing jobs */
.job { display: flex; justify-content: space-between; align-items: center; gap: 1em; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm); padding: 1rem 1.25rem; box-shadow: var(--shadow); }
.job.prio-page, .job.prio-emergency { border-left-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 5%, var(--card)); }
.job.prio-bell { border-left-color: var(--warn); }
.badge { display: inline-flex; align-items: center; font-size: .68rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; padding: .15em .6em; border-radius: var(--radius-sm); background: var(--chip);
  border: 1px solid var(--line-strong); color: var(--muted); }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent);
  background: color-mix(in srgb, var(--ok) 10%, transparent); }
.badge.bad { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, transparent); }

.entries { width: 100%; border-collapse: collapse; margin-top: .5em; }
.entries td, .entries th { padding: .55em .6em; border-bottom: 1px solid var(--line); text-align: left; font-size: .92rem; }
.entries th { color: var(--muted); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.days { display: flex; gap: .3em; flex-wrap: wrap; }

/* Live paging */
.talk-row { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; margin: .75rem 0; }
.talk { font-size: 1.15rem; font-weight: 700; min-height: 3.75rem; padding: 0 2.25rem; border-radius: 999px;
  background: var(--accent); color: var(--accent-text); border: none;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.talk:hover { background: var(--accent-hover); color: var(--accent-text); }
.talk.live { background: var(--danger); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--danger) 22%, transparent); } }
.meter { flex: 1; min-width: 160px; height: 10px; background: var(--chip); border-radius: 999px; overflow: hidden; }
#meter-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), #faa419 75%, var(--danger));
  background-size: 100vw 100%; transition: width .08s; }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(var(--hero) 0 42%, var(--bg) 42%); }
.auth-card { width: min(400px, 100%); padding: 2rem; box-shadow: var(--shadow-lg); border: none; }
.auth-card h1 { color: var(--brand); font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
.auth-card button { width: 100%; margin-top: .5em; min-height: 2.75rem; }

dialog { border: none; border-radius: var(--radius); background: var(--card); color: var(--text);
  width: min(560px, calc(100% - 32px)); padding: 1.75rem; box-shadow: var(--shadow-lg); }
dialog h3 { font-size: 1.25rem; text-transform: none; letter-spacing: -.01em; font-weight: 700; }
dialog h3::before { display: none; }
dialog::backdrop { background: rgb(10 11 16 / .55); backdrop-filter: blur(2px); }
.toast { position: fixed; bottom: 1.5em; left: 50%; transform: translateX(-50%); background: var(--brand);
  color: #fff; padding: .75em 1.25em; border-radius: var(--radius-sm); z-index: 50; max-width: calc(100% - 32px);
  font-weight: 500; box-shadow: var(--shadow-lg); }
@media (prefers-color-scheme: dark) { .toast { background: #f3f4f6; color: #0a0b10; } }
.toast.error { background: var(--danger); color: #fff; }

@media (max-width: 700px) {
  h2 { font-size: 1.6rem; }
  .topbar { padding-block: .6rem; gap: .25rem 1rem; }
  #nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  #nav a { min-height: 2.75rem; white-space: nowrap; }
  .view > h2, .view > .row-between { padding: 2rem 0 1.75rem; }
}

[hidden] { display: none !important; }
body:not(.is-admin) [data-admin] { display: none !important; }

/* Server usage (dashboard) */
.sys-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 1rem; }
.sys-tile { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1rem;
  display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.sys-label { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sys-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sys-bar { height: 8px; background: var(--chip); border-radius: 999px; overflow: hidden; }
.sys-bar > div { height: 100%; width: 0; background: var(--accent); transition: width .4s ease; }
.sys-bar > div.warn { background: var(--warn); } .sys-bar > div.bad { background: var(--danger); }
.sys-net { display: flex; flex-direction: column; font-size: .95rem; font-variant-numeric: tabular-nums; }
.sys-net strong { font-size: 1.15rem; }
.sys-tile .sub { margin-top: 0; overflow-wrap: anywhere; }
.card > .row-between h3 { margin: 0; }
