:root {
  --bg: #0b1220;
  --bg-elev: #121a2b;
  --bg-soft: #182338;
  --line: rgba(148, 163, 184, 0.16);
  --text: #e8eef9;
  --muted: #93a0b8;
  --accent: #2dd4bf;
  --accent-2: #38bdf8;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --sidebar: 280px;
  --font: "DM Sans", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(45, 212, 191, 0.12), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(56, 189, 248, 0.10), transparent 50%),
    linear-gradient(180deg, #0a101c 0%, var(--bg) 40%, #0a0f19 100%);
  min-height: 100vh;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--accent); }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrap { white-space: pre-wrap; word-break: break-word; }
.text-ok { color: var(--ok); }

.app-shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: rgba(10, 16, 28, 0.92);
  border-right: 1px solid var(--line);
  padding: 1.25rem;
  display: flex; flex-direction: column; gap: 1.25rem;
  backdrop-filter: blur(10px);
}
.brand { display: flex; gap: 0.85rem; align-items: center; }
.brand-center { justify-content: center; margin-bottom: 1rem; }
.brand strong { display: block; }
.brand small { color: var(--muted); }
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #041018; font-weight: 800; font-family: var(--mono);
  box-shadow: 0 10px 30px rgba(45, 212, 191, 0.25);
  animation: markIn 0.6s ease both;
}
.nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; overflow: auto; }
.nav-link {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.7rem 0.85rem; border-radius: 12px; color: var(--muted);
  transition: background .2s, color .2s, transform .2s;
}
.nav-link:hover, .nav-link.is-active {
  background: rgba(45, 212, 191, 0.1);
  color: var(--text);
  transform: translateX(2px);
}
.nav-ico::before {
  content: "•";
  color: var(--accent);
  font-weight: 700;
}
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 1rem; display: grid; gap: 0.75rem; }
.user-chip { display: grid; }
.user-chip small { color: var(--muted); }

.main { min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 18, 32, 0.7);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 1.15rem; margin: 0; flex: 1; }
.topbar-actions { display: flex; gap: 0.5rem; }
.content { padding: 1.5rem; display: grid; gap: 1.25rem; }
.menu-toggle { display: none; }

.panel, .stat-card, .auth-card, .usage-card {
  background: linear-gradient(180deg, rgba(24, 35, 56, 0.95), rgba(18, 26, 43, 0.98));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: rise 0.45s ease both;
}
.panel { padding: 1.15rem 1.25rem; }
.panel.narrow { max-width: 820px; }
.panel.nested { box-shadow: none; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-bottom: 1rem;
}
.panel-head h2, .panel-head h3 { margin: 0; font-size: 1.05rem; }

.grid { display: grid; gap: 1.25rem; }
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two-col { grid-template-columns: 1.2fr 1fr; }
.stat-card { padding: 1.1rem 1.2rem; display: grid; gap: 0.35rem; }
.stat-card span { color: var(--muted); font-size: 0.9rem; }
.stat-card strong { font-size: 1.7rem; letter-spacing: -0.02em; }

.usage-grid { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
.usage-card { padding: 1rem; }
.usage-label { color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; }
.usage-value { font-size: 1.35rem; margin: 0.35rem 0 0.7rem; }
.usage-meta { color: var(--muted); font-size: 0.9rem; margin-top: 0.55rem; }
.progress {
  height: 10px; border-radius: 999px; background: rgba(148,163,184,0.15); overflow: hidden;
}
.progress > span {
  display: block; height: 100%; width: var(--p, 0%);
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: inherit;
  transition: width 0.6s ease;
}

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.75rem 0.55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.filters, .form-grid, .stack { display: grid; gap: 0.85rem; }
.filters { grid-template-columns: 2fr repeat(4, 1fr) auto; margin-bottom: 1rem; }
.form-grid { grid-template-columns: 1fr 1fr; }
.form-grid .full, .form-actions { grid-column: 1 / -1; }
.stack.compact { margin-top: 0.6rem; }
label { display: grid; gap: 0.35rem; color: var(--muted); font-size: 0.9rem; }
label.checkbox { display: flex; align-items: center; gap: 0.5rem; color: var(--text); }
input, select, textarea, button {
  font: inherit;
}
input, select, textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(45, 212, 191, 0.55);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.12);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  border: 1px solid transparent; border-radius: 12px;
  padding: 0.65rem 0.95rem; cursor: pointer; color: var(--text);
  background: var(--bg-soft); transition: transform .15s, background .2s, border-color .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn-block { width: 100%; }
.btn-sm { padding: 0.35rem 0.6rem; font-size: 0.85rem; border-radius: 10px; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #14b8a6); color: #042018; font-weight: 700; }
.btn-secondary { background: rgba(56,189,248,0.12); border-color: rgba(56,189,248,0.25); }
.btn-warning { background: rgba(251,191,36,0.14); border-color: rgba(251,191,36,0.3); color: #fde68a; }
.btn-danger { background: rgba(248,113,113,0.12); border-color: rgba(248,113,113,0.28); color: #fecaca; }
.btn-ghost { background: transparent; border-color: var(--line); }
.form-actions, .action-row { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.inline { display: inline; }

.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.55rem; border-radius: 999px;
  font-size: 0.78rem; border: 1px solid var(--line); background: rgba(255,255,255,0.03);
}
.badge-type { color: var(--accent-2); border-color: rgba(56,189,248,0.3); }
.badge-active, .badge-online { color: var(--ok); border-color: rgba(52,211,153,0.35); }
.badge-pending, .badge-unknown { color: var(--warn); border-color: rgba(251,191,36,0.35); }
.badge-suspended, .badge-expired, .badge-offline { color: #fdba74; border-color: rgba(251,146,60,0.35); }
.badge-revoked { color: var(--danger); border-color: rgba(248,113,113,0.35); }

.alert {
  padding: 0.85rem 1rem; border-radius: 12px; border: 1px solid var(--line);
  animation: rise 0.35s ease both;
}
.alert-success { background: rgba(52,211,153,0.1); border-color: rgba(52,211,153,0.3); }
.alert-error { background: rgba(248,113,113,0.1); border-color: rgba(248,113,113,0.3); }

.meta-list { display: grid; gap: 0.65rem; margin: 1rem 0; }
.meta-list > div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px dashed var(--line); padding-bottom: 0.45rem; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; }
.note { background: rgba(255,255,255,0.03); border: 1px solid var(--line); border-radius: 12px; padding: 0.85rem; }
.mini-stats { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; color: var(--muted); }
.bar-list { display: grid; gap: 0.9rem; }
.bar-row-top { display: flex; justify-content: space-between; margin-bottom: 0.35rem; }
.pagination { display: flex; gap: 0.35rem; margin-top: 1rem; }
.pagination a {
  min-width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line); color: var(--text);
}
.pagination a.is-active { background: rgba(45,212,191,0.16); border-color: rgba(45,212,191,0.4); }
.tabs { display: flex; gap: 0.4rem; }
.tabs a { padding: 0.4rem 0.7rem; border-radius: 10px; color: var(--muted); border: 1px solid transparent; }
.tabs a.is-active { color: var(--text); border-color: var(--line); background: rgba(255,255,255,0.03); }
.pill { color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.cards-stack { display: grid; gap: 1rem; }

.auth-body {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
}
.auth-wrap { width: min(440px, 100%); }
.auth-card { padding: 1.5rem; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes markIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

@media (max-width: 1100px) {
  .stats-grid, .two-col, .usage-grid, .filters { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px);
    transform: translateX(-105%); transition: transform .25s ease; z-index: 20;
  }
  .sidebar.is-open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .stats-grid, .two-col, .usage-grid, .filters, .form-grid { grid-template-columns: 1fr; }
}
