:root {
  color-scheme: dark;
  --bg: #020617;
  --panel: rgba(15, 23, 42, 0.82);
  --panel-2: rgba(20, 30, 52, 0.78);
  --line: rgba(125, 211, 252, 0.18);
  --muted: #8090aa;
  --text: #e8f0fb;
  --cyan: #7dd3fc;
  --amber: #f8d85d;
  --green: #8df0bc;
  --red: #fb7185;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: radial-gradient(circle at 18% -10%, rgba(14, 165, 233, 0.2), transparent 34%),
    radial-gradient(circle at 82% 4%, rgba(245, 158, 11, 0.11), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.page {
  min-height: 100vh;
}

.hero {
  position: relative;
  min-height: 250px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background-image: linear-gradient(to bottom, rgba(2, 6, 23, 0.2), #020617 92%), url("./hero-bg.jpg");
  background-position: center;
  background-size: cover;
}

.hero-inner,
.shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
}

.hero-inner {
  padding: 44px 0 58px;
  text-align: center;
}

.topbar {
  position: absolute;
  inset: 18px 16px auto;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.pill,
.ghost-btn,
.primary-btn,
.danger-btn,
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: var(--cyan);
  padding: 8px 12px;
  line-height: 1;
  text-decoration: none;
}

.ghost-btn,
.primary-btn,
.danger-btn {
  border-radius: 8px;
  min-height: 38px;
}

.primary-btn {
  background: rgba(125, 211, 252, 0.16);
  color: #dff7ff;
}

.danger-btn {
  border-color: rgba(251, 113, 133, 0.3);
  background: rgba(251, 113, 133, 0.08);
  color: #fda4af;
}

.ghost-btn:hover,
.primary-btn:hover,
.danger-btn:hover,
.chip:hover {
  border-color: rgba(125, 211, 252, 0.48);
  background: rgba(30, 41, 59, 0.94);
}

h1 {
  margin: 14px 0 8px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.05;
  letter-spacing: 0;
}

.subtitle {
  margin: 0 auto;
  max-width: 720px;
  color: #a1acc2;
  font-size: 17px;
}

.shell {
  padding: 26px 0 42px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

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

.card,
.stat,
.material-card,
.rank-item,
.plan-item {
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
}

.card {
  padding: 22px;
}

.card.soft {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.9), rgba(6, 11, 27, 0.86));
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.title-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon {
  width: 22px;
  height: 22px;
  color: var(--cyan);
}

.muted {
  color: var(--muted);
}

.stat {
  padding: 18px;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  margin-top: 8px;
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1;
  font-weight: 800;
}

.amber {
  color: var(--amber);
}

.cyan {
  color: var(--cyan);
}

.green {
  color: var(--green);
}

.red {
  color: var(--red);
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(125, 211, 252, 0.28);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.62);
  color: #dff7ff;
  padding: 12px 13px;
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(125, 211, 252, 0.62);
  box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.08);
}

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

.ops-inputs {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 118px 118px;
  gap: 10px;
  min-width: min(520px, 100%);
}

.mini-field input {
  min-height: 42px;
}

.chip {
  min-height: 34px;
  padding: 7px 10px;
  color: #c6d6eb;
}

.chip.active {
  border-color: rgba(125, 211, 252, 0.58);
  background: rgba(125, 211, 252, 0.16);
  color: #e6fbff;
}

.progress-shell {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: rgba(51, 65, 85, 0.7);
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #f59e0b, #7dd3fc, #34d399);
  transition: width 0.25s ease;
}

.progress-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 15px;
}

.progress-meta strong {
  color: #dff7ff;
  font-weight: 800;
}

.rank-item,
.plan-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-top: 10px;
  background: rgba(15, 23, 42, 0.72);
}

.plan-item {
  border-color: rgba(125, 211, 252, 0.25);
  background: rgba(8, 47, 73, 0.35);
}

.name {
  font-weight: 700;
}

.sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.materials-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 170px 170px auto;
  gap: 10px;
  margin: 28px 0 16px;
}

.template-panel {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 14px;
  align-items: end;
  border: 1px solid rgba(125, 211, 252, 0.16);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.28);
  padding: 14px;
  margin-bottom: 16px;
}

.template-copy {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.template-copy strong {
  color: var(--text);
  font-size: 16px;
}

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

.material-table-wrap {
  overflow: auto;
  max-height: min(72vh, 920px);
  border: 1px solid rgba(125, 211, 252, 0.18);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.34);
}

.material-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

.material-table th,
.material-table td {
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

.material-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(15, 23, 42, 0.98);
  color: #b8c6dc;
  font-size: 12px;
  font-weight: 700;
}

.material-table tbody tr {
  background: rgba(15, 23, 42, 0.46);
}

.material-table tbody tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.28);
}

.material-table tbody tr:hover {
  background: rgba(8, 47, 73, 0.38);
}

.material-table tbody tr.staged {
  box-shadow: inset 3px 0 0 rgba(125, 211, 252, 0.64);
}

.material-table tbody tr.done {
  opacity: 0.72;
}

.material-table .num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.strong {
  font-weight: 800;
}

.material-name-cell {
  width: 210px;
  min-width: 210px;
}

.row-progress {
  overflow: hidden;
  height: 5px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(51, 65, 85, 0.62);
}

.row-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f59e0b, #7dd3fc, #34d399);
}

.custom-cell {
  display: grid;
  grid-template-columns: 78px 38px;
  gap: 6px;
  min-width: 134px;
}

.custom-cell input {
  min-height: 32px;
  padding: 6px 8px;
}

.custom-cell button,
.row-actions button {
  min-height: 32px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.84);
  color: #dcecff;
  padding: 0 9px;
}

.custom-cell button:hover,
.row-actions button:hover {
  border-color: rgba(125, 211, 252, 0.52);
  background: rgba(8, 47, 73, 0.58);
}

.row-actions {
  display: grid;
  grid-template-columns: repeat(4, max-content);
  gap: 6px;
  min-width: 280px;
}

.material-card {
  padding: 16px;
  background: linear-gradient(180deg, rgba(20, 30, 52, 0.86), rgba(15, 23, 42, 0.76));
}

.material-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
}

.badge {
  height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(125, 211, 252, 0.12);
  color: var(--cyan);
  font-size: 12px;
  white-space: nowrap;
}

.material-numbers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.mini {
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.38);
  padding: 9px;
}

.mini span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.mini strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.material-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.custom-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}

.custom-stage input {
  min-height: 36px;
  padding: 8px 10px;
}

.material-actions button,
.custom-stage button {
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.82);
  color: #cbd5e1;
  min-height: 34px;
  padding: 0 10px;
}

.empty {
  border: 1px dashed rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.footer {
  color: #526076;
  text-align: center;
  padding: 8px 0 32px;
  font-size: 13px;
}

.hide {
  display: none !important;
}

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

  .materials-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .ops-inputs {
    grid-template-columns: 1fr 1fr;
    min-width: 0;
  }

  .ops-inputs .field:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .hero-inner,
  .shell {
    width: min(100% - 22px, 1220px);
  }

  .topbar {
    position: static;
    justify-content: center;
    flex-direction: column;
    margin-bottom: 18px;
  }

  .top-actions {
    justify-content: center;
  }

  .hero-inner {
    padding-top: 22px;
  }

  .grid.stats,
  .grid.ops,
  .grid.cols-2,
  .template-panel,
  .materials-toolbar,
  .ops-inputs {
    grid-template-columns: 1fr;
  }

  .ops-inputs .field:first-child {
    grid-column: auto;
  }

  .material-table-wrap {
    max-height: 76vh;
  }

  .card,
  .stat {
    padding: 16px;
  }

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