:root {
  --deep: #071b4d;
  --blue: #1677ff;
  --cyan: #20d4ff;
  --green: #20e58f;
  --orange: #ff6b3d;
  --text: #eaf6ff;
  --muted: #8fb4d8;
  --line: rgba(32, 212, 255, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  background:
    linear-gradient(rgba(32, 212, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(32, 212, 255, 0.08) 1px, transparent 1px),
    radial-gradient(circle at 18% 12%, rgba(32, 212, 255, 0.24), transparent 26%),
    radial-gradient(circle at 78% 18%, rgba(123, 77, 255, 0.2), transparent 24%),
    linear-gradient(145deg, #031032 0%, var(--deep) 48%, #020815 100%);
  background-size: 42px 42px, 42px 42px, auto, auto, auto;
  overflow-x: hidden;
}

body::after {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.025) 0,
    rgba(255, 255, 255, 0.025) 1px,
    transparent 1px,
    transparent 7px
  );
}

.beam {
  position: fixed;
  z-index: -1;
  width: 42vw;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(32, 212, 255, 0.48), transparent);
  filter: blur(1px);
  animation: scan 6s linear infinite;
}

.beam-a {
  top: 18%;
}

.beam-b {
  top: 64%;
  animation-delay: -2.4s;
}

@keyframes scan {
  from {
    transform: translateX(-45vw);
  }
  to {
    transform: translateX(110vw);
  }
}

.hidden {
  display: none !important;
}

.glass {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(11, 39, 95, 0.76), rgba(4, 16, 45, 0.58));
  box-shadow: 0 0 24px rgba(22, 119, 255, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(460px, 100%);
  padding: 36px;
  border-radius: 8px;
}

.brand-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid rgba(32, 212, 255, 0.55);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  color: #fff;
  font-weight: 800;
  box-shadow: 0 0 28px rgba(32, 212, 255, 0.34);
}

.brand-mark.small {
  width: 42px;
  height: 42px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.muted {
  color: var(--muted);
  line-height: 1.7;
}

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

label {
  display: grid;
  gap: 8px;
  color: #bfe7ff;
  font-size: 14px;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(32, 212, 255, 0.25);
  border-radius: 6px;
  outline: none;
  background: rgba(2, 11, 31, 0.68);
  color: var(--text);
  font: inherit;
  box-shadow: inset 0 0 18px rgba(22, 119, 255, 0.08);
}

input {
  height: 46px;
  padding: 0 14px;
}

textarea {
  min-height: 132px;
  resize: vertical;
  padding: 14px;
}

.primary-btn,
.ghost-btn,
.nav-item {
  min-height: 42px;
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.primary-btn {
  border: 0;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  font-weight: 700;
  box-shadow: 0 0 22px rgba(22, 119, 255, 0.34);
}

.ghost-btn,
.nav-item {
  border: 1px solid rgba(32, 212, 255, 0.32);
  background: rgba(8, 31, 79, 0.28);
}

.error-text {
  min-height: 20px;
  margin: 0;
  color: #ff8b66;
}

.app-shell {
  display: grid;
  grid-template-columns: 252px 1fr;
  min-height: 100vh;
  gap: 20px;
  padding: 20px;
}

.sidebar {
  position: sticky;
  top: 20px;
  height: calc(100vh - 40px);
  padding: 20px;
  border-radius: 8px;
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.logo-row span,
.side-status small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

nav {
  display: grid;
  gap: 10px;
}

.nav-item {
  text-align: left;
  padding: 0 14px;
}

.nav-item.active {
  border-color: rgba(32, 212, 255, 0.72);
  background: linear-gradient(90deg, rgba(22, 119, 255, 0.28), rgba(32, 212, 255, 0.08));
}

.side-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  padding: 14px;
  border: 1px solid rgba(32, 212, 255, 0.18);
  border-radius: 8px;
  background: rgba(4, 14, 38, 0.42);
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 16px var(--green);
}

.workspace {
  display: grid;
  gap: 18px;
  align-content: start;
  grid-auto-rows: max-content;
}

.page {
  display: none;
}

.page.active {
  display: grid;
  gap: 18px;
}

.topbar,
.hero-band,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  position: sticky;
  top: 20px;
  z-index: 20;
  min-height: 96px;
  padding: 18px 0;
}

.topbar h1 {
  margin-bottom: 0;
  font-size: clamp(24px, 3vw, 42px);
}

.top-actions {
  display: flex;
  gap: 10px;
}

.hero-band {
  min-height: 180px;
  padding: 28px;
  border-radius: 8px;
  background:
    linear-gradient(120deg, rgba(22, 119, 255, 0.22), transparent 55%),
    linear-gradient(145deg, rgba(11, 39, 95, 0.78), rgba(4, 16, 45, 0.62));
}

.hero-band h2 {
  margin-bottom: 8px;
  font-size: clamp(28px, 4vw, 56px);
}

.score-dial {
  position: relative;
  display: grid;
  width: 138px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--cyan) 0deg, var(--blue) 300deg, rgba(255, 255, 255, 0.12) 300deg);
  box-shadow: 0 0 34px rgba(32, 212, 255, 0.24);
}

.score-dial::before {
  position: absolute;
  width: 102px;
  aspect-ratio: 1;
  border-radius: 50%;
  content: "";
  background: #061740;
}

.score-dial span,
.score-dial small {
  position: relative;
}

.score-dial span {
  font-size: 34px;
  font-weight: 800;
}

.score-dial small {
  margin-top: -44px;
  color: var(--muted);
}

.metric-grid,
.dashboard-grid,
.rewrite-grid {
  display: grid;
  gap: 18px;
}

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

.dashboard-grid {
  grid-template-columns: 1.2fr 0.9fr 0.9fr;
}

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

.metric-card,
.panel {
  border-radius: 8px;
  padding: 20px;
}

.metric-card span {
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 10px 0;
  font-size: clamp(28px, 4vw, 46px);
}

.metric-card small,
.panel-head span {
  color: var(--muted);
}

.accent-blue {
  color: #65a6ff !important;
}

.accent-cyan {
  color: var(--cyan) !important;
}

.accent-green {
  color: var(--green) !important;
}

.accent-orange {
  color: var(--orange) !important;
}

.panel h3 {
  margin-bottom: 0;
}

canvas {
  width: 100%;
  margin-top: 14px;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 20px;
}

.heat-cell {
  aspect-ratio: 1;
  border: 1px solid rgba(32, 212, 255, 0.18);
  border-radius: 4px;
  background: rgba(32, 212, 255, var(--heat));
  box-shadow: 0 0 calc(20px * var(--heat)) rgba(32, 212, 255, 0.42);
}

.output-box {
  margin-top: 14px;
  border: 1px solid rgba(32, 212, 255, 0.18);
  border-radius: 8px;
  background: rgba(2, 11, 31, 0.42);
}

.output-box h4 {
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(32, 212, 255, 0.14);
  color: var(--cyan);
}

pre {
  min-height: 110px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  color: #d8eeff;
  white-space: pre-wrap;
  word-break: break-word;
}

.recent-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.recent-item {
  display: grid;
  grid-template-columns: 90px 1fr 120px 80px;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(32, 212, 255, 0.15);
  border-radius: 6px;
  background: rgba(2, 11, 31, 0.34);
  color: var(--text);
  font: inherit;
  text-align: left;
}

.recent-item span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.job-row {
  cursor: pointer;
}

.job-row:hover,
.job-row.active {
  border-color: rgba(32, 212, 255, 0.58);
  background: linear-gradient(90deg, rgba(22, 119, 255, 0.24), rgba(32, 212, 255, 0.08));
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.detail-grid .output-box:first-child {
  grid-column: 1 / -1;
}

.detail-grid pre {
  max-height: 340px;
}

.badge {
  display: inline-grid;
  min-height: 26px;
  place-items: center;
  border-radius: 999px;
  background: rgba(32, 229, 143, 0.14);
  color: var(--green);
  font-size: 12px;
}

.badge.failed {
  background: rgba(255, 107, 61, 0.14);
  color: var(--orange);
}

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

  .sidebar {
    position: relative;
    top: 0;
    height: auto;
  }

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

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .metric-grid,
  .dashboard-grid,
  .rewrite-grid,
  .detail-grid,
  .recent-item {
    grid-template-columns: 1fr;
  }

  .topbar,
  .hero-band,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
