:root {
  color-scheme: dark;
  --bg: #090b10;
  --panel: #141922;
  --panel-2: #10151d;
  --text: #f3f7fb;
  --muted: #92a0b4;
  --line: #273142;
  --green: #39d98a;
  --red: #ff5c73;
  --amber: #f8c14a;
  --blue: #4aa3ff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 54px;
  padding: 14px 16px;
  background: #202838;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

button:hover { background: #2a3549; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--blue); color: #04111f; border-color: var(--blue); }
button.danger { background: #4b1722; border-color: #7b2636; color: #ffd9df; }
button.ghost { min-height: 40px; background: transparent; }

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #0e131b;
  color: var(--text);
}

.muted { color: var(--muted); font-size: 0.92rem; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px clamp(14px, 3vw, 28px);
  background: rgba(9, 11, 16, 0.96);
  border-bottom: 1px solid var(--line);
}

.dashboard {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 28px) 36px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.login-card h1 { margin: 0 0 8px; }
.login-card form { display: grid; gap: 16px; margin-top: 22px; }
.login-card label { display: grid; gap: 8px; color: var(--muted); }

.status-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  margin-bottom: 16px;
}
.status-dot {
  width: 18px;
  height: 18px;
  border-radius: 99px;
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(255, 92, 115, 0.15);
}
.status-dot.connected { background: var(--green); box-shadow: 0 0 0 5px rgba(57, 217, 138, 0.15); }
.status-dot.stale { background: var(--amber); box-shadow: 0 0 0 5px rgba(248, 193, 74, 0.15); }

.grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 16px;
  margin-bottom: 16px;
}
.panel h2 { margin: 0 0 14px; font-size: 1.05rem; }

.state-list {
  display: grid;
  gap: 10px;
  margin: 0;
}
.state-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.state-list dt { color: var(--muted); }
.state-list dd { margin: 0; font-weight: 800; text-align: right; }

.called-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 48px;
}
.ball {
  min-width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #e9eef7;
  color: #10151d;
  font-weight: 900;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.custom-message {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}
.flash { min-height: 24px; margin-top: 10px; color: var(--muted); }
.flash.success { color: var(--green); }
.flash.error { color: var(--red); }
.alert.error {
  background: rgba(255, 92, 115, 0.14);
  border: 1px solid rgba(255, 92, 115, 0.38);
  color: #ffdce2;
  padding: 12px;
  border-radius: 8px;
}

.audit-table {
  display: grid;
  gap: 8px;
}
.audit-row {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid rgba(255,255,255,0.05);
}
.badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: #2d3547;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}
.badge.ok { color: #07160f; background: var(--green); }
.badge.fail { color: #2a040a; background: var(--red); }
.badge.pending { color: #261c04; background: var(--amber); }

@media (max-width: 760px) {
  .grid.two, .control-grid, .custom-message { grid-template-columns: 1fr; }
  .audit-row { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  button { min-height: 58px; }
}

