@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design Tokens ── */
:root {
  --bg: #0b1116;
  --bg-soft: #121a22;
  --surface: rgba(18, 26, 34, 0.76);
  --surface-solid: #16212c;
  --surface-2: #1b2835;
  --line: rgba(126, 156, 180, 0.26);
  --text: #eaf2f8;
  --text-muted: #98adbe;
  --accent: #2de2bf;
  --accent-2: #5ec7ff;
  --warn: #ff9f66;
  --danger: #ff647f;
  --ok: #3ce59d;
  --shadow: 0 14px 46px rgba(1, 6, 12, 0.45);
  --radius: 18px;
  --transition-fast: 180ms ease;
  --transition-smooth: 320ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: 'Space Grotesk', 'Avenir Next', 'Segoe UI', sans-serif;
  background:
    radial-gradient(900px 540px at 3% -12%, rgba(46, 226, 191, 0.2), transparent 70%),
    radial-gradient(700px 400px at 100% -8%, rgba(94, 199, 255, 0.15), transparent 72%),
    linear-gradient(140deg, #0a0f14 0%, #121c26 70%, #0f171e 100%);
}

/* Themed scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(126, 156, 180, 0.25); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(126, 156, 180, 0.45); }
* { scrollbar-width: thin; scrollbar-color: rgba(126,156,180,0.25) transparent; }

/* ── Noise Texture ── */
.noise-layer {
  position: fixed; inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image:
    linear-gradient(45deg, rgba(255,255,255,0.25) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.25) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.25) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.25) 75%);
  background-size: 3px 3px;
  z-index: 0;
}

/* ── Chip / Badge ── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(45, 226, 191, 0.12);
  border: 1px solid rgba(45, 226, 191, 0.38);
  color: #b5f8ea;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

/* ── Animation Utilities ── */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  animation: inUp 0.66s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.reveal.delay-1 { animation-delay: 0.12s; }
.reveal.delay-2 { animation-delay: 0.24s; }

.lift {
  transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1),
              box-shadow 260ms ease,
              border-color 260ms ease;
}
.lift:hover {
  transform: translateY(-3px) scale(1.003);
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.38);
  border-color: rgba(94, 199, 255, 0.35);
}

/* ── Inputs & Buttons ── */
input, select, button, textarea { font: inherit; }

input, select, textarea {
  width: 100%;
  border: 1px solid rgba(127, 156, 179, 0.35);
  border-radius: 12px;
  background: rgba(12, 18, 24, 0.75);
  color: var(--text);
  padding: 11px 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(94, 199, 255, 0.85);
  box-shadow: 0 0 0 3px rgba(94, 199, 255, 0.15);
  background: rgba(12, 18, 24, 0.95);
}

/* Focus-visible for keyboard a11y */
:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; /* already styled */
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  color: var(--text);
  background: rgba(31, 45, 57, 0.85);
  cursor: pointer;
  font-weight: 500;
  transition: transform var(--transition-fast), filter var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
}
.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  filter: none;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  background: linear-gradient(132deg, rgba(45, 226, 191, 0.95), rgba(94, 199, 255, 0.95));
  color: #07212d;
  font-weight: 700;
}
.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(45, 226, 191, 0.3);
}

.btn-ghost {
  border: 1px solid rgba(127, 156, 179, 0.3);
  background: rgba(16, 24, 32, 0.56);
}
.btn-ghost:hover {
  border-color: rgba(94, 199, 255, 0.5);
  background: rgba(16, 24, 32, 0.85);
}

.btn-danger {
  border: 1px solid rgba(255, 100, 127, 0.4);
  background: rgba(255, 100, 127, 0.1);
  color: #ffc1ce;
}
.btn-danger:hover {
  border-color: rgba(255, 100, 127, 0.7);
  background: rgba(255, 100, 127, 0.2);
  box-shadow: 0 4px 16px rgba(255, 100, 127, 0.15);
}

.btn-warn {
  border: 1px solid rgba(255, 159, 102, 0.4);
  background: rgba(255, 159, 102, 0.08);
  color: #ffd2b2;
}
.btn-warn:hover {
  border-color: rgba(255, 159, 102, 0.65);
  background: rgba(255, 159, 102, 0.18);
  box-shadow: 0 4px 16px rgba(255, 159, 102, 0.12);
}

/* Empty states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 2rem;
  opacity: 0.5;
}
.empty-state-text {
  font-size: 0.92rem;
}

/* Button loading spinner */
.btn.is-loading {
  color: transparent;
  pointer-events: none;
}
.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  top: 50%; left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.btn-primary.is-loading::after {
  border-color: rgba(7,33,45,0.3);
  border-top-color: #07212d;
}

.alert {
  border-radius: 12px;
  padding: 10px 14px;
  border: 1px solid transparent;
  margin-bottom: 10px;
  font-size: 0.92rem;
}
.alert.error {
  border-color: rgba(255, 100, 127, 0.5);
  background: rgba(255, 100, 127, 0.12);
  color: #ffd7df;
}

/* ═══════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════ */

.login-body {
  display: grid;
  place-items: center;
  padding: clamp(16px, 2vw, 28px);
  min-height: 100vh;
  overflow: hidden;
}

/* Animated gradient orbs */
.login-body::before,
.login-body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(80px);
  opacity: 0.4;
}
.login-body::before {
  width: 500px; height: 500px;
  top: -100px; left: -100px;
  background: radial-gradient(circle, rgba(45, 226, 191, 0.4), transparent 70%);
  animation: floatOrb 8s ease-in-out infinite alternate;
}
.login-body::after {
  width: 400px; height: 400px;
  bottom: -80px; right: -80px;
  background: radial-gradient(circle, rgba(94, 199, 255, 0.35), transparent 70%);
  animation: floatOrb2 10s ease-in-out infinite alternate;
}

.login-layout {
  z-index: 1;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  width: min(1080px, 100%);
  gap: 24px;
}

.login-brand, .login-card {
  padding: clamp(24px, 3vw, 38px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(165deg, rgba(18, 26, 34, 0.92), rgba(18, 26, 34, 0.72));
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.login-brand h1 {
  margin: 16px 0 10px;
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1;
}

.brand-bullets {
  margin: 24px 0 0;
  padding-left: 0;
  list-style: none;
  color: #cde2f2;
  display: grid;
  gap: 10px;
}
.brand-bullets li {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bullet-icon {
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.login-card h2 { margin-top: 0; font-size: 1.45rem; }

.login-form { display: grid; gap: 16px; }

.login-form label, .inline-vertical label {
  display: grid;
  gap: 6px;
  position: relative;
}

.login-form span, .inline-vertical span {
  font-size: 0.88rem;
  color: #c7d9e8;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.login-form label:focus-within span {
  color: var(--accent);
}

.pwd-toggle {
  position: absolute;
  right: 10px;
  bottom: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 0.9rem;
  border-radius: 6px;
  transition: color var(--transition-fast), background var(--transition-fast);
  line-height: 1;
}
.pwd-toggle:hover {
  color: var(--accent);
  background: rgba(45, 226, 191, 0.1);
}

.login-form input[name="password"] {
  padding-right: 40px;
}

/* ═══════════════════════════════════════════════
   MAIN PANEL LAYOUT
   ═══════════════════════════════════════════════ */

.panel-body { padding: 18px; }

.app-shell {
  z-index: 1;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  min-height: calc(100vh - 36px);
}

.sidebar, .main-stage, .panel-card, .hero-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

/* ── Sidebar ── */
.sidebar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.22rem;
  line-height: 1;
}

.nav-stack {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  justify-content: center;
}

.nav-btn {
  text-align: center;
  border-radius: 12px;
  border: 1px solid rgba(126, 156, 180, 0.18);
  background: rgba(13, 20, 28, 0.5);
  color: #d6e6f3;
  min-width: 136px;
  height: 44px;
  padding: 0 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 500;
  transition: border-color var(--transition-fast), transform var(--transition-fast),
              background var(--transition-fast), color var(--transition-fast);
}
.nav-btn:hover {
  border-color: rgba(94, 199, 255, 0.5);
  background: rgba(94, 199, 255, 0.06);
  transform: translateY(-1px);
  color: #fff;
}
.nav-btn.is-active {
  border-color: rgba(45, 226, 191, 0.65);
  background: linear-gradient(120deg, rgba(45, 226, 191, 0.18), rgba(16, 27, 37, 0.8));
  color: #fff;
}

.nav-icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-footer {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-left: auto;
  flex-wrap: wrap;
}

.sidebar-footer .muted {
  font-size: 0.86rem;
  white-space: nowrap;
}

/* ── Main Stage ── */
.main-stage {
  padding: 20px;
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.topbar h2 { margin: 0; font-size: clamp(1.4rem, 2.6vw, 1.9rem); }

.topbar-actions {
  display: inline-flex;
  gap: 10px;
  flex-shrink: 0;
}

/* Search bar */
.search-bar {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.search-bar input {
  padding-left: 36px;
  background: rgba(12, 18, 24, 0.6);
}
.search-bar::before {
  content: '⌕';
  position: absolute;
  top: 50%; left: 12px;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
}

/* State filter */
.state-filter {
  width: auto;
  min-width: 120px;
}

/* ── Views with fade transition ── */
.view {
  display: none;
  opacity: 0;
  transform: translateY(10px);
}
.view.is-visible {
  display: grid;
  gap: 16px;
  animation: fadeView 0.38s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* ── Last Updated ── */
.last-updated {
  font-size: 0.78rem;
  white-space: nowrap;
  opacity: 0.7;
}

/* ── Hero Panel ── */
.hero-panel {
  padding: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background:
    linear-gradient(138deg, rgba(20, 36, 48, 0.9), rgba(11, 20, 28, 0.88)),
    radial-gradient(500px 280px at 5% 10%, rgba(45, 226, 191, 0.22), transparent 65%);
}
.hero-panel h3 {
  margin: 12px 0 8px;
  font-size: clamp(1.2rem, 2.2vw, 1.6rem);
}
.hero-dismiss {
  flex-shrink: 0;
  opacity: 0.5;
}
.hero-dismiss:hover {
  opacity: 1;
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(156deg, rgba(16, 24, 32, 0.85), rgba(20, 29, 38, 0.72));
  padding: 16px;
  min-height: 110px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition-fast);
}
.stat-card:hover { border-color: rgba(94, 199, 255, 0.3); }
.stat-card::after {
  content: '';
  position: absolute;
  inset: auto auto -20px -20px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(45, 226, 191, 0.18), transparent 70%);
  pointer-events: none;
}
.stat-icon {
  font-size: 1.4rem;
  margin-bottom: 4px;
  opacity: 0.7;
}
.stat-card h4 { margin: 0; font-size: 0.88rem; color: #b6cbdb; font-weight: 500; }
.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.5rem, 2.4vw, 2.1rem);
  letter-spacing: 0.03em;
}
/* Pulse when updated */
.stat-card.pulse strong {
  animation: statPulse 0.5s ease;
}

/* ── Charts Grid ── */
.chart-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.chart-card { min-height: 240px; }

/* Donut */
.donut-wrap {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}
.donut {
  width: 130px; height: 130px;
  border-radius: 50%;
  border: 1px solid rgba(127, 156, 179, 0.2);
  background: conic-gradient(#2de2bf 0deg 360deg);
  position: relative;
  justify-self: center;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.24);
  transition: transform 0.4s ease;
}
.donut:hover { transform: scale(1.04); }
.donut::after {
  content: '';
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: rgba(8, 14, 20, 0.95);
  border: 1px solid rgba(127, 156, 179, 0.15);
}
.donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 1;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  pointer-events: none;
}
.donut-legend { display: grid; gap: 8px; }

.legend-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 0.86rem;
}
.legend-swatch {
  width: 10px; height: 10px;
  border-radius: 50%;
}

/* Bar charts */
.bar-list { display: grid; gap: 12px; }
.bar-item { display: grid; gap: 5px; }
.bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  color: #c9dceb;
}
.bar-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  border: 1px solid rgba(127, 156, 179, 0.15);
  background: rgba(9, 14, 20, 0.8);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(45, 226, 191, 0.95), rgba(94, 199, 255, 0.95));
  transform-origin: left center;
  animation: growBar 500ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ── Panel Cards & Sections ── */
.panel-card { padding: 18px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.section-head h3 { margin: 0; }

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* ── Tables ── */
.table-wrap {
  overflow: auto;
  border: 1px solid rgba(126, 156, 180, 0.18);
  border-radius: 14px;
}

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

th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(126, 156, 180, 0.1);
}

th {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #b3c8d8;
  background: rgba(9, 15, 22, 0.7);
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: blur(6px);
}

td { font-size: 0.92rem; }

/* Zebra striping */
tbody tr:nth-child(even) {
  background: rgba(94, 199, 255, 0.025);
}
tbody tr {
  transition: background var(--transition-fast);
}
tbody tr:hover {
  background: rgba(94, 199, 255, 0.07);
}

/* State pills */
.state-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid rgba(127, 156, 179, 0.2);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.state-pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.state-running {
  border-color: rgba(60, 229, 157, 0.5);
  color: #85f8c8;
}
.state-running::before { animation: statusPulse 2s ease-in-out infinite; }
.state-stopped, .state-off {
  border-color: rgba(255, 100, 127, 0.45);
  color: #ffc1ce;
}
.state-rebooting, .state-installing {
  border-color: rgba(255, 159, 102, 0.55);
  color: #ffd2b2;
}
.state-rebooting::before, .state-installing::before {
  animation: spin 1.2s linear infinite;
}

/* Action buttons in tables */
.action-row {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 5px;
}
.action-row .btn {
  padding: 5px 9px;
  font-size: 0.78rem;
}

/* ── Copyable elements ── */
[data-copyable] {
  cursor: copy;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background var(--transition-fast), color var(--transition-fast);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.86rem;
}
[data-copyable]:hover {
  background: rgba(45, 226, 191, 0.12);
  color: var(--accent);
}

/* ── Server Cards (Inventory) ── */
.server-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.server-card {
  border: 1px solid rgba(126, 156, 180, 0.22);
  border-radius: 14px;
  padding: 14px;
  background: rgba(11, 18, 24, 0.68);
  display: grid;
  gap: 10px;
  transition: border-color var(--transition-fast), transform 260ms ease, box-shadow 260ms ease;
}
.server-card:hover {
  border-color: rgba(94, 199, 255, 0.35);
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(0,0,0,0.25);
}
.server-card { position: relative; }
.server-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.server-card h4 { margin: 0; font-size: 1rem; }
.server-meta { color: #b6cada; font-size: 0.86rem; }

.server-card.is-assigned {
  border-color: rgba(45, 226, 191, 0.3);
}
.server-card.is-assigned::after {
  content: 'Assigned';
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  opacity: 0.6;
  pointer-events: none;
}
.server-card.is-assigned .server-card-head {
  padding-right: 52px;
}

.provider-badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.provider-badge.ovh {
  background: rgba(94, 199, 255, 0.12);
  color: var(--accent-2);
  border: 1px solid rgba(94, 199, 255, 0.25);
}
.provider-badge.lsw {
  background: rgba(45, 226, 191, 0.12);
  color: var(--accent);
  border: 1px solid rgba(45, 226, 191, 0.25);
}

.location-indicator {
  font-size: 0.86rem;
  margin-bottom: 8px;
}

/* ── Split Grid (Users view) ── */
.split-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* ── Pagination ── */
.pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

/* ═══════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════ */

.modal {
  border: 0;
  background: transparent;
  padding: 0;
  max-width: 100vw;
  max-height: 100vh;
}
.modal::backdrop {
  background: rgba(1, 8, 16, 0.7);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal article {
  width: min(860px, calc(100vw - 24px));
  max-height: calc(100vh - 34px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(168deg, rgba(16, 23, 32, 0.98), rgba(20, 30, 40, 0.95));
  color: #deecf8;
  padding: 18px;
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.5);
  animation: modalSlideUp 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.modal header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(126, 156, 180, 0.12);
}
.modal header h3 { margin: 0; }

.modal pre {
  margin: 0;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(127, 156, 179, 0.2);
  background: rgba(6, 12, 18, 0.85);
  color: #d2e6f6;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  max-height: 400px;
  overflow: auto;
}

.icon-btn {
  border: 1px solid rgba(126, 156, 180, 0.3);
  border-radius: 10px;
  background: rgba(12, 20, 30, 0.9);
  color: var(--text);
  width: 36px; height: 36px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}
.icon-btn:hover {
  background: rgba(255, 100, 127, 0.15);
  border-color: rgba(255, 100, 127, 0.5);
  transform: rotate(90deg);
}

.inline-vertical { display: grid; gap: 14px; }

.panel-inset {
  border: 1px solid rgba(127, 156, 179, 0.22);
  border-radius: 14px;
  background: rgba(8, 14, 20, 0.55);
  padding: 14px;
  transition: border-color var(--transition-fast);
}
.panel-inset:hover { border-color: rgba(126, 156, 180, 0.35); }

.ops-summary {
  margin-bottom: 14px;
}
.ops-summary h4 { margin: 0 0 6px; }

.ops-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}
.ops-grid h4 { margin: 0 0 8px; }

.ops-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ops-group {
  margin-bottom: 12px;
}
.ops-group:last-child {
  margin-bottom: 0;
}
.ops-group-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

#opsOutput { min-height: 180px; }
#opsOutput:empty::before {
  content: 'Output will appear here\2026';
  color: var(--text-muted);
  font-style: italic;
  opacity: 0.5;
}

/* Detail modal formatted view */
.detail-grid {
  display: grid;
  gap: 1px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(127, 156, 179, 0.2);
  background: rgba(8, 13, 20, 0.95);
}
.detail-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  background: rgba(6, 12, 18, 0.88);
}
.detail-row:nth-child(even) { background: rgba(10, 18, 26, 0.9); }
.detail-key {
  padding: 10px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #9db6c9;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-right: 1px solid rgba(127, 156, 179, 0.12);
  background: rgba(4, 9, 15, 0.65);
  word-break: break-word;
}
.detail-value {
  padding: 10px 14px;
  font-size: 0.9rem;
  color: #e7f4ff;
  font-family: 'JetBrains Mono', monospace;
  word-break: break-all;
  display: flex;
  align-items: center;
  gap: 8px;
}

#detailFormatted,
#detailFormatted * {
  text-shadow: none;
}
.copy-btn {
  border: 1px solid rgba(126, 156, 180, 0.25);
  border-radius: 6px;
  background: rgba(45, 226, 191, 0.1);
  color: var(--accent);
  padding: 2px 6px;
  font-size: 0.72rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}
.copy-btn:hover {
  background: rgba(45, 226, 191, 0.25);
  border-color: rgba(45, 226, 191, 0.5);
}

/* ── Toasts ── */
.toast-rack {
  position: fixed;
  right: 18px; bottom: 18px;
  display: grid;
  gap: 10px;
  z-index: 30;
}

.toast {
  min-width: 240px;
  max-width: 360px;
  border-radius: 14px;
  border: 1px solid rgba(126, 156, 180, 0.3);
  background: rgba(10, 18, 25, 0.96);
  backdrop-filter: blur(8px);
  color: #d7e8f5;
  padding: 12px 14px 14px;
  transform: translateX(18px);
  opacity: 0;
  animation: toastIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9rem;
  position: relative;
  overflow: hidden;
}
.toast::before {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}
.toast.ok { border-color: rgba(60, 229, 157, 0.4); }
.toast.ok::before { content: '✓'; color: var(--ok); }
.toast.error { border-color: rgba(255, 100, 127, 0.5); }
.toast.error::before { content: '\2715'; color: var(--danger); }
.toast.info { border-color: rgba(94, 199, 255, 0.4); }
.toast.info::before { content: '\2139'; color: var(--accent-2); }
.toast.info .toast-progress { background: var(--accent-2); }
.toast.warn { border-color: rgba(255, 159, 102, 0.4); }
.toast.warn::before { content: '\26A0'; color: var(--warn); }
.toast.warn .toast-progress { background: var(--warn); }

/* Toast progress drain */
.toast-progress {
  position: absolute;
  bottom: 0; left: 0;
  height: 3px;
  border-radius: 0 0 14px 14px;
  animation: toastDrain 2.8s linear forwards;
}
.toast.ok .toast-progress { background: var(--ok); }
.toast.error .toast-progress { background: var(--danger); }

/* ── Skeleton Loading ── */
.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(44, 64, 84, 0.2);
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent, rgba(122, 163, 192, 0.12), transparent);
  animation: shimmer 1.5s ease infinite;
}

.skeleton-row {
  height: 44px;
  border-bottom: 1px solid rgba(126, 156, 180, 0.06);
}

.skeleton-stat {
  height: 110px;
  border-radius: 14px;
}

.loading {
  position: relative;
  color: transparent;
}
.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(44, 64, 84, 0.2), rgba(122, 163, 192, 0.25), rgba(44, 64, 84, 0.2));
  background-size: 220% 100%;
  border-radius: 8px;
  animation: shimmer 1.3s linear infinite;
}

/* ═══════════════════════════════════════════════
   KEYFRAMES
   ═══════════════════════════════════════════════ */

@keyframes inUp {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeView {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes toastIn {
  to { transform: translateX(0); opacity: 1; }
}
@keyframes toastDrain {
  from { width: 100%; }
  to { width: 0%; }
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
@keyframes growBar {
  from { transform: scaleX(0.15); opacity: 0.5; }
  to { transform: scaleX(1); opacity: 1; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes statPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); color: var(--accent); }
}
@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes floatOrb {
  from { transform: translate(0, 0); }
  to { transform: translate(40px, 30px); }
}
@keyframes floatOrb2 {
  from { transform: translate(0, 0); }
  to { transform: translate(-30px, -40px); }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .sidebar {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
  }

  .nav-stack {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .sidebar-footer {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
  }
}

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

  .main-stage { padding: 14px; }

  .split-grid { grid-template-columns: 1fr; }

  .topbar {
    flex-wrap: wrap;
    gap: 10px;
  }

  .search-bar { max-width: 100%; order: 10; }

  .nav-btn {
    min-width: 120px;
    height: 40px;
  }
}

@media (max-width: 620px) {
  .panel-body { padding: 10px; }
  .main-stage { padding: 12px; }

  .stats-grid { grid-template-columns: 1fr 1fr; }
  .chart-grid { grid-template-columns: 1fr; }

  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }

  .nav-stack {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
  }

  .nav-btn {
    width: 100%;
    min-width: 0;
  }

  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1; }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .detail-row { grid-template-columns: 1fr; }
  .detail-key { border-right: 0; border-bottom: 1px solid rgba(127, 156, 179, 0.1); }
}
