:root {
  --bg: #f5f7fa;
  --bg-soft: #eef3f9;
  --panel: rgba(255, 255, 255, .92);
  --panel-solid: #fff;
  --line: rgba(17, 24, 39, .08);
  --line-strong: rgba(17, 24, 39, .12);
  --text: #111827;
  --muted: #6b7280;
  --muted-2: #94a3b8;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --soft-blue: #eff6ff;
  --green: #22c55e;
  --soft-green: #ecfdf3;
  --orange: #f59e0b;
  --soft-orange: #fffbeb;
  --red: #ef4444;
  --soft-red: #fef2f2;
  --shadow: 0 10px 40px rgba(15, 23, 42, .05);
  --shadow-hover: 0 18px 52px rgba(15, 23, 42, .10);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --space: 24px;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% -10%, rgba(37, 99, 235, .10), transparent 30%),
    radial-gradient(circle at 100% 0%, rgba(34, 197, 94, .08), transparent 24%),
    linear-gradient(180deg, #f8fafc 0%, var(--bg) 44%, #eef3f9 100%);
  color: var(--text);
  font-family: Inter, "HarmonyOS Sans", "MiSans", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button, input, select {
  font: inherit;
}

button:focus,
input:focus,
select:focus {
  outline: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}

button {
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}

button:hover {
  transform: translateY(-1px);
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: rgba(255, 255, 255, .78);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(22px);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  margin-bottom: 22px;
  color: #0f172a;
  font-size: 15px;
  font-weight: 800;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue), #60a5fa);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 24px rgba(37, 99, 235, .24);
}

.nav {
  width: 100%;
  height: 42px;
  border: 1px solid transparent;
  background: transparent;
  color: #334155;
  border-radius: 12px;
  padding: 0 12px;
  margin-bottom: 6px;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
}

.nav.active,
.nav:hover {
  background: var(--soft-blue);
  border-color: rgba(37, 99, 235, .10);
  color: var(--blue);
}

main {
  min-width: 0;
  max-width: 1720px;
  width: 100%;
  padding: 26px 28px 48px;
}

.topbar {
  min-height: 72px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  margin: 10px 0 0;
  font-size: 14px;
}

.primary, .ghost {
  height: 40px;
  border-radius: var(--radius-md);
  padding: 0 16px;
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 14px;
  font-weight: 750;
}

.primary {
  background: linear-gradient(180deg, #3b82f6, var(--blue));
  color: #fff;
  border-color: rgba(37, 99, 235, .88);
  box-shadow: 0 12px 28px rgba(37, 99, 235, .22);
}

.primary:hover {
  background: linear-gradient(180deg, #2563eb, var(--blue-dark));
  box-shadow: 0 16px 34px rgba(37, 99, 235, .28);
}

.ghost {
  background: rgba(255, 255, 255, .85);
  color: #334155;
}

.page {
  display: none;
  animation: pageIn .24s ease both;
}

.page.active { display: block; }

@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space);
  margin-bottom: var(--space);
}

.stat, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  transition: transform .24s ease, box-shadow .24s ease, border-color .24s ease;
}

.stat:hover, .panel:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(37, 99, 235, .16);
}

.stat {
  padding: 22px;
  min-height: 124px;
}

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

.stat strong {
  display: block;
  font-size: 30px;
  margin: 10px 0 8px;
  line-height: 1;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.grid {
  display: grid;
  gap: var(--space);
}

.grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(420px, .9fr);
}

.panel {
  overflow: hidden;
}

.panel-head {
  min-height: 64px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.88), rgba(255,255,255,.62));
}

.panel h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.table-wrap {
  overflow: auto;
}

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

th {
  color: #64748b;
  background: #f8fafc;
  font-weight: 750;
  font-size: 13px;
}

th, td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

tbody tr {
  transition: background .18s ease;
}

tbody tr:hover td {
  background: rgba(37, 99, 235, .035);
}

.tag {
  display: inline-flex;
  min-height: 24px;
  min-width: 54px;
  justify-content: center;
  align-items: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 10px;
}

.tag.ok { background: var(--soft-green); color: #16a34a; }
.tag.bad { background: var(--soft-red); color: var(--red); }
.tag.in { background: var(--soft-blue); color: var(--blue); }

.purchase-list {
  padding: 18px;
  display: grid;
  gap: 16px;
}

.purchase-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255,255,255,.8);
}

.purchase-card header {
  background: #fbfdff;
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
  color: #64748b;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}

.empty {
  padding: 56px;
  text-align: center;
}

.actions, .ops {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.link-btn, .danger-btn {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.link-btn { color: var(--blue); }
.danger-btn { color: var(--red); }
.muted { color: var(--muted); font-size: 12px; }
.hint { margin: 0; color: var(--muted); font-size: 12px; }

dialog {
  border: 0;
  border-radius: 20px;
  box-shadow: 0 28px 90px rgba(15, 23, 42, .28);
  width: min(720px, calc(100vw - 32px));
  padding: 0;
}

dialog::backdrop {
  background: rgba(15, 23, 42, .34);
  backdrop-filter: blur(6px);
}

.modal {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.modal-head, .modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-head h2 {
  margin: 0;
  font-size: 22px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  background: #f1f5f9;
  border-radius: 12px;
  font-size: 20px;
  cursor: pointer;
}

label {
  display: grid;
  gap: 8px;
  color: #475569;
  font-size: 13px;
  font-weight: 650;
}

input, select {
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}

input:focus, select:focus {
  border-color: rgba(37, 99, 235, .65);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .10);
}

.modal-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.line { border-top: 1px solid var(--line); }

.form-panel {
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 1fr 160px auto;
  gap: 14px;
  align-items: end;
  border-bottom: 1px solid var(--line);
}

.bom-editor {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.bom-editor-head,
.bom-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 120px 80px;
  gap: 10px;
  align-items: center;
}

.bom-editor-head {
  background: #f8fafc;
  color: #64748b;
  font-weight: 800;
  font-size: 13px;
  padding: 12px 14px;
}

.bom-row {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.bom-editor > .ghost {
  margin: 12px 14px 14px;
}

.assembly-workbench {
  background: rgba(255, 255, 255, .88);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.assembly-top {
  min-height: 92px;
  padding: 24px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(15, 23, 42, .03), rgba(37, 99, 235, .06)),
    rgba(255, 255, 255, .78);
}

.assembly-top h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 900;
}

.assembly-top label {
  min-width: 260px;
}

.assembly-grid {
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(280px, .9fr) minmax(420px, 1.25fr) minmax(300px, .85fr);
  gap: 22px;
  align-items: stretch;
}

.assembly-product {
  position: relative;
  min-height: 520px;
  padding: 26px 22px;
  border: 1px solid rgba(37, 99, 235, .10);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(239, 246, 255, .85), rgba(255, 255, 255, .92)),
    #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.72);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.nas-cube {
  width: 118px;
  height: 118px;
  margin: 18px 0 20px;
  border-radius: 28px;
  background:
    linear-gradient(145deg, #0f172a 0%, #1e293b 48%, #334155 100%);
  box-shadow:
    0 26px 50px rgba(15, 23, 42, .26),
    inset -12px -12px 24px rgba(0, 0, 0, .22),
    inset 10px 10px 22px rgba(255, 255, 255, .08);
  position: relative;
}

.nas-cube::before {
  content: "";
  position: absolute;
  inset: 22px 24px auto;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #22c55e);
  box-shadow: 0 22px 0 rgba(148, 163, 184, .35), 0 44px 0 rgba(148, 163, 184, .25);
}

.nas-cube::after {
  content: "";
  position: absolute;
  right: 22px;
  bottom: 20px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 7px rgba(34, 197, 94, .14);
}

.assembly-product h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
}

.assembly-product p {
  min-height: 22px;
  margin-bottom: 18px;
}

.assembly-requirements {
  width: 100%;
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.requirement-row {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .78);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  text-align: left;
}

.requirement-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.requirement-row b,
.requirement-row em {
  min-width: 58px;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
}

.requirement-row b {
  background: var(--soft-blue);
  color: var(--blue);
}

.requirement-row em {
  background: var(--soft-orange);
  color: #b45309;
}

.assembly-stock-panel,
.assembly-action-panel {
  min-height: 520px;
}

.assembly-stock-panel table td,
.assembly-stock-panel table th {
  padding: 15px 16px;
}

.assembly-available {
  margin: 18px;
  min-height: 78px;
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 18px 38px rgba(15, 23, 42, .18);
}

.assembly-controls {
  padding: 22px;
  display: grid;
  gap: 16px;
}

.qty-control {
  height: 56px;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: #fff;
}

.qty-control button {
  border: 0;
  background: #f8fafc;
  cursor: pointer;
  font-size: 24px;
  font-weight: 900;
  color: #0f172a;
}

.qty-control input {
  height: 56px;
  border: 0;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-radius: 0;
  text-align: center;
  font-size: 24px;
  font-weight: 900;
}

.quick-counts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.quick-counts button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: #334155;
  cursor: pointer;
  font-weight: 850;
}

.quick-counts button:hover {
  border-color: rgba(15, 23, 42, .22);
  background: #f8fafc;
}

.assemble-main-btn {
  width: 100%;
  height: 54px;
  border-radius: 16px;
  background: linear-gradient(180deg, #111827, #020617);
  border-color: #020617;
  box-shadow: 0 18px 38px rgba(15, 23, 42, .24);
  font-size: 16px;
}

.assemble-main-btn:hover {
  background: linear-gradient(180deg, #1f2937, #0f172a);
  box-shadow: 0 22px 46px rgba(15, 23, 42, .30);
}

.cost-list {
  margin-top: 4px;
  padding: 18px;
  border: 1px solid rgba(34, 197, 94, .20);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(236, 253, 243, .96), rgba(255, 255, 255, .92));
}

.cost-list h3 {
  margin: 0 0 12px;
  color: #166534;
  font-size: 15px;
  font-weight: 900;
}

.cost-line,
.cost-total {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #475569;
  font-size: 13px;
}

.cost-line b {
  color: #0f172a;
}

.cost-total {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(34, 197, 94, .22);
}

.cost-total strong {
  color: #15803d;
  font-size: 24px;
  font-weight: 950;
}

.success-pulse {
  animation: successPulse .68s ease both;
}

@keyframes successPulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .45); }
  100% { box-shadow: 0 0 0 18px rgba(34, 197, 94, 0); }
}

/* Unified page redesign */
.topbar {
  min-height: 104px;
  margin-bottom: 24px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .95), rgba(239, 246, 255, .78)),
    rgba(255, 255, 255, .86);
  box-shadow: var(--shadow);
}

.topbar p {
  max-width: 720px;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .92), rgba(248, 250, 252, .78));
}

.brand-mark {
  background: linear-gradient(145deg, #0f172a, #334155);
}

.nav {
  position: relative;
  height: 44px;
  padding-left: 36px;
}

.nav::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  transform: translateY(-50%);
}

.nav.active {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
  box-shadow: 0 14px 30px rgba(15, 23, 42, .16);
}

.nav.active::before {
  background: #22c55e;
  box-shadow: 0 0 0 6px rgba(34, 197, 94, .14);
}

.nav:hover:not(.active) {
  background: rgba(241, 245, 249, .9);
  color: #0f172a;
}

.stats {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.stat {
  position: relative;
  min-height: 142px;
  padding: 24px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,250,252,.86)),
    #fff;
}

.stat::before {
  content: "";
  position: absolute;
  right: 20px;
  top: 20px;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: #eff6ff;
}

.stat::after {
  content: "";
  position: absolute;
  right: 35px;
  top: 34px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--blue);
}

.stat:nth-child(2)::before { background: var(--soft-orange); }
.stat:nth-child(2)::after { background: var(--orange); }
.stat:nth-child(3)::before { background: var(--soft-green); }
.stat:nth-child(3)::after { background: var(--green); }
.stat:nth-child(4)::before { background: #f1f5f9; }
.stat:nth-child(4)::after { background: #0f172a; }
.stat:nth-child(5)::before { background: #fef2f2; }
.stat:nth-child(5)::after { background: var(--red); }

.stat-saleable::before {
  background: rgba(34, 197, 94, .12);
}

.stat-saleable::after {
  background: var(--green);
}

.stat.clickable {
  cursor: pointer;
}

.stat.clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 42px rgba(15, 23, 42, .12);
}

.stat span {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  font-weight: 800;
}

.stat strong {
  margin-top: 18px;
  font-size: 34px;
}

.panel {
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(255,255,255,.86));
}

.panel-head {
  min-height: 74px;
  padding: 20px 22px;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, .03), rgba(37, 99, 235, .05)),
    rgba(255, 255, 255, .76);
}

.panel h2 {
  font-size: 21px;
  font-weight: 900;
}

.table-wrap {
  margin: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

th {
  height: 48px;
  background: #f8fafc;
  color: #64748b;
}

th:first-child { border-top-left-radius: 18px; }
th:last-child { border-top-right-radius: 18px; }

tbody tr:last-child td {
  border-bottom: 0;
}

td:first-child {
  color: #0f172a;
  font-weight: 760;
}

.tag {
  min-height: 28px;
  min-width: 64px;
}

.tag.ok {
  border: 1px solid rgba(34, 197, 94, .16);
}

.tag.bad {
  border: 1px solid rgba(239, 68, 68, .18);
}

.tag.in {
  border: 1px solid rgba(37, 99, 235, .14);
}

.purchase-list {
  padding: 22px;
  gap: 18px;
}

.purchase-card {
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 12px 34px rgba(15, 23, 42, .04);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.purchase-card:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, .16);
  box-shadow: var(--shadow-hover);
}

.purchase-card header {
  min-height: 70px;
  padding: 18px 20px;
  background:
    linear-gradient(135deg, rgba(248, 250, 252, .96), rgba(239, 246, 255, .78));
  color: #475569;
}

.purchase-card header strong:first-child {
  color: #0f172a;
  font-size: 16px;
  font-weight: 900;
}

.purchase-card .table-wrap,
.purchase-card table {
  margin: 0;
  border: 0;
  border-radius: 0;
}

.empty {
  min-height: 260px;
  border: 1px dashed rgba(148, 163, 184, .55);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(248,250,252,.84), rgba(255,255,255,.92));
  display: grid;
  place-items: center;
}

.empty h2 {
  margin: 0;
  font-size: 22px;
}

.primary, .ghost {
  height: 42px;
  border-radius: 14px;
}

.ghost {
  background: #fff;
}

.link-btn,
.danger-btn {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
}

.link-btn {
  background: var(--soft-blue);
}

.danger-btn {
  background: var(--soft-red);
}

dialog {
  border-radius: 24px;
  background: rgba(255, 255, 255, .96);
}

.modal {
  padding: 24px;
}

.modal-head {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.modal-actions {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

label {
  color: #334155;
  font-weight: 800;
}

input, select {
  height: 44px;
  border-radius: 14px;
  background: #fff;
}

.bom-editor {
  border-radius: 18px;
}

.bom-editor-head {
  min-height: 48px;
  background: #f8fafc;
}

.bom-row {
  min-height: 62px;
}

#parts .panel,
#logs .panel,
#nas .panel,
#orders .panel,
#profit .panel,
#boms .panel,
#purchases .panel {
  min-height: 620px;
}

#dashboard .grid.two {
  align-items: start;
}

#dashboard .panel {
  min-height: 420px;
}

#profit .stat:nth-child(3) {
  background:
    linear-gradient(180deg, rgba(236,253,243,.92), rgba(255,255,255,.92));
}

.topbar {
  display: none;
}

main {
  padding-top: 24px;
}

.dashboard-filter-bar {
  min-height: 52px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.filter-tabs {
  height: 44px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .04);
  display: inline-grid;
  grid-template-columns: repeat(4, 74px);
  gap: 4px;
}

.filter-tabs button {
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #475569;
  cursor: pointer;
  font-size: 14px;
  font-weight: 850;
}

.filter-tabs button.active {
  background: #0f172a;
  color: #fff;
  box-shadow: 0 10px 22px rgba(15, 23, 42, .18);
}

#dashboard-filter-date {
  width: 170px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .04);
}

.panel-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}

.panel-tools select {
  width: 180px;
}

.panel-tools input[type="search"] {
  width: 280px;
}

.order-profit-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.order-profit-preview > div {
  min-height: 78px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(248,250,252,.96), rgba(255,255,255,.94));
}

.order-profit-preview span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
}

.order-profit-preview strong {
  color: #0f172a;
  font-size: 24px;
  font-weight: 950;
}

.order-profit-preview strong.negative {
  color: var(--red);
}

.purchase-items-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.purchase-items-head strong {
  color: #0f172a;
  font-size: 14px;
  font-weight: 900;
}

.purchase-items {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.purchase-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 120px 76px;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(248, 250, 252, .82);
}

.purchase-item-row label {
  margin: 0;
  min-width: 0;
}

.purchase-item-row select,
.purchase-item-row input {
  width: 100%;
  min-width: 0;
}

.purchase-item-remove {
  height: 42px;
  min-width: 72px;
  padding: 0 12px;
}

.purchase-item-remove:disabled {
  cursor: not-allowed;
  opacity: .35;
}

#purchases .panel-head {
  align-items: center;
}

#purchases .panel-head .primary {
  margin-left: 0;
}

.order-filter-tools select {
  width: 132px;
}

.order-filter-tools input[type="search"] {
  width: 230px;
}

#order-date-filter {
  width: 148px;
}

#orders .panel-head,
#nas .panel-head {
  align-items: center;
  flex-wrap: wrap;
}

.profit-filter-tools select {
  width: 132px;
}

#profit-date-filter {
  width: 148px;
}

#profit .panel-head {
  align-items: center;
  flex-wrap: wrap;
}

@media (max-width: 1180px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .brand { grid-column: 1 / -1; }
  main { padding: 22px 18px 36px; }
  .grid.two { grid-template-columns: 1fr; }
  .modal-row,
  .form-panel,
  .bom-editor-head,
  .bom-row { grid-template-columns: 1fr; }
  .assembly-top,
  .assembly-grid { grid-template-columns: 1fr; }
  .assembly-top { align-items: stretch; }
  .assembly-top label { min-width: 0; }
  .assembly-product,
  .assembly-stock-panel,
  .assembly-action-panel { min-height: auto; }
  .purchase-card header { grid-template-columns: 1fr; }
  .purchase-item-row { grid-template-columns: 1fr 1fr; }
  .purchase-item-row label:first-child { grid-column: 1 / -1; }
  .purchase-item-remove {
    grid-column: 1 / -1;
    width: 100%;
  }
}

/* V2 commercial dashboard polish */
:root {
  --bg: #eef5ff;
  --bg-soft: #e7f0fb;
  --panel: rgba(255, 255, 255, .94);
  --panel-solid: #fff;
  --line: rgba(30, 41, 59, .08);
  --line-strong: rgba(30, 41, 59, .14);
  --text: #172033;
  --muted: #6d7890;
  --muted-2: #a0abc0;
  --blue: #2f73ff;
  --blue-dark: #1857d7;
  --soft-blue: #edf4ff;
  --green: #16c784;
  --soft-green: #eafbf3;
  --orange: #ffb020;
  --soft-orange: #fff6df;
  --red: #f04438;
  --soft-red: #fff0ef;
  --shadow: 0 18px 54px rgba(30, 64, 175, .08);
  --shadow-hover: 0 24px 70px rgba(30, 64, 175, .14);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

body {
  background:
    linear-gradient(135deg, rgba(47, 115, 255, .13), transparent 30%),
    linear-gradient(180deg, #f5f9ff 0%, #edf5ff 54%, #f8fbff 100%);
  font-family: "Microsoft YaHei", "PingFang SC", "HarmonyOS Sans", "Segoe UI", sans-serif;
}

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

.sidebar {
  padding: 20px 14px;
  background:
    linear-gradient(180deg, rgba(244, 249, 255, .96), rgba(225, 238, 255, .88));
  border-right: 1px solid rgba(47, 115, 255, .08);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .7);
}

.brand {
  min-height: 52px;
  margin: 2px 4px 24px;
}

.brand > div {
  display: grid;
  gap: 2px;
}

.brand strong {
  font-size: 16px;
  letter-spacing: 0;
}

.brand small {
  color: #7d8ba5;
  font-size: 12px;
  font-weight: 700;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(145deg, #156bff, #5ab1ff);
  box-shadow: 0 14px 26px rgba(47, 115, 255, .26);
  font-weight: 950;
}

.nav {
  height: 46px;
  margin-bottom: 8px;
  border-radius: 13px;
  color: #5f6f86;
  font-size: 15px;
  font-weight: 800;
}

.nav::before {
  width: 9px;
  height: 9px;
  background: rgba(47, 115, 255, .24);
}

.nav.active {
  background: linear-gradient(135deg, #1870ff, #5a9cff);
  border-color: rgba(47, 115, 255, .4);
  color: #fff;
  box-shadow: 0 16px 30px rgba(47, 115, 255, .24);
}

.nav.active::before {
  background: #fff;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, .16);
}

.nav:hover:not(.active) {
  background: rgba(255, 255, 255, .72);
  color: #1f4fbf;
}

main {
  max-width: none;
  padding: 24px 28px 44px;
}

.topbar {
  display: none;
}

.dashboard-hero {
  min-height: 190px;
  margin-bottom: 18px;
  padding: 30px 34px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 82% 30%, rgba(22, 199, 132, .18), transparent 23%),
    radial-gradient(circle at 68% 10%, rgba(255, 176, 32, .18), transparent 18%),
    linear-gradient(120deg, rgba(255, 255, 255, .98), rgba(235, 244, 255, .92) 52%, rgba(229, 241, 255, .96));
  border: 1px solid rgba(47, 115, 255, .09);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  overflow: hidden;
  position: relative;
}

.dashboard-hero::after {
  content: "";
  width: 138px;
  height: 138px;
  position: absolute;
  right: 92px;
  top: 26px;
  border-radius: 34px;
  background:
    linear-gradient(145deg, #172033, #334155);
  box-shadow:
    0 30px 54px rgba(30, 41, 59, .20),
    inset 10px 10px 18px rgba(255,255,255,.08),
    inset -12px -16px 24px rgba(0,0,0,.24);
  transform: rotate(-8deg);
  opacity: .94;
}

.dashboard-hero::before {
  content: "";
  position: absolute;
  right: 126px;
  top: 70px;
  width: 58px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #46d3ff, #16c784);
  box-shadow: 0 26px 0 rgba(148, 163, 184, .34), 0 52px 0 rgba(148, 163, 184, .22);
  z-index: 1;
}

.dashboard-hero > div,
.dashboard-hero > button {
  position: relative;
  z-index: 2;
}

.eyebrow {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  color: #1d5ee6;
  background: rgba(47, 115, 255, .10);
  font-size: 12px;
  font-weight: 950;
}

.dashboard-hero h2 {
  margin: 14px 0 0;
  font-size: 34px;
  line-height: 1.18;
  font-weight: 950;
  color: #111827;
}

.dashboard-hero p {
  max-width: 580px;
  margin-top: 12px;
  color: #64748b;
  font-size: 15px;
}

.dashboard-filter-bar {
  justify-content: flex-start;
  margin: 0 0 18px;
}

.filter-tabs {
  background: rgba(255, 255, 255, .9);
  border-color: rgba(47, 115, 255, .10);
}

.filter-tabs button.active {
  background: linear-gradient(135deg, #1870ff, #5a9cff);
  box-shadow: 0 10px 22px rgba(47, 115, 255, .22);
}

.stats {
  grid-template-columns: repeat(5, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.stat {
  min-height: 136px;
  padding: 22px 20px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(249,252,255,.92));
  border-color: rgba(47, 115, 255, .08);
}

.stat span {
  background: transparent;
  padding: 0;
  color: #65748b;
  font-size: 14px;
}

.stat strong {
  color: #111827;
  font-size: 32px;
}

.stat small {
  color: #9aa6b8;
}

.stat::before {
  right: 18px;
  top: 18px;
  width: 44px;
  height: 44px;
  border-radius: 13px;
}

.panel {
  border-radius: 18px;
  border-color: rgba(47, 115, 255, .08);
}

.panel-head {
  min-height: 66px;
  padding: 18px 20px;
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(247,251,255,.88));
}

.panel h2 {
  font-size: 19px;
}

.table-wrap {
  margin: 14px;
  border-radius: 14px;
}

th {
  height: 44px;
  background: #f6f9fe;
}

td, th {
  padding: 14px 16px;
}

.primary {
  background: linear-gradient(135deg, #1870ff, #5a9cff);
  border-color: rgba(47, 115, 255, .55);
  box-shadow: 0 14px 28px rgba(47, 115, 255, .22);
}

.ghost {
  background: rgba(255, 255, 255, .9);
}

.purchase-card {
  border-radius: 16px;
}

.assembly-workbench {
  border-radius: 20px;
}

@media (max-width: 1280px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dashboard-hero::before,
  .dashboard-hero::after {
    display: none;
  }
}

/* V2.1 Business console refinement */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255,255,255,.42) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255,255,255,.38) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.35), transparent 58%);
}

.sidebar::after {
  content: "稳定版 V1 业务内核";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  min-height: 42px;
  border: 1px solid rgba(47, 115, 255, .12);
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #5271a7;
  background: rgba(255,255,255,.58);
  font-size: 12px;
  font-weight: 850;
}

.nav {
  overflow: hidden;
}

.nav::after {
  content: "";
  position: absolute;
  right: -18px;
  top: 7px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  opacity: 0;
  transition: opacity .18s ease;
}

.nav.active::after {
  opacity: 1;
}

.dashboard-hero {
  isolation: isolate;
}

.dashboard-hero h2 {
  max-width: 620px;
}

.stats .stat {
  animation: cardRise .34s ease both;
}

.stats .stat:nth-child(2) { animation-delay: .03s; }
.stats .stat:nth-child(3) { animation-delay: .06s; }
.stats .stat:nth-child(4) { animation-delay: .09s; }
.stats .stat:nth-child(5) { animation-delay: .12s; }

@keyframes cardRise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.stat strong {
  font-variant-numeric: tabular-nums;
  letter-spacing: .2px;
}

.stat small::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: .46;
  vertical-align: 1px;
}

.panel {
  position: relative;
}

.panel::before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(47,115,255,.28), transparent);
}

.panel-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.panel-head h2::before {
  content: "";
  width: 8px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #1870ff, #16c784);
}

tbody tr:hover td:first-child {
  color: #1857d7;
}

.tag {
  box-shadow: inset 0 1px 0 rgba(255,255,255,.72);
}

.purchase-card {
  border-color: rgba(47,115,255,.09);
}

.purchase-card header {
  grid-template-columns: minmax(180px, 1.2fr) minmax(120px, 1fr) minmax(120px, .8fr) minmax(20px, .2fr) auto;
}

.assembly-workbench {
  background:
    radial-gradient(circle at 14% 18%, rgba(47,115,255,.08), transparent 24%),
    radial-gradient(circle at 86% 0%, rgba(22,199,132,.10), transparent 20%),
    rgba(255,255,255,.94);
}

.assembly-top {
  background:
    linear-gradient(135deg, rgba(255,255,255,.98), rgba(237,244,255,.9));
}

.assembly-top h2 {
  color: #14213d;
}

.assembly-product {
  background:
    radial-gradient(circle at 50% 22%, rgba(47,115,255,.12), transparent 28%),
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(241,247,255,.92));
}

.nas-cube {
  transform: rotate(-4deg);
}

.assembly-available {
  background: linear-gradient(135deg, #14213d, #1857d7);
}

.cost-list {
  border-color: rgba(22,199,132,.24);
}

dialog {
  border: 1px solid rgba(47,115,255,.12);
}

.modal-head h2::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 22px;
  margin-right: 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, #1870ff, #16c784);
  vertical-align: -4px;
}

.modal-actions .primary {
  min-width: 118px;
}

.empty {
  color: #64748b;
}

.empty h2 {
  color: #172033;
}

.panel-tools select,
.panel-tools input[type="search"],
#dashboard-filter-date {
  border-color: rgba(47,115,255,.12);
}

.order-profit-preview > div {
  background:
    linear-gradient(135deg, rgba(255,255,255,.98), rgba(237,244,255,.82));
}

.order-profit-preview > div:last-child {
  background:
    linear-gradient(135deg, rgba(255,255,255,.98), rgba(234,251,243,.86));
}

@media (max-width: 1180px) {
  .sidebar::after {
    display: none;
  }
}

/* V2.2 UI/UX Pro Max pass: clarity, interaction, responsiveness */
.dashboard-hero::before,
.dashboard-hero::after {
  display: none;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.hero-device {
  position: relative;
  flex: 0 0 176px;
  width: 176px;
  height: 142px;
  border-radius: 28px;
  background: linear-gradient(145deg, #172033, #334155);
  box-shadow:
    0 28px 60px rgba(30, 41, 59, .22),
    inset 10px 10px 20px rgba(255,255,255,.08),
    inset -12px -16px 26px rgba(0,0,0,.24);
  transform: rotate(-5deg);
}

.hero-device span {
  position: absolute;
  left: 32px;
  right: 32px;
  top: 38px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #46d3ff, #16c784);
  box-shadow: 0 28px 0 rgba(148, 163, 184, .34), 0 56px 0 rgba(148, 163, 184, .22);
}

.hero-device i {
  position: absolute;
  right: 30px;
  bottom: 24px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #16c784;
  box-shadow: 0 0 0 8px rgba(22, 199, 132, .15);
}

button,
.stat.clickable,
select,
input {
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
  opacity: .62;
  transform: none;
  box-shadow: none;
}

button.is-loading {
  position: relative;
  color: rgba(255,255,255,.92);
}

button.is-loading::before {
  content: "";
  width: 14px;
  height: 14px;
  margin-right: 8px;
  display: inline-block;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.table-wrap {
  max-width: 100%;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

td:nth-child(n+3),
th:nth-child(n+3) {
  font-variant-numeric: tabular-nums;
}

.link-btn,
.danger-btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.danger-btn:hover {
  background: #fee2e2;
}

.link-btn:hover {
  background: #dbeafe;
}

.modal {
  max-height: min(86vh, 820px);
  overflow: auto;
}

.modal-head {
  position: sticky;
  top: -24px;
  z-index: 2;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px);
}

.modal-actions {
  position: sticky;
  bottom: -24px;
  z-index: 2;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px);
}

.purchase-item-row,
.bom-row {
  transition: border-color .18s ease, background .18s ease;
}

.purchase-item-row:focus-within,
.bom-row:focus-within {
  border-color: rgba(47, 115, 255, .34);
  background: #fff;
}

.assembly-top label,
.panel-tools select,
.panel-tools input,
#dashboard-filter-date {
  min-height: 44px;
}

.requirement-row {
  border-color: rgba(47, 115, 255, .10);
}

.requirement-row b,
.requirement-row em {
  min-height: 28px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

@media (max-width: 900px) {
  main {
    padding: 16px 12px 28px;
  }

  .dashboard-hero {
    min-height: auto;
    padding: 24px 20px;
  }

  .hero-device {
    display: none;
  }

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

  .filter-tabs {
    width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .dashboard-filter-bar,
  .panel-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-tools select,
  .panel-tools input[type="search"],
  #dashboard-filter-date,
  #order-date-filter,
  #profit-date-filter {
    width: 100%;
  }

  .modal {
    width: calc(100vw - 18px);
  }
}

.nas-row {
  cursor: pointer;
}

.nas-row:focus-visible {
  outline: 3px solid rgba(47, 115, 255, .24);
  outline-offset: -3px;
}

.nas-row:hover td {
  background: #f6f9ff;
}

.row-hint {
  display: block;
  margin-top: 4px;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 650;
}

.nas-cost-modal {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

#nas-cost-dialog {
  width: min(860px, calc(100vw - 48px));
  max-width: calc(100vw - 48px);
  overflow: hidden;
}

.nas-cost-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.nas-cost-summary > div {
  min-height: 76px;
  padding: 14px 16px;
  border: 1px solid rgba(47, 115, 255, .12);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
}

.nas-cost-summary span {
  display: block;
  color: #64748b;
  font-size: 12px;
  font-weight: 850;
  margin-bottom: 8px;
}

.nas-cost-summary strong {
  display: block;
  color: #0f172a;
  font-size: 16px;
  font-weight: 950;
  word-break: break-all;
}

.nas-cost-summary > div:nth-child(3) strong,
.nas-cost-summary > div:nth-child(4) strong {
  color: #059669;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.table-wrap.compact {
  margin: 0;
}

.nas-cost-modal .table-wrap.compact {
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

.nas-cost-modal table {
  width: 100%;
  table-layout: fixed;
}

.nas-cost-modal th,
.nas-cost-modal td {
  padding: 14px 12px;
  white-space: normal;
  word-break: break-word;
}

.nas-cost-modal th:first-child,
.nas-cost-modal td:first-child {
  width: 36%;
}

.cost-skeleton,
.cost-error {
  grid-column: 1 / -1;
  min-height: 76px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(148, 163, 184, .55);
  border-radius: 16px;
  color: #64748b;
  background: #f8fafc;
}

.cost-error {
  color: #dc2626;
  background: #fff1f2;
  border-color: rgba(220, 38, 38, .20);
}

@media (max-width: 760px) {
  .nas-cost-summary {
    grid-template-columns: 1fr 1fr;
  }
}
