:root {
  --bg: #f3f6f8;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #667085;
  --line: #d9e1e8;
  --line-soft: #edf1f5;
  --primary: #0f766e;
  --primary-soft: #e0f2ee;
  --danger: #c24135;
  --warning: #b7791f;
  --info: #2563a8;
  --nav: #10201d;
  --shadow: 0 14px 34px rgba(28, 45, 55, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "Microsoft YaHei UI", "Noto Sans SC", "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
}

button:hover {
  filter: brightness(.98);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px;
  color: #e6f3f0;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, .25), transparent),
    var(--nav);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 4px 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: var(--nav);
  background: #d7f4ec;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 3px;
  color: #9fb7b1;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav button {
  width: 100%;
  padding: 12px 14px;
  color: #bfd5d0;
  background: transparent;
  text-align: left;
}

.side-nav button.is-active,
.side-nav button:hover {
  color: #fff;
  background: rgba(255, 255, 255, .1);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

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

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  margin-bottom: 10px;
  font-size: 18px;
}

.ghost,
.menu-btn {
  color: var(--primary);
  border: 1px solid var(--line);
  background: #fff;
}

.menu-btn {
  display: none;
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 21px;
}

.notice {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.notice.error {
  border-color: var(--danger);
}

.is-hidden {
  display: none;
}

.page {
  display: none;
}

.page.is-active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric {
  position: relative;
  overflow: hidden;
  padding: 16px;
}

.metric::after {
  content: "";
  position: absolute;
  right: -24px;
  bottom: -32px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: rgba(15, 118, 110, .07);
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 32px;
}

.metric small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.metric.accent {
  background: linear-gradient(135deg, var(--primary-soft), #fff7e5);
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .8fr);
  align-items: center;
  gap: 18px;
  min-height: 188px;
  padding: 24px;
  overflow: hidden;
  background:
    radial-gradient(circle at 92% 12%, rgba(15, 118, 110, .16), transparent 28%),
    linear-gradient(135deg, #ffffff, #f4faf8 58%, #fff8eb);
}

.dashboard-hero h2 {
  max-width: 760px;
  margin-bottom: 10px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.12;
  letter-spacing: -.04em;
}

.dashboard-hero p {
  max-width: 640px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.8;
}

.dashboard-health {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.health-pill {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .74);
  box-shadow: 0 10px 24px rgba(28, 45, 55, .06);
}

.health-pill span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.health-pill strong {
  display: block;
  margin-top: 7px;
  font-size: 25px;
}

.health-pill.good strong {
  color: var(--primary);
}

.health-pill.warning strong {
  color: var(--warning);
}

.health-pill.danger strong {
  color: var(--danger);
}

.health-pill.info strong {
  color: var(--info);
}

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

.action-panel {
  min-height: 100%;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quick-actions button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "num title"
    "num desc";
  align-items: center;
  column-gap: 12px;
  min-height: 86px;
  padding: 14px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfd;
  text-align: left;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.quick-actions button:hover {
  transform: translateY(-2px);
  border-color: rgba(15, 118, 110, .35);
  box-shadow: 0 12px 24px rgba(28, 45, 55, .1);
  filter: none;
}

.quick-actions span {
  grid-area: num;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 900;
}

.quick-actions strong {
  grid-area: title;
  font-size: 15px;
}

.quick-actions em {
  grid-area: desc;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.dashboard-list {
  display: grid;
  gap: 9px;
}

.dashboard-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px;
  color: var(--ink);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #fbfcfd;
  text-align: left;
}

.dashboard-row:hover {
  border-color: rgba(15, 118, 110, .32);
  background: #f6fbf9;
  filter: none;
}

.row-main {
  min-width: 0;
}

.row-main strong,
.row-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-main strong {
  font-size: 14px;
}

.row-main small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.row-stat {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 12px;
  font-weight: 900;
}

.risk-row {
  border-left: 5px solid var(--line);
}

.risk-row.severity-critical {
  border-left-color: var(--danger);
}

.risk-row.severity-high {
  border-left-color: var(--warning);
}

.risk-row.severity-normal {
  border-left-color: var(--info);
}

.compact-list {
  max-height: 366px;
  overflow: auto;
}

.dashboard-empty {
  padding: 24px 14px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fbfcfd;
  text-align: center;
}

.panel {
  padding: 16px;
  margin-bottom: 14px;
}

.table-card {
  padding: 0;
  overflow: hidden;
}

.table-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.table-card-head h2 {
  margin-bottom: 5px;
}

.table-card-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.result-count {
  min-width: 64px;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.hero {
  min-height: 220px;
}

.hero h2 {
  max-width: 760px;
  font-size: 30px;
  line-height: 1.25;
}

.hero p {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.8;
}

.overview-grid,
.split-page,
.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 14px;
}

.module-list,
.settings-grid,
.settings-form {
  display: grid;
  gap: 10px;
}

.module-list span,
.settings-grid label {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8fafb;
}

.hint,
.meta,
.subtle {
  color: var(--muted);
  font-size: 12px;
}

.panel-subtitle {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.text-link {
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.settings-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.settings-form input[type="text"],
.settings-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 11px;
  outline: 0;
}

.settings-form input[type="text"]:focus,
.settings-form textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, .12);
}

.shop-config-panel {
  grid-column: 1 / -1;
}

.panel-head,
.toolbar,
.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toolbar {
  margin-bottom: 12px;
}

.product-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 220px 150px;
  align-items: end;
  padding: 16px 20px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--line-soft);
  background: #fbfcfd;
}

.form-control {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.form-control > span {
  font-weight: 700;
}

.searchbox {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.searchbox input {
  width: 100%;
  height: 40px;
  border: 0;
  outline: 0;
  background: transparent;
}

select,
input[type="file"] {
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.searchbox:focus-within,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, .12);
  outline: 0;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  color: var(--muted);
}

.table-wrap {
  max-height: calc(100vh - 215px);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: #4b5563;
  background: #f7f9fb;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

th[data-col="name"] {
  width: 210px;
}

th[data-col="category"] {
  width: 120px;
}

th[data-col="size"] {
  width: 145px;
}

th[data-col="price"] {
  width: 100px;
}

th[data-col="pack1"],
th[data-col="pack2"],
th[data-col="pack3"] {
  width: 135px;
}

th[data-col="remark"] {
  width: 220px;
}

th[data-col="source"] {
  width: 120px;
}

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

tbody tr:hover td {
  background: #f8fbfb;
}

td.price {
  font-weight: 800;
}

td.name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.name-main {
  display: inline-block;
  max-width: 100%;
  vertical-align: middle;
}

td.remark {
  max-width: 280px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-row td {
  background: #fffdf7;
  border-bottom-color: #f1e7ce;
}

.child-row td:first-child {
  padding-left: 48px;
  color: var(--muted);
  font-weight: 500;
}

.child-row td {
  background: #fff;
}

.fold-btn {
  width: 25px;
  height: 25px;
  margin-right: 8px;
  padding: 0;
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 900;
}

.tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag.neutral {
  color: #475467;
  background: #f2f4f7;
}

.price-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 800;
}

.operation-col {
  position: sticky;
  right: 0;
  z-index: 1;
  width: 82px;
  text-align: center;
  background: inherit;
  box-shadow: -8px 0 12px rgba(31, 41, 55, .03);
}

th.operation-col {
  z-index: 3;
  background: #f7f9fb;
}

.link-btn {
  padding: 4px 6px;
  color: var(--primary);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

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

.empty-cell {
  padding: 42px 16px;
  color: var(--muted);
  text-align: center;
}

.timeline,
.changes,
.comparison-list,
.order-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  max-height: calc(100vh - 230px);
  overflow: auto;
}

.import-item,
.change-item,
.comparison-item,
.order-card {
  padding: 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  text-align: left;
}

.order-list {
  padding: 16px 20px;
  margin-top: 0;
}

.order-main {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.order-main strong {
  margin-right: 8px;
}

.order-total {
  color: var(--primary);
  font-size: 22px;
  font-weight: 900;
}

.order-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.order-items span {
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: #f4f7f8;
  font-size: 12px;
}

.change-item strong,
.comparison-item strong,
.import-item strong {
  display: block;
  margin: 6px 0;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 12px;
  font-weight: 800;
}

.badge.updated {
  color: var(--info);
  background: #e3eefc;
}

.badge.deleted {
  color: var(--danger);
  background: #fae6e2;
}

.badge.pack {
  color: var(--warning);
  background: #fff0cf;
}

.compare-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .9fr);
  gap: 18px;
}

.compare-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.compare-stat {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafb;
}

.compare-stat span {
  color: var(--muted);
  font-size: 12px;
}

.compare-stat strong {
  display: block;
  margin-top: 5px;
  font-size: 24px;
}

.comparison-list {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.comparison-item {
  display: grid;
  gap: 7px;
  border-left: 5px solid var(--line);
}

.severity-critical {
  border-left-color: var(--danger);
}

.severity-high {
  border-left-color: var(--warning);
}

.severity-normal {
  border-left-color: var(--info);
}

.compare-values {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.compare-values span {
  max-width: 180px;
  padding: 4px 7px;
  border-radius: 999px;
  background: #f3f6f8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compare-values b {
  color: var(--primary);
}

.compare-values em {
  color: var(--danger);
  font-style: normal;
  font-weight: 800;
}

.upload {
  display: grid;
  align-content: start;
  gap: 12px;
}

.is-compact th,
.is-compact td {
  padding: 8px 10px;
  font-size: 13px;
}

dialog {
  width: min(820px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(15, 24, 33, .35);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-head button {
  padding: 4px 10px;
  color: var(--ink);
  background: transparent;
  font-size: 22px;
}

pre {
  max-height: 70vh;
  margin: 0;
  padding: 16px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
}

.mobile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(16, 32, 29, .3);
  opacity: 0;
  transition: opacity .18s ease;
}

.mobile-backdrop.is-open {
  opacity: 1;
}

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

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 21;
    width: min(290px, calc(100vw - 48px));
    transform: translateX(-102%);
    transition: transform .2s ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .menu-btn {
    display: block;
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .toolbar,
  .panel-head,
  .filter-row {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .dashboard-hero,
  .dashboard-health,
  .overview-grid,
  .split-page,
  .settings-layout,
  .compare-intro,
  .compare-stats {
    grid-template-columns: 1fr;
  }

  .dashboard-hero {
    padding: 18px;
  }

  .dashboard-hero h2 {
    font-size: 30px;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    max-height: none;
  }

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

  .table-card-head,
  .table-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
