:root {
  --bg: #eef1f7;
  --panel: #ffffff;
  --ink: #18213a;
  --muted: #5d6885;
  --line: #dde2ee;
  --cobalt: #13306f;
  --cobalt-2: #1f4aa8;
  --accent: #ffb627;
  --red: #c4343a;
  --green: #17895a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 15px/1.45 "Barlow", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--cobalt-2); }
:focus-visible { outline: 2px solid var(--cobalt-2); outline-offset: 2px; }

.bar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px; height: 60px;
  background: var(--cobalt); color: #fff;
}
.bar-mark { height: 30px; display: flex; align-items: center; font: 700 24px/1 "Barlow Condensed", sans-serif; }
.bar .brand { font: 500 20px/1 "Barlow Condensed", sans-serif; opacity: 0.75; padding-left: 12px; border-left: 1px solid rgba(255,255,255,0.3); }
.bar .who { margin-left: auto; font-size: 14px; opacity: 0.85; }
.bar button { background: transparent; border: 1px solid rgba(255,255,255,0.35); color: #fff; border-radius: 8px; padding: 6px 12px; cursor: pointer; }

nav.tabs { display: flex; gap: 4px; padding: 0 28px; background: var(--panel); border-bottom: 1px solid var(--line); }
nav.tabs a {
  padding: 14px 14px 12px; text-decoration: none; color: var(--muted);
  font: 600 17px/1 "Barlow Condensed", sans-serif; border-bottom: 3px solid transparent;
}
nav.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

main { max-width: 1180px; margin: 0 auto; padding: 26px 28px 60px; }
.head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 16px; }
.head h1 { margin: 0; font: 600 30px/1.1 "Barlow Condensed", sans-serif; }
.head p { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }
.head .actions { margin-left: auto; display: flex; gap: 8px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font: 600 14px/1.2 "Barlow Condensed", sans-serif; color: var(--muted); background: #f7f8fc; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; }
td .sub { display: block; font-size: 13px; color: var(--muted); }
td.right, th.right { text-align: right; white-space: nowrap; }
.empty-row td { text-align: center; color: var(--muted); padding: 34px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 13px; background: #e8ecf6; color: var(--ink); margin: 2px 4px 2px 0; }
.pill.ok { background: #dcf3e8; color: var(--green); }
.pill.warn { background: #fff1d1; color: #8a5a00; }
.pill.bad { background: #fbe1e2; color: var(--red); }
.code { font: 700 16px/1 "Barlow Condensed", sans-serif; letter-spacing: 0.12em; }
.err-text { color: var(--red); font-size: 13px; max-width: 42ch; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--panel);
  padding: 7px 12px; cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { border-color: #c4cbe0; }
.btn.primary { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
.btn.primary:hover { background: var(--cobalt-2); }
.btn.danger { color: var(--red); }
.btn.small { padding: 4px 9px; font-size: 14px; }
.btn:disabled { opacity: 0.55; cursor: progress; }

dialog {
  border: 0; border-radius: 14px; padding: 0; width: min(620px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(10, 20, 50, 0.35); color: var(--ink);
}
dialog.wide { width: min(980px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(14, 24, 52, 0.45); }
dialog form, dialog .body { padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; max-height: 80vh; overflow: auto; }
dialog h2 { margin: 0; font: 600 24px/1.15 "Barlow Condensed", sans-serif; }
dialog .foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 6px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label, .field .label { font-weight: 600; font-size: 14px; }
.field .hint { font-size: 13px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
input[type="text"], input[type="password"], input[type="url"], input[type="number"], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: #fff; width: 100%;
}
textarea { min-height: 120px; font: 13px/1.4 ui-monospace, Menlo, Consolas, monospace; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31, 74, 168, 0.35); border-color: var(--cobalt-2); }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { margin-top: 4px; }
.check > span { display: flex; flex-direction: column; }
.check .hint { font-size: 13px; color: var(--muted); }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; }
.form-error { color: var(--red); margin: 0; min-height: 0; }
.or { text-align: center; color: var(--muted); font-size: 13px; }

.login-card { max-width: 380px; margin: 12vh auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 0; font: 600 30px/1.1 "Barlow Condensed", sans-serif; }
.login-card p { margin: 0; color: var(--muted); }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 100;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

@media (max-width: 760px) {
  main { padding: 18px 14px 40px; }
  .head { flex-wrap: wrap; }
  .grid2 { grid-template-columns: 1fr; }
  .panel { overflow-x: auto; }
  nav.tabs { overflow-x: auto; padding: 0 12px; }
}

/* Brand mark (logo or wordmark) */
.brand-logo { display: block; height: 100%; width: auto; max-width: 260px; object-fit: contain; }
.brand-word { white-space: nowrap; }
.login-mark { height: 40px; font: 700 30px/40px "Barlow Condensed", sans-serif; color: var(--cobalt); background: var(--cobalt); align-self: flex-start; padding: 6px 12px; border-radius: 10px; box-sizing: content-box; }
.login-mark .brand-word { color: #fff; }

/* Branding tab */
.brand-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.form-panel { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; overflow: visible; }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type="color"] { width: 48px; height: 40px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.color-row input[type="text"] { width: 110px; font-variant-numeric: tabular-nums; }
.logo-row { display: flex; gap: 14px; align-items: center; }
.logo-tile { width: 220px; height: 84px; border-radius: 10px; background: #0d1b3a; display: flex; align-items: center; justify-content: center; padding: 12px; }
.logo-tile img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-tile .hint { color: #b8c3de; text-align: center; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.preview-panel { padding: 16px; position: sticky; top: 16px; }
.preview-label { font: 600 14px/1 "Barlow Condensed", sans-serif; color: var(--muted); margin-bottom: 10px; }
.tv-preview {
  position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden;
  background: linear-gradient(180deg, var(--pv-navy2), var(--pv-navy)); color: var(--pv-ice);
  font-family: "Barlow Condensed", sans-serif; padding: 12px; display: flex; flex-direction: column; gap: 4px;
}
.pv-top { display: flex; justify-content: space-between; align-items: center; min-height: 26px; margin-bottom: 4px; font-weight: 700; font-size: calc(18px * var(--pv-scale, 1)); }
.pv-mark { height: calc(22px * var(--pv-scale, 1)); display: flex; align-items: center; }
.pv-mark img { height: 100%; width: auto; }
.pv-time { font-size: 16px; }
.pv-row { display: grid; grid-template-columns: 26% 1fr 1fr; gap: 3px; height: 30px; font-size: 14px; font-weight: 500; }
.pv-row span { display: flex; align-items: center; padding: 0 8px; overflow: hidden; white-space: nowrap; }
.pv-ch { background: var(--pv-chan); color: var(--pv-steel); font-weight: 600; }
.pv-cell { background: var(--pv-cell); }
.pv-cell.live { background: var(--pv-live); }
.pv-cell.focus { background: var(--pv-accent); color: var(--pv-accent-ink); font-weight: 700; }
.pv-banner {
  position: absolute; left: 12px; right: 12px; bottom: 12px; height: 56px; border-radius: 8px;
  background: linear-gradient(180deg, var(--pv-live), var(--pv-navy)); display: flex; align-items: center; gap: 12px; padding: 0 14px;
  border: 1px solid rgba(255,255,255,0.14);
}
.pv-tab { position: absolute; left: 12px; bottom: 100%; background: var(--pv-accent); color: var(--pv-accent-ink); font-weight: 700; font-size: 12px; padding: 3px 9px; border-radius: 6px 6px 0 0; }
.pv-num { font-size: 30px; font-weight: 700; }
.pv-title { display: flex; flex-direction: column; font-size: 18px; font-weight: 700; line-height: 1.1; }
.pv-title small { font-size: 13px; font-weight: 500; color: var(--pv-steel); }

/* Slideshow tab */
.slide-tools { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 18px 36px; margin-bottom: 18px; }
.slide-tools .hint { flex-basis: 100%; font-size: 13px; color: var(--muted); }
.tool-group { display: flex; align-items: flex-end; gap: 12px; }
.tool-group input[type="number"] { width: 110px; }
.tool-group .check { align-self: center; margin-top: 18px; }
.slide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.slide-card { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.slide-thumb { aspect-ratio: 16 / 9; background: #0d1b3a center / cover no-repeat; }
.slide-card figcaption { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.slide-row { display: flex; gap: 8px; }
.slide-row select { flex: 1; min-width: 0; }
.empty-panel { padding: 30px; text-align: center; color: var(--muted); grid-column: 1 / -1; }
label.btn { cursor: pointer; }

@media (max-width: 900px) {
  .brand-layout { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
}

/* Households search, account numbers, household picker, logo size */
.search-row { margin-bottom: 12px; }
.search-row input { width: min(420px, 100%); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: #fff; }
.acct { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.picker { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.picker-q { margin-bottom: 6px; }
.scale-row { display: flex; align-items: center; gap: 12px; }
.scale-row input[type="range"] { flex: 1; accent-color: var(--cobalt); }
.scale-row output { min-width: 48px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* Sign-in steps, roles, audit log */
.wide-card { max-width: 480px; }
.steps { margin: 0; padding-left: 20px; color: var(--muted); }
.enroll-qr { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.enroll-qr img { width: 200px; height: 200px; image-rendering: pixelated; }
.secret { font-size: 14px; letter-spacing: 0.06em; color: var(--ink); background: #f3f5fa; padding: 6px 10px; border-radius: 6px; }
.codes { list-style: none; margin: 0; padding: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: #f3f5fa; border-radius: 10px; }
.codes code { font-size: 15px; letter-spacing: 0.04em; }
.role-pill { margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,0.18); font-size: 12px; }
.bar button + button { margin-left: 4px; }
.pill.role { background: #e3e9fb; color: var(--cobalt); }
.inline-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.note { padding: 10px 12px; border-radius: 8px; background: #eef3ff; color: var(--ink); font-size: 14px; }
table.audit td { font-size: 14px; vertical-align: top; }
table.audit .action { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
table.audit .details { color: var(--muted); max-width: 36ch; overflow-wrap: anywhere; }
.more-row { display: flex; justify-content: center; padding: 16px; }
