:root {
  --bg: #0b0f14;
  --card: #111822;
  --card-2: #0e141c;
  --line: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --faint: #64748b;
  --emerald: #34d399;
  --amber: #fbbf24;
  --rose: #fb7185;
  --mono: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; }
h1 { font-size: 24px; margin: 0 0 20px; font-weight: 600; }
h2 { font-size: 18px; margin: 0; font-weight: 600; }
h3 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 28px;
  height: 60px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(11, 15, 20, 0.92);
  backdrop-filter: blur(8px);
  z-index: 10;
}
.brand { font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; font-size: 13px; white-space: nowrap; }
.brand span { color: var(--muted); font-weight: 500; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs a {
  text-decoration: none;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 6px;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.tabs a:hover { color: var(--text); background: rgba(30, 41, 59, 0.5); }
.tabs a.on { color: var(--text); background: rgba(30, 41, 59, 0.8); }
.utility { display: flex; align-items: center; gap: 16px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  width: fit-content;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-ok { color: var(--emerald); background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.2); }
.pill-wait { color: var(--amber); background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.2); }
.pill-bad { color: var(--rose); background: rgba(244, 63, 94, 0.1); border-color: rgba(244, 63, 94, 0.2); }
.pill-muted { color: var(--faint); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge.ok { color: var(--emerald); background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.2); }
.badge.wait { color: var(--amber); background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.2); }
.badge.bad { color: var(--rose); background: rgba(244, 63, 94, 0.1); border-color: rgba(244, 63, 94, 0.2); }

.profile { position: relative; }
.profile summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.profile summary::-webkit-details-marker { display: none; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: #1e293b; font-size: 12px; font-weight: 600;
}
.profile-text { display: flex; flex-direction: column; line-height: 1.2; }
.profile-text b { font-size: 13px; font-weight: 600; }
.profile-text small { color: var(--muted); font-size: 11px; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 240px; padding: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}
.menu-label { margin: 4px 8px 6px; font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.08em; }
.menu-item {
  display: block; width: 100%; text-align: left;
  padding: 8px; border-radius: 6px; border: 0; background: none;
  color: var(--text); font: inherit; text-decoration: none; cursor: pointer;
}
.menu-item:hover { background: rgba(30, 41, 59, 0.6); }
.menu-item small { display: block; color: var(--muted); font-size: 11px; }
.menu-item.on { background: rgba(30, 41, 59, 0.8); }

.page { max-width: 1280px; margin: 0 auto; padding: 32px 28px 80px; }
section { scroll-margin-top: 80px; margin-bottom: 40px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar input { width: 240px; }
.toolbar select { width: 170px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px; display: flex; flex-direction: column; gap: 8px;
}
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-family: var(--mono); font-size: 24px; font-weight: 600; }
.kpi-value small { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi-sub { color: var(--faint); font-size: 12px; }
.kpi .btn { margin-top: auto; align-self: flex-start; }

.channels h2 { margin-bottom: 12px; font-size: 15px; }
.channel-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.channels .muted { margin: 10px 0 0; font-size: 13px; }

.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--faint); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: rgba(30, 41, 59, 0.4); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
td.num, td .num { font-family: var(--mono); }
td small { display: block; color: var(--faint); font-size: 11px; font-family: var(--mono); }
.id-link { font-family: var(--mono); text-decoration: none; color: var(--text); }
.id-link:hover { text-decoration: underline; }
.empty { color: var(--muted); text-align: center; padding: 28px 16px; margin: 0; }

.callout {
  border: 1px solid rgba(245, 158, 11, 0.25); background: rgba(245, 158, 11, 0.06);
  color: #fcd34d; border-radius: 8px; padding: 10px 14px; margin: 0 0 16px; font-size: 13px;
}
.okbox, .errbox { border-radius: 8px; padding: 10px 14px; margin: 12px 0; font-size: 13px; }
.okbox { border: 1px solid rgba(16, 185, 129, 0.3); color: var(--emerald); background: rgba(16, 185, 129, 0.06); }
.errbox { border: 1px solid rgba(244, 63, 94, 0.3); color: var(--rose); background: rgba(244, 63, 94, 0.06); }
.okbox a { color: inherit; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn-primary { background: #f1f5f9; color: #0b0f14; }
.btn-primary:hover { background: #ffffff; }
.btn-ghost { background: transparent; color: var(--text); border-color: #334155; }
.btn-ghost:hover { background: rgba(30, 41, 59, 0.6); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.icon-btn {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  padding: 2px 6px; border-radius: 4px; font: inherit; font-size: 12px;
}
.icon-btn:hover { color: var(--text); background: rgba(30, 41, 59, 0.6); }

label { display: block; font-size: 12px; color: var(--muted); margin: 14px 0 6px; }
input, select, textarea {
  width: 100%; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  font: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #475569; }
input:disabled { opacity: 0.6; }
.field { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--card-2); color: var(--muted); }
.field-row { display: flex; gap: 8px; align-items: center; }
.field-row .field { flex: 1; }

.dev-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; }
.dev-grid .pill { margin-top: 14px; }
.dev-grid .muted { font-size: 13px; }
.settings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 16px; }
.settings div { display: flex; flex-direction: column; gap: 4px; }
.settings .muted { font-size: 12px; }
#developers > h2, #settings > h2 { margin-bottom: 0; }

dialog { color: var(--text); padding: 0; border: 1px solid var(--line); background: var(--card); }
dialog::backdrop { background: rgba(2, 6, 12, 0.65); }
.modal { width: min(440px, calc(100vw - 32px)); border-radius: 14px; }
.modal form { padding: 24px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal[open] { animation: pop 0.18s ease-out; }

.drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0;
  width: min(440px, 100vw); height: 100vh; max-height: 100vh;
  border-width: 0 0 0 1px; border-radius: 0;
  box-shadow: -16px 0 40px rgba(0, 0, 0, 0.45);
  z-index: 20;
}
.drawer[open] { animation: slide 0.22s ease-out; }
.drawer-body { padding: 24px; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.drawer dl { margin: 0; display: grid; gap: 16px; }
.drawer dt { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.drawer dd { margin: 0; }
.drawer .btn { margin-top: 24px; }

@keyframes slide { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes pop { from { transform: scale(0.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .dev-grid, .settings { grid-template-columns: 1fr 1fr; }
  .profile-text { display: none; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 12px 16px; gap: 12px; }
  .tabs { order: 3; width: 100%; }
  .page { padding: 24px 16px 60px; }
  .kpis, .dev-grid, .settings { grid-template-columns: 1fr; }
  .toolbar input, .toolbar select { width: 100%; }
}
