:root {
  color-scheme: light;
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-muted: #eef1ed;
  --ink: #17201d;
  --muted: #66716d;
  --line: #d9dfda;
  --brand: #1f7656;
  --brand-dark: #15583f;
  --accent: #d7653d;
  --info: #2f66a0;
  --danger: #b83b3b;
  --warning: #9c6816;
  --shadow: 0 10px 30px rgba(24, 37, 31, .08);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.danger-text { color: var(--danger); }
.brand-text { color: var(--brand); }
.mono { font-family: Consolas, monospace; }
.nowrap { white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: 0 0 auto; }

.topbar {
  height: 64px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 36px; height: 36px; display: grid; place-items: center; color: white;
  background: var(--brand); border-radius: 6px;
}
.brand-name { font-size: 17px; font-weight: 700; white-space: nowrap; }
.brand-sub { display: block; color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.page-shell { width: min(1180px, calc(100% - 32px)); margin: 28px auto 52px; }
.page-title { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 20px; }
.page-title h1 { margin: 0; font-size: 26px; line-height: 1.2; letter-spacing: 0; }
.page-title p { margin: 5px 0 0; color: var(--muted); }

.btn {
  min-height: 40px; border: 1px solid transparent; border-radius: 6px; padding: 8px 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brand); color: #fff; font-weight: 600;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { color: var(--ink); background: var(--surface); border-color: var(--line); }
.btn.secondary:hover { background: var(--surface-muted); }
.btn.danger { background: var(--danger); }
.btn.ghost { background: transparent; color: var(--muted); padding-inline: 10px; }
.btn.ghost:hover { background: var(--surface-muted); color: var(--ink); }
.btn.icon-only { width: 40px; padding: 0; }
.btn.small { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.btn.full { width: 100%; }

.tabs, .segmented { display: flex; gap: 4px; align-items: center; }
.tabs { border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; }
.tab {
  border: 0; background: transparent; padding: 12px 15px; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap; display: flex; gap: 7px; align-items: center;
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }
.segmented { padding: 3px; background: var(--surface-muted); border-radius: 6px; }
.segmented button { border: 0; border-radius: 4px; padding: 7px 12px; background: transparent; color: var(--muted); }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; box-shadow: var(--shadow); }
.panel-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-head h2, .panel-head h3 { font-size: 16px; margin: 0; letter-spacing: 0; }
.panel-body { padding: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-2 > *, .grid-3 > * { min-width: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { min-height: 118px; padding: 18px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.stat-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
.stat-icon { width: 34px; height: 34px; display: grid; place-items: center; background: var(--surface-muted); border-radius: 6px; color: var(--brand); }
.stat-value { margin-top: 15px; font-size: 26px; line-height: 1; font-weight: 750; }
.stat-note { color: var(--muted); font-size: 12px; margin-top: 8px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-weight: 650; font-size: 13px; }
.field .hint { font-size: 12px; color: var(--muted); }
input, select, textarea {
  width: 100%; min-height: 42px; border: 1px solid #cbd3cd; border-radius: 6px;
  padding: 9px 11px; color: var(--ink); background: #fff; outline: none;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,118,86,.12); }
.amounts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.amount-chip { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 11px 6px; font-weight: 650; color: var(--ink); }
.amount-chip.active { border-color: var(--brand); background: #eaf5ef; color: var(--brand-dark); }
.amount-chip span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 500; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.field-gap, .panel-gap { margin-top: 16px; }
.inline-actions { display: flex; align-items: stretch; gap: 8px; min-width: 0; }
.inline-actions > input, .inline-actions > select { min-width: 0; flex: 1; }
.input-suffix { display: flex; align-items: center; border: 1px solid #cbd3cd; border-radius: 6px; background: #fff; overflow: hidden; }
.input-suffix:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,118,86,.12); }
.input-suffix input { border: 0; box-shadow: none !important; }
.input-suffix span { padding-right: 11px; color: var(--muted); white-space: nowrap; }

.table-tools { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.table-tools input, .table-tools select { width: auto; min-width: 150px; min-height: 38px; }
.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 740px; }
th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 650; background: #fafbfa; white-space: nowrap; }
td { font-size: 13px; }
tbody tr:hover { background: #fafcfb; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 8px; font-size: 12px; font-weight: 650; background: var(--surface-muted); color: var(--muted); white-space: nowrap; }
.badge.success { color: #176344; background: #e5f4ec; }
.badge.warning { color: #83540d; background: #fff1d8; }
.badge.danger { color: #9f2f2f; background: #fde7e7; }
.badge.info { color: #285f96; background: #e7f0fa; }

.goods-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.goods-card { border: 1px solid var(--line); border-radius: 7px; background: var(--surface); padding: 18px; display: flex; flex-direction: column; min-height: 190px; }
.goods-card-top { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.goods-visual { width: 42px; height: 42px; border-radius: 6px; display: grid; place-items: center; background: #eaf5ef; color: var(--brand); }
.goods-card h3 { margin: 14px 0 5px; font-size: 16px; }
.goods-card p { margin: 0; color: var(--muted); font-size: 13px; }
.goods-foot { margin-top: auto; padding-top: 18px; display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.price { font-size: 23px; font-weight: 750; color: var(--accent); }
.old-price { text-decoration: line-through; color: var(--muted); font-size: 12px; }

.notice { border-left: 3px solid var(--info); background: #edf4fb; color: #244d75; padding: 11px 13px; border-radius: 4px; font-size: 13px; }
.agent-strip { display: flex; align-items: center; gap: 10px; background: #edf7f1; border: 1px solid #cfe7d9; color: #205e46; padding: 10px 13px; border-radius: 6px; margin-bottom: 18px; }
.order-result { padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: #fafbfa; }
.order-result dl { display: grid; grid-template-columns: 105px 1fr; margin: 0; gap: 8px 12px; }
.order-result dt { color: var(--muted); }
.order-result dd { margin: 0; word-break: break-all; }
.order-summary { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
.secret-value { padding: 10px; margin-bottom: 8px; color: var(--brand-dark); background: #eaf5ef; border: 1px dashed #8bc4a7; border-radius: 5px; font-weight: 700; }
.token-text { font-size: 12px; }
.payment-code { display: grid; gap: 9px; margin-top: 14px; overflow-wrap: anywhere; }
.compact-select { width: 210px; }
.compact-empty { padding: 18px 10px; }
.stats-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stats-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 620px; }
.category-list { display: grid; gap: 2px; }
.category-list > div { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.category-list > div:last-child { border-bottom: 0; }
.category-list span { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.category-list strong { font-size: 16px; }

.app-layout { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { background: #18221e; color: #dce6e0; padding: 22px 14px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 0 8px 22px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar .brand-sub { color: #91a198; }
.nav { margin-top: 18px; display: flex; flex-direction: column; gap: 4px; }
.nav button { width: 100%; height: 42px; border: 0; border-radius: 6px; background: transparent; color: #aebcb4; padding: 0 12px; display: flex; align-items: center; gap: 11px; text-align: left; }
.nav button:hover, .nav button.active { background: rgba(255,255,255,.09); color: #fff; }
.sidebar-foot { position: absolute; left: 14px; right: 14px; bottom: 18px; }
.main { min-width: 0; }
.main .topbar { padding-inline: 24px; }
.main-content { padding: 24px; max-width: 1500px; margin: 0 auto; }
.view-title { margin: 0 0 18px; display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.view-title h1 { margin: 0; font-size: 22px; }
.view-title p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.chart { height: 190px; display: flex; align-items: end; gap: 10px; padding-top: 20px; }
.bar-item { flex: 1; min-width: 24px; display: flex; flex-direction: column; align-items: center; justify-content: end; height: 100%; gap: 7px; }
.bar { width: min(34px, 80%); min-height: 3px; background: var(--brand); border-radius: 3px 3px 0 0; }
.bar-label { font-size: 11px; color: var(--muted); }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(14, 21, 18, .52); display: grid; place-items: center; padding: 18px; }
.modal { width: min(620px, 100%); max-height: calc(100vh - 36px); overflow: auto; background: var(--surface); border-radius: 7px; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.modal.wide { width: min(980px, 100%); }
.modal-head { padding: 17px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px; }
.toast-stack { position: fixed; right: 18px; top: 78px; z-index: 200; display: grid; gap: 8px; width: min(360px, calc(100% - 36px)); }
.toast { background: #18221e; color: #fff; border-radius: 6px; padding: 12px 14px; box-shadow: var(--shadow); display: flex; gap: 9px; align-items: flex-start; }
.toast.error { background: #8e2929; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(280px, .85fr) minmax(390px, 1.15fr); background: var(--surface); }
.login-aside { background: #18221e; color: white; padding: clamp(30px, 7vw, 90px); display: flex; flex-direction: column; justify-content: space-between; }
.login-aside h1 { margin: 32px 0 12px; font-size: 34px; line-height: 1.2; letter-spacing: 0; }
.login-aside p { color: #aebcb4; max-width: 420px; }
.login-form-wrap { display: grid; place-items: center; padding: 28px; }
.login-form { width: min(390px, 100%); }
.login-form h2 { margin: 0 0 6px; font-size: 25px; }
.login-form > p { margin: 0 0 25px; color: var(--muted); }
.login-form .field { margin-bottom: 15px; }
.section-label { margin: 20px 0 12px; padding-bottom: 7px; border-bottom: 1px solid var(--line); font-weight: 700; }
.section-label:first-child { margin-top: 0; }
.split-input, .triple-input { display: grid; gap: 7px; }
.split-input { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.triple-input { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.search-results { display: grid; gap: 6px; max-height: 260px; overflow: auto; }
.search-result { width: 100%; min-height: 48px; padding: 8px 11px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: var(--ink); text-align: left; }
.search-result:hover, .search-result.selected { border-color: var(--brand); background: #eef8f2; }
.search-result.static:hover { border-color: var(--line); background: #fff; }
.search-result span:first-child { min-width: 0; }
.search-result strong, .search-result small { display: block; overflow-wrap: anywhere; }
.search-result small { color: var(--muted); font-weight: 400; margin-top: 2px; }
.config-editor { min-height: 250px; font-size: 12px; line-height: 1.55; }

@media (max-width: 960px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .goods-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-layout { grid-template-columns: 72px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .sidebar .brand-name, .sidebar .brand-sub, .nav button span { display: none; }
  .sidebar .brand { justify-content: center; padding-inline: 0; }
  .nav button { justify-content: center; padding: 0; }
}
@media (max-width: 680px) {
  .topbar { height: 58px; padding-inline: 16px; }
  .brand-sub { display: none; }
  .page-shell { width: min(100% - 22px, 1180px); margin-top: 18px; }
  .page-title { align-items: start; }
  .page-title h1 { font-size: 22px; }
  .grid-2, .grid-3, .form-grid, .goods-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat { min-height: 100px; padding: 13px; }
  .stat-value { font-size: 21px; }
  .amounts { grid-template-columns: repeat(2, 1fr); }
  .inline-actions { align-items: stretch; }
  .inline-actions .btn:not(.icon-only) { padding-inline: 10px; }
  .split-input, .triple-input { grid-template-columns: 1fr; }
  .compact-select { width: 150px; }
  .panel-body, .modal-body { padding: 15px; }
  .panel-head { padding: 14px 15px; }
  .app-layout { display: block; padding-bottom: 82px; }
  .sidebar { position: fixed; z-index: 60; height: 76px; bottom: 0; top: auto; left: 0; right: 0; width: 100%; padding: 5px 7px; }
  .sidebar .brand, .sidebar-foot { display: none; }
  .nav { margin: 0; display: flex; flex-direction: row; gap: 2px; overflow-x: auto; overflow-y: hidden; padding-bottom: 1px; }
  .nav button { height: 64px; min-width: 76px; padding: 4px 6px; flex-direction: column; justify-content: center; gap: 2px; }
  .nav button span { display: block; font-size: 10px; line-height: 1.1; white-space: nowrap; }
  .main .topbar { padding-inline: 14px; }
  .main, .main-content { width: 100%; min-width: 0; }
  .main-content { padding: 16px 11px; }
  .view-title { align-items: start; }
  .login-shell { display: block; background: var(--bg); padding: 18px; }
  .login-aside { display: none; }
  .login-form-wrap { min-height: calc(100vh - 36px); padding: 20px; background: white; border: 1px solid var(--line); border-radius: 7px; }
}
