:root {
  /* Premium Dark Theme Color Palette */
  --bg-deep: #050b14;
  --bg-main: #0a1120;
  --bg-card: rgba(18, 30, 56, 0.75);
  --bg-card-hover: rgba(24, 40, 75, 0.85);
  
  --line-soft: rgba(66, 99, 163, 0.2);
  --line-strong: rgba(66, 99, 163, 0.4);
  
  --text-main: #f0f4f8;
  --text-muted: #8aa4c8;
  --text-dim: #5c779c;
  
  --accent-primary: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.5);
  --accent-secondary: #0ea5e9;
  
  --status-ok: #10b981;
  --status-ok-bg: rgba(16, 185, 129, 0.15);
  --status-warn: #f59e0b;
  --status-warn-bg: rgba(245, 158, 11, 0.15);
  --status-bad: #ef4444;
  --status-bad-bg: rgba(239, 68, 68, 0.15);
  
  /* Layout & Sizing */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;
  
  --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 0 24px var(--accent-glow);
  
  --transition-fast: 0.15s ease-out;
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Reset & Typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-deep);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  background-image: 
    radial-gradient(circle at 15% 0%, rgba(59, 130, 246, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 85% 100%, rgba(16, 185, 129, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-primary);
}

pre, code {
  font-family: 'JetBrains Mono', Consolas, Monaco, monospace;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.hidden {
  display: none !important;
}

/* Layout Utilities */
.wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.page-content {
  animation: fadeIn 0.4s ease-out forwards;
}

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

.grid { display: grid; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* Navigation Topbar */
.main-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(5, 11, 20, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
  padding: 12px 24px;
  margin-bottom: 24px;
}

.nav-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.nav-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.navlink {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.navlink:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.navlink.active {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--accent-primary);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.1) inset;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.userbox {
  color: var(--text-dim);
  font-size: 13px;
  font-family: monospace;
  background: rgba(0,0,0,0.2);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-soft);
}

/* Forms & Inputs */
input, select, textarea {
  width: 100%;
  background: rgba(10, 17, 32, 0.8);
  color: var(--text-main);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: inherit;
  font-size: 13px;
  transition: all var(--transition-fast);
}

input[type="checkbox"], input[type="radio"] {
  width: auto;
  padding: 0;
  cursor: pointer;
  accent-color: var(--accent-primary);
}

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

input::placeholder, textarea::placeholder {
  color: var(--text-dim);
}

.row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.row label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Buttons */
.btn, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
}

/* Default / Primary Button */
button {
  background: var(--accent-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

button:hover:not(:disabled) {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(100%);
}

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

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--text-muted);
  transform: translateY(0);
}

.danger {
  background: var(--status-bad);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.danger:hover:not(:disabled) {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* Panels & Cards (Glassmorphism) */
.panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-subtle);
  min-width: 0;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 16px;
  min-width: 0;
  word-break: break-word;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  border-color: var(--line-strong);
  background: var(--bg-card-hover);
}

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

.card .value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 700;
  color: white;
}

.card .meta {
  margin-top: 6px;
  color: var(--text-dim);
  font-size: 11px;
}

/* Hero Section */
.hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.hero-main {
  padding: 32px;
  border-radius: 24px;
  background: 
    linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, transparent 60%),
    var(--bg-card);
  border: 1px solid rgba(59, 130, 246, 0.2);
  position: relative;
  overflow: hidden;
}

.hero-main::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.03) 0%, transparent 50%);
  pointer-events: none;
}

.eyebrow {
  color: var(--accent-secondary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 12px;
}

.hero-title {
  font-size: 36px;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 12px;
  background: linear-gradient(to right, #ffffff, #a5b4fc);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-sub {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  max-width: 60ch;
}

/* Typography Helpers */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.meta-text {
  color: var(--text-dim);
  font-size: 12px;
}

.statusline {
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(0,0,0,0.3);
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--text-muted);
  font-family: monospace;
}

/* Pills & Badges */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--line-strong);
  background: rgba(0,0,0,0.2);
  color: var(--text-main);
}

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

.pill.ok { color: var(--status-ok); border-color: rgba(16, 185, 129, 0.3); background: var(--status-ok-bg); }
.pill.warn { color: var(--status-warn); border-color: rgba(245, 158, 11, 0.3); background: var(--status-warn-bg); }
.pill.bad { color: var(--status-bad); border-color: rgba(239, 68, 68, 0.3); background: var(--status-bad-bg); }

/* Login Modal */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 24px;
  padding: 32px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.login h2 {
  font-size: 24px;
  margin-bottom: 24px;
  text-align: center;
}

.login button {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  font-size: 14px;
}

.login-msg {
  text-align: center;
  margin-top: 16px;
  color: var(--status-bad);
  font-size: 13px;
  min-height: 20px;
}

/* Pre / Code Blocks */
pre {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 12px;
  color: var(--text-muted);
  overflow-x: auto;
  max-height: 400px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

pre::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

pre::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 3px;
}

/* Standard Grids used across pages */
.cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.layout-sidebar {
  display: grid;
  grid-template-columns: 60% 40%;
  gap: 24px;
  align-items: start;
  width: 100%;
}

.layout-sidebar > * {
  min-width: 0;
}

.actions-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* Lists and Items */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 650px;
  overflow-y: auto;
  padding-right: 8px;
}

.item-list::-webkit-scrollbar {
  width: 6px;
}
.item-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}

.list-item {
  background: rgba(16, 25, 43, 0.4);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.list-item:hover {
  background: rgba(30, 45, 75, 0.6);
  border-color: rgba(59, 130, 246, 0.4);
  transform: translateX(4px);
}

.list-item.active {
  background: linear-gradient(to right, rgba(59, 130, 246, 0.15), rgba(16, 25, 43, 0.6));
  border-left: 3px solid var(--accent-primary);
  border-top-color: rgba(59, 130, 246, 0.3);
  border-right-color: rgba(59, 130, 246, 0.3);
  border-bottom-color: rgba(59, 130, 246, 0.3);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2) inset;
}

/* Responsive Overrides */
@media (max-width: 1024px) {
  .hero, .layout-sidebar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .cards-row {
    grid-template-columns: 1fr 1fr;
  }
  .wrap {
    padding: 16px;
  }
}

/* Modal System */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  overflow-y: auto;
  padding: 24px;
  box-sizing: border-box;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 820px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: scale(0.96) translateY(8px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  flex-shrink: 0;
  margin: auto;
}

.modal-backdrop.open .modal-content {
  transform: scale(1) translateY(0);
}

.modal-header {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-main);
  margin: 0;
}

.modal-close {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  box-shadow: none;
}

.modal-close:hover {
  color: white;
  background: rgba(255,255,255,0.1);
  transform: none;
}

.modal-body {
  overflow-y: auto;
  flex: 1;
  padding-right: 8px;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}
