/* Buzz Wash admin — internal tool. Light, dense, legible. */

:root {
  /* Same palette as the public site — this is the operator-facing half of one
     product, so it wears the same clothes. */
  --surface: #141414;
  --surface-alt: #161616;
  --plane: #0c0c0c;
  --sunken: #0f0f0f;
  --well: #101010;

  --ink: #f7f5f1;
  --ink-2: #c9c4ba;
  --muted: #8a857d;
  --faint: #6e6a64;

  --grid: #242424;
  --axis: #3a3a3a;
  --border: #242424;
  --border-strong: #333331;

  --brand: #ffc220;
  --brand-ink: #0c0c0c;
  --accent: #ffc220;
  --accent-ink: #0c0c0c;
  --accent-soft: rgba(255, 194, 32, 0.12);
  --accent-line: #4a3d1c;

  --good: #6fd46f;
  --good-mark: #0ca30c;
  --critical: #e66767;
  --warning: #fab219;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);

  --sans: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --display: 'Archivo Black', system-ui, sans-serif;
  --rail: 68px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.u-hidden { display: none !important; }
.u-visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.tabular { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ login -- */

.login {
  /* align-content, not place-items: two children must stack together under the
     card, not spread to opposite ends of the viewport. */
  min-height: 100vh; display: grid; align-content: center; justify-items: center;
  gap: 14px; padding: 24px;
  background: radial-gradient(900px 500px at 70% -10%, rgba(255, 194, 32, 0.16), transparent 70%), var(--plane);
}
.login__card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow); padding: 32px;
}
.login__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login__brand img { width: 40px; height: 40px; border-radius: 9px; }
.login__brand strong { font-family: var(--display); font-size: 18px; letter-spacing: -0.02em; color: var(--brand); }
.login h1 { font-family: var(--display); font-size: 22px; margin: 0 0 4px; }
.login p.sub { margin: 0 0 22px; color: var(--muted); }

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

.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }

.rail {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 14px 0; position: sticky; top: 0; height: 100vh;
}
.rail__logo { width: 38px; height: 38px; border-radius: 9px; margin-bottom: 14px; }
.rail__btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; background: none; border-radius: 11px; cursor: pointer;
  color: var(--muted); transition: background-color 120ms ease, color 120ms ease;
}
.rail__btn:hover { background: var(--sunken); color: var(--ink); }
.rail__btn[aria-current='page'] { background: var(--accent-soft); color: var(--accent); }
.rail__btn svg { width: 21px; height: 21px; }
.rail__spacer { flex: 1; }
.rail__avatar {
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13px;
}

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 18px 28px 0; }
.topbar__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.topbar h1 { font-family: var(--display); font-size: 22px; margin: 0; letter-spacing: -0.02em; }
.topbar .sub { color: var(--muted); margin: 2px 0 0; font-size: 13px; }

.tabs { display: flex; gap: 2px; margin-top: 14px; overflow-x: auto; }
.tabs button {
  border: 0; background: none; padding: 9px 12px; cursor: pointer;
  color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected='true'] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.filters {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.filters__spacer { flex: 1; }

.content { padding: 24px 28px 56px; }

/* --------------------------------------------------------------- controls -- */

.btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  border-radius: 9px; padding: 8px 14px; font-weight: 500;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.btn:hover:not(:disabled) { background: var(--sunken); border-color: var(--faint); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn--primary:hover:not(:disabled) { background: #ffd75e; border-color: #ffd75e; }
.btn--accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn--accent:hover:not(:disabled) { background: #ffd75e; border-color: #ffd75e; }
.btn--danger { color: var(--critical); border-color: #4a2626; }
.btn--danger:hover:not(:disabled) { background: #241616; }
.btn--sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn--block { width: 100%; justify-content: center; }

label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block; font-size: 12px; font-weight: 600; color: var(--ink-2);
  margin-bottom: 5px; letter-spacing: 0.01em;
}
label.field small { display: block; font-weight: 400; color: var(--muted); margin-top: 4px; }

input:not([type]), input[type='text'], input[type='email'], input[type='password'],
input[type='url'], input[type='number'], input[type='date'], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border-strong);
  border-radius: 8px; background: var(--sunken); color: var(--ink); font: inherit;
}
textarea { min-height: 88px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
input, textarea, select { color-scheme: dark; }
input::placeholder, textarea::placeholder { color: var(--faint); }
select { appearance: none; color-scheme: dark; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

.chip-toggle { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-toggle button {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; cursor: pointer; font-size: 13px;
}
.chip-toggle button[aria-pressed='true'] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ------------------------------------------------------------------ cards -- */

.grid { display: grid; gap: 16px; }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.grid > * { min-width: 0; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.card__title { font-size: 14px; font-weight: 600; margin: 0; }
.card__sub { color: var(--muted); font-size: 12px; margin: 0; }
.card--link { cursor: pointer; text-align: left; width: 100%; font: inherit; }
.card--link:hover { border-color: var(--accent); }

.tile__body { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-top: 10px; }
.tile__value { font-family: var(--display); font-size: 27px; letter-spacing: -0.02em; line-height: 1.1; color: var(--ink); }
.tile__value--sm { font-size: 21px; }
.tile__foot { display: flex; gap: 18px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.tile__foot b { display: block; color: var(--ink-2); font-size: 13px; }
.tile__viz { flex: 0 0 auto; width: 46%; max-width: 190px; }

.delta { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.delta--up { color: var(--good); }
.delta--down { color: var(--critical); }
.delta--flat { color: var(--muted); }
.delta span.since { color: var(--muted); font-weight: 400; margin-left: 4px; }

/* ------------------------------------------------------------------ table -- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 10px 14px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--sunken); position: sticky; top: 0; }
table.data tbody tr:hover { background: var(--sunken); }
table.data tbody tr.is-total { font-weight: 600; background: var(--sunken); }
table.data tr:last-child td { border-bottom: 0; }

/* --------------------------------------------------------------- viz bits -- */

.viz-tip {
  position: fixed; top: 0; left: 0; z-index: 90; pointer-events: none;
  background: #000; border: 1px solid var(--border); color: var(--ink); padding: 7px 10px; border-radius: 8px;
  font-size: 12px; line-height: 1.4; max-width: 260px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.24);
}
.viz-tip b { display: block; font-weight: 600; }
.viz-tip span { color: var(--muted); }

.viz-axis { font-size: 11px; fill: var(--muted); font-family: var(--sans); font-variant-numeric: tabular-nums; }
.viz-axis-title { font-size: 11px; fill: var(--muted); font-family: var(--sans); }
.viz-scroll { overflow-x: auto; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; font-size: 12px; color: var(--ink-2); }
.viz-legend__item { display: inline-flex; align-items: center; gap: 6px; }
.viz-legend__item i { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }

.spark { width: 100%; height: 72px; display: block; overflow: visible; }
.spark--empty { height: 72px; }
.donut { width: 92px; height: 92px; }
.heat-thumb { width: 100%; max-width: 150px; height: auto; }

.heat { --cell-min: 34px; overflow-x: auto; padding-bottom: 4px; }
.heat__grid { border-collapse: separate; border-spacing: 2px; width: 100%; font-variant-numeric: tabular-nums; }
.heat__grid td, .heat__grid th { padding: 0; }
.heat__grid tbody td {
  min-width: var(--cell-min); height: 34px; text-align: center; font-size: 12px;
  border-radius: 3px; cursor: default;
}
.heat__grid tbody th { text-align: right; padding-right: 10px; font-size: 12px; color: var(--ink-2); font-weight: 500; }
.heat__grid thead th {
  font-weight: 400; font-size: 11px; color: var(--muted); height: 78px;
  vertical-align: bottom; padding-bottom: 6px;
}
.heat__grid thead th span { display: inline-block; transform: rotate(-45deg); transform-origin: left bottom; white-space: nowrap; }
.heat__corner { width: 44px; }
.heat__legend { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-size: 12px; color: var(--muted); }
.heat__ramp { display: flex; flex: 1; height: 8px; border-radius: 4px; overflow: hidden; max-width: 420px; }
.heat__ramp span { flex: 1; }

/* ------------------------------------------------------------- pacing tbl -- */

.pacing { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; box-shadow: var(--shadow); }
.pacing__head { display: flex; align-items: center; gap: 8px; padding: 14px 18px 10px; font-weight: 600; }
.pacing__head svg { width: 16px; height: 16px; color: var(--muted); }

/* ---------------------------------------------------------------- editor --- */

.editor { display: grid; grid-template-columns: 232px 1fr; gap: 20px; align-items: start; }
.editor__nav { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 2px; }
.editor__nav button {
  border: 0; background: none; text-align: left; padding: 8px 12px; border-radius: 8px;
  cursor: pointer; color: var(--ink-2);
}
.editor__nav button:hover { background: var(--surface); }
.editor__nav button[aria-current='true'] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.editor__nav hr { border: 0; border-top: 1px solid var(--border); margin: 8px 4px; }

.repeat { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 12px; background: var(--sunken); }
.repeat__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.repeat__title { font-weight: 600; font-size: 13px; }
.repeat__tools { display: flex; gap: 4px; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.media-item { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.media-item__img { aspect-ratio: 4 / 3; background: repeating-conic-gradient(#161616 0% 25%, #1c1c1c 0% 50%) 50% / 16px 16px; display: grid; place-items: center; }
.media-item__img img { width: 100%; height: 100%; object-fit: contain; }
.media-item__meta { padding: 9px 11px; font-size: 12px; }
.media-item__meta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.media-item__meta span { color: var(--muted); }
.media-item__tools { display: flex; gap: 6px; padding: 0 11px 11px; }

.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  padding: 28px; text-align: center; color: var(--muted); background: var(--surface);
  margin-bottom: 18px; transition: border-color 120ms ease, background-color 120ms ease;
}
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.picker-grid button { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 0; cursor: pointer; overflow: hidden; }
.picker-grid button:hover { border-color: var(--accent); }
.picker-grid img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.picker-grid figcaption { font-size: 11px; padding: 6px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.photo-field { display: flex; gap: 12px; align-items: flex-start; }
.photo-field__preview {
  width: 116px; flex: 0 0 auto; aspect-ratio: 4/3; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: var(--sunken); display: grid; place-items: center;
  font-size: 11px; color: var(--muted); text-align: center; padding: 6px;
}
.photo-field__preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-field__body { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- status --- */

.banner {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px;
  border: 1px solid transparent;
}
.banner svg { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 1px; }
.banner--info { background: rgba(255, 194, 32, 0.08); border-color: var(--accent-line); color: var(--ink-2); }
.banner--good { background: rgba(12, 163, 12, 0.10); border-color: #234a23; color: #a6dda6; }
.banner--warn { background: rgba(250, 178, 25, 0.10); border-color: #4a3d1c; color: #f0d79a; }
.banner--error { background: rgba(230, 103, 103, 0.10); border-color: #4a2626; color: #f0b9b9; }
.banner ul { margin: 6px 0 0; padding-left: 18px; }

.toast-wrap { position: fixed; right: 20px; bottom: 20px; z-index: 95; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #16161a; color: #fff; border-radius: 10px; padding: 11px 15px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5); font-size: 13px; max-width: 380px;
}
.toast--error { background: #7d2b2b; color: #ffecec; }
.toast--good { background: #1c5c1c; color: #ddf5dd; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.pill--ok { background: rgba(12, 163, 12, 0.16); color: #6fd46f; }
.pill--error { background: rgba(230, 103, 103, 0.14); color: var(--critical); }
.pill--idle { background: var(--sunken); color: var(--muted); }
.pill--role { background: var(--accent-soft); color: var(--accent); text-transform: capitalize; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h3 { font-family: var(--display); color: var(--ink); margin: 0 0 6px; font-size: 16px; }

.spinner {
  width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; display: inline-block; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.66); z-index: 88;
  display: grid; place-items: center; padding: 24px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  width: min(620px, 100%); max-height: 86vh; overflow: auto; padding: 22px;
}
.modal h2 { font-family: var(--display); margin: 0 0 4px; font-size: 18px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row--end { justify-content: flex-end; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
h2.section-title { font-family: var(--display); font-size: 16px; margin: 26px 0 12px; letter-spacing: -0.01em; }
h2.section-title:first-child { margin-top: 0; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    flex-direction: row; height: auto; position: sticky; top: 0; z-index: 40;
    border-right: 0; border-bottom: 1px solid var(--border); padding: 8px 12px; gap: 2px;
    overflow-x: auto;
  }
  .rail__logo { margin-bottom: 0; }
  .rail__spacer { flex: 1; }
  .editor { grid-template-columns: 1fr; }
  .editor__nav { position: static; flex-direction: row; overflow-x: auto; }
  .topbar, .filters, .content { padding-left: 16px; padding-right: 16px; }
  .tile__viz { display: none; }
}

/* Equipment */
.device--offline { border-color: #4a2626; }
.device__meta { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--ink-2); }
.device__dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.device__dot--online { background: var(--good-mark); box-shadow: 0 0 0 3px rgba(12,163,12,.18); }
.device__dot--offline { background: var(--critical); box-shadow: 0 0 0 3px rgba(230,103,103,.16); }
.device__dot--unknown { background: var(--muted); }
.device__error { margin: 10px 0 0; font-size: 12px; color: var(--critical); font-family: ui-monospace, Menlo, monospace; }

/* Sign-in hint — localhost only; the server will not send it anywhere else. */
.login-hint {
  width: min(400px, 100%); padding: 14px 16px; border-radius: var(--radius-sm);
  border: 1px dashed var(--border-strong); background: var(--sunken); font-size: 13px;
}
.login-hint__title {
  margin: 0 0 10px; font-size: 11px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--brand);
}
.login-hint__row { margin: 0 0 10px; line-height: 1.7; color: var(--ink-2); }
.login-hint__row:last-child { margin-bottom: 0; }
.login-hint__row b { display: block; font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); font-weight: 700; }
.login-hint button[data-fill] {
  background: none; border: 0; padding: 0; cursor: pointer; font: inherit;
  color: var(--brand); text-decoration: underline; text-underline-offset: 3px;
}
.login-hint code { font-size: 12px; color: var(--ink-2); }
