:root {
  --bg: #0c0c0c;
  --surface: #141414;
  --surface-elevated: #1a1a1a;
  --surface-card: #1c1c1c;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --text: #f0f0f0;
  --text-muted: #6b6b6b;
  --text-secondary: #a0a0a0;
  --accent: #c8f135;
  --accent-dim: rgba(200, 241, 53, 0.12);
  --accent-glow: rgba(200, 241, 53, 0.25);
  --green: #4ade80;
  --red: #f87171;
  --radius: 20px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --sidebar-width: 220px;
}

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

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

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

a:hover {
  text-decoration: underline;
}

.mono {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.9em;
}

/* ── App Shell ── */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0 0.35rem;
}

.brand strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand span {
  display: block;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: #0c0c0c;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-centered {
  justify-content: center;
  margin-bottom: 1.5rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 0.75rem;
  margin-bottom: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-secondary);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-pill);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-decoration: none;
}

.nav-item.active {
  background: #fff;
  color: #0c0c0c;
  text-decoration: none;
}

.nav-item.active .nav-icon {
  opacity: 1;
  color: var(--accent);
  filter: brightness(0.3) sepia(1) saturate(5) hue-rotate(30deg);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.35rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.user-info strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
}

.user-info span {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.logout-form {
  margin: 0;
}

/* ── Main Content ── */

.main-content {
  padding: 1.75rem 2rem 2.5rem;
  min-width: 0;
}

/* ── Topbar ── */

.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.topbar-title {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.topbar-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  outline: none;
  border-color: var(--border-hover);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-hover);
  color: var(--text);
}

/* ── Page Header (fallback) ── */

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Stats Grid ── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

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

.stat-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s;
}

.stat-card-link:hover {
  border-color: rgba(200, 241, 53, 0.25);
  box-shadow: 0 0 40px rgba(200, 241, 53, 0.06);
  transform: translateY(-1px);
  text-decoration: none;
}

.stat-card-warning {
  border-color: rgba(248, 113, 113, 0.2);
  background:
    radial-gradient(ellipse 80% 60% at 80% 0%, rgba(248, 113, 113, 0.08), transparent),
    var(--surface-card);
}

.stat-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
}

.stat-card.featured {
  background:
    radial-gradient(ellipse 80% 60% at 20% 100%, rgba(200, 241, 53, 0.18), transparent),
    var(--surface-card);
  border-color: rgba(200, 241, 53, 0.12);
}

.stat-card-label {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-card-value {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat-card-trend {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
}

.stat-card-trend.up {
  color: var(--green);
  background: rgba(74, 222, 128, 0.1);
}

.stat-card-trend.down {
  color: var(--red);
  background: rgba(248, 113, 113, 0.1);
}

.stat-card-trend.neutral {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
}

/* ── Cards ── */

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

.section-title {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.client-grid,
.key-list {
  display: grid;
  gap: 0.85rem;
}

.client-card,
.key-card {
  transition: border-color 0.2s, box-shadow 0.2s;
}

.client-card:hover,
.key-card:hover {
  border-color: rgba(200, 241, 53, 0.15);
  box-shadow: 0 0 40px rgba(200, 241, 53, 0.04);
}

.client-card-header h2,
.key-card-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.client-email {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.85rem 0;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid var(--border);
}

.status-chip.active {
  background: rgba(74, 222, 128, 0.08);
  border-color: rgba(74, 222, 128, 0.2);
  color: var(--green);
}

.status-chip.inactive {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-chip.active .status-dot {
  box-shadow: 0 0 6px var(--green);
}

.meta-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.meta-list dt {
  margin: 0;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.meta-list dd {
  margin: 0.1rem 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.meta-list .meta-full {
  grid-column: 1 / -1;
}

.meta-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
}

.update-link {
  color: var(--accent);
  font-weight: 500;
}

.update-link:hover {
  text-decoration: underline;
}

.info-callout {
  background: var(--accent-dim);
  border: 1px solid rgba(200, 241, 53, 0.15);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.info-callout p {
  margin: 0;
}

.info-callout-muted {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border);
}

.update-client-section {
  margin-bottom: 2rem;
}

.update-client-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.update-client-header .section-title {
  margin-bottom: 0.25rem;
}

.update-table-card {
  padding: 0;
  overflow: hidden;
}

.update-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.update-table th,
.update-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.update-table th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.02);
}

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

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

.update-table .row-security {
  background: rgba(248, 113, 113, 0.04);
}

.type-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.type-core {
  background: rgba(96, 165, 250, 0.12);
  color: #93c5fd;
}

.type-plugin {
  background: rgba(200, 241, 53, 0.12);
  color: var(--accent);
}

.type-theme {
  background: rgba(192, 132, 252, 0.12);
  color: #c4b5fd;
}

.vuln-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.severity-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
}

.severity-high {
  background: rgba(248, 113, 113, 0.15);
  color: #fca5a5;
}

.severity-medium {
  background: rgba(251, 191, 36, 0.12);
  color: #fcd34d;
}

.severity-low {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s, border-color 0.15s;
  white-space: nowrap;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #0c0c0c;
}

.btn-primary:hover {
  background: #d4f44a;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  border-color: var(--border-hover);
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.2);
  color: var(--red);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.15);
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
}

.btn-full {
  width: 100%;
}

/* ── Alerts ── */

.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.alert-error {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: #fca5a5;
}

.alert-success {
  background: rgba(74, 222, 128, 0.08);
  border: 1px solid rgba(74, 222, 128, 0.2);
  color: #86efac;
}

/* ── Forms ── */

.form-card {
  max-width: 560px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
select {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(200, 241, 53, 0.3);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.toggle-label input {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
}

/* ── Empty State ── */

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

.empty-state .btn {
  margin-top: 1rem;
}

/* ── API Keys ── */

.key-reveal {
  margin-bottom: 1rem;
  border-color: rgba(200, 241, 53, 0.2);
  box-shadow: 0 0 40px rgba(200, 241, 53, 0.06);
}

.key-display {
  display: block;
  padding: 0.85rem 1rem;
  background: var(--surface-elevated);
  border-radius: var(--radius-sm);
  word-break: break-all;
  margin: 0.75rem 0;
}

.key-prefix {
  margin: 0.5rem 0;
  color: var(--text-muted);
}

.hint {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.hint code {
  background: var(--surface-elevated);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.key-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* ── Login ── */

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(200, 241, 53, 0.06), transparent),
    var(--bg);
}

.login-shell {
  width: 100%;
  max-width: 400px;
  padding: 1.5rem;
}

.login-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.4);
}

/* ── Search filter ── */

.client-card.hidden {
  display: none;
}

/* ── Responsive ── */

@media (max-width: 900px) {
  .stats-grid,
  .stats-grid-2 {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .topbar-search {
    order: 3;
    max-width: 100%;
    flex-basis: 100%;
  }
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    position: static;
    height: auto;
  }

  .sidebar-footer {
    display: none;
  }

  .main-content {
    padding: 1.25rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .update-table-card {
    overflow-x: auto;
  }

  .update-table {
    min-width: 640px;
  }

  .update-client-header {
    flex-direction: column;
  }
}
