:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas,
    "Courier New", monospace;
  --space-2xs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --transition-fast: 0.15s ease;
  --transition-mid: 0.25s ease;
  --bg: #111111;
  --bg-soft: #1c1c1c;
  --bg-elevated: #2c2c2c;
  --text: #e1e1e1;
  --text-muted: #b3b3b3;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.18);
  --accent-strong: #2563eb;
  --border: #3a3a3a;
  --sidebar: #1c1c1c;
  --sidebar-text: #e1e1e1;
  --sidebar-muted: #b3b3b3;
  --sidebar-accent: #8b5cf6;
  --success: #10b981;
  --danger: #ef4444;
}

[data-theme="dark"] {
  --bg: #111111;
  --bg-soft: #1c1c1c;
  --bg-elevated: #2c2c2c;
  --text: #e1e1e1;
  --text-muted: #b3b3b3;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.18);
  --accent-strong: #2563eb;
  --border: #3a3a3a;
  --sidebar: #1c1c1c;
  --sidebar-text: #e1e1e1;
  --sidebar-muted: #b3b3b3;
  --sidebar-accent: #8b5cf6;
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
  --bg: #f5f5f5;
  --bg-soft: #ffffff;
  --bg-elevated: #e5e5e5;
  --text: #1a1a1a;
  --text-muted: #4a4a4a;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.16);
  --accent-strong: #2563eb;
  --border: #d1d1d1;
  --sidebar: #ffffff;
  --sidebar-text: #1a1a1a;
  --sidebar-muted: #4a4a4a;
  --sidebar-accent: #3b82f6;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.15);
}

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

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

button,
input,
select {
  font-family: inherit;
}

.sr-only {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

.hidden {
  display: none !important;
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  transition: grid-template-columns var(--transition-mid);
}

.app.is-collapsed {
  grid-template-columns: 86px 1fr;
}

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: var(--space-lg) var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: var(--shadow-lg);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 1px;
  box-shadow: var(--shadow-sm);
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
  display: block;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--sidebar-muted);
  display: block;
}

.icon-button {
  border: 0;
  background: rgba(255, 255, 255, 0.1);
  color: var(--sidebar-text);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.icon-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.18);
}

.sidebar-group {
  display: grid;
  gap: var(--space-xs);
}

.sidebar-group-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--sidebar-muted);
  margin-bottom: var(--space-xs);
}

.nav-item {
  border: 0;
  background: transparent;
  color: var(--sidebar-text);
  text-align: left;
  padding: var(--space-xs) var(--space-sm);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
}

.nav-item.is-active {
  background: rgba(255, 255, 255, 0.18);
  color: var(--sidebar-accent);
}

.nav-icon {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  display: grid;
  place-items: center;
  font-size: 0.9rem;
}

.nav-link {
  text-decoration: none;
}

.sidebar-group-bottom {
  margin-top: auto;
}

.main {
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  animation: fadeUp 0.6s ease;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.topbar-title h1 {
  margin: 0 0 var(--space-2xs) 0;
  font-size: 1.8rem;
}

.topbar-subtitle {
  margin: 0;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.select-wrapper select {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  background: var(--accent);
  color: #1f140b;
  font-weight: 600;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.button.primary {
  background: var(--accent);
}

.button.ghost {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: none;
}

.button.outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
}

.grid {
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.card {
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  animation: cardPop 0.5s ease;
}

.card h2 {
  margin-top: 0;
  margin-bottom: var(--space-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.kv-list {
  display: grid;
  gap: var(--space-xs);
}

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  border-bottom: 1px dashed var(--border);
  padding-bottom: var(--space-xs);
}

.kv-key {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.kv-value {
  font-weight: 600;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-xs);
}

.list-item {
  padding: var(--space-xs) var(--space-sm);
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
}

.table {
  display: grid;
  gap: var(--space-xs);
}

.table-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: var(--space-md);
  padding: var(--space-xs) var(--space-sm);
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.table-row.header {
  font-weight: 700;
  background: transparent;
  border: 0;
  padding-left: 0;
}

.empty-state {
  padding: var(--space-lg);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  color: var(--text-muted);
  background: var(--bg-elevated);
}

.code-block {
  background: #0c0f19;
  color: #f1f2f6;
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  min-height: 240px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.view {
  display: none;
  animation: fadeUp 0.4s ease;
}

.view.is-active {
  display: block;
}

.settings-list {
  display: grid;
  gap: var(--space-md);
}

.setting-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-sm);
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.setting-label {
  font-weight: 600;
}

.setting-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.setting-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  white-space: pre-wrap;
  text-align: right;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(9, 10, 18, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(5px);
}

.modal-card {
  background: var(--bg-soft);
  padding: var(--space-xl);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 320px;
  border: 1px solid var(--border);
}

.modal-subtitle {
  color: var(--text-muted);
  margin-top: 0;
}

.field {
  display: grid;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.field input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
}

.login-error {
  color: var(--danger);
  margin-bottom: var(--space-sm);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardPop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

  .sidebar {
    position: relative;
    height: auto;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
  }

  .topbar-title h1 {
    font-size: 1.5rem;
  }

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

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