:root {
  --bg-0: #070707;
  --bg-1: #131313;
  --bg-2: #1b1b1b;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f4f4;
  --muted: #a9a9a9;
  --yellow: #ffe100;
  --yellow-soft: #ffd44d;
  --red: #ff2d20;
  --red-soft: #ff624f;
  --panel: rgba(15, 15, 15, 0.78);
  --radius: 18px;
  --shadow-red: 0 0 24px rgba(255, 45, 32, 0.4);
  --shadow-yellow: 0 0 28px rgba(255, 225, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 225, 0, 0.12), transparent 30%),
    radial-gradient(circle at 88% 4%, rgba(255, 45, 32, 0.2), transparent 42%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 42%, var(--bg-2));
  font-family: "Rajdhani", "Segoe UI", sans-serif;
  letter-spacing: 0.02em;
  position: relative;
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at center, black 45%, transparent 100%);
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 75%, rgba(255, 225, 0, 0.11), transparent 30%),
    radial-gradient(circle at 85% 70%, rgba(255, 45, 32, 0.12), transparent 28%);
}

.topbar {
  margin: 1.25rem auto 1rem;
  width: min(1200px, calc(100% - 2rem));
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
}

.brand-wrap h1 {
  margin: 0;
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: clamp(1.25rem, 2.2vw, 2.05rem);
  color: var(--yellow);
  text-shadow: var(--shadow-yellow);
}

.tag {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.84rem;
  letter-spacing: 0.2em;
}

.top-stats {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
  display: grid;
  min-width: 92px;
  backdrop-filter: blur(3px);
}

.chip span {
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.chip strong {
  font-family: "Orbitron", sans-serif;
  font-size: 1rem;
  color: var(--yellow-soft);
}

.chip.warning strong {
  color: var(--yellow);
}

.chip.danger strong {
  color: var(--red-soft);
}

.dashboard {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto 1.2rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: 2fr 1.2fr;
  grid-template-areas:
    "gauges systems"
    "logs command";
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02), 0 16px 40px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}

.gauges {
  grid-area: gauges;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.8rem;
}

.systems {
  grid-area: systems;
}

.logs {
  grid-area: logs;
}

.command {
  grid-area: command;
}

.section-head {
  margin-bottom: 1rem;
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 1rem;
}

.section-head h2 {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.gauge-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  width: 100%;
}

.gauge-card {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 0.65rem;
  background: rgba(255, 255, 255, 0.01);
}

.gauge {
  --value: 80;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 50%, #111 0 52%, transparent 53%),
    conic-gradient(from 180deg, var(--yellow) calc(var(--value) * 1%), rgba(255, 255, 255, 0.08) 0);
  box-shadow: var(--shadow-yellow), inset 0 0 28px rgba(255, 225, 0, 0.14);
  transition: background 360ms ease;
}

.gauge.danger {
  background:
    radial-gradient(circle at 50% 50%, #111 0 52%, transparent 53%),
    conic-gradient(from 180deg, var(--red) calc(var(--value) * 1%), rgba(255, 255, 255, 0.08) 0);
  box-shadow: var(--shadow-red), inset 0 0 28px rgba(255, 45, 32, 0.16);
}

.gauge-inner {
  width: 72%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(160deg, #1e1e1e, #090909);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  place-content: center;
  text-align: center;
}

.gauge-number {
  font-family: "Orbitron", sans-serif;
  color: var(--yellow-soft);
  font-size: 1.05rem;
}

.gauge.danger .gauge-number {
  color: var(--red-soft);
}

.gauge-label {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bar-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  height: 300px;
  overflow-y: auto;
  padding-right: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 225, 0, 0.5) rgba(255, 255, 255, 0.05);
}

.bar-list::-webkit-scrollbar {
  width: 8px;
}

.bar-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 4px;
}

.bar-list::-webkit-scrollbar-thumb {
  background: rgba(255, 225, 0, 0.45);
  border-radius: 4px;
}

.systems-link {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  border-left: 2px solid rgba(255, 225, 0, 0.5);
  padding: 0.65rem 0.75rem;
  background: linear-gradient(90deg, rgba(255, 225, 0, 0.08), transparent);
  border-radius: 8px;
  transition: all 180ms ease;
  grid-template-columns: unset;
}

.track {
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}

.track i {
  --fill: 50%;
  display: block;
  width: var(--fill);
  height: 100%;
  background: linear-gradient(90deg, #ffb700, #ffe100);
  box-shadow: var(--shadow-yellow);
}

.track i.danger {
  background: linear-gradient(90deg, #ff684b, #ff2d20);
  box-shadow: var(--shadow-red);
}

.logs ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.logs li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.6rem;
  align-items: baseline;
  border-left: 2px solid rgba(255, 225, 0, 0.45);
  padding: 0.3rem 0.2rem 0.3rem 0.65rem;
  background: linear-gradient(90deg, rgba(255, 225, 0, 0.07), transparent);
}

.logs time {
  font-family: "Orbitron", sans-serif;
  font-size: 0.74rem;
  color: var(--yellow-soft);
}

.logs p {
  margin: 0;
  font-size: 0.9rem;
}

.logs a {
  color: var(--yellow-soft);
  text-decoration: none;
  border-bottom: 1px dashed rgba(255, 225, 0, 0.45);
}

.logs a:hover,
.logs a:focus-visible {
  color: #fff38a;
  border-bottom-color: rgba(255, 225, 0, 0.9);
}

.systems-link:hover {
  border-left-color: rgba(255, 225, 0, 0.9);
  background: linear-gradient(90deg, rgba(255, 225, 0, 0.14), transparent);
  box-shadow: var(--shadow-yellow);
}

.bar-row span,
.bar-row em {
  font-style: normal;
  font-size: 0.92rem;
}

.bar-row:not(.systems-link) {
  display: grid;
  grid-template-columns: 1fr 2.2fr auto;
  align-items: center;
  gap: 0.7rem;
}

.systems-link-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--yellow-soft);
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 180ms ease;
}

.systems-link-item:hover,
.systems-link-item:focus-visible {
  color: #fff38a;
}

.systems-link-item::before {
  content: '→';
  font-weight: bold;
  opacity: 0.7;
}

.systems-link-text {
  word-break: break-word;
}

.bar-list {
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 225, 0, 0.5) rgba(255, 255, 255, 0.05);
}

.bar-list::-webkit-scrollbar {
  width: 8px;
}

.bar-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 4px;
}

.bar-list::-webkit-scrollbar-thumb {
  background: rgba(255, 225, 0, 0.45);
  border-radius: 4px;
}

.bar-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 225, 0, 0.75);
}

.command-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

button {
  border: 1px solid rgba(255, 225, 0, 0.45);
  background: linear-gradient(160deg, rgba(255, 225, 0, 0.18), rgba(255, 225, 0, 0.04));
  color: var(--text);
  border-radius: 12px;
  padding: 0.8rem;
  font-family: "Orbitron", sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-yellow);
}

button.danger {
  border-color: rgba(255, 45, 32, 0.52);
  background: linear-gradient(160deg, rgba(255, 45, 32, 0.24), rgba(255, 45, 32, 0.06));
}

button.danger:hover {
  box-shadow: var(--shadow-red);
}

.reveal-up {
  opacity: 0;
  transform: translateY(12px);
  animation: revealUp 680ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  animation-delay: var(--delay, 0s);
}

.pulse-red {
  animation: pulseRed 1.8s ease-in-out infinite;
}

@keyframes revealUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseRed {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(255, 45, 32, 0);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 45, 32, 0.35);
  }
}

@media (max-width: 960px) {
  .dashboard {
    grid-template-columns: 1fr;
    grid-template-areas:
      "gauges"
      "systems"
      "logs"
      "command";
  }

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

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

  .top-stats {
    width: 100%;
    justify-content: flex-start;
  }

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

  .bar-row {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }

  .command-buttons {
    grid-template-columns: 1fr;
  }
}

.article-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease;
}

.article-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.article-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px);
}

.article-panel {
  position: relative;
  z-index: 1000;
  width: min(92vw, 720px);
  max-height: 85vh;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02), 0 0 40px rgba(255, 225, 0, 0.2);
  overflow: hidden;
}

.article-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(255, 225, 0, 0.06), rgba(255, 45, 32, 0.03));
}

.article-header h2 {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-size: 1.2rem;
  color: var(--yellow);
  text-shadow: var(--shadow-yellow);
  letter-spacing: 0.08em;
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.article-close {
  border: 1px solid rgba(255, 225, 0, 0.35);
  background: transparent;
  color: var(--yellow-soft);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 180ms ease;
}

.article-close:hover,
.article-close:focus-visible {
  transform: rotate(90deg);
  box-shadow: var(--shadow-yellow);
  border-color: rgba(255, 225, 0, 0.7);
}

.article-content {
  padding: 1.5rem;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.6;
}

.article-content p {
  margin: 0 0 1rem;
  color: var(--text);
}

.article-content p:last-child {
  margin-bottom: 0;
}

.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1rem 0;
  border: 1px solid var(--line);
}

.article-content h3,
.article-content h4 {
  margin: 1.5rem 0 0.75rem;
  color: var(--yellow-soft);
  font-family: "Orbitron", sans-serif;
}

.article-content strong {
  color: var(--yellow-soft);
}

.article-content a {
  color: var(--yellow-soft);
  border-bottom: 1px dashed rgba(255, 225, 0, 0.45);
  text-decoration: none;
}

.article-content a:hover {
  color: #fff38a;
  border-bottom-color: rgba(255, 225, 0, 0.9);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
