:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --green: #059669;
  --green-bg: #ecfdf5;
  --yellow: #d97706;
  --yellow-bg: #fffbeb;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --violet: #7c3aed;
  --violet-bg: #f5f3ff;
  --slate: #475569;
  --slate-bg: #f1f5f9;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.04);
  --font: Inter, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 20; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 8px; }

.topbar {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px;
  padding: 20px 28px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; gap: 14px; align-items: center; }
.logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(145deg, #2563eb, #1d4ed8);
  display: grid; place-items: center; position: relative;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.25);
}
.logo-belt {
  width: 22px; height: 8px; border-radius: 999px;
  background: rgba(255,255,255,0.9);
  box-shadow: 0 -6px 0 rgba(255,255,255,0.35), 0 6px 0 rgba(255,255,255,0.55);
}
h1 { margin: 0; font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 0.82rem; }

.kpi-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.kpi {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 14px;
  min-width: 96px;
}
.kpi .n { font-size: 1.25rem; font-weight: 700; line-height: 1.1; }
.kpi .l { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
.kpi.warn .n { color: var(--red); }

.nav {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 8;
}
.nav-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
}
.nav-btn:hover { color: var(--text); background: var(--slate-bg); }
.nav-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: #bfdbfe;
  font-weight: 600;
}
.nav-btn.nav-secondary { opacity: 0.85; font-size: 0.84rem; }

main { max-width: 1180px; margin: 0 auto; padding: 22px 24px 56px; }
.panel { display: none; }
.panel.active { display: block; }
.panel[hidden] { display: none !important; }

.panel-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
  align-items: flex-end; margin-bottom: 16px;
}
.panel-head h2 { margin: 0; font-size: 1.15rem; }
.muted { margin: 4px 0 0; color: var(--muted); font-size: 0.86rem; }
.subhead { margin: 28px 0 10px; font-size: 0.95rem; }

.select-wrap {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 0.78rem; color: var(--muted);
}
.select-wrap select, input, textarea, select {
  font: inherit; color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  width: 100%;
}
.select-wrap select { min-width: 220px; }
textarea { resize: vertical; }

/* Conveyor */
.conveyor {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 980px) {
  .conveyor { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .conveyor { grid-template-columns: 1fr; }
  main { padding: 16px; }
  .topbar, .nav { padding-left: 16px; padding-right: 16px; }
}
.station {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  position: relative;
  min-height: 148px;
  display: flex; flex-direction: column; gap: 8px;
}
.station.current {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12), var(--shadow);
}
.station-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.station-id {
  font-size: 0.72rem; font-weight: 700; color: var(--accent);
  letter-spacing: 0.04em;
}
.station-name { font-weight: 700; font-size: 1rem; margin: 0; }
.station-gate { font-size: 0.75rem; color: var(--muted); }
.station-result {
  margin-top: auto;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px;
  font-size: 0.84rem;
}
.station-result .art { color: var(--muted); font-size: 0.72rem; margin-bottom: 2px; }
.station-parallel {
  position: absolute; top: 10px; right: 10px;
  font-size: 0.65rem; color: var(--violet);
  background: var(--violet-bg); padding: 2px 6px; border-radius: 999px;
}

.pill {
  display: inline-flex; align-items: center;
  font-size: 0.72rem; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
  background: var(--slate-bg); color: var(--slate);
}
.st-waiting { background: var(--slate-bg); color: var(--slate); }
.st-running { background: var(--accent-soft); color: var(--accent); }
.st-done { background: var(--green-bg); color: var(--green); }
.st-blocked { background: var(--red-bg); color: var(--red); }
.st-repair { background: var(--yellow-bg); color: var(--yellow); }
.st-live { background: #ecfeff; color: #0891b2; }
.st-review { background: var(--violet-bg); color: var(--violet); }

.legend { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  font: inherit; color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.project-card:hover, .project-card.active {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1), var(--shadow);
}
.project-card .title { font-weight: 700; font-size: 1.02rem; margin: 0 0 4px; }
.project-card .meta { color: var(--muted); font-size: 0.8rem; margin-bottom: 10px; }
.project-card .progress {
  height: 6px; background: var(--slate-bg); border-radius: 999px; overflow: hidden; margin: 10px 0;
}
.project-card .progress > span {
  display: block; height: 100%; background: linear-gradient(90deg, #60a5fa, #2563eb); border-radius: 999px;
}
.project-card .foot-row {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  font-size: 0.8rem; color: var(--muted);
}

.project-detail {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.project-detail h3 { margin: 0 0 8px; }
.detail-stations {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.detail-st {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--surface-2);
  font-size: 0.84rem;
}

/* Ops */
.ops-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.ops-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.ops-card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.health {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.82rem; font-weight: 600; color: var(--green);
}
.health::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green);
}
.ops-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.ops-links a {
  font-size: 0.84rem; color: var(--accent); text-decoration: none;
  border: 1px solid #bfdbfe; background: var(--accent-soft);
  padding: 6px 10px; border-radius: 8px;
}
.ops-links a:hover { background: #dbeafe; }
.ops-block {
  margin-top: 10px; padding: 10px; border-radius: 10px;
  background: var(--yellow-bg); color: #92400e; font-size: 0.84rem;
}
.ops-block ul { margin: 6px 0 0; padding-left: 18px; }
.decision {
  display: inline-block; margin-top: 8px;
  font-size: 0.78rem; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  background: var(--green-bg); color: var(--green);
}

/* Forms */
.form-card { padding: 18px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.form-grid.two { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 720px) {
  .form-grid, .form-grid.two { grid-template-columns: 1fr; }
}
label { display: flex; flex-direction: column; gap: 6px; font-size: 0.84rem; color: var(--muted); margin-bottom: 10px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.form-hint { min-height: 1.2em; color: var(--green); font-size: 0.86rem; }

.btn {
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: #1d4ed8; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--slate-bg); }

.q-set {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 0 0 12px;
}
.q-set legend { padding: 0 6px; font-size: 0.84rem; color: var(--muted); }
.q-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.q-item:last-child { border-bottom: 0; }
.q-title { font-size: 0.92rem; color: var(--text); font-weight: 600; }
.q-hint { font-size: 0.78rem; color: var(--muted); margin: 2px 0 6px; }
.q-choices { display: flex; flex-wrap: wrap; gap: 14px; }
.q-choices label {
  flex-direction: row; align-items: center; gap: 6px;
  margin: 0; color: var(--text); font-size: 0.86rem;
}
.score-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; font-size: 0.95rem;
}
.verdict {
  font-size: 0.82rem; font-weight: 700;
  padding: 6px 12px; border-radius: 999px;
}
.verdict.queue { background: var(--green-bg); color: var(--green); }
.verdict.hold { background: var(--yellow-bg); color: var(--yellow); }
.verdict.kill { background: var(--red-bg); color: var(--red); }

.table-card { padding: 0; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); color: var(--muted); font-weight: 600; }
.empty { padding: 18px; color: var(--muted); margin: 0; }

.foot {
  max-width: 1180px; margin: 0 auto;
  padding: 8px 24px 28px;
  display: flex; flex-wrap: wrap; gap: 14px;
  color: var(--muted); font-size: 0.78rem;
}
.foot a { color: var(--accent); text-decoration: none; }
