:root {
  color-scheme: dark;
  --bg: #070b12;
  --panel: #0d141f;
  --panel-2: #111b28;
  --text: #f5f8ff;
  --muted: #8ea0b8;
  --line: #1e2b3a;
  --blue: #2f82ff;
  --blue-2: #64a7ff;
  --green: #22c55e;
  --red: #f05252;
  --amber: #f59e0b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(47, 130, 255, 0.18), transparent 32rem),
    linear-gradient(135deg, #05070b 0%, #09111d 48%, #06080c 100%);
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.login-view {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 0%, rgba(47, 130, 255, 0.22), transparent 30rem),
    rgba(5, 8, 13, 0.96);
}

.login-card {
  display: grid;
  gap: 18px;
  width: min(430px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(13, 20, 31, 0.94);
  box-shadow: var(--shadow);
}

.login-card p {
  color: var(--muted);
  margin-top: 8px;
}

.login-brand {
  margin-bottom: 4px;
}

.login-error {
  min-height: 20px;
  color: #ffb7b7 !important;
  font-size: 13px;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 22px;
  background: rgba(8, 12, 19, 0.8);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 34px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #274469;
  background: #0b1320;
  color: #ddebff;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand strong, .brand span {
  display: block;
}

.brand span, .eyebrow, .panel p, .auth-card p, th {
  color: var(--muted);
}

.brand span, .eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.nav {
  display: grid;
  gap: 8px;
  margin-bottom: 28px;
}

.nav a {
  color: #bad0ee;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
}

.nav a.active, .nav a:hover {
  color: white;
  background: #121d2b;
}

.auth-card, .panel, .stat-card, .modal, .drawer {
  border: 1px solid var(--line);
  background: rgba(13, 20, 31, 0.88);
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 14px;
  border-radius: 10px;
}

label {
  display: grid;
  gap: 7px;
  color: #c8d8ee;
  font-size: 13px;
  font-weight: 650;
}

.session-card {
  display: grid;
  gap: 10px;
}

.session-card span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.session-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
}

input, select {
  width: 100%;
  border: 1px solid #223248;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: #0a111b;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 130, 255, 0.18);
}

.main {
  padding: 26px;
  overflow: auto;
}

.topbar, .panel-head, .modal-head, .drawer-head, .modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: 30px;
  letter-spacing: -0.04em;
}

h2 {
  font-size: 19px;
  letter-spacing: -0.02em;
}

.topbar-actions, .filters {
  display: flex;
  gap: 10px;
  align-items: center;
}

.primary-button, .ghost-button, .danger-button, .icon-button {
  border: 1px solid #24354b;
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  background: #101927;
}

.primary-button {
  border-color: #3f8cff;
  background: linear-gradient(180deg, #3f8cff, #1f62d6);
  font-weight: 760;
}

.ghost-button:hover, .icon-button:hover {
  border-color: #426189;
}

.danger-button {
  color: #ffd6d6;
  border-color: rgba(240, 82, 82, 0.42);
  background: rgba(240, 82, 82, 0.12);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 24px 0;
}

.stat-card {
  padding: 18px;
  border-radius: 10px;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
}

.panel {
  border-radius: 12px;
  margin-bottom: 18px;
  overflow: hidden;
}

.panel-head {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.filters {
  min-width: min(520px, 100%);
}

.filters input { flex: 1; }
.filters select { width: 130px; }

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th, td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid rgba(30, 43, 58, 0.78);
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

td {
  color: #dbe7fa;
}

.owner {
  display: grid;
  gap: 3px;
}

.owner small, .key-preview {
  color: var(--muted);
}

.key-preview {
  font-family: "JetBrains Mono", "Consolas", monospace;
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #29405e;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 760;
}

.badge.active { color: #a8f3c6; border-color: rgba(34, 197, 94, 0.4); }
.badge.revoked { color: #ffb7b7; border-color: rgba(240, 82, 82, 0.4); }
.badge.expired { color: #ffd28a; border-color: rgba(245, 158, 11, 0.42); }

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.row-actions button {
  padding: 7px 10px;
}

.empty-state {
  padding: 42px;
  text-align: center;
  color: var(--muted);
}

.audit-list {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.audit-item {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid #1d2b3e;
  border-radius: 8px;
  background: #0a111b;
}

.audit-item code, .key-block {
  font-family: "JetBrains Mono", "Consolas", monospace;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.62);
  z-index: 20;
}

.modal {
  display: grid;
  gap: 14px;
  width: min(520px, 100%);
  padding: 20px;
  border-radius: 14px;
}

.checkbox-row {
  display: flex;
  align-items: center;
}

.checkbox-row input {
  width: auto;
}

.drawer {
  position: fixed;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: min(440px, calc(100vw - 32px));
  padding: 20px;
  border-radius: 14px;
  z-index: 15;
  overflow: auto;
}

.key-block {
  display: block;
  margin: 16px 0 22px;
  padding: 12px;
  border: 1px solid #203047;
  border-radius: 8px;
  background: #080d15;
  color: #bcd7ff;
  white-space: normal;
  overflow-wrap: anywhere;
}

.server-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.server-card {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid #223248;
  border-radius: 8px;
  background: #0a111b;
}

.server-card footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 12px 14px;
  border: 1px solid #31527a;
  border-radius: 8px;
  background: #0f1b2a;
  box-shadow: var(--shadow);
  z-index: 30;
}

.hidden {
  display: none !important;
}

@media (max-width: 880px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar, .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .filters {
    flex-direction: column;
    min-width: 0;
  }

  .filters select {
    width: 100%;
  }
}
