/* ALLMADN control room: design system
   Black, white and gray only; the white-filled crest sits on flat charcoal.
   Calm by default: sections are a heading plus content separated by space,
   lists use thin dividers, and icons appear in the nav (and only where a
   button would be unclear without one). State is shown by shape + label
   (solid dot = on, hollow ring = off); red is reserved for errors and
   destructive actions.
   Layout: slim left rail on desktop, top bar + drop-down menu on phones;
   content column capped at 1040px. One theme only: charcoal. */

:root {
  --bg: #3A3A3A;
  --surface: #333333;
  --surface-2: #474747;
  --line: #555555;
  --line-strong: #6A6A6A;
  --text: #F5F5F5;
  --muted: #BDBDBD;
  --accent: #FFFFFF;
  --accent-ink: #111111;
  --accent-text: #FFFFFF;
  --danger: #FF6B6B;
  --on-danger: #111111;
  --focus: #FFFFFF;
  --shadow-pop: 0 14px 40px rgba(0, 0, 0, 0.4);

  --font-display: 'Saira Semi Condensed', 'Arial Narrow', sans-serif;
  --font-body: "Archivo", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --rail-w: 216px;
  color-scheme: dark;
}

/* ---------- Base ---------- */

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: #3A3A3A;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }
a { color: inherit; }
p { margin: 0; }
h1, h2, h3, h4 { margin: 0; text-wrap: balance; }
ul, ol { margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.hidden, [hidden] { display: none !important; }
.opacity-50 { opacity: 0.5; }
.loading { opacity: 0.5; pointer-events: none; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.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;
}

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 200;
  padding: 8px 12px; border-radius: var(--r-sm);
  background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 12px; }

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.05em 0.35em;
  border-radius: 4px;
  background: var(--surface-2);
  overflow-wrap: anywhere;
}

.crest { display: block; }

/* ---------- Shell ---------- */

.shell { display: flex; min-height: 100vh; }

.rail {
  position: sticky; top: 0;
  flex: 0 0 var(--rail-w);
  width: var(--rail-w);
  height: 100vh;
  display: flex; flex-direction: column;
  padding: 24px 14px 20px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 8px 28px;
  text-decoration: none;
}
.brand .crest { width: 44px; height: auto; }
.brand__name {
  font: 800 22px/1 var(--font-display);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.rail-nav { display: grid; gap: 2px; }

.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--muted);
  font: 600 14.5px/1.2 var(--font-body);
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}
.nav-link i { width: 18px; text-align: center; font-size: 14px; }
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.is-active { color: var(--text); background: var(--surface-2); }

.rail-logout {
  margin-top: auto;
  padding: 0 10px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}
.rail-logout:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

.main-col { flex: 1; min-width: 0; }

.content {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 40px 48px 72px;
}

/* Top bar + menu: phones and small tablets only */
.topbar {
  display: none;
  position: sticky; top: 0; z-index: 50;
  align-items: center; gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { padding: 0; margin-right: auto; }
.topbar .brand .crest { width: 36px; }
.topbar .brand__name { font-size: 19px; }

.mobile-menu {
  position: relative; z-index: 40;
  display: grid; gap: 2px;
  padding: 8px 12px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
}
.mobile-menu .nav-link { padding: 12px 10px; }
.mobile-menu .rail-logout { margin-top: 8px; padding: 8px 10px 0; }

@media (max-width: 899px) {
  .shell { display: block; }
  .rail { display: none; }
  .topbar { display: flex; }
  .content { padding: 24px 16px 56px; }
}
@media (min-width: 900px) {
  .mobile-menu { display: none !important; }
}

/* ---------- Page header & sections ---------- */

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px 20px; flex-wrap: wrap;
  margin-bottom: 32px;
}
.page-title {
  font: 800 clamp(30px, 4.4vw, 44px)/1.05 var(--font-display);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.block { margin-top: 44px; min-width: 0; }
.block:first-child, .page-head + .block { margin-top: 0; }
.block__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px 16px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.block__title {
  font: 700 17px/1.2 var(--font-display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.block__hint { font-size: 13px; color: var(--muted); margin: -4px 0 14px; max-width: 70ch; }
/* Blocks that can appear first on a page (others may be hidden) */
.block--lead { margin-top: 0; }
.block--panel { margin-bottom: 44px; }
.field--narrow { max-width: 280px; }

.text-link {
  color: var(--text);
  font-weight: 600; font-size: 13.5px;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
}
.text-link:hover { text-decoration-color: currentColor; }

/* ---------- Layout helpers ---------- */

.stack { display: grid; gap: 20px; }
.stack--sm { gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 520px) { .grid-3 { grid-template-columns: minmax(0, 1fr); } }

.inline-actions { display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap; }
.inline-actions form { display: contents; }
.inline-actions--after { margin-top: 14px; }
.inline-actions--before { margin-bottom: 12px; }

/* ---------- Status: shape + label ---------- */

.status-indicator {
  display: inline-flex; align-items: center; gap: 8px;
  font: 600 12px/1 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.status-indicator::before {
  content: "";
  flex: none;
  width: 9px; height: 9px;
  border-radius: 50%;
  box-sizing: border-box;
}
.status-indicator i { display: none; }
.status-online { color: var(--text); }
.status-online::before { background: currentColor; }
.status-offline { color: var(--muted); }
.status-offline::before { border: 1.5px solid currentColor; }
.status-warning { color: var(--text); }
.status-warning::before { border: 1.5px solid currentColor; background: linear-gradient(90deg, currentColor 50%, transparent 50%); }

/* The dashboard's bot status is the headline of the page. */
#forwarder-status {
  font: 800 30px/1 var(--font-display);
  letter-spacing: 0.03em;
  gap: 12px;
}
#forwarder-status::before { width: 14px; height: 14px; }
#forwarder-status.status-offline::before { border-width: 2px; }
#forwarder-status.status-online::before { animation: pulse 2s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.status-row {
  display: flex; align-items: center; gap: 14px 24px; flex-wrap: wrap;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}
.status-row__league { color: var(--muted); font-size: 14.5px; }
.status-row__control { display: flex; gap: 10px; }
.status-row__control form { display: contents; }
#connection-info:empty { display: none; }
.connection { font-size: 13.5px; color: var(--muted); }

.notice {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  margin-top: 16px;
  font-size: 14px;
  color: var(--muted);
}
.notice strong { color: var(--text); font-weight: 600; }

/* ---------- Plain lists ---------- */

.list { list-style: none; border-top: 1px solid var(--line); }
.list__row {
  display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.list__main { flex: 1 1 260px; min-width: 0; display: grid; gap: 3px; }
.list__name { font-weight: 600; font-size: 14.5px; overflow-wrap: anywhere; }
.list__meta { font: 400 12.5px/1.45 var(--font-mono); color: var(--muted); overflow-wrap: anywhere; }
.list__aside { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; }
.list__aside form { display: contents; }
.list__more { padding-top: 10px; font-size: 13px; color: var(--muted); }
.list__tag { font-weight: 400; color: var(--muted); }

.empty-line { padding: 14px 2px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }

/* ---------- Tables (Members) ---------- */

.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
.table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  font: 600 12px/1.2 var(--font-body);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table td.mono { font: 500 13px/1.4 var(--font-mono); }
.table .table__action { text-align: right; }
.cell-sub { display: block; margin-top: 3px; font-size: 12.5px; color: var(--muted); }
a.cell-sub { text-decoration: none; }
a.cell-sub:hover { color: var(--text); }

.team-cell { display: flex; align-items: center; gap: 10px; font-weight: 700; white-space: nowrap; }
.team-cell img, .team-title img { flex: none; object-fit: contain; }
.team-title { display: flex; align-items: center; gap: 14px; }

.progress-head { display: flex; align-items: baseline; gap: 6px 12px; flex-wrap: wrap; margin-bottom: 12px; }
.progress-count { font: 800 34px/1 var(--font-display); }
.progress { height: 8px; border-radius: 4px; background: var(--surface); overflow: hidden; }
.progress__bar { height: 100%; background: var(--accent); }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; padding: 0; margin: 0; }
.seg label {
  display: flex; align-items: center;
  min-height: 38px; padding: 0 14px;
  font: 600 13px/1 var(--font-body);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.seg label + label { border-left: 1px solid var(--line-strong); }
.seg label:hover { color: var(--text); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent); color: var(--accent-ink); }
.seg label:has(input:focus-visible) { outline: 2px solid currentColor; outline-offset: -4px; }

/* ---------- League ---------- */

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px;
  padding-bottom: 28px; border-bottom: 1px solid var(--line);
}
.stat { display: grid; gap: 4px; align-content: start; min-width: 0; }
.stat__label { font: 600 12px/1.2 var(--font-body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.stat__value { display: flex; align-items: center; gap: 10px; font: 800 26px/1.05 var(--font-display); }
.stat__detail { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }
.dot--ok { background: var(--text); }
.dot--off { border: 2px solid var(--muted); }
.dot--warn { border: 2px solid var(--text); background: linear-gradient(90deg, var(--text) 50%, transparent 50%); }
.dot--error { background: var(--danger); }

.league-cols { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 44px 48px; margin-top: 36px; }
.league-cols > .block { flex: 1 1 320px; margin-top: 0; }
.league-cols > .block:last-child { flex: 1.3 1 420px; }

.event-list { list-style: none; border-top: 1px solid var(--line); }
.event {
  display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 12px;
  padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.event__when { font-size: 12px; color: var(--muted); padding-top: 2px; }
.resync { margin-top: 24px; }

.switch-row {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 24px;
  padding: 12px 2px; border-bottom: 1px solid var(--line);
}
.switch-row:first-child { border-top: 1px solid var(--line); }
.switch-row__what { display: grid; gap: 2px; min-width: 0; }
.switch-row__name { font-weight: 600; font-size: 14.5px; }
@media (max-width: 640px) { .switch-row { flex-direction: column; align-items: flex-start; } }

/* Phone: one compact row per team (team and Edit, gamertag, who's linked, status) */
@media (max-width: 640px) {
  .table-wrap { overflow: visible; }
  .table, .table tbody { display: block; min-width: 0; }
  .table thead { display: none; }
  .table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "team action" "tag action" "tg action" "status action";
    gap: 4px 12px;
    align-items: center;
    padding: 12px 2px;
    border-bottom: 1px solid var(--line);
  }
  .table td { padding: 0; border: 0; }
  .table .col-team { grid-area: team; }
  .table .col-tag { grid-area: tag; font-size: 12.5px; color: var(--muted); }
  .table .col-tg { grid-area: tg; }
  .table .col-status { grid-area: status; padding-top: 2px; }
  .table .table__action { grid-area: action; align-self: start; }
  .table .col-twitch, .table .col-tz, .table .col-tg.muted { display: none; }
  .table .col-tg .cell-sub { display: inline; margin-left: 6px; }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px;
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font: 600 14px/1.2 var(--font-body);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled, .btn[disabled] { opacity: 0.42; cursor: not-allowed; }
.btn i { font-size: 0.9em; }

/* Primary and "go" actions share the solid fill. */
.btn-primary, .btn-success { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover, .btn-success:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 86%, var(--bg));
  border-color: color-mix(in srgb, var(--accent) 86%, var(--bg));
}
.btn-outline { background: transparent; }

/* Red only for destructive actions. */
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 55%, transparent); }
.btn-danger:hover:not(:disabled) { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }

.btn-warning { border-style: dashed; }

.btn-sm { min-height: 32px; padding: 5px 12px; font-size: 13px; }

/* Plain text buttons for secondary actions */
.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: 600 13.5px/1.3 var(--font-body);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.link-btn:hover { color: var(--text); text-decoration-color: currentColor; }
.link-btn--danger { color: var(--danger); }
.link-btn--danger:hover { color: var(--danger); }
.link-btn--strong { color: var(--text); text-decoration-color: var(--line-strong); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; flex: none;
  border-radius: var(--r-sm);
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

/* ---------- Forms ---------- */

.form-grid { display: grid; gap: 18px; }
.form-group, .field { display: grid; gap: 6px; min-width: 0; align-content: start; }

.form-label {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font: 600 13.5px/1.3 var(--font-body);
  color: var(--text);
}
.form-label--sm { font-size: 12.5px; color: var(--muted); }

.hint { font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.hint--error { color: var(--danger); }
.hint--spaced { margin-top: 8px; }
.field--medium { max-width: 420px; }
.fieldset-plain { border: 0; padding: 0; margin: 0; min-width: 0; }
.fieldset-plain > legend { padding: 0; margin-bottom: 8px; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font: 400 14.5px/1.4 var(--font-body);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input::placeholder, .form-textarea::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.form-input:hover, .form-select:hover, .form-textarea:hover { border-color: var(--line-strong); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent-text);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.form-input:disabled, .form-select:disabled, .form-textarea:disabled { opacity: 0.6; cursor: not-allowed; }
.form-input.mono, .form-textarea.mono { font-family: var(--font-mono); font-size: 13.5px; }

.form-select {
  appearance: none; -webkit-appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  background-color: var(--surface-2);
}
.form-select option { background: var(--surface); color: var(--text); }

.form-textarea { min-height: 160px; resize: vertical; line-height: 1.55; }
.form-textarea.code { font: 400 13px/1.6 var(--font-mono); tab-size: 2; }

.is-invalid, .form-input.is-invalid { border-color: var(--danger) !important; }

.check { width: 18px; height: 18px; flex: none; margin: 1px 0 0; accent-color: var(--accent); cursor: pointer; }
.check-row { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14.5px; }
.check-row .hint { display: block; }

.switch {
  appearance: none; -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 40px; height: 22px;
  margin: 0;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.switch::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s, background-color 0.15s;
}
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(18px); background: var(--accent-ink); }

.radios { display: flex; gap: 10px 24px; flex-wrap: wrap; }
.radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14.5px; }
.radio input { accent-color: var(--accent); margin: 0; }

/* Settings: one row per feature (toggle, name, channel) */
.setting-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 300px);
  align-items: center;
  gap: 10px 16px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}
.setting-row:first-child { border-top: 1px solid var(--line); }
.setting-row--parent { border-bottom: 0; }
.setting-row__name { font-weight: 600; font-size: 14.5px; cursor: pointer; }
.setting-row__config { min-width: 0; transition: opacity 0.15s; }
.setting-sub {
  display: grid; gap: 16px;
  padding: 4px 2px 18px 56px;
  border-bottom: 1px solid var(--line);
  transition: opacity 0.15s;
}
.setting-sub__title { font-size: 12.5px; font-weight: 600; color: var(--muted); }
@media (max-width: 640px) {
  .setting-row { grid-template-columns: auto minmax(0, 1fr); }
  .setting-row__config { grid-column: 1 / -1; }
  .setting-sub { padding-left: 2px; }
}

.schedule-row { display: flex; align-items: center; gap: 8px; }
.schedule-row .form-input, .schedule-row .form-select { flex: 1; min-width: 0; }

.savebar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap;
  margin-top: 36px;
  padding: 14px 0;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.savebar__end { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-left: auto; }

/* ---------- Flash messages & toasts ---------- */

.flashes { display: grid; gap: 8px; max-width: 1040px; width: 100%; margin: 0 auto; padding: 20px 48px 0; }
@media (max-width: 899px) { .flashes { padding: 16px 16px 0; } }

.flash {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 8px 8px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: 14px;
}
.flash > i { flex: none; color: var(--text); }
.flash__msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.flash--error { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 60%, transparent); }
.flash--error > i { color: var(--danger); }
.flash--info > i, .flash--message > i { color: var(--muted); }

.toast {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: calc(16px + env(safe-area-inset-right, 0px));
  z-index: 300;
  display: flex; align-items: center; gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 8px 10px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  box-shadow: var(--shadow-pop);
  font-size: 14px;
}
.toast > i { color: var(--text); }
.toast--error { box-shadow: var(--shadow-pop), inset 0 0 0 1px color-mix(in srgb, var(--danger) 60%, transparent); }
.toast--error > i { color: var(--danger); }

.fade-in { animation: fadeIn 0.2s ease-out both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- Logs ---------- */

.toolbar { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .form-select { width: auto; min-width: 150px; }
.toolbar .form-input { flex: 1 1 220px; width: auto; }

.log-technical { font-size: 13.5px; color: var(--muted); white-space: nowrap; }
#log-count { margin: -6px 0 14px; }

.log-day + .log-day { margin-top: 28px; }
.log-day__title {
  font: 700 15px/1.2 var(--font-display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.log-list { list-style: none; border-top: 1px solid var(--line); }
.log-line {
  display: grid;
  grid-template-columns: 96px 104px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 4px 14px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line);
}
.log-line__time { font: 400 12.5px/1.4 var(--font-mono); color: var(--muted); white-space: nowrap; }
.log-line__area { font: 600 11.5px/1.4 var(--font-body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.log-line__text { font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.log-line__level {
  display: inline-block; margin-right: 6px; padding: 1px 6px;
  border: 1px solid currentColor; border-radius: 4px;
  font: 600 11px/1.4 var(--font-body); letter-spacing: 0.05em; text-transform: uppercase;
}
.log-line--warning .log-line__text { color: var(--text); font-weight: 600; }
.log-line--error .log-line__text, .log-line--critical .log-line__text { color: var(--danger); font-weight: 600; }
/* Copy button stays out of the way until the line is hovered or focused. */
.log-line .icon-btn { align-self: center; width: 28px; height: 28px; font-size: 12px; opacity: 0; }
.log-line:hover .icon-btn, .log-line .icon-btn:focus-visible { opacity: 1; }
@media (hover: none) { .log-line .icon-btn { opacity: 0.6; } }
@media (max-width: 640px) {
  .log-line { grid-template-columns: auto minmax(0, 1fr) auto; }
  .log-line__text { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- Code blocks, help, misc ---------- */

.code-block {
  margin: 0;
  padding: 14px 16px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font: 400 12.5px/1.6 var(--font-mono);
  overflow-x: auto;
  white-space: pre;
}

.kv { display: grid; gap: 8px; list-style: none; }
.kv li { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 4px 12px; align-items: baseline; font-size: 13.5px; color: var(--muted); }
.kv code, .kv .kv__value { color: var(--text); }
@media (max-width: 520px) { .kv li { grid-template-columns: minmax(0, 1fr); } }

.steps { display: grid; gap: 6px; padding-left: 20px; font-size: 13.5px; color: var(--muted); }
.steps a { color: var(--text); }

.help { margin-top: 36px; }
.help--flush { margin-top: 0; }
.help > summary {
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer;
  list-style: none;
  color: var(--muted);
  font: 600 13.5px/1.3 var(--font-body);
}
.help > summary:hover { color: var(--text); }
.help > summary::-webkit-details-marker { display: none; }
.help > summary::before {
  content: "";
  width: 6px; height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
.help[open] > summary::before { transform: rotate(45deg); }
.help__body { display: grid; gap: 16px; padding: 14px 0 0 14px; }
.help__title { font-weight: 600; font-size: 14px; margin-bottom: 6px; }

/* ---------- Login ---------- */

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
}
.login-hero {
  display: grid; place-items: center;
  padding: 48px;
  background: var(--bg);
}
.login-hero .crest { width: min(320px, 70%); height: auto; }
.login-panel { display: grid; place-items: center; padding: 48px 24px; background: var(--surface); }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 24px; }
.login-title {
  font: 800 50px/1.05 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.login-foot {
  font-size: 12.5px;
  color: var(--muted);
}

@media (max-width: 859px) {
  .login-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .login-hero { padding: 36px 24px 28px; }
  .login-hero .crest { width: min(180px, 50%); }
  .login-panel { place-items: start center; padding: 32px 16px 48px; }
  .login-title { font-size: 40px; }
}

/* ---------- Motion ---------- */

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

@media print {
  .rail, .topbar, .mobile-menu, .no-print { display: none !important; }
}
