:root {
  --bg: var(--bg-deep, #050814);
  --bg-deep: var(--bg-deep, #02040a);
  --panel: var(--bg-card, rgba(8, 12, 24, 0.94));
  --panel-border: var(--border, rgba(96, 116, 255, 0.30));
  --text: var(--text, #eef6ff);
  --muted: var(--muted, #aeb8d6);
  --pink: var(--pink, #ff00f0);
  --cyan: var(--info, #16e0ff);
  --purple: var(--purple, #8a6bff);
  --green: var(--accent, #4dff93);
  --yellow: #ffd84d;
  --red: #ff5d7a;
  --button-bg: linear-gradient(90deg, #171d34 0%, #1f2746 100%);
  --button-border: rgba(90, 109, 255, 0.55);
  --glow-pink: 0 0 18px rgba(255, 0, 240, 0.14);
  --glow-cyan: 0 0 18px rgba(22, 224, 255, 0.12);
  --glow-strong-pink: 0 0 28px rgba(255, 0, 240, 0.22);
  --glow-strong-cyan: 0 0 28px rgba(22, 224, 255, 0.18);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 0, 240, 0.16), transparent 22%),
    radial-gradient(circle at top right, rgba(22, 224, 255, 0.14), transparent 24%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  animation: bodyPulse 10s ease-in-out infinite alternate;
}

.app-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding-bottom: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: 28px 28px 24px;
  background: linear-gradient(90deg, #ff00f0 0%, #8a6bff 52%, #16e0ff 100%);
  box-shadow: var(--glow-strong-pink), var(--glow-strong-cyan);
  position: relative;
  overflow: hidden;
}

.topbar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 0%, rgba(255,255,255,0.10) 48%, transparent 56%);
  transform: translateX(-120%);
  animation: headerSweep 7s linear infinite;
  pointer-events: none;
}

.topbar h1 {
  margin: 0;
  font-size: 3rem;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #ffffff;
  text-shadow: 0 0 12px rgba(255,255,255,0.10);
}

.subtitle {
  margin: 12px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 1rem;
}

.status-pill {
  margin-top: 6px;
  background: #171717;
  color: #ffffff;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
  box-shadow: 0 0 14px rgba(22, 224, 255, 0.16);
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  padding: 14px 28px 0;
}

.panel {
  grid-column: span 4;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 18px 18px 20px;
  box-shadow: var(--glow-pink), var(--glow-cyan);
  position: relative;
  overflow: hidden;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,0,240,0.04), transparent 30%, transparent 70%, rgba(22,224,255,0.04));
  pointer-events: none;
}

.panel:hover {
  transform: translateY(-2px);
  border-color: rgba(22, 224, 255, 0.52);
  box-shadow: 0 0 18px rgba(255, 0, 240, 0.20), 0 0 18px rgba(22, 224, 255, 0.18);
}

.wide {
  grid-column: span 12;
}

.panel h2 {
  margin: 0 0 18px;
  color: var(--pink);
  font-size: 1.05rem;
  line-height: 1.2;
  font-weight: 800;
  text-shadow: 0 0 8px rgba(255, 0, 240, 0.14);
}

.panel p,
.panel li,
.panel span,
.panel div,
.panel a,
.panel button {
  color: var(--text);
}

.panel p {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.25;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 42px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--button-border);
  background: var(--button-bg);
  color: #f4f8ff;
  font-size: 0.98rem;
  font-weight: 800;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(90, 109, 255, 0.16);
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.action-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(22, 224, 255, 0.85);
  box-shadow: 0 0 14px rgba(255, 0, 240, 0.20), 0 0 14px rgba(22, 224, 255, 0.18);
  background: linear-gradient(90deg, #1c2442 0%, #263057 100%);
}

.action-btn.alert {
  border-color: rgba(255, 93, 122, 0.95);
  background: linear-gradient(90deg, rgba(88,18,34,0.96) 0%, rgba(140,28,54,0.96) 100%);
  color: #ffffff;
  animation: alertFlash 1.1s ease-in-out infinite;
  box-shadow: 0 0 16px rgba(255, 93, 122, 0.26), 0 0 26px rgba(255, 93, 122, 0.18);
}

.panel-note {
  margin-top: 14px !important;
  color: var(--muted) !important;
  font-size: 0.92rem !important;
  line-height: 1.35 !important;
}

.stat-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.compact-top {
  margin-top: 16px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(90, 109, 255, 0.14);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  color: var(--muted) !important;
  font-weight: 600;
}

.stat-value {
  color: var(--text) !important;
  text-align: right;
  font-weight: 700;
  max-width: 70%;
  word-break: break-word;
}

.doctor-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.doctor-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(90, 109, 255, 0.14);
}

.doctor-line:last-child {
  border-bottom: none;
}

.doctor-key {
  color: var(--muted) !important;
  font-weight: 600;
}

.doctor-val {
  color: var(--text) !important;
  text-align: right;
  font-weight: 700;
}

.doctor-good {
  color: var(--green) !important;
  text-shadow: 0 0 10px rgba(77,255,147,0.22);
}

.conn-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.conn-item {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(90, 109, 255, 0.14);
}

.conn-item:last-child {
  border-bottom: none;
}

.conn-name {
  color: var(--text) !important;
  font-weight: 700;
}

.conn-state {
  color: var(--muted) !important;
  font-size: 0.92rem;
  font-weight: 700;
}

.light {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
  box-shadow: 0 0 10px currentColor;
  animation: lightPulse 2.2s ease-in-out infinite;
}

.light.good {
  background: var(--green);
  color: var(--green);
}

.light.warn {
  background: var(--yellow);
  color: var(--yellow);
}

.light.bad {
  background: var(--red);
  color: var(--red);
}

.meter-block {
  margin-bottom: 16px;
}

.meter-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.meter-track {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: rgba(35, 43, 78, 0.85);
  border: 1px solid rgba(90, 109, 255, 0.22);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  animation: meterShimmer 5s linear infinite;
}

.meter-fill-cyan {
  background: linear-gradient(90deg, #16e0ff 0%, #57f0ff 100%);
  box-shadow: 0 0 10px rgba(22, 224, 255, 0.25);
}

.meter-fill-pink {
  background: linear-gradient(90deg, #ff00f0 0%, #ff66f5 100%);
  box-shadow: 0 0 10px rgba(255, 0, 240, 0.25);
}

.action-result-box,
.log-window {
  background: rgba(4, 7, 14, 0.95);
  border: 1px solid rgba(90, 109, 255, 0.22);
  border-radius: 14px;
  padding: 14px;
  box-shadow: inset 0 0 20px rgba(22, 224, 255, 0.04);
}

.action-result-box {
  min-height: 90px;
}

.log-window {
  min-height: 180px;
  max-height: 260px;
  overflow-y: auto;
}

.action-result-line,
.log-line {
  font-family: "JetBrains Mono", "Consolas", monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #bfeeff;
  margin-bottom: 6px;
}

.action-result-line:last-child,
.log-line:last-child {
  margin-bottom: 0;
}

@keyframes bodyPulse {
  0% { background-position: 0 0, 100% 0, 0 0; }
  100% { background-position: 0 0, 100% 0, 0 12px; }
}

@keyframes headerSweep {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(120%); }
}

@keyframes lightPulse {
  0%, 100% { opacity: 1; filter: brightness(1); }
  50% { opacity: 0.72; filter: brightness(1.35); }
}

@keyframes meterShimmer {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.16); }
  100% { filter: brightness(1); }
}

@keyframes alertFlash {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.015); filter: brightness(1.22); }
}

@media (max-width: 1200px) {
  .panel { grid-column: span 6; }
  .wide { grid-column: span 12; }
}

@media (max-width: 820px) {
  .panel, .wide { grid-column: span 12; }

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

  .topbar h1 {
    font-size: 2.2rem;
  }

  .stat-row,
  .doctor-line {
    flex-direction: column;
    align-items: flex-start;
  }

  .stat-value,
  .doctor-val {
    text-align: left;
    max-width: 100%;
  }
}
