:root {
  color-scheme: dark;
  --background: #090e1b;
  --surface: #111a2b;
  --surface-raised: #172338;
  --border: #24334b;
  --text: #edf3fc;
  --muted: #91a2bc;
  --accent: #56d6c1;
  --accent-soft: rgba(86, 214, 193, .13);
  --warning: #f0bf67;
  --danger: #ff7b83;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(ellipse at 10% -15%, rgba(32, 84, 105, .2), transparent 38rem),
    var(--background);
  color: var(--text);
}

button, input { font: inherit; }
a { color: inherit; text-decoration: none; }

.topbar {
  min-height: 76px;
  padding: 12px clamp(18px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(145, 162, 188, .14);
  background: rgba(9, 14, 27, .88);
}

.brand, .topbar-actions, .connection, .metric-heading, .section-heading, .dialog-heading {
  display: flex;
  align-items: center;
}

.brand { gap: 12px; }
.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, #7aead4, #38a994);
  color: #09231f;
  font-weight: 850;
  box-shadow: 0 7px 22px rgba(86, 214, 193, .19);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .02em; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 2px; }

.topbar-actions { gap: 10px; }
.topbar-actions form { margin: 0; }
.connection { gap: 8px; color: var(--muted); font-size: 12px; margin-right: 10px; }
.connection i { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); }
.connection.online i { background: var(--accent); box-shadow: 0 0 10px rgba(86, 214, 193, .6); }
.connection.offline i { background: var(--danger); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  color: var(--text);
  background: var(--surface-raised);
  font-size: 12px;
  font-weight: 650;
  transition: border-color .16s ease, transform .16s ease, background .16s ease;
}
.button:hover { border-color: #54708f; background: #1b2a41; }
.button:active { transform: translateY(1px); }
.button.primary { border-color: transparent; background: var(--accent); color: #08251f; }
.button.primary:hover { background: #7ce6d5; }
.button.subtle { background: transparent; }
.button.full-width { width: 100%; margin-top: 8px; }
.button.small { min-height: 30px; padding: 5px 9px; font-size: 11px; }
.button.danger { color: var(--danger); border-color: rgba(255, 123, 131, .35); }

.layout { width: min(1440px, 100%); margin: 0 auto; padding: 34px clamp(18px, 4vw, 56px) 56px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 7px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .15em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(26px, 3vw, 36px); letter-spacing: -.035em; }
h2 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.muted, .updated, .metric-note { color: var(--muted); }
.page-heading .muted { margin: 0; font-size: 13px; }
.updated { margin: 0 0 4px; font-size: 11px; }
.updated strong { color: var(--text); font-weight: 600; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.panel {
  border: 1px solid var(--border);
  border-radius: 15px;
  background: linear-gradient(150deg, rgba(20, 31, 50, .98), rgba(15, 23, 39, .98));
  box-shadow: 0 10px 28px rgba(0, 0, 0, .12);
}
.metric-card { min-height: 176px; padding: 18px; }
.metric-heading { justify-content: space-between; color: #c4d0e0; font-size: 12px; font-weight: 650; }
.metric-icon {
  display: inline-flex;
  padding: 5px 7px;
  border: 1px solid rgba(86, 214, 193, .2);
  border-radius: 6px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 9px;
  letter-spacing: .08em;
}
.metric-value { display: block; margin: 18px 0 12px; font-size: 31px; letter-spacing: -.04em; }
.metric-value.compact { font-size: 19px; margin: 16px 0 10px; }
.meter { height: 6px; overflow: hidden; border-radius: 8px; background: #25334a; }
.meter span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #45baa8, #8ee6d7); transition: width .4s ease; }
.meter span.warning { background: var(--warning); }
.meter span.danger { background: var(--danger); }
.metric-note { margin: 9px 0 0; font-size: 10px; }
.metric-note strong { color: var(--text); font-weight: 600; }

.content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.lower-grid { grid-template-columns: 1fr 1fr; }
.section-panel { min-width: 0; padding: 18px; }
.section-heading { justify-content: space-between; margin-bottom: 17px; }
.section-heading .eyebrow { margin-bottom: 5px; }
.count { display: inline-grid; min-width: 28px; height: 26px; padding: 0 8px; place-items: center; border-radius: 8px; background: var(--surface-raised); color: #c8d3e2; font-size: 11px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 0 9px 10px; color: #7588a4; font-size: 9px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
td { padding: 10px 9px; border-top: 1px solid rgba(145, 162, 188, .11); color: #cbd6e5; font-size: 11px; vertical-align: middle; }
td:first-child { color: var(--text); font-weight: 650; }
td .description { display: block; max-width: 220px; overflow: hidden; color: var(--muted); font-size: 10px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.status { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.status::before { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); content: ""; }
.status.up::before, .status.active::before { background: var(--accent); }
.status.down::before, .status.failed::before { background: var(--danger); }
.status.warning::before { background: var(--warning); }
.row-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.empty { padding: 16px 9px; color: var(--muted); font-size: 11px; }
.health-list { display: grid; gap: 8px; }
.health-item, .allowed-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid rgba(145, 162, 188, .12); border-radius: 9px; background: rgba(23, 35, 56, .5); color: #d3deec; font-size: 11px; }
.health-item .status { color: var(--muted); }
.allowed-actions { display: grid; gap: 8px; }
.message { padding: 10px 12px; border: 1px solid; border-radius: 9px; font-size: 12px; }
.message.error { border-color: rgba(255, 123, 131, .32); background: rgba(120, 35, 50, .2); color: #ffabb0; }
.message.success { border-color: rgba(86, 214, 193, .32); background: var(--accent-soft); color: #9de8db; }
.page-error { margin-top: 16px; }

.logs-dialog { width: min(920px, calc(100% - 28px)); max-height: 85vh; padding: 20px; border: 1px solid #344760; border-radius: 16px; background: #0e1726; color: var(--text); box-shadow: 0 24px 80px rgba(0, 0, 0, .55); }
.logs-dialog::backdrop { background: rgba(2, 6, 12, .76); backdrop-filter: blur(4px); }
.dialog-heading { justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.log-output { max-height: 65vh; margin: 0; padding: 14px; overflow: auto; border: 1px solid rgba(145, 162, 188, .14); border-radius: 9px; background: #080e18; color: #bdcbe0; font: 11px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

.auth-page { display: grid; min-height: 100vh; padding: 18px; place-items: center; }
.auth-card { width: min(420px, 100%); padding: 34px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); box-shadow: 0 20px 70px rgba(0, 0, 0, .3); }
.auth-card .brand-mark { margin-bottom: 24px; }
.auth-card h1 { font-size: 27px; }
.auth-card .muted { font-size: 12px; line-height: 1.6; }
.auth-card form { display: grid; gap: 9px; margin-top: 22px; }
.auth-card label { margin-top: 5px; color: #cbd6e5; font-size: 11px; font-weight: 650; }
.auth-card input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; outline: none; background: #0b1321; color: var(--text); }
.auth-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-card .button { margin-top: 10px; min-height: 42px; }

@media (max-width: 900px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; flex-wrap: wrap; }
  .connection { flex: 1 1 100%; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .metrics-grid { gap: 9px; }
  .metric-card { min-height: 155px; padding: 14px; }
  .metric-value { font-size: 25px; }
  .section-panel { padding: 14px 10px; }
}
