:root {
  color-scheme: dark;
  --bg: #0d111b;
  --surface: #141a26;
  --surface-2: #1a2231;
  --border: #283246;
  --text: #f2f5fa;
  --muted: #9ca8bb;
  --faint: #657086;
  --yellow: #ffd83d;
  --green: #48d597;
  --orange: #ff9e4a;
  --red: #ff6f72;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at 75% -10%, #4b3e121f, transparent 35%), var(--bg);
}
button, input, select { font: inherit; }
button { color: inherit; }
.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh;
  padding: 22px 15px; border-right: 1px solid var(--border); background: #0e131eeb;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 0 7px 28px; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: var(--faint); font-size: 11px; }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px;
  color: #171409; background: linear-gradient(145deg, #ffe45e, #f5bd1e); font-size: 12px; font-weight: 900;
}
nav { display: grid; gap: 5px; }
.nav {
  min-height: 43px; padding: 0 12px; border: 1px solid transparent; border-radius: 9px;
  color: var(--muted); background: transparent; cursor: pointer; text-align: left;
}
.nav:hover, .nav.active { color: var(--text); background: #1a2231; }
.nav.active { border-color: #ffd83d2e; }
.sidebar-note {
  display: flex; gap: 9px; align-items: center; margin-top: auto; padding: 12px;
  border: 1px solid var(--border); border-radius: 10px; color: var(--muted); background: var(--surface); font-size: 12px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dot.ready { background: var(--green); box-shadow: 0 0 0 4px #48d59718; }
main { min-width: 0; padding: 28px clamp(18px, 3vw, 42px) 50px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; max-width: 1450px; margin: 0 auto 25px; }
h1 { margin: 4px 0 0; font-size: clamp(25px, 3vw, 34px); letter-spacing: -.04em; }
h2 { margin: 4px 0 0; font-size: 18px; }
.eyebrow { margin: 0; color: var(--yellow); font-size: 10px; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
.actions, .dialog-actions { display: flex; gap: 9px; align-items: center; }
.button { min-height: 39px; padding: 0 14px; border: 0; border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 800; }
.button.primary { color: #181409; background: linear-gradient(145deg, #ffe45e, #f5bd1e); }
.button.secondary { border: 1px solid var(--border); background: var(--surface-2); }
.button.ghost { color: var(--muted); background: transparent; }
.button.full { width: 100%; }
.view { display: none; max-width: 1450px; margin: 0 auto; }
.view.active { display: block; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.metrics article, .panel { border: 1px solid var(--border); border-radius: 13px; background: linear-gradient(145deg, #171e2b, #121824); box-shadow: 0 20px 60px #03060d40; }
.metrics article { min-height: 130px; padding: 20px; }
.metrics span { color: var(--muted); font-size: 11px; font-weight: 700; }
.metrics strong { display: block; margin: 12px 0 5px; font-size: 32px; letter-spacing: -.05em; }
.metrics small { color: var(--faint); }
.metrics .warning strong { color: var(--orange); }
.grid.two { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .7fr); gap: 12px; }
.panel { margin-bottom: 12px; padding: 21px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.muted { color: var(--muted); font-size: 12px; line-height: 1.55; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.card { padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.card-head { display: flex; justify-content: space-between; gap: 10px; }
.card h3 { margin: 0; font-size: 13px; }
.card p { margin: 4px 0 0; color: var(--faint); font-size: 10px; overflow-wrap: anywhere; }
.badge { display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border: 1px solid currentColor; border-radius: 99px; font-size: 9px; font-weight: 850; }
.badge.ready, .badge.success { color: var(--green); }
.badge.busy, .badge.cooldown, .badge.assigned, .badge.processing { color: var(--orange); }
.badge.error, .badge.failed { color: var(--red); }
.badge.offline, .badge.disabled, .badge.unknown { color: var(--faint); }
.stats { display: flex; gap: 13px; margin-top: 13px; color: var(--muted); font-size: 10px; }
.status-list, .event-list { display: grid; gap: 8px; }
.status-row, .event-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 11px; }
.status-row span, .event-row span { color: var(--muted); }
.event-row { display: grid; grid-template-columns: 85px 130px 1fr; }
.empty { padding: 30px; color: var(--faint); text-align: center; font-size: 12px; }
.setup-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(260px, .8fr); gap: 12px; }
.setup-box { display: grid; gap: 10px; padding: 15px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.setup-box span { color: var(--muted); font-size: 11px; font-weight: 800; }
.setup-box code { display: block; padding: 12px; border: 1px solid #ffd83d33; border-radius: 8px; color: var(--yellow); background: #0c111b; overflow-wrap: anywhere; }
.setup-box p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--faint); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
td { color: var(--muted); }
td strong { color: var(--text); }
.sub { display: block; max-width: 320px; margin-top: 3px; overflow: hidden; color: var(--faint); font-size: 9px; text-overflow: ellipsis; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.tiny { min-height: 28px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); background: var(--surface-2); cursor: pointer; font-size: 9px; }
.tiny.danger { border-color: #ff6f724d; color: #ff9a9c; }
.tiny:hover { border-color: #ffd83d55; color: var(--text); }
.tiny.danger:hover { border-color: #ff6f72a6; color: #ffd7d8; }
dialog { width: min(570px, calc(100vw - 28px)); padding: 22px; border: 1px solid #37445c; border-radius: 14px; color: var(--text); background: var(--surface); box-shadow: 0 30px 90px #02050bbf; }
dialog::backdrop { background: #050811c9; backdrop-filter: blur(4px); }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.close { width: 32px; height: 32px; border: 0; border-radius: 8px; color: var(--muted); background: var(--surface-2); cursor: pointer; font-size: 20px; }
.field { display: grid; gap: 6px; margin-bottom: 13px; }
.field span { color: var(--muted); font-size: 11px; font-weight: 750; }
.field input, .field select { width: 100%; min-height: 41px; padding: 0 11px; outline: 0; border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: #0e141f; }
.field input:focus, .field select:focus { border-color: #ffd83d8c; box-shadow: 0 0 0 3px #ffd83d14; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog-actions { justify-content: flex-end; margin-top: 8px; }
.secret-code { display: block; padding: 15px; border: 1px solid #ffd83d4a; border-radius: 9px; color: var(--yellow); background: #0c111b; overflow-wrap: anywhere; }
.form-error { min-height: 18px; color: var(--red); font-size: 11px; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: 390px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); opacity: 0; transform: translateY(8px); pointer-events: none; transition: .18s ease-out; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { border-color: #ff6f7270; }
.login-page { display: grid; place-items: center; padding: 18px; }
.login-card { width: min(420px, 100%); padding: 28px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface); box-shadow: 0 30px 90px #02050b80; }
.login-card h1 { margin-bottom: 12px; font-size: 25px; }
.login-card .brand-mark { margin-bottom: 18px; }
@media (max-width: 1000px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .shell { display: block; }
  .sidebar { position: static; display: block; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding-bottom: 14px; }
  nav { display: flex; overflow-x: auto; }
  .nav { flex: 0 0 auto; }
  .sidebar-note { display: none; }
  main { padding: 20px 13px 40px; }
  .topbar { display: block; }
  .actions { margin-top: 15px; overflow-x: auto; }
  .metrics, .cards, .form-grid { grid-template-columns: 1fr; }
  .setup-grid { grid-template-columns: 1fr; }
  .event-row { grid-template-columns: 70px 105px 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
