:root {
  --bg: #080c16;
  --surface: #101726;
  --surface-2: #162034;
  --border: rgba(148, 163, 184, 0.16);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --cyan: #26c6da;
  --emerald: #34d399;
  --amber: #fbbf24;
  --rose: #fb7185;
  --violet: #a78bfa;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 12px)
           calc(env(safe-area-inset-right, 0px) + 14px)
           calc(env(safe-area-inset-bottom, 0px) + 24px)
           calc(env(safe-area-inset-left, 0px) + 14px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-icon {
  border-radius: 9px;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subline {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.status-pill.live {
  background: rgba(52, 211, 153, 0.15);
  color: var(--emerald);
  border-color: rgba(52, 211, 153, 0.4);
}

.status-pill.offline {
  background: rgba(251, 191, 36, 0.14);
  color: var(--amber);
  border-color: rgba(251, 191, 36, 0.35);
}

.ghost-btn, .primary-btn, .ctrl-btn {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 9px;
  padding: 7px 11px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.primary-btn {
  background: var(--cyan);
  color: #04121d;
  border-color: transparent;
}

.ctrl-btn.active {
  background: rgba(38, 198, 218, 0.22);
  border-color: var(--cyan);
  color: #7ef4ff;
}

.ctrl-btn.warn {
  border-color: rgba(251, 113, 133, 0.38);
  color: #fda4af;
}

.auth-card, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px;
}

.auth-card {
  margin-bottom: 14px;
}

.auth-card h2 {
  margin: 0 0 6px;
  font-size: 0.98rem;
}

.auth-card p {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

.token-row {
  display: flex;
  gap: 8px;
}

.token-row input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #0b101d;
  color: var(--text);
  font: inherit;
}

.error-msg {
  color: var(--rose) !important;
  min-height: 1em;
}

.hidden {
  display: none !important;
}

.tab-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  background: var(--surface);
  padding: 5px;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-btn.active {
  background: var(--surface-2);
  color: var(--text);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.privacy-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.badge {
  font-size: 0.73rem;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.badge.alert {
  background: rgba(251, 113, 133, 0.16);
  color: #fecdd3;
  border-color: rgba(251, 113, 133, 0.45);
}

.badge.good {
  background: rgba(52, 211, 153, 0.13);
  color: var(--emerald);
  border-color: rgba(52, 211, 153, 0.35);
}

.grid-cards {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.hero-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.two-col {
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
}

@media (max-width: 440px) {
  .two-col, .hero-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.card-head strong {
  font-size: 1.15rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.sparkline {
  width: 100%;
  height: 52px;
  display: block;
  background: rgba(8, 12, 22, 0.55);
  border-radius: 8px;
  margin-bottom: 7px;
}

.meta-row {
  font-size: 0.76rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: #0b101d;
  overflow: hidden;
  margin-bottom: 9px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--cyan);
  transition: width 0.25s ease;
}

.progress-fill.emerald { background: var(--emerald); }
.progress-fill.amber { background: var(--amber); }
.progress-fill.rose { background: var(--rose); }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  font-size: 0.78rem;
}

.kv-item {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  min-width: 0;
}

.kv-item span:first-child {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kv-item strong {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.controls-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bars-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.bar-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 58px;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.bar-row .label {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-row .val {
  text-align: right;
  font-weight: 600;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 11px 0;
}

.proc-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.proc-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px 74px;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.proc-row .pname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.proc-row .pnum {
  text-align: right;
  color: var(--muted);
}

.subtle-tag {
  font-size: 0.74rem;
  color: var(--cyan);
}
