:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel2: #f0f4f8;
  --text: #333333;
  --muted: #666666;
  --border: #e4e7ed;
  --primary: #409eff;
  --warn: #e6a23c;
  --danger: #f56c6c;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica,
    Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}

a {
  color: inherit;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 1.25rem auto 3.5rem auto;
  padding: 0 0.625rem;
}

.legal-banner {
  background: #f5f7fa;
  color: #555555;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 4px;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  margin: 0 0 12px 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0.875rem 0.625rem;
  position: relative;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.2px;
  text-decoration: none;
}

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

.navtoggle {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
}

.navtoggle__bars {
  width: 18px;
  height: 2px;
  background: #606266;
  position: relative;
  border-radius: 2px;
}

.navtoggle__bars::before,
.navtoggle__bars::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: #606266;
  border-radius: 2px;
}

.navtoggle__bars::before {
  top: -6px;
}

.navtoggle__bars::after {
  top: 6px;
}

.nav__link {
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 10px;
  color: #333333;
  border: 1px solid transparent;
}

.nav__link:hover {
  color: #333333;
  border-color: var(--border);
  background: #eaf4ff;
}

.userbox {
  display: flex;
  gap: 10px;
  align-items: center;
  color: #666666;
  font-size: 14px;
  position: relative;
}

.userbox__name {
  color: #333333;
  font-weight: 600;
}

.userbox__role {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f0f4f8;
  color: #606266;
}

.usermenu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
  padding: 6px;
  z-index: 20;
}

.usermenu__toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.usermenu__avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f0f4f8;
  color: #333333;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  flex: 0 0 auto;
}

.usermenu__name {
  color: #333333;
  font-weight: 600;
}

.usermenu__role {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f0f4f8;
  color: #606266;
  font-size: 12px;
}

.usermenu__caret {
  margin-left: 2px;
  color: #606266;
  font-size: 12px;
}

.usermenu__item {
  display: block;
  padding: 10px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: #333333;
  border: 1px solid transparent;
}

.usermenu__item:hover {
  border-color: var(--border);
  background: #eaf4ff;
  color: #333333;
}

.usermenu__item--form {
  margin: 0;
}

.usermenu__btn {
  width: 100%;
  text-align: left;
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.pagehead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 0 14px 0;
}

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

.h2 {
  font-size: 16px;
  margin: 0 0 12px 0;
  color: #333333;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.text-danger {
  color: #dc3545;
}

.diff-line {
  display: block;
}

.diff-del {
  color: #dc3545;
  text-decoration: line-through;
}

.diff-add {
  color: #dc3545;
  background: rgba(220, 53, 69, 0.12);
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
}

.card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card--narrow {
  width: min(460px, 100%);
  margin: 40px auto;
}

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

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

@media (max-width: 920px) {
  .grid--2 {
    grid-template-columns: 1fr;
  }
}

.field {
  display: block;
  margin: 12px 0;
}

.field--inline {
  margin: 0;
}

.field__label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.input,
.select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  outline: none;
}

.input:focus,
.select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(64, 158, 255, 0.18);
}

.btn {
  border: 1px solid var(--border);
  background: #f0f4f8;
  color: #606266;
  border-radius: 12px;
  padding: 9px 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  background: #e4e7ed;
}

.btn--primary {
  background: #409eff;
  border-color: #409eff;
  color: #ffffff;
}

.btn--primary:hover {
  background: #66b1ff;
  border-color: #66b1ff;
}

.btn--warn {
  background: #e6a23c;
  border-color: #e6a23c;
  color: #ffffff;
}

.btn--warn:hover {
  background: #f2c660;
  border-color: #f2c660;
}

.btn--ghost {
  background: #f0f4f8;
  color: #606266;
}

.btn--tag {
  padding: 8px 10px;
}

.btn--mini {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 10px;
}

.inline {
  display: inline;
}

.alert {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin: 10px 0;
}

.alert--danger {
  border-color: rgba(245, 108, 108, 0.35);
  background: rgba(245, 108, 108, 0.08);
  color: #333333;
}

.table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table thead th {
  text-align: left;
  font-size: 13px;
  color: #333333;
  background: #f0f4f8;
}

.th-sortable {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.sort-ind {
  margin-left: 6px;
  font-size: 12px;
  color: #909399;
}

.sort-ind--active {
  color: #333333;
}

.table tbody tr:hover {
  background: #f5f9ff;
}

table[data-materials-table] tbody tr:hover {
  background: transparent;
}

.table tfoot .batch-summary-row > td {
  background: #f0f4f8;
  border-top: 1px solid var(--border);
  font-weight: 700;
}

.table tfoot .batch-summary-row > td:last-child {
  background: #f0f4f8;
}

.table[data-admin-materials] td[data-col="使用状态"],
.table[data-staff-materials] td[data-col="使用状态"] {
  text-align: center;
}

.table[data-admin-materials] .use-tag,
.table[data-staff-materials] .use-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1;
}

.use-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1;
}

.table[data-admin-materials] .use-tag--unused,
.table[data-staff-materials] .use-tag--unused {
  background: #ecfdf3;
  color: #16a34a;
}

.use-tag--unused {
  background: #ecfdf3;
  color: #16a34a;
}

.table[data-admin-materials] .use-tag--used,
.table[data-staff-materials] .use-tag--used {
  background: #eff6ff;
  color: #dc2626;
}

.use-tag--used {
  background: #eff6ff;
  color: #dc2626;
}

.table[data-admin-materials] tbody tr.row-latest-action {
  box-shadow: 0 0 8px rgba(64, 158, 255, 0.25);
  transition: all 0.3s ease;
  position: relative;
  z-index: 2;
}

.table[data-admin-materials] tbody tr.row-latest-action > td {
  background-color: #e6f4ff !important;
}

.table[data-admin-materials] tbody tr.row-latest-action:hover > td {
  background-color: #e6f4ff !important;
}

.table[data-staff-materials] tbody tr.row-latest-action {
  transition: all 0.3s ease;
}

.table[data-staff-materials] tbody tr.row-latest-action > td {
  background-color: #dbeafe !important;
}

.table[data-staff-materials] tbody tr.row-latest-action:hover > td {
  background-color: #dbeafe !important;
}

.table[data-staff-materials] tbody tr.row-latest-action > td:first-child {
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

.table[data-staff-materials] tbody tr.row-latest-action > td:last-child {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

.table[data-admin-materials] tbody tr.row-latest-action > td:first-child {
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

.table[data-admin-materials] tbody tr.row-latest-action > td:last-child {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

.t-right {
  text-align: right;
}

.col-seq {
  width: 64px;
}

.cell {
  max-width: 520px;
  word-break: break-word;
}

.copyable-text {
  cursor: pointer;
}

.txt-rename-link {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: #eeeeee;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.txt-rename-link::after {
  content: "✎";
  font-size: 13px;
  line-height: 1;
  color: #c0c4cc;
  flex: 0 0 auto;
}

.txt-rename-link:hover {
  color: var(--primary);
  text-decoration-color: var(--primary);
  text-decoration-style: solid;
}

.txt-rename-link:hover::after {
  color: var(--primary);
}

.copyable-cell {
  cursor: pointer;
}

.copyable-cell .copyable-text {
  color: inherit;
  text-decoration: underline;
}

.copyable-cell:hover .copyable-text {
  color: inherit;
}

.row-click-highlight > td {
  background-color: #e6f4ff !important;
}

.table[data-staff-materials] tbody tr.row-click-highlight > td {
  background-color: #dbeafe !important;
}

.row {
  display: flex;
  align-items: center;
}

form.row.row--gap {
  align-items: flex-end;
}

form[data-sold-filter-form] .txt-sold-filter__options {
  min-height: 42px;
}

.row--gap {
  gap: 10px;
  flex-wrap: wrap;
}

.row--between {
  justify-content: space-between;
}

.pager {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.pager__info {
  color: #666666;
}

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

.pager__btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 4px;
  border: 1px solid #e4e7ed;
  background: #ffffff;
  color: #333333;
  cursor: pointer;
  font-size: 14px;
}

.pager__btn:hover {
  background: #f5f7fa;
}

.pager__btn:disabled {
  background: #f5f7fa;
  color: #999999;
  cursor: not-allowed;
}

.pager__jump {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pager__input {
  width: 72px;
  height: 36px;
  border-radius: 4px;
  border: 1px solid #e4e7ed;
  padding: 0 8px;
  font-size: 14px;
  color: #333333;
  outline: none;
  background: #ffffff;
}

.pager__input:focus {
  border-color: #409eff;
  box-shadow: 0 0 0 4px rgba(64, 158, 255, 0.12);
}

.pager__unit {
  color: #666666;
  font-size: 14px;
}

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

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  color: #606266;
  background: #f0f4f8;
}

.pill--ok {
  border-color: rgba(103, 194, 58, 0.35);
  background: rgba(103, 194, 58, 0.12);
  color: #67c23a;
}

.pill--muted {
  background: #f0f4f8;
}

.pill--color {
  text-transform: uppercase;
}

.pill--none {
  background: #f0f4f8;
}

.pill--red {
  border-color: rgba(245, 108, 108, 0.35);
  background: rgba(245, 108, 108, 0.12);
  color: #f56c6c;
}

.pill--yellow {
  border-color: rgba(230, 162, 60, 0.35);
  background: rgba(230, 162, 60, 0.14);
  color: #e6a23c;
}

.pill--green {
  border-color: rgba(103, 194, 58, 0.35);
  background: rgba(103, 194, 58, 0.12);
  color: #67c23a;
}

.pill--blue {
  border-color: rgba(64, 158, 255, 0.35);
  background: rgba(64, 158, 255, 0.12);
  color: #409eff;
}

.row-color--red {
  background: rgba(245, 108, 108, 0.1);
}

.row-color--yellow {
  background: rgba(230, 162, 60, 0.1);
}

.row-color--green {
  background: rgba(103, 194, 58, 0.08);
}

.row-color--blue {
  background: rgba(64, 158, 255, 0.08);
}

.row-color--none {
  background: #ffffff;
}

.table[data-admin-materials] tbody tr.row-resend--1 {
  background: rgba(255, 244, 180, 0.55);
}

.table[data-admin-materials] tbody tr.row-resend--2 {
  background: rgba(255, 214, 170, 0.55);
}

.table[data-admin-materials] tbody tr.row-resend--3p {
  background: rgba(255, 170, 170, 0.45);
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.tabs__tab {
  appearance: none;
  border: 1px solid var(--border);
  background: #ffffff;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.tabs__tab[aria-selected="true"],
.tabs__tab.tabs__tab--active {
  background: rgba(17, 28, 51, 0.92);
  border-color: rgba(17, 28, 51, 0.92);
  color: #e6edf7;
}

.tabs__pane {
  margin-top: 12px;
}

.tab-scroll {
  overflow-x: auto;
}

@media (max-width: 1199px) and (min-width: 768px) {
  body {
    font-size: 15px;
  }

  .btn {
    min-height: 44px;
  }

  .pager__btn,
  .pager__input {
    height: 44px;
  }

  .table {
    font-size: 14px;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 767px) {
  body {
    font-size: 14px;
  }

  .btn {
    min-height: 44px;
  }

  .pager__btn,
  .pager__input {
    height: 44px;
  }

  .navtoggle {
    display: inline-flex;
    flex: 0 0 auto;
  }

  .nav {
    display: none;
  }

  body.nav-open .nav {
    display: flex;
  }

  body.nav-open .nav[data-top-nav] {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 6px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
    padding: 6px;
    z-index: 21;
  }

  body.nav-open .nav[data-top-nav] .nav__link {
    display: block;
    width: 100%;
  }

  .table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table[data-materials-table] thead {
    display: none;
  }

  table[data-materials-table],
  table[data-materials-table] tbody,
  table[data-materials-table] tr,
  table[data-materials-table] td {
    display: block;
    width: 100%;
  }

  table[data-materials-table] tr {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem;
    margin-top: 0.75rem;
  }

  table[data-materials-table] td {
    padding: 0.35rem 0;
    border: none;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
  }

  table[data-materials-table] td::before {
    content: attr(data-col) "：";
    color: var(--muted);
    flex: 0 0 auto;
    max-width: 45%;
  }

  table[data-materials-table] td[data-col="操作"] {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: space-between;
    padding-top: 0.75rem;
    margin-top: 0.5rem;
    border-top: 1px dashed rgba(0, 0, 0, 0.08);
  }

  table[data-materials-table] td[data-col="操作"]::before {
    content: "";
    display: none;
  }

  table[data-materials-table] td[data-col="操作"] .btn {
    flex: 1 1 calc(50% - 0.5rem);
  }
}

.text-link {
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}

a.text-link {
  cursor: pointer;
}

.hover-card {
  position: fixed;
  width: 360px;
  max-width: calc(100vw - 20px);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
  z-index: 10000;
  padding: 12px 12px;
}

.hover-card__title {
  font-weight: 800;
  margin-bottom: 8px;
}

.hover-card__row {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px dashed rgba(0, 0, 0, 0.08);
}

.hover-card__row:first-child {
  border-top: none;
}

.hover-card__label {
  color: var(--muted);
  font-size: 12px;
}

.hover-card__value {
  font-size: 12px;
  word-break: break-word;
}

.hover-card__value--copy {
  text-decoration: underline;
  cursor: pointer;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
}

.modal__panel {
  position: relative;
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  margin: 16px auto;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #ffffff;
  z-index: 1;
}

.modal__title {
  font-weight: 800;
}

.modal__body {
  padding: 12px 12px;
}

.row-voided {
  opacity: 0.55;
  text-decoration: line-through;
}

.table tbody tr.row-voided > td {
  background-color: #e9e9e9 !important;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 140px;
  background: #ffffff;
}

.stat__label {
  font-size: 12px;
  color: var(--muted);
}

.stat__value {
  font-size: 20px;
  font-weight: 800;
  margin-top: 4px;
}

.progress__track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f0f4f8;
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  background: linear-gradient(90deg, rgba(64, 158, 255, 0.9), rgba(103, 194, 58, 0.85));
  width: 0%;
}

.progress__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.imggrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.imgcard {
  display: block;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
}

.imgcard__img {
  width: 100%;
  height: 160px;
  object-fit: contain;
  display: block;
}

.footer {
  border-top: 1px solid var(--border);
  background: #ffffff;
}

.footer__inner {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0;
  color: var(--muted);
  font-size: 13px;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  pointer-events: auto;
}

.modal[hidden] {
  display: none !important;
}

.modal[data-modal-level="1"] {
  z-index: 50;
}

.modal[data-modal-level="2"] {
  z-index: 60;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 0;
}

.modal__panel {
  position: relative;
  width: min(980px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  z-index: 1;
}

.linklike {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
}
