:root {
  --bg: #1a1d21;
  --surface: #252932;
  --surface-hover: #2d3340;
  --border: #343b48;
  --text: #e8eaed;
  --muted: #8b93a5;
  --accent: #a855f7;
  --accent-dim: #7c3aed;
  --ok: #22c55e;
  --danger: #ef4444;
  --radius: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #15171c;
  border-right: 1px solid var(--border);
  padding: 1.25rem 0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 0 1.25rem 1rem;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.sidebar-brand span {
  color: var(--accent);
}

.nav-section {
  padding: 0.5rem 0.75rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  cursor: default;
}

.nav-item.active {
  color: var(--text);
  background: rgba(168, 85, 247, 0.08);
  border-left-color: var(--accent);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  opacity: 0.85;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--border);
  background: rgba(21, 23, 28, 0.6);
  backdrop-filter: blur(8px);
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  font-size: 1.05rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ok);
  margin-left: 0.75rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  font-family: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: var(--surface-hover);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-dim), var(--accent));
  border-color: transparent;
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-ghost {
  background: transparent;
}

.content {
  padding: 1.5rem 1.75rem 2rem;
  flex: 1;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab {
  padding: 0.6rem 1rem;
  font-size: 0.88rem;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
}

.card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.card .value {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card .sub {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-top: 0.5rem;
}

.donut {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: conic-gradient(
    var(--ok) calc(var(--pct, 0) * 1%),
    #2a3038 0
  );
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.donut-inner {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.donut-inner small {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}

.spark {
  height: 64px;
  margin-top: 0.75rem;
  background: linear-gradient(
    180deg,
    rgba(168, 85, 247, 0.15) 0%,
    transparent 100%
  );
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.spark::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 28%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.9;
}

.list-compact {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  max-height: 220px;
  overflow: auto;
  font-size: 0.8rem;
}

.list-compact li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.list-compact li span:last-child {
  color: var(--ok);
  flex-shrink: 0;
}

.list-compact li span.meta-neutral {
  color: var(--muted);
  font-size: 0.75rem;
}

.list-compact li span.meta-warn {
  color: #ca8a04;
  flex-shrink: 0;
}

.list-compact li span.meta-danger {
  color: var(--danger);
  flex-shrink: 0;
}

.infra-twocol {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.1rem;
}

@media (max-width: 768px) {
  .infra-twocol {
    grid-template-columns: 1fr;
  }
}

.infra-twocol .card {
  min-height: 0;
}

.list-compact.infra-scroll {
  max-height: 280px;
}

.cfg-hint {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.15rem;
  word-break: break-word;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(
      ellipse at 20% 0%,
      rgba(168, 85, 247, 0.12),
      transparent 50%
    ),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

.login-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
}

.login-card p {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.form-group input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2);
}

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  display: none;
}

.login-error.visible {
  display: block;
}

.login-step {
  display: none;
}

.login-step.active {
  display: block;
}

.qr-wrap {
  text-align: center;
  margin: 0.75rem 0;
}

.qr-wrap img {
  max-width: 220px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.mono {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  word-break: break-all;
  color: var(--muted);
}

.twofa-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.tab-btn {
  cursor: pointer;
}

.tab-btn:hover {
  color: var(--text);
}

.btn-danger {
  background: linear-gradient(135deg, #b91c1c, var(--danger));
  border-color: transparent;
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(1.06);
}

.btn-danger-outline {
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
  background: transparent;
}

.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: var(--danger);
  color: #fecaca;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.modal-box {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

.modal-box h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.modal-text {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.modal .login-error {
  margin: 0 0 0.75rem;
}

@media (max-width: 768px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.75rem;
  }

  .sidebar-brand {
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .nav-item {
    padding: 0.4rem 0.75rem;
  }
}
