:root {
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --ink: #17211f;
  --muted: #687672;
  --line: #dfe6e3;
  --line-strong: #cad5d1;
  --sidebar: #182522;
  --sidebar-muted: #9eb1ab;
  --primary: #147d64;
  --primary-dark: #0c604c;
  --primary-soft: #e7f4ef;
  --blue: #2563a9;
  --blue-soft: #eaf1fa;
  --amber: #b96910;
  --amber-soft: #fff4df;
  --red: #b74242;
  --red-soft: #fbeaea;
  --violet: #76539f;
  --shadow: 0 8px 26px rgba(22, 37, 33, .08);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; }
body { background: var(--bg); font-size: 14px; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid rgba(20, 125, 100, .35); outline-offset: 2px; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; z-index: 30; height: 100vh; padding: 20px 14px; display: flex; flex-direction: column; background: var(--sidebar); color: #fff; }
.brand { height: 48px; padding: 0 8px; display: flex; gap: 11px; align-items: center; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.18); background: #1f8e70; border-radius: 6px; }
.brand-mark svg { width: 20px; height: 20px; }
.brand b { display: block; font-size: 16px; }
.brand small { display: block; margin-top: 3px; color: var(--sidebar-muted); font-size: 10px; }
.nav-list { min-height: 0; margin-top: 20px; padding-right: 3px; display: flex; flex: 1 1 auto; flex-direction: column; gap: 3px; overflow-y: auto; scrollbar-width: thin; }
.nav-item { position: relative; width: 100%; min-height: 42px; padding: 0 11px; border: 0; border-radius: 5px; display: grid; grid-template-columns: 20px 1fr auto; gap: 10px; align-items: center; background: transparent; color: #c4d0cc; text-align: left; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: #234238; color: #fff; box-shadow: inset 3px 0 #40c49e; }
.nav-item em { min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; display: grid; place-items: center; background: #b85e28; color: #fff; font-size: 11px; font-style: normal; }
.nav-divider { height: 1px; margin: 12px 8px; background: rgba(255,255,255,.1); }
.sidebar-foot { flex: 0 0 auto; margin-top: 10px; padding: 14px 10px 4px; border-top: 1px solid rgba(255,255,255,.1); }
.plan-line { display: flex; justify-content: space-between; color: var(--sidebar-muted); font-size: 11px; }
.plan-line strong { color: #fff; font-weight: 600; }
.balance-track { height: 4px; margin: 10px 0 8px; overflow: hidden; background: rgba(255,255,255,.1); border-radius: 2px; }
.balance-track span { display: block; width: 68%; height: 100%; background: #40c49e; }
.sidebar-foot small { color: #c8d5d1; font-size: 11px; }

.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; height: 64px; padding: 0 26px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 18px; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); }
.global-search { width: min(460px, 45vw); height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 5px; display: grid; grid-template-columns: 20px 1fr auto; gap: 8px; align-items: center; color: var(--muted); background: #f8faf9; }
.global-search input { min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }
.global-search kbd { padding: 2px 5px; border: 1px solid var(--line-strong); border-radius: 3px; background: #fff; color: var(--muted); font-size: 10px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.connection { margin-right: 6px; display: inline-flex; gap: 7px; align-items: center; color: var(--muted); font-size: 12px; white-space: nowrap; }
.connection i { width: 7px; height: 7px; border-radius: 50%; background: #27a77f; box-shadow: 0 0 0 3px #dff5ed; }
.icon-btn { position: relative; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 5px; display: inline-grid; place-items: center; background: #fff; color: #52615d; }
.icon-btn:hover { border-color: var(--line-strong); background: var(--surface-soft); color: var(--ink); }
.icon-btn.compact { width: 30px; height: 30px; }
.icon-btn.compact svg { width: 15px; height: 15px; }
.notify-dot { position: absolute; top: 7px; right: 7px; width: 6px; height: 6px; border-radius: 50%; background: #cf553e; box-shadow: 0 0 0 2px #fff; }
.account-btn { min-width: 164px; height: 42px; padding: 0 7px; border: 0; display: grid; grid-template-columns: 32px 1fr 16px; align-items: center; gap: 8px; background: transparent; text-align: left; color: var(--ink); }
.account-btn > span:first-child { width: 32px; height: 32px; border-radius: 5px; display: grid; place-items: center; background: #dceae5; color: var(--primary-dark); font-weight: 700; }
.account-btn b, .account-btn small { display: block; white-space: nowrap; }
.account-btn b { max-width: 90px; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.account-btn small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.mobile-menu { display: none; }

.content { min-height: calc(100vh - 64px); padding: 24px 26px 46px; }
.page-head { min-height: 48px; margin-bottom: 18px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.page-head h1 { margin: 0; font-size: 22px; line-height: 1.2; }
.page-head p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.head-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.date-chip { height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 4px; display: inline-flex; align-items: center; gap: 7px; background: #fff; color: var(--muted); font-size: 12px; }

.btn { min-height: 36px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: #fff; color: #31403c; font-weight: 600; font-size: 12px; }
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-soft); }
.btn.primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { border-color: #e2b4b4; color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { cursor: not-allowed; opacity: .52; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric-card { min-height: 120px; padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.metric-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; }
.metric-icon { width: 32px; height: 32px; border-radius: 5px; display: grid; place-items: center; }
.metric-icon.green { background: var(--primary-soft); color: var(--primary); }
.metric-icon.blue { background: var(--blue-soft); color: var(--blue); }
.metric-icon.amber { background: var(--amber-soft); color: var(--amber); }
.metric-icon.violet { background: #f1ebf7; color: var(--violet); }
.metric-value { margin-top: 10px; display: flex; align-items: flex-end; gap: 8px; }
.metric-value strong { font-size: 26px; line-height: 1; }
.metric-value small { padding-bottom: 2px; color: var(--muted); font-size: 11px; }
.metric-foot { margin-top: 9px; color: var(--muted); font-size: 11px; }
.metric-foot b { color: var(--primary); font-weight: 600; }

.dashboard-grid { margin-top: 12px; display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(270px, .75fr); gap: 12px; }
.dashboard-grid > *, .settings-layout > * { min-width: 0; }
.panel { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.panel-head { min-height: 51px; padding: 0 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.panel-head h2 { margin: 0; font-size: 14px; }
.panel-head p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.panel-body { padding: 16px; }
.chart-wrap { height: 232px; position: relative; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.task-list { list-style: none; padding: 0; margin: 0; }
.task-list li { min-height: 54px; padding: 9px 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; }
.task-list li:last-child { border-bottom: 0; }
.task-list i { width: 30px; height: 30px; border-radius: 5px; display: grid; place-items: center; }
.task-list i svg { width: 15px; height: 15px; }
.task-list b, .task-list small { display: block; }
.task-list b { font-size: 12px; }
.task-list small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.task-list strong { font-size: 17px; }
.recent-panel { margin-top: 12px; }

.toolbar { min-height: 48px; padding: 8px 12px; border: 1px solid var(--line); border-bottom: 0; border-radius: 6px 6px 0 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; background: #fff; }
.toolbar-left, .toolbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar-search { width: 230px; height: 32px; padding: 0 9px; border: 1px solid var(--line); border-radius: 4px; display: grid; grid-template-columns: 17px 1fr; gap: 6px; align-items: center; background: var(--surface-soft); color: var(--muted); }
.toolbar-search svg { width: 15px; height: 15px; }
.toolbar-search input { min-width: 0; border: 0; outline: 0; background: transparent; font-size: 12px; }
.segmented { padding: 2px; border: 1px solid var(--line); border-radius: 5px; display: inline-flex; background: var(--surface-soft); }
.segmented button { min-height: 27px; padding: 0 9px; border: 0; border-radius: 3px; background: transparent; color: var(--muted); font-size: 11px; }
.segmented button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(22,37,33,.1); }
.selection-summary { color: var(--muted); font-size: 11px; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 0 0 6px 6px; background: #fff; }
.table-wrap.standalone { border-radius: 6px; }
.data-table { width: 100%; min-width: 860px; border-collapse: collapse; }
.data-table th { height: 40px; padding: 0 12px; border-bottom: 1px solid var(--line); background: #f7f9f8; color: #6c7975; font-size: 10px; font-weight: 600; text-align: left; white-space: nowrap; }
.data-table td { height: 57px; padding: 8px 12px; border-bottom: 1px solid #edf1ef; color: #35423f; font-size: 12px; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafcfb; }
.data-table input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--primary); }
.data-table .select-column { width: 42px; min-width: 42px; padding-left: 14px; padding-right: 8px; }
.primary-cell { display: flex; gap: 9px; align-items: center; }
.primary-cell .thumb { width: 38px; height: 38px; flex: 0 0 38px; border: 1px solid var(--line); border-radius: 4px; display: grid; place-items: center; background: #eef2f0; color: #61706b; font-weight: 700; font-size: 10px; }
.primary-cell .thumb img { width: 100%; height: 100%; border-radius: 3px; display: block; object-fit: cover; }
.primary-cell b, .primary-cell small { display: block; }
.primary-cell b { max-width: 240px; overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-size: 12px; white-space: nowrap; }
.primary-cell small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.listing-stores { max-width: 150px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-id { color: var(--blue); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; font-weight: 600; }
.money { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.status { height: 23px; padding: 0 7px; border-radius: 3px; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; font-size: 10px; font-weight: 600; }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.green { background: var(--primary-soft); color: var(--primary-dark); }
.status.blue { background: var(--blue-soft); color: var(--blue); }
.status.amber { background: var(--amber-soft); color: var(--amber); }
.status.red { background: var(--red-soft); color: var(--red); }
.status.gray { background: #edf1ef; color: #65726e; }
.status.violet { background: #f1ebf7; color: var(--violet); }
.table-actions { display: flex; align-items: center; gap: 5px; }
.stock-value { font-variant-numeric: tabular-nums; }
.stock-value.low { color: var(--red); font-weight: 700; }
.muted { color: var(--muted); }
.tiny { font-size: 10px; }
.empty-row { padding: 48px !important; color: var(--muted) !important; text-align: center; }

.summary-strip { margin-bottom: 12px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); background: transparent; }
.summary-item { padding: 0 18px; border-right: 1px solid var(--line); }
.summary-item:last-child { border-right: 0; }
.summary-item small, .summary-item strong { display: block; }
.summary-item small { color: var(--muted); font-size: 10px; }
.summary-item strong { margin-top: 5px; font-size: 17px; }
.summary-item .summary-long { overflow-wrap: anywhere; font-size: 13px; line-height: 1.4; }

.receipt-progress { min-width: 112px; }
.receipt-progress span { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
.receipt-progress span b { color: var(--ink); }
.receipt-progress > i { height: 5px; margin-top: 6px; overflow: hidden; display: block; border-radius: 3px; background: #e8eeeb; }
.receipt-progress > i > em { height: 100%; display: block; border-radius: 3px; background: var(--primary); }
.quantity-delta { font-variant-numeric: tabular-nums; font-weight: 700; }
.quantity-delta.positive { color: var(--primary); }
.quantity-delta.negative, .money.negative { color: var(--red); }
.table-link { color: var(--blue); text-decoration: none; }
.table-link:hover { text-decoration: underline; }
.compact-table { width: 100%; min-width: 0; overflow-x: auto; }

.currency-band { padding: 14px 16px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.currency-band > div { min-width: 0; padding: 4px 16px; border-right: 1px solid var(--line); }
.currency-band > div:first-child { padding-left: 0; }
.currency-band > div:last-child { border-right: 0; }
.currency-band small, .currency-band strong { display: block; }
.currency-band small { color: var(--muted); font-size: 10px; }
.currency-band strong { margin-top: 6px; overflow-wrap: anywhere; font-size: 16px; }

.notice { margin-bottom: 14px; padding: 12px 14px; border: 1px solid #cbded7; border-left: 3px solid var(--primary); border-radius: 4px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; background: #f5fbf8; }
.notice.warning { border-color: #ead4ad; border-left-color: var(--amber); background: #fffaf1; }
.notice strong, .notice p { margin: 0; }
.notice strong { display: block; font-size: 12px; }
.notice p { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.5; }

.store-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.store-card, .warehouse-card { min-height: 174px; padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.store-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.store-ident { display: flex; align-items: center; gap: 10px; }
.country-mark { width: 38px; height: 38px; border-radius: 5px; display: grid; place-items: center; background: #f3e8c8; color: #6f5823; font-weight: 800; font-size: 11px; }
.store-ident b, .store-ident small { display: block; }
.store-ident small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.store-stats { margin-top: 22px; display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.store-stats div { padding-right: 10px; border-right: 1px solid var(--line); }
.store-stats div:last-child { border: 0; }
.store-stats small, .store-stats strong { display: block; }
.store-stats small { color: var(--muted); font-size: 10px; }
.store-stats strong { margin-top: 5px; font-size: 14px; }
.store-card-foot { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.store-card-foot small { color: var(--muted); font-size: 10px; }
.store-sync-meta { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.store-sync-actions { display: flex; align-items: center; gap: 2px; }
.store-sync-actions .btn { padding: 0 7px; }

.warehouse-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.warehouse-card { min-height: 148px; }
.warehouse-card .warehouse-icon { width: 34px; height: 34px; border-radius: 5px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); }
.warehouse-card h3 { margin: 12px 0 3px; font-size: 14px; }
.warehouse-card p { margin: 0; color: var(--muted); font-size: 10px; }
.warehouse-card footer { margin-top: 14px; display: flex; justify-content: space-between; align-items: center; }

.billing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bill-summary { padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.bill-summary h2 { margin: 0 0 16px; font-size: 14px; }
.balance-large { display: flex; align-items: flex-end; gap: 6px; }
.balance-large strong { font-size: 32px; line-height: 1; }
.balance-large span { padding-bottom: 3px; color: var(--muted); font-size: 11px; }
.bill-meta { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3,1fr); }
.bill-meta small, .bill-meta b { display: block; }
.bill-meta small { color: var(--muted); font-size: 10px; }
.bill-meta b { margin-top: 4px; font-size: 13px; }
.store-usage { display: flex; flex-direction: column; gap: 14px; }
.usage-line header { margin-bottom: 6px; display: flex; justify-content: space-between; font-size: 11px; }
.usage-line header span { color: var(--muted); }
.usage-bar { height: 6px; overflow: hidden; border-radius: 3px; background: #edf1ef; }
.usage-bar i { display: block; height: 100%; border-radius: 3px; background: var(--blue); }

.settings-layout { display: grid; grid-template-columns: minmax(0,1.45fr) minmax(280px,.75fr); gap: 12px; }
.settings-section { border-bottom: 1px solid var(--line); padding: 18px 0; }
.settings-section:first-child { padding-top: 0; }
.settings-section:last-child { border: 0; }
.settings-section h2 { margin: 0 0 6px; font-size: 14px; }
.settings-section > p { margin: 0 0 16px; color: var(--muted); font-size: 11px; }
.config-code { padding: 12px; overflow-x: auto; border: 1px solid #30403c; border-radius: 4px; background: #1d2926; color: #d7e5e0; font: 11px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre; }
.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li { min-height: 40px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 24px minmax(0, 1fr) minmax(0, 1fr); gap: 9px; align-items: center; }
.check-list li:last-child { border: 0; }
.check-list i { color: var(--primary); }
.check-list span { font-size: 11px; }
.check-list small { min-width: 0; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; text-align: right; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { margin-bottom: 6px; display: block; color: #4d5a56; font-size: 11px; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 4px; background: #fff; color: var(--ink); }
.field textarea { min-height: 82px; resize: vertical; }
.field small { margin-top: 5px; display: block; color: var(--muted); font-size: 10px; line-height: 1.5; }
.checkbox-row { min-height: 38px; margin: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 4px; display: flex; align-items: center; gap: 9px; background: var(--surface-soft); color: var(--muted); font-size: 11px; }
.checkbox-row input { width: 16px; height: 16px; flex: 0 0 16px; accent-color: var(--primary); }
.form-actions { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.line-section-head { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.line-section-head label { margin: 0; }
#purchase-lines, .receive-lines { display: flex; flex-direction: column; gap: 8px; }
.purchase-line { padding: 10px; border: 1px solid var(--line); border-radius: 5px; display: grid; grid-template-columns: minmax(190px, 1fr) 100px 120px 30px; gap: 8px; align-items: end; background: var(--surface-soft); }
.purchase-line .remove-line { margin-bottom: 4px; }
.receive-line { min-height: 66px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 5px; display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 14px; align-items: center; }
.receive-line b, .receive-line small { display: block; }
.receive-line b { font-size: 11px; }
.receive-line small { margin-top: 5px; color: var(--muted); font-size: 10px; }
.receive-line .field label { margin-bottom: 4px; }
.receive-meta { margin-top: 14px; }
.check-control { min-height: 40px; margin: 0 !important; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 4px; display: flex !important; align-items: center; gap: 9px; background: #fff; }
.check-control input { width: 16px; min-height: 16px; padding: 0; accent-color: var(--primary); }

.modal { width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0; overflow: hidden; border: 0; border-radius: 7px; box-shadow: var(--shadow); color: var(--ink); }
.modal.wide-modal { width: min(1020px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(11, 21, 18, .54); backdrop-filter: blur(2px); }
.modal-head { min-height: 70px; padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-head p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
#modal-body { max-height: calc(100vh - 112px); padding: 18px; overflow-y: auto; }

.catalog-tabs { width: max-content; margin: 0 0 14px; }
.catalog-tabs button { min-width: 138px; min-height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.catalog-tabs button svg { width: 15px; height: 15px; }
.catalog-tabs button b { min-width: 20px; padding: 2px 5px; border-radius: 10px; background: #e8eeeb; color: #50605b; font-size: 10px; }
.catalog-tabs button.active b { background: var(--primary-soft); color: var(--primary-dark); }
.primary-icon { color: var(--primary); border-color: #b7d8ce; background: var(--primary-soft); }
.danger-icon { color: #b42318; border-color: #efc2bd; background: #fff7f6; }
.danger-icon:hover { color: #8f1c13; border-color: #df9f97; background: #fff0ee; }
.capture-summary { margin-bottom: 4px; border: 1px solid var(--line); display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); background: var(--line); gap: 1px; }
.capture-summary > div { min-height: 58px; padding: 10px 12px; display: flex; flex-direction: column; justify-content: center; background: #fff; }
.capture-summary small,.capture-summary b { display: block; }
.capture-summary small { color: var(--muted); font-size: 9px; }
.capture-summary b { margin-top: 5px; font-size: 17px; }
.catalog-form-section { padding: 18px 0; border-bottom: 1px solid var(--line); }
.catalog-form-section:first-child { padding-top: 0; }
.catalog-form-section:last-of-type { border-bottom: 0; }
.catalog-form-section h3 { margin: 0 0 14px; font-size: 13px; }
.category-helper { padding: 12px 0 4px; border-bottom: 1px solid var(--line); }
.category-suggestions { margin-top: 7px; border: 1px solid var(--line); max-height: 180px; overflow-y: auto; }
.category-suggestions button { width: 100%; min-height: 48px; padding: 7px 9px; border: 0; border-bottom: 1px solid var(--line); display: block; background: #fff; text-align: left; }
.category-suggestions button:last-child { border-bottom: 0; }
.category-suggestions button:hover,.category-suggestions button.active { background: var(--primary-soft); }
.category-suggestions b,.category-suggestions small { display: block; }
.category-suggestions b { font-size: 10px; }
.category-suggestions small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.section-title { min-height: 30px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-title h3 { margin: 0; }
.section-title > span { color: var(--muted); font-size: 10px; }
.catalog-images { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.catalog-image-groups { display: grid; gap: 20px; }
.catalog-image-group + .catalog-image-group { padding-top: 18px; border-top: 1px solid var(--line); }
.image-group-head { margin-bottom: 10px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.image-group-head h4 { margin: 0; font-size: 13px; }
.image-group-head p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.image-group-head > b { min-width: 28px; padding: 4px 7px; border-radius: 4px; background: var(--surface-soft); color: var(--text); font-size: 11px; text-align: center; }
.catalog-image { min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.catalog-image > img { width: 100%; aspect-ratio: 1; display: block; object-fit: contain; background: var(--surface-soft); border-radius: 3px; }
.catalog-image > small { min-height: 16px; margin-top: 6px; display: block; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.catalog-image > div { min-height: 38px; padding-top: 7px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.compact-table { max-height: 310px; overflow: auto; border-radius: 5px; }
.compact-table .data-table { min-width: 720px; }
.compact-table .data-table td { height: 46px; }
.compact-table .data-table small { margin-top: 3px; display: block; color: var(--muted); font-size: 9px; }
.sku-thumb { width: 38px; height: 38px; display: block; object-fit: contain; border: 1px solid var(--line); border-radius: 3px; background: var(--surface-soft); }
.empty-inline { min-height: 56px; padding: 16px; display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.validation-summary { min-height: 62px; padding: 12px 14px; border-left: 3px solid var(--primary); display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: center; background: var(--primary-soft); }
.validation-summary.invalid { border-left-color: var(--red); background: var(--red-soft); }
.validation-summary svg { color: var(--primary); }
.validation-summary.invalid svg { color: var(--red); }
.validation-summary b,.validation-summary small { display: block; }
.validation-summary small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.validation-group { padding: 16px 0; border-bottom: 1px solid var(--line); }
.validation-group h3 { margin: 0 0 10px; font-size: 12px; }
.validation-group ul { margin: 0; padding-left: 18px; }
.validation-group li { margin: 7px 0; }
.validation-group li b,.validation-group li small { display: block; }
.validation-group li b { font-size: 11px; }
.validation-group li small { margin-top: 2px; color: var(--muted); font: 10px ui-monospace,Consolas,monospace; }
.attribute-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.attribute-list span { min-width: 0; padding: 10px; display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; background: #fff; }
.attribute-list b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.attribute-list code { color: var(--primary-dark); font-size: 10px; }
.attribute-list small { grid-column: 1 / -1; color: var(--muted); font-size: 9px; }
.catalog-download { padding-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.token-secret { margin-bottom: 14px; padding: 10px 12px; border: 1px solid #d8c58d; display: grid; grid-template-columns: minmax(0,1fr) 36px; gap: 8px; align-items: center; background: #fff9e8; }
.token-secret code { overflow-wrap: anywhere; font-size: 11px; }
.token-list { border-top: 1px solid var(--line); }
.token-list > div { min-height: 56px; padding: 8px 2px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.token-list b,.token-list small { display: block; }
.token-list b { font-size: 11px; }
.token-list small { margin-top: 4px; color: var(--muted); font-size: 9px; }

.toast-stack { position: fixed; z-index: 100; right: 20px; bottom: 20px; width: min(360px, calc(100vw - 40px)); display: flex; flex-direction: column; gap: 8px; }
.toast { min-height: 52px; padding: 10px 12px; border: 1px solid var(--line); border-left: 3px solid var(--primary); border-radius: 5px; display: grid; grid-template-columns: 22px 1fr; gap: 9px; align-items: center; background: #fff; box-shadow: var(--shadow); animation: toast-in .18s ease-out; }
.toast.error { border-left-color: var(--red); }
.toast b, .toast small { display: block; }
.toast b { font-size: 11px; }
.toast small { margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.4; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.spinner { width: 22px; height: 22px; border: 2px solid #d5e3de; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state { min-height: 55vh; display: grid; place-items: center; align-content: center; gap: 10px; color: var(--muted); font-size: 12px; }
.sidebar-scrim { display: none; }

@media (max-width: 1080px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .store-grid, .warehouse-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .account-btn { min-width: 36px; width: 36px; padding: 0; grid-template-columns: 32px; }
  .account-btn > span:nth-child(2), .account-btn > svg { display: none; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); width: 224px; transition: transform .18s ease; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 25; background: rgba(9,20,17,.46); }
  body.sidebar-open .sidebar-scrim { display: block; }
  .mobile-menu { display: inline-grid; flex: 0 0 36px; }
  .topbar { padding: 0 14px; }
  .global-search { width: min(460px, 100%); }
  .global-search kbd, .connection { display: none; }
  .content { padding: 18px 14px 38px; }
  .dashboard-grid, .settings-layout, .billing-grid { grid-template-columns: 1fr; }
  .currency-band { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 14px; }
  .currency-band > div:nth-child(2n) { border-right: 0; }
}

@media (max-width: 560px) {
  .topbar-actions .account-btn, .topbar-actions button[aria-label="通知"] { display: none; }
  .page-head { align-items: stretch; flex-direction: column; }
  .head-actions { justify-content: flex-start; }
  .metrics-grid, .store-grid, .warehouse-grid, .summary-strip { grid-template-columns: 1fr; }
  .summary-item { min-height: 48px; padding: 8px 4px; border-right: 0; border-bottom: 1px solid var(--line); }
  .summary-item:last-child { border-bottom: 0; }
  .metric-card { min-height: 108px; }
  .toolbar, .toolbar-left, .toolbar-right { align-items: stretch; flex-direction: column; }
  .toolbar-search { width: 100%; }
  .segmented { width: 100%; overflow-x: auto; }
  .segmented button { flex: 1 0 auto; }
  .form-grid { grid-template-columns: 1fr; }
  .catalog-form-section .section-title { align-items: flex-start; flex-direction: column; gap: 4px; }
  .catalog-images, .attribute-list, .capture-summary { grid-template-columns: 1fr; }
  .catalog-download { align-items: stretch; flex-direction: column; }
  .catalog-download .btn { justify-content: center; }
  .field.full { grid-column: auto; }
  .bill-meta { grid-template-columns: 1fr; gap: 12px; }
  .purchase-line { grid-template-columns: 1fr 1fr 30px; }
  .purchase-line .field:first-child { grid-column: 1 / -1; }
  .receive-line { grid-template-columns: 1fr; }
  .currency-band { grid-template-columns: 1fr; }
  .currency-band > div { padding: 8px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .currency-band > div:last-child { border-bottom: 0; }
  .toast-stack { right: 12px; bottom: 12px; width: calc(100vw - 24px); }
}

[hidden] { display: none !important; }
.read-value { min-height: 40px; padding: 10px 12px; border: 1px solid var(--line); background: #f5f7f6; color: var(--ink); font-weight: 700; }
.audit-action { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; color: #2d5f51; }
.ops-context { display: flex; flex-direction: column; gap: 2px; }
.ops-context b { font-size: 13px; }
.ops-context span { color: var(--muted); font-size: 10px; }
.ops-page .sidebar { background: #202326; }
.ops-page .brand-mark { background: #d7b85f; color: #202326; }
.ops-page .nav-item.active { background: #f3f5f4; color: #202326; }

.auth-page { min-height: 100vh; margin: 0; background: #eef1ef; color: var(--ink); }
.auth-layout { width: min(420px, calc(100vw - 32px)); min-height: 100vh; margin: 0 auto; display: flex; flex-direction: column; justify-content: center; gap: 22px; padding: 32px 0; }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand b { display: block; font-size: 20px; }
.auth-brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.auth-logo { width: 44px; height: 44px; display: grid; place-items: center; background: var(--sidebar); color: #fff; border-radius: 7px; }
.auth-logo svg { width: 23px; height: 23px; }
.auth-panel { padding: 28px; border: 1px solid #d5ddda; border-radius: 7px; background: #fff; box-shadow: 0 18px 45px rgba(20,35,30,.09); }
.auth-panel header { margin-bottom: 24px; }
.auth-panel h1 { margin: 0; font-size: 24px; }
.auth-panel header p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.auth-panel form { display: grid; gap: 16px; }
.password-field { position: relative; }
.password-field input { width: 100%; padding-right: 46px; }
.password-field .icon-btn { position: absolute; top: 3px; right: 3px; border: 0; }
.auth-error { padding: 10px 12px; border-left: 3px solid #b23b36; background: #fff2f1; color: #8c2823; font-size: 11px; line-height: 1.5; }
.auth-submit { width: 100%; justify-content: center; min-height: 42px; }
.auth-panel footer { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.auth-panel footer svg { width: 14px; height: 14px; color: var(--green); }

@media (max-width: 560px) {
  .auth-panel { padding: 22px 18px; }
  .ops-context { display: none; }
}
