:root {
  color-scheme: light;
  --ink: #1d2840;
  --muted: #5d6a80;
  --border: #dce3ee;
  --soft-border: #e8edf4;
  --canvas: #f3f6fb;
  --paper: #fff;
  --navy: #151f34;
  --accent: #334fcb;
  --accent-hover: #273fa9;
  --accent-pale: #edf1ff;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-size: 14px; }
h1, h2, h3, p, dl, dd { margin: 0; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; }
button, select, input[type="checkbox"] { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
button, input, select, textarea { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid #5271f0; outline-offset: 3px; }

.sr-only {
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}
.muted { color: var(--muted); }

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

.sidebar {
  min-height: 100vh;
  position: sticky;
  top: 0;
  align-self: start;
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--navy);
  color: #f5f7ff;
  padding: 28px 13px 14px;
}

.sidebar-heading { padding: 0 12px 27px; }
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: .04em;
}
.wordmark strong { font-weight: 750; letter-spacing: .055em; }
.brand-mark {
  width: 31px;
  height: 31px;
  padding: 8px 6px;
  display: grid;
  gap: 3px;
  place-content: center;
  background: #536ce7;
  color: #fff;
  border-radius: 8px;
}
.brand-mark i { width: 16px; height: 2px; border-radius: 2px; background: currentColor; }
.brand-mark i:nth-child(2) { width: 12px; }
.brand-mark i:nth-child(3) { width: 8px; opacity: .8; }

.sidebar-nav { display: grid; gap: 5px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  min-height: 42px;
  border-radius: 7px;
  color: #c1cae1;
  text-decoration: none;
}
.nav-link:hover { color: #fff; background: #24334f; }
.nav-link--active { color: #fff; background: #2b3d69; font-weight: 660; }
.nav-icon { flex: none; width: 16px; height: 16px; opacity: .85; position: relative; }
.nav-icon--table { border: 1.5px solid currentColor; border-radius: 3px; }
.nav-icon--table::before, .nav-icon--table::after {
  content: ""; position: absolute; top: 4px; left: 0; right: 0; border-top: 1px solid currentColor;
}
.nav-icon--table::after { top: 8px; }
.nav-icon--key::before {
  content: ""; width: 8px; height: 8px; border: 1.5px solid currentColor; border-radius: 50%;
  position: absolute; top: 2px; left: 1px;
}
.nav-icon--key::after {
  content: ""; width: 8px; height: 5px; border-top: 1.5px solid currentColor; border-right: 1.5px solid currentColor;
  position: absolute; left: 7px; top: 8px; transform: rotate(28deg);
}
.sidebar-account {
  display: grid;
  grid-template-columns: 31px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  margin-top: auto;
  padding: 12px 4px 2px;
  border-top: 1px solid #39445a;
}
.avatar {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 50%;
  color: #eaf0ff;
  background: #3f5386;
  font-weight: 700;
}
.account-text { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.account-text strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
.account-text small { color: #acb9d3; font-size: 11px; }
.logout-button {
  color: #c1cae1;
  border: 0;
  background: transparent;
  border-radius: 4px;
  padding: 5px 2px;
  font-size: 12px;
}
.logout-button:hover { color: #fff; text-decoration: underline; }

.main-panel { min-width: 0; padding: 30px 27px 35px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 0 0 21px; }
.page-heading h1, .auth-panel h1 { font-size: clamp(24px, 3vw, 30px); line-height: 1.25; letter-spacing: -.02em; }
.page-count { margin-top: 6px; color: var(--muted); font-variant-numeric: tabular-nums; }

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  color: #374761;
  font-weight: 660;
  font-size: 13px;
}
.field input, .field select, .field textarea {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 450;
}
.field input:not([type="file"]):not([readonly]):hover,
.field select:hover, .field textarea:hover { border-color: #aebbd3; }
.field input[readonly] { background: #f2f5fb; color: var(--muted); }
.field textarea { resize: vertical; }
.field-source { color: var(--muted); font-size: 12px; font-weight: 450; }

.button, .text-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 650;
}
.button--primary { background: var(--accent); color: #fff; }
.button--primary:hover:not(:disabled) { background: var(--accent-hover); }
.button--secondary { background: #fff; color: var(--ink); border-color: #cdd7e8; }
.button--secondary:hover:not(:disabled) { background: #f5f7fc; border-color: #aebbd3; }
.text-button { background: transparent; color: var(--accent); padding-inline: 8px; }
.text-button:hover { background: var(--accent-pale); }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  padding: 15px;
  margin-bottom: 14px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filters > .field { min-width: 101px; }
.filters > .filters-search { flex: 1 1 166px; max-width: 285px; }
.filters input[type="date"] { min-width: 124px; }
.filter-actions { display: flex; align-items: center; gap: 3px; }
.filter-actions .button, .filter-actions .text-button { min-height: 36px; }

.table-panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--paper); overflow: hidden; }
.export-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--soft-border);
}
.selection-summary { color: var(--muted); font-size: 13px; }
.export-actions, .pagination, .token-actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }

.table-viewport { max-height: min(70vh, 750px); overflow: auto; }
.tracker-table {
  width: 100%;
  border-spacing: 0;
  font-size: 13px;
  text-align: start;
}
.tracker-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 11px 12px;
  color: #475770;
  background: #f6f8fc;
  font-weight: 680;
  text-align: start;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tracker-table tr.item-row > * {
  padding: 9px 12px;
  border-bottom: 1px solid var(--soft-border);
  min-height: 47px;
  text-align: start;
}
.tracker-table tbody:last-of-type tr.item-row:last-child > * { border-bottom: 0; }
.tracker-table tr.item-row:hover > * { background: #f8faff; }
.tracker-table tr.item-row:has(input[type="checkbox"]:checked) > * { background: #eef3ff; }
.tracker-table .selection-cell { width: 40px; padding-inline: 12px; }
.selection-cell input { width: 15px; height: 15px; margin: 0; vertical-align: middle; accent-color: var(--accent); }
.tracker-table .order-cell { width: 127px; min-width: 114px; }
.tracker-table .product-cell { min-width: 157px; max-width: 250px; }
.tracker-table .data-cell { min-width: 74px; max-width: 156px; }
.tracker-table .data-cell--quantity, .tracker-table .files-cell, .tracker-table .action-cell { min-width: 57px; width: 1%; white-space: nowrap; }
.tracker-table .data-cell--quantity, .tracker-table .data-cell--total { font-variant-numeric: tabular-nums; }
.tracker-table .data-cell--variations, .tracker-table .data-cell--process { min-width: 137px; }
.tracker-table .action-cell { padding-right: 10px; }

.group-row th {
  padding: 8px 12px;
  border-block: 1px solid #e2e8f3;
  color: #34486c;
  background: #eef3fc;
  text-align: start;
  font-size: 13px;
  font-weight: 740;
}
.group-row small { margin-left: 9px; color: #566987; font-weight: 500; }
.order-number, .order-meta { display: block; }
.order-number { color: #273650; font-weight: 700; font-variant-numeric: tabular-nums; }
.order-meta { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.45; white-space: nowrap; }
.order-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 0;
  color: var(--accent);
  border-radius: 4px;
  padding: 3px 2px;
  margin-top: 1px;
  font-size: 11px;
  white-space: nowrap;
}
.order-chevron { width: 6px; height: 6px; border-right: 1.5px solid; border-bottom: 1.5px solid; transform: rotate(45deg); margin-top: -3px; }
.order-toggle[aria-expanded="false"] .order-chevron { transform: rotate(-45deg); margin-top: 0; }
.related-mark { display: block; margin-left: 7px; width: 11px; height: 11px; border-left: 1px solid #b9c8e1; border-bottom: 1px solid #b9c8e1; }
.product-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: none;
  color: #203355;
  text-align: start;
  line-height: 1.45;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.product-name:hover { color: var(--accent); text-decoration: underline; }
.cell-content { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.empty-value { color: #6c7890; }
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 20px;
  background: #eef2f8;
  color: #495773;
  font-size: 11px;
  font-weight: 660;
  white-space: nowrap;
}
.status-pill[data-status="处理中"], .status-pill[data-status="采购中"] { background: #eaf0ff; color: #2b49a8; }
.status-pill[data-status="已完成"], .status-pill[data-status="已采购"] { background: #e5f5ed; color: #216743; }
.status-pill[data-status="加急"], .status-pill[data-status="紧急"] { background: #fff1d9; color: #8b4b05; }
.attachment-count {
  padding: 3px 6px;
  border: 1px solid #dce5f5;
  border-radius: 5px;
  background: #f2f6fc;
  color: #3f5478;
  white-space: nowrap;
  font-size: 12px;
}
.attachment-count:hover { border-color: #aec0e1; }
.table-footer { display: flex; justify-content: space-between; align-items: center; gap: 9px; padding: 10px 14px; border-top: 1px solid var(--soft-border); font-size: 12px; }
.empty-table { min-height: 230px; padding: 35px 18px; display: grid; justify-items: center; align-content: center; gap: 10px; text-align: center; }
.empty-table h2 { font-size: 17px; }

.notice {
  padding: 10px 13px;
  margin: 0 0 13px;
  border: 1px solid #b9e4ce;
  border-radius: 7px;
  background: #ecf9f1;
  color: #255c45;
  overflow-wrap: anywhere;
}
.notice--error { border-color: #f1c6c6; background: #fff1f1; color: #942c2c; }

.item-dialog {
  width: min(740px, calc(100% - 28px));
  max-height: calc(100% - 36px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 22px 65px rgb(17 30 63 / .24);
}
.item-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.item-dialog::backdrop { background: rgb(18 29 50 / .56); }
.dialog-heading, .dialog-footer { padding: 14px 20px; display: flex; gap: 12px; align-items: center; background: var(--paper); }
.dialog-heading { border-bottom: 1px solid var(--border); justify-content: space-between; }
.dialog-heading h2 { font-size: 20px; line-height: 1.3; margin-top: 4px; overflow-wrap: anywhere; }
.dialog-heading .order-meta { white-space: normal; }
.close-button { flex: none; border: 0; background: #f0f3fb; border-radius: 6px; font-size: 21px; width: 31px; height: 31px; line-height: 1; }
.close-button:hover { background: #e5eafa; }
.dialog-body { overflow: auto; padding: 17px 20px; }
.dialog-footer { border-top: 1px solid var(--border); justify-content: end; }
.detail-grid, .edit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.detail-value { background: #f6f8fc; padding: 8px 10px; border-radius: 6px; }
.detail-value dt { margin-bottom: 4px; color: #526480; font-weight: 650; font-size: 12px; }
.detail-value dd { line-height: 1.5; overflow-wrap: anywhere; }
.detail-value dd > span:not(.status-pill) { white-space: pre-wrap; }
.detail-value--wide, .field--wide { grid-column: 1 / -1; }
.dialog-section { margin-top: 16px; }
.dialog-section h3 { margin-bottom: 10px; font-size: 15px; }
.upload-help { margin-bottom: 10px; font-size: 12px; }
.update-form .field input[type="file"] { padding: 6px; }
.update-form .field input[type="file"]::file-selector-button {
  margin-right: 6px;
  padding: 4px 7px;
  color: #354867;
  background: #eef2fa;
  border: 1px solid #dce4f1;
  border-radius: 4px;
  cursor: pointer;
}

.attachment-list { display: grid; gap: 6px; padding: 0; list-style: none; margin: 0; }
.attachment {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--soft-border);
  border-radius: 7px;
}
.attachment-preview, .attachment-icon { flex: none; display: block; width: 37px; height: 37px; border-radius: 5px; overflow: hidden; background: #ebf0fa; }
.attachment-preview img { width: 100%; height: 100%; display: block; object-fit: cover; }
.attachment-icon { display: grid; place-items: center; }
.attachment-icon::before { content: ""; width: 13px; height: 17px; border: 1.5px solid #6379a5; border-radius: 2px; }
.attachment-name { display: grid; gap: 3px; min-width: 0; margin-right: auto; }
.attachment-name strong { overflow-wrap: anywhere; font-size: 13px; }
.attachment-name small { color: var(--muted); }
.attachment-download { white-space: nowrap; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.auth-panel, .token-panel {
  padding: 26px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.auth-panel { width: min(100%, 400px); box-shadow: 0 12px 40px rgb(38 60 101 / .08); }
.auth-panel h1 { margin: 20px 0 6px; }
.auth-form { display: grid; gap: 13px; margin-top: 17px; }
.auth-form .button { width: 100%; min-height: 39px; }
.auth-panel .notice { margin: 12px 0 0; }
.token-panel { max-width: 650px; }
.token-panel h2 { margin-bottom: 8px; font-size: 18px; }
.token-panel p { margin-bottom: 12px; line-height: 1.6; }
.token-panel .field { margin-bottom: 13px; }
.token-panel input { font-family: ui-monospace, monospace; }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 157px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .sidebar-heading { padding-inline: 8px; }
  .main-panel { padding: 24px 18px 27px; }
}

@media (max-width: 690px) {
  .workspace { display: block; }
  .sidebar {
    position: static;
    display: flex;
    flex-flow: row wrap;
    align-items: center;
    justify-content: space-between;
    gap: 9px;
    min-height: 0;
    height: auto;
    padding: 9px 10px;
  }
  .sidebar-heading { padding: 0; }
  .sidebar-nav { order: 3; width: 100%; display: flex; align-items: center; }
  .nav-link { min-height: 33px; padding: 7px 9px; font-size: 12px; }
  .sidebar-account { max-width: 56%; margin: 0; padding: 0; border: 0; }
  .main-panel { padding: 17px 10px 24px; }
  .page-heading { margin-bottom: 14px; }
  .filters { gap: 8px; padding: 10px; margin-bottom: 9px; }
  .filters > .field { width: calc(50% - 4px); }
  .filters > .filters-search { flex: 1 1 100%; max-width: none; }
  .filters input[type="date"] { min-width: 0; }
  .filter-actions { margin-left: auto; }
  .export-bar { padding: 9px 10px; }
  .dialog-heading, .dialog-body, .dialog-footer { padding-inline: 13px; }
  .detail-grid, .edit-grid { gap: 8px; }
  .field input, .field select, .field textarea { font-size: 16px; }
}

@media print {
  .sidebar, .filters, .export-bar, .action-cell, .selection-cell, .table-footer, .item-dialog { display: none; }
  .workspace { display: block; }
  .main-panel { padding: 0; }
  .table-viewport { max-height: none; overflow: visible; }
}

.error-actions { margin-top: 16px; }

.account-admin-badge {
  align-self: start;
  border-radius: 4px;
  background: #344771;
  color: #edf1ff !important;
  padding: 1px 4px;
}

.nav-icon--users::before {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  top: 0;
  left: 5px;
  border: 1.5px solid;
  border-radius: 50%;
}
.nav-icon--users::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 7px;
  left: 1px;
  bottom: 0;
  border: 1.5px solid;
  border-radius: 7px 7px 3px 3px;
}

.admin-heading { align-items: center; }
.admin-breadcrumb + .admin-heading { max-width: 1120px; }
.admin-breadcrumb { display: flex; gap: 8px; align-items: center; margin-bottom: 15px; color: var(--muted); font-size: 13px; }
.admin-breadcrumb a { text-decoration: none; }
.admin-breadcrumb a:hover, .admin-account-link:hover { text-decoration: underline; }
.admin-table .item-row th { min-width: 150px; }
.admin-table :is(th, td) { min-width: 86px; }
.admin-table .action-cell { min-width: 65px; }
.admin-account-link { color: #203355; text-decoration: none; overflow-wrap: anywhere; font-weight: 700; }
.admin-privilege { color: #334baf; background: var(--accent-pale); }
.status-pill[data-token-state="active"] { background: #e5f5ed; color: #216743; }
.status-pill[data-token-state="expired"] { background: #fff1d9; color: #8b4b05; }
.status-pill[data-token-state="revoked"] { background: #f5eced; color: #84434a; }

.admin-layout {
  display: grid;
  max-width: 1120px;
  grid-template-columns: minmax(0, 1.7fr) minmax(260px, 1fr);
  align-items: start;
  gap: 15px;
}
.admin-profile-form, .admin-security { display: grid; gap: 13px; min-width: 0; }
.admin-card, .secret-card {
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--paper);
  border-radius: var(--radius);
  padding: 17px;
}
.admin-card h2, .secret-card h2 { font-size: 16px; margin-bottom: 11px; }
.admin-card > .muted { line-height: 1.6; }
.admin-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 11px; }
.admin-card-heading h2 { margin: 0; }
.admin-card-hint { margin-top: 12px; font-size: 13px; line-height: 1.45; }

.admin-checkbox { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; line-height: 1.45; }
.admin-checkbox input, .shop-option input { flex: none; margin: 0; width: 16px; height: 16px; accent-color: var(--accent); }
.account-state { align-self: end; min-height: 36px; padding-inline: 4px; }
.shop-search { display: flex; flex-wrap: wrap; align-items: end; gap: 7px 12px; margin-bottom: 9px; }
.shop-search .field { flex: 1 1 140px; max-width: 360px; }
.shop-search [data-shop-selected] { min-height: 35px; display: flex; align-items: center; font-size: 13px; }
.shop-checklist {
  display: grid;
  gap: 0 11px;
  grid-template-columns: repeat(auto-fit, minmax(min(185px, 100%), 1fr));
  max-height: 245px;
  overflow: auto;
  padding: 4px 8px;
  border: 1px solid var(--soft-border);
  border-radius: 6px;
}
.shop-option {
  display: grid;
  align-items: center;
  grid-template-columns: 16px min-content minmax(0, 1fr);
  gap: 7px;
  min-height: 35px;
  padding: 5px 4px;
  border-bottom: 1px solid var(--soft-border);
  font-size: 13px;
}
.shop-option:hover { background: #f6f8fc; }
.shop-option span { overflow-wrap: anywhere; }
.shop-empty { margin-top: 8px; }
.inactive-shops { margin-top: 12px; color: var(--muted); font-size: 12px; }
.inactive-shops ul { margin-block: 6px 0; padding-inline-start: 18px; }
.admin-profile-form:last-child { grid-column: 1 / -1; max-width: 720px; }
.admin-profile-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; padding-top: 2px; }

.admin-action { border-top: 1px solid var(--soft-border); }
.admin-action summary { color: var(--accent); font-weight: 650; padding: 10px 2px; cursor: pointer; }
.admin-action form { display: grid; justify-items: start; gap: 10px; padding: 2px 0 12px; }
.admin-action form p { max-width: 280px; line-height: 1.5; }
.admin-action .field { max-width: 142px; }
.button--danger { color: #8e2e38; border-color: #ecc9cd; background: #fff2f3; }
.button--danger:hover { background: #ffe6e9; }
.token-mask { margin: 3px 0 9px; color: var(--muted); font-family: ui-monospace, monospace; letter-spacing: .12em; }
.admin-token-details { margin-bottom: 8px; }
.admin-token-details div { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 9px; padding: 4px 0; font-size: 13px; }
.admin-token-details dt { color: var(--muted); }
.admin-token-details dd { overflow-wrap: anywhere; }
.secret-card { max-width: 1120px; margin-bottom: 13px; border-color: #b5c5f4; background: #f3f6ff; }
.secret-card p { margin-bottom: 10px; color: var(--muted); line-height: 1.5; }
.secret-card .field input { font-family: ui-monospace, monospace; background: var(--paper); }
.secret-card .token-actions { margin-top: 9px; }

@media (max-width: 850px) {
  .admin-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 690px) {
  .sidebar-nav { flex-wrap: wrap; }
  .admin-card, .secret-card { padding: 13px; }
}

.personal-token-form { display: grid; justify-items: start; gap: 9px; }
