/* Sheriff Bot control panel.
   Operate surface: dark (used beside Discord), one sans for the interface,
   the department's Michelangelus for the wordmark and page titles only.
   All sizes are rem so the whole panel steps up on large screens. */

@font-face {
  font-family: "Michelangelus";
  src: url("/fonts/michelangelus-bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  /* surfaces */
  --bg: #0d1012;
  --rail: #12161a;
  --surface: #161b1f;
  --surface-2: #1c2227;
  --surface-3: #242b31;
  --border: #283037;
  --border-strong: #36404a;

  /* text */
  --text: #e8ebee;
  --muted: #a0a9b1;
  --faint: #7f8992;

  /* department green: deep tone for filled controls, light tone for text and icons on dark */
  --brand: #004f29;
  --primary: #0b6b3a;
  --primary-hover: #0f7d45;
  --accent: #3fb871;
  --accent-soft: rgba(63, 184, 113, 0.12);
  --brand-soft: rgba(0, 120, 62, 0.28);

  /* states */
  --danger: #f06267;
  --danger-soft: rgba(240, 98, 103, 0.12);
  --warn: #f0b232;
  --warn-soft: rgba(240, 178, 50, 0.12);
  --info: #5b9dff;
  --info-soft: rgba(91, 157, 255, 0.12);
  --focus: #7fd3a2;
  --blurple: #5865f2;

  --radius: 0.625rem;
  --radius-sm: 0.4375rem;
  --shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.4), 0 0.125rem 0.375rem rgba(0, 0, 0, 0.3);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --sidebar-w: 16rem;
  --content-max: 92rem;
  --gutter: clamp(1.25rem, 3vw, 3rem);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Michelangelus", "PT Serif", Georgia, serif;
  --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  color-scheme: dark;
  accent-color: var(--accent);
  scrollbar-color: var(--border-strong) transparent;
}

/* 15px base; 16px on phones (keeps inputs from zooming) and on large
   monitors (1440p and up), where 15px reads small. */
html { font-size: 93.75%; }
@media (max-width: 47.99rem), (min-width: 112.5rem) { html { font-size: 100%; } }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  caret-color: var(--accent);
}

::selection { background: rgba(63, 184, 113, 0.32); color: #fff; }

a { color: var(--accent); text-underline-offset: 0.18em; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { text-wrap: balance; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.icon { width: 1.125rem; height: 1.125rem; flex: none; display: inline-flex; }
.icon svg { width: 100%; height: 100%; }
.num { font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------- boot / sign-in ---------------- */

#app.boot, .center-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.spinner {
  width: 1.75rem; height: 1.75rem;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.center-screen {
  background:
    radial-gradient(60rem 32rem at 50% -12%, rgba(0, 120, 62, 0.22), transparent 70%),
    var(--bg);
}

.signin {
  width: min(26rem, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 2.5rem 2rem 1.75rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.signin-logo {
  width: 4.5rem; height: 4.5rem;
  margin: 0 auto 1.25rem;
  display: grid; place-items: center;
  border-radius: 1.25rem;
  background: var(--brand-soft);
  color: var(--accent);
}
.signin-logo img { width: 3.25rem; height: 3.25rem; object-fit: contain; }
.signin-logo .icon { width: 2.25rem; height: 2.25rem; }

.signin h1 {
  font: 700 1.875rem/1.15 var(--display);
  letter-spacing: 0.005em;
  margin: 0 0 0.375rem;
}
.signin .lede { color: var(--muted); margin: 0 0 1.75rem; }

.btn-discord {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.625rem;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.6875rem 1rem;
  background: var(--blurple);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  transition: filter 0.15s var(--ease);
}
.btn-discord:hover { filter: brightness(1.1); }

.signin-foot { margin-top: 1.125rem; font-size: 0.8125rem; color: var(--faint); }

.denied-user {
  display: flex; align-items: center; gap: 0.75rem;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 1.125rem;
}
.denied-user img { width: 2.5rem; height: 2.5rem; border-radius: 50%; }
.denied-user .who { flex: 1; min-width: 0; }
.denied-user .id { font: 0.8125rem var(--mono); color: var(--muted); }

/* ---------------- shell ---------------- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  background: var(--rail);
  border-right: 1px solid var(--border);
  padding: 1.125rem 0.75rem 0.75rem;
  overflow-y: auto;
  scrollbar-width: thin;
}

.brand {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.25rem 0.5rem 1.125rem;
}
.brand-logo {
  width: 2.5rem; height: 2.5rem; flex: none;
  display: grid; place-items: center;
  border-radius: 0.75rem;
  background: var(--brand-soft);
  color: var(--accent);
}
.brand-logo img { width: 1.875rem; height: 1.875rem; object-fit: contain; }
.brand-name { font: 700 1.125rem/1.1 var(--display); letter-spacing: 0.005em; }
.brand-sub { font-size: 0.8125rem; color: var(--muted); margin-top: 0.125rem; }

.search {
  position: relative;
  margin: 0 0.25rem 0.5rem;
}
.search .icon {
  position: absolute; left: 0.625rem; top: 50%;
  width: 1rem; height: 1rem;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}
.search input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4375rem 2rem 0.4375rem 2.125rem;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.search input::placeholder { color: var(--faint); }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search kbd {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  font: 0.75rem var(--mono);
  color: var(--faint);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  padding: 0 0.3125rem;
}
.search input:focus + kbd, .search input:not(:placeholder-shown) + kbd { display: none; }

.nav-label {
  font-size: 0.75rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--faint);
  padding: 1rem 0.75rem 0.375rem;
}

.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  width: 100%;
  min-height: 2.25rem;
  padding: 0.4375rem 0.75rem;
  border: 0; border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--brand-soft); color: var(--text); font-weight: 550; }
.nav-item[aria-current="page"] .icon { color: var(--accent); }
.nav-item .count {
  margin-left: auto;
  min-width: 1.375rem;
  font-size: 0.75rem; font-weight: 650; text-align: center;
  background: var(--surface-3);
  color: var(--text);
  border-radius: 999px;
  padding: 0 0.4375rem;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.me { display: flex; align-items: center; gap: 0.625rem; padding: 0.5rem; }
.me img { width: 2.125rem; height: 2.125rem; border-radius: 50%; }
.me .who { min-width: 0; flex: 1; }
.me-name { font-weight: 600; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-role { font-size: 0.8125rem; color: var(--muted); text-transform: capitalize; }

.main-wrap { min-width: 0; }
.savebar-slot { display: contents; }
.topbar { display: none; }
.scrim { display: none; }

.main {
  min-width: 0;
  padding: 2.25rem var(--gutter) 7rem;
}

.content { max-width: var(--content-max); margin-inline: auto; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin-bottom: 1.75rem;
}
.page-head h1 {
  font: 700 2.25rem/1.05 var(--display);
  letter-spacing: 0.005em;
  margin: 0;
}
.page-head p { margin: 0.5rem 0 0; color: var(--muted); max-width: 65ch; }
.page-head .actions-row { margin-bottom: 0.125rem; }

.actions-row { display: flex; flex-wrap: wrap; gap: 0.625rem; }

/* ---------------- panels ---------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 1rem; margin: 0; }
.panel-head .hint { font-size: 0.8125rem; color: var(--muted); }
.panel-body { padding: 1rem 1.25rem; }

/* Status strip: one row of facts, not a wall of metric cards. */
.status {
  display: flex; flex-wrap: wrap;
  margin: 0 0 1.25rem;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.status > div {
  flex: 1 1 9rem;
  padding: 0.875rem 1.25rem;
  border-left: 1px solid var(--border);
}
.status > div:first-child { border-left: 0; }
.status dt { font-size: 0.8125rem; color: var(--muted); }
.status dd {
  margin: 0.125rem 0 0;
  font-size: 1.125rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 0.5rem;
}
.dot { width: 0.5625rem; height: 0.5625rem; border-radius: 50%; background: var(--faint); flex: none; }
.dot.on { background: var(--accent); box-shadow: 0 0 0 0.25rem var(--accent-soft); }
.dot.off { background: var(--danger); box-shadow: 0 0 0 0.25rem var(--danger-soft); }

.overview-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}
@media (min-width: 75rem) {
  .overview-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
}

.changed { list-style: none; margin: 0; padding: 0; }
.changed li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.25rem 1rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
}
.changed li:first-child { border-top: 0; }
.changed .what { font-weight: 550; }
.changed .where { font-size: 0.8125rem; color: var(--muted); }
.changed .value {
  grid-column: 1;
  font-size: 0.875rem; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center; gap: 0.5rem;
}
.changed .btn { grid-row: 1 / span 2; grid-column: 2; }
.swatch-sm { width: 0.75rem; height: 0.75rem; border-radius: 0.1875rem; border: 1px solid rgba(255, 255, 255, 0.15); flex: none; }

.empty {
  padding: 1.75rem 1.25rem;
  color: var(--muted);
  text-align: center;
}
.empty strong { display: block; color: var(--text); margin-bottom: 0.25rem; font-weight: 600; }

.banner {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 0.875rem 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: 1rem;
}
.banner .icon { width: 1.25rem; height: 1.25rem; }
.banner .grow { flex: 1; }
.banner.warn { background: var(--warn-soft); border-color: rgba(240, 178, 50, 0.35); }
.banner.warn .icon { color: var(--warn); }
.banner.info { background: var(--info-soft); border-color: rgba(91, 157, 255, 0.35); }
.banner.info .icon { color: var(--info); }

/* ---------------- buttons ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 2.25rem;
  padding: 0.4375rem 0.875rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease), color 0.12s var(--ease);
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn .icon { width: 1rem; height: 1rem; }
.btn.primary { background: var(--primary); border-color: #148a4c; color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: rgba(240, 98, 103, 0.5); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.small { min-height: 1.875rem; padding: 0.25rem 0.625rem; font-size: 0.875rem; }
.btn.icon-only { padding: 0.4375rem; min-width: 2.25rem; }
.btn.busy { pointer-events: none; opacity: 0.7; }

/* ---------------- settings ---------------- */

.field-list {
  container-type: inline-size;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.field {
  display: grid;
  gap: 0.625rem;
  padding: 1.125rem 1.25rem;
  border-top: 1px solid var(--border);
  scroll-margin-top: 5rem;
  transition: background 0.6s var(--ease);
}
.field:first-child { border-top: 0; }
.field.flash { background: var(--accent-soft); transition: none; }

/* Label and help on the left, the control on the right, once there's room. */
@container (min-width: 50rem) {
  .field { grid-template-columns: minmax(14rem, 1fr) minmax(0, 1.9fr); gap: 2rem; padding: 1.25rem 1.5rem; }
  .field.wide { grid-template-columns: minmax(0, 1fr); gap: 0.875rem; }
}

.field-head {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 0.375rem 0.5rem;
}
.field-label { font-weight: 600; }
.field-help { color: var(--muted); font-size: 0.875rem; margin: 0.25rem 0 0; max-width: 60ch; }
.field-error { color: var(--danger); font-size: 0.875rem; margin-top: 0.375rem; }
.field-tools { margin-top: 0.375rem; }
.field-control { min-width: 0; }

.badge {
  font-size: 0.75rem; font-weight: 600; line-height: 1.5;
  padding: 0 0.5rem;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
}
.badge.reload { color: var(--info); border-color: rgba(91, 157, 255, 0.4); background: var(--info-soft); }
.badge.restart { color: var(--warn); border-color: rgba(240, 178, 50, 0.4); background: var(--warn-soft); }
.badge.custom { color: var(--accent); border-color: rgba(63, 184, 113, 0.4); background: var(--accent-soft); }
.badge.unsaved { color: var(--text); border-color: var(--border-strong); background: var(--surface-3); }

.link-btn {
  font-size: 0.8125rem;
  color: var(--muted);
  background: none; border: 0; cursor: pointer;
  padding: 0.125rem 0;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-color: var(--border-strong);
}
.link-btn:hover { color: var(--text); text-decoration-color: currentColor; }

.input {
  width: 100%;
  min-height: 2.375rem;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.4375rem 0.6875rem;
  transition: border-color 0.12s var(--ease), box-shadow 0.12s var(--ease);
}
.input::placeholder { color: var(--faint); }
.input:hover:not(:disabled) { border-color: #45505b; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.input:disabled { opacity: 0.65; cursor: not-allowed; }
.input.invalid { border-color: var(--danger); }
textarea.input { resize: vertical; min-height: 5.5rem; line-height: 1.55; }
textarea.input.code { font: 0.84rem/1.6 var(--mono); min-height: 18rem; }
input[type="number"].input { max-width: 12rem; font-variant-numeric: tabular-nums; }
.field-control > div > input[type="text"].input, .field-control > select.input { max-width: 40rem; }
select.input { max-width: 30rem; cursor: pointer; }
select.input option, select.input optgroup { background: var(--surface-2); }

.colour-row { display: flex; align-items: center; gap: 0.625rem; flex-wrap: wrap; }
.colour-row input[type="color"] {
  width: 2.75rem; height: 2.375rem; padding: 0.1875rem;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.colour-row .input { max-width: 8.5rem; font-family: var(--mono); }
.check { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--muted); cursor: pointer; }

.emoji-preview { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.5rem; }
.emoji-preview img { width: 1.375rem; height: 1.375rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-bottom: 0.625rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.375rem;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.1875rem 0.25rem 0.1875rem 0.625rem;
  font-size: 0.875rem;
}
.chip .swatch { width: 0.5625rem; height: 0.5625rem; border-radius: 50%; background: var(--faint); }
.chip button {
  display: grid; place-items: center;
  border: 0; background: none; color: var(--faint); cursor: pointer;
  width: 1.25rem; height: 1.25rem; border-radius: 50%;
}
.chip button svg { width: 0.75rem; height: 0.75rem; }
.chip button:hover { background: var(--surface-3); color: var(--text); }

.toggle { position: relative; display: inline-block; width: 2.375rem; height: 1.375rem; flex: none; }
.toggle input { opacity: 0; width: 100%; height: 100%; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.toggle span {
  position: absolute; inset: 0;
  background: var(--border-strong);
  border-radius: 999px;
  transition: background 0.15s var(--ease);
}
.toggle span::after {
  content: ""; position: absolute; left: 0.1875rem; top: 0.1875rem;
  width: 1rem; height: 1rem; border-radius: 50%;
  background: #fff;
  transition: transform 0.18s var(--ease);
}
.toggle input:checked + span { background: var(--primary); }
.toggle input:checked + span::after { transform: translateX(1rem); }
.toggle input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.toggle input:disabled { cursor: not-allowed; }
.toggle input:disabled + span { opacity: 0.6; }

.rows { display: grid; gap: 0.5rem; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) 10rem auto; gap: 0.5rem; align-items: center; }

/* Divisions: groups separated by rules inside the one field, not boxes in a box. */
.divisions { display: grid; }
.division { padding: 1.125rem 0; border-top: 1px solid var(--border); }
.division:first-child { border-top: 0; padding-top: 0.25rem; }
.division:last-child { padding-bottom: 0; }
.division-head { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 0.75rem; margin-bottom: 0.875rem; }
.division-head strong { font-size: 1rem; }
.division-head .key { font: 0.8125rem var(--mono); color: var(--faint); }
.division-head .spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(22rem, 100%), 1fr)); gap: 0.75rem 1rem; }
.mini { display: grid; gap: 0.25rem; }
.mini-label { font-size: 0.8125rem; color: var(--muted); }
.grid-2 select.input { max-width: none; }

.results-group { margin-bottom: 1.75rem; }
.results-group h2 {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.9375rem; color: var(--muted); font-weight: 600;
  margin: 0 0 0.625rem;
}
.results-group h2 .icon { width: 1rem; height: 1rem; color: var(--accent); }

/* ---------------- access ---------------- */

.add-form { display: grid; grid-template-columns: minmax(0, 1fr) 10rem auto; gap: 0.5rem; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 0.8125rem; font-weight: 600; color: var(--faint);
  padding: 0.625rem 1.25rem; border-bottom: 1px solid var(--border);
}
.table td { padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.person { display: flex; align-items: center; gap: 0.625rem; }
.person img { width: 2rem; height: 2rem; border-radius: 50%; }
.person .handle { font-size: 0.8125rem; color: var(--muted); }
.mono { font: 0.8125rem var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.table select.input { min-height: 2rem; padding: 0.25rem 0.5rem; width: auto; }
.table td.end { text-align: right; }

/* ---------------- logs ---------------- */

.logs {
  background: #090b0d;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  font: 0.8125rem/1.65 var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  overflow: auto;
  scrollbar-width: thin;
}
.logs.full { height: calc(100vh - 13rem); min-height: 20rem; }
.logs.compact { border: 0; border-radius: 0 0 var(--radius) var(--radius); max-height: 22rem; }
.logs .warn { color: var(--warn); }
.logs .error { color: var(--danger); }
.skeleton-line {
  height: 0.75rem; margin: 0.5rem 0;
  border-radius: 0.25rem;
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------- save bar / toasts / dialog ---------------- */

.savebar {
  position: fixed;
  left: var(--sidebar-w); right: 0;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  padding: 0 var(--gutter);
  pointer-events: none;
  z-index: 10;
}
.savebar-inner {
  max-width: var(--content-max);
  margin-inline: auto;
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 0.75rem;
  padding: 0.625rem 0.75rem 0.625rem 1rem;
  box-shadow: var(--shadow);
  transform: translateY(calc(100% + 2rem));
  opacity: 0;
  transition: transform 0.25s var(--ease), opacity 0.2s var(--ease);
}
.savebar.show .savebar-inner { transform: none; opacity: 1; pointer-events: auto; }
.savebar .grow { flex: 1; }
.savebar .icon { color: var(--accent); }

#toasts {
  position: fixed; top: 1.25rem; right: 1.25rem;
  display: grid; gap: 0.5rem;
  z-index: 50;
}
.toast {
  display: flex; align-items: center; gap: 0.625rem;
  width: min(24rem, calc(100vw - 2.5rem));
  background: var(--surface-3);
  border: 1px solid rgba(63, 184, 113, 0.4);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem;
  box-shadow: var(--shadow);
  animation: toast-in 0.22s var(--ease);
}
.toast .icon { color: var(--accent); }
.toast.error { border-color: rgba(240, 98, 103, 0.5); }
.toast.error .icon { color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-0.375rem); } }

.dialog-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: grid; place-items: center;
  z-index: 40;
  padding: 1.25rem;
  animation: fade 0.15s var(--ease);
}
.dialog {
  width: min(27rem, 100%);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 0.875rem;
  padding: 1.375rem;
  box-shadow: var(--shadow);
}
.dialog h3 { margin: 0 0 0.5rem; font-size: 1.125rem; }
.dialog p { margin: 0 0 1.25rem; color: var(--muted); }
.dialog .actions-row { justify-content: flex-end; }
@keyframes fade { from { opacity: 0; } }

/* ---------------- tablet & phone ---------------- */

@media (max-width: 63.99rem) {
  .shell { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: fixed; z-index: 30; left: 0; top: 0;
    width: min(18rem, 86vw);
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease);
    padding-top: max(1.125rem, env(safe-area-inset-top));
  }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .scrim {
    display: block;
    position: fixed; inset: 0; z-index: 25;
    background: rgba(0, 0, 0, 0.55);
    border: 0;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s var(--ease);
  }
  .shell.nav-open .scrim { opacity: 1; pointer-events: auto; }

  .topbar {
    display: flex; align-items: center; gap: 0.75rem;
    position: sticky; top: 0; z-index: 20;
    padding: max(0.625rem, env(safe-area-inset-top)) var(--gutter) 0.625rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }
  .topbar .title { font: 700 1.1875rem/1.1 var(--display); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .brand-logo { width: 2rem; height: 2rem; border-radius: 0.5625rem; }
  .topbar .brand-logo img { width: 1.5rem; height: 1.5rem; }

  .main { padding-top: 1.5rem; }
  .savebar { left: 0; }
}

@media (max-width: 47.99rem) {
  .page-head { flex-direction: column; align-items: stretch; margin-bottom: 1.25rem; }
  .page-head h1 { font-size: 1.875rem; }
  .page-head .actions-row > .btn { flex: 1; }

  .status > div { flex-basis: 50%; border-left: 0; border-top: 1px solid var(--border); }
  .status > div:nth-child(-n+2) { border-top: 0; }
  .status > div:nth-child(even) { border-left: 1px solid var(--border); }

  .add-form, .row { grid-template-columns: minmax(0, 1fr); }
  .row { padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }

  /* Whitelist rows become stacked entries. */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border); }
  .table tr:last-child { border-bottom: 0; }
  .table td { padding: 0.25rem 0; border: 0; }
  .table td.end { text-align: left; padding-top: 0.5rem; }
  .table td[data-label]::before { content: attr(data-label) " "; color: var(--faint); font-family: var(--font); }

  .savebar-inner .label-long { display: none; }
  .logs.full { height: calc(100vh - 14rem); }
}

/* Touch screens get 44px targets whatever their width. */
@media (pointer: coarse) {
  .btn, .nav-item, .input, .search input { min-height: 2.75rem; }
  .btn.small { min-height: 2.5rem; }
  .chip button { width: 1.75rem; height: 1.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
