:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --text-muted: #8b9cb3;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

a:hover {
  text-decoration: underline;
}

.auth-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(59, 130, 246, 0.12), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(99, 102, 241, 0.08), transparent 50%),
    var(--bg);
}

.login-page {
  min-height: 100vh;
  background: var(--bg);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.login-panel {
  background: linear-gradient(160deg, #1e3a5f 0%, #0f1419 55%, #111827 100%);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 48px;
}

.login-panel-inner {
  max-width: 420px;
}

.login-main {
  display: grid;
  place-items: center;
  padding: 48px 32px;
}

.brand-lg .brand-icon {
  width: 44px;
  height: 44px;
  font-size: 1rem;
}

.brand-tagline {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.panel-title {
  margin: 36px 0 12px;
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.25;
}

.panel-copy {
  margin: 0 0 28px;
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.panel-features {
  margin: 0;
  padding: 0;
  list-style: none;
}

.panel-features li {
  position: relative;
  padding-left: 22px;
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.panel-features li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.auth-card-flat {
  box-shadow: none;
  border: none;
  background: transparent;
  padding: 0;
  max-width: 380px;
  width: 100%;
}

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

  .login-panel {
    display: none;
  }

  .login-main {
    background:
      radial-gradient(ellipse at 50% 0%, rgba(59, 130, 246, 0.1), transparent 60%),
      var(--bg);
  }

  .auth-card-flat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    padding: 36px 32px;
    box-shadow: var(--shadow);
  }
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 40px 36px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 600;
}

.auth-card .subtitle {
  margin: 0 0 28px;
  color: var(--text-muted);
  font-size: 0.925rem;
}

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

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.875rem;
}

.form-group {
  margin-bottom: 18px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9375rem;
  transition: border-color 0.15s;
}

input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 7px 12px;
  font-size: 0.8125rem;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.12);
}

.alert {
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 18px;
}

.alert-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.alert-success {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #86efac;
}

.auth-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Dashboard */
.dashboard {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-badge {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 28px 48px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  margin-top: 36px;
}

.section-header:first-of-type {
  margin-top: 0;
}

.section-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  overflow: hidden;
}

.keys-table {
  width: 100%;
  border-collapse: collapse;
}

.keys-table th,
.keys-table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.keys-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}

.keys-table tr:last-child td {
  border-bottom: none;
}

.keys-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.mono {
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.875rem;
}

.status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-active {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.status-revoked {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

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

body.modal-open {
  overflow: hidden;
}

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

.modal-overlay.hidden {
  display: none;
}

.modal {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 28px;
  box-shadow: var(--shadow);
}

.modal h3 {
  margin: 0 0 8px;
}

.modal p {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.secret-box {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.secret-box input {
  flex: 1;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.8125rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.info-box {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 28px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.info-box code {
  color: var(--text);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8125rem;
}

.hidden {
  display: none !important;
}
