:root {
  --bg: #f4f6f9;
  --card: #fff;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #94a3b8;
  --line: #e6e9ef;
  --brand: #26a17b;
  --brand-600: #1e8a68;
  --brand-50: #e9f7f2;
  --danger: #e5484d;
  --side: #0b1220;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .05);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, .18);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.link { color: var(--brand-600); cursor: pointer; }
.link:hover { text-decoration: underline; }

/* layout */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: #cbd5e1; padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: #fff; font-weight: 700; font-size: 16px; }
.logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, #26a17b, #3ecf9c); color: #fff; font-weight: 800; flex-shrink: 0; }
.side-brand small { display: block; font-weight: 400; font-size: 12px; color: #64748b; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #94a3b8; font-size: 14px; transition: .15s; }
.side nav a:hover { background: rgba(255, 255, 255, .05); color: #e2e8f0; }
.side nav a.active { background: rgba(62, 207, 156, .14); color: #fff; }
.side nav a.active svg { color: #3ecf9c; }
.side nav .cnt { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; padding: 0 7px; border-radius: 999px; line-height: 18px; }
.side-foot { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 14px; display: flex; flex-direction: column; gap: 4px; }
.side-foot a, .side-foot button { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: #94a3b8; background: none; border: 0; cursor: pointer; font-size: 13px; text-align: left; }
.side-foot a:hover, .side-foot button:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.main { padding: 28px 32px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; letter-spacing: -.3px; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* card, buttons, inputs */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid #edf0f4; }
.card-pad { padding: 20px 22px; }
.card-title { display: flex; justify-content: space-between; align-items: center; margin: 0 0 14px; font-size: 15px; font-weight: 700; }
.card-title a { font-size: 13px; font-weight: 500; color: var(--brand-600); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; font-weight: 600; font-size: 13px; transition: .15s; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-600); }
.btn-dark { background: var(--text); color: #fff; }
.btn-dark:hover:not(:disabled) { background: #1e293b; }
.btn-ghost { background: #fff; border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: #f8fafc; border-color: #cbd5e1; }
.btn-danger { background: #fff; border-color: #fecdd3; color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #fff1f2; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.input, select.input, textarea.input { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none; transition: .15s; }
textarea.input { height: auto; min-height: 80px; padding: 9px 12px; resize: vertical; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(38, 161, 123, .14); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; cursor: pointer; transition: .2s; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(16px); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { padding: 16px 18px; cursor: pointer; transition: .15s; position: relative; }
.stat:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(15, 23, 42, .08); }
.stat .label { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.stat .label i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.stat .num { font-size: 28px; font-weight: 800; letter-spacing: -.5px; margin-top: 4px; }
.stat.hot { border-color: #bfdbfe; background: linear-gradient(180deg, #f5f9ff, #fff); }
.stat.hot::after { content: '待处理'; position: absolute; right: 12px; top: 12px; font-size: 11px; font-weight: 700; color: #1d4ed8; background: #dbeafe; padding: 1px 8px; border-radius: 999px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 18px 20px; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .num { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.kpi .num small { font-size: 13px; font-weight: 600; color: var(--text-2); margin-left: 4px; }
.dash-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; margin-bottom: 18px; }
.alert { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; font-size: 13px; }
.alert.warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert.err { background: #fff1f2; border: 1px solid #fecdd3; color: #9f1239; }
.alert a { font-weight: 700; text-decoration: underline; margin-left: auto; white-space: nowrap; }

/* chart */
.chart { position: relative; height: 220px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .grid-line { stroke: #eef1f5; stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--brand); transition: opacity .15s; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart g:hover .bar { fill: var(--brand-600); }
.chart-tip { position: absolute; pointer-events: none; background: var(--text); color: #fff; padding: 8px 10px; border-radius: 8px; font-size: 12px; white-space: nowrap; transform: translate(-50%, calc(-100% - 8px)); box-shadow: var(--shadow-lg); z-index: 5; }
.chart-tip b { font-size: 14px; }

/* low stock */
.low-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f1f5f9; }
.low-item:last-child { border-bottom: 0; }
.low-item img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; background: #f1f5f9; }
.low-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stock-badge { font-weight: 700; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: #fff7ed; color: #c2410c; }
.stock-badge.zero { background: #fff1f2; color: var(--danger); }

/* tables */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { width: 260px; }
.toolbar .grow { flex: 1; }
.tabs { display: flex; gap: 4px; background: #fff; padding: 4px; border-radius: 12px; border: 1px solid var(--line); flex-wrap: wrap; margin-bottom: 14px; width: fit-content; }
.tab { padding: 6px 12px; border-radius: 8px; border: 0; background: none; cursor: pointer; font-size: 13px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { background: #f1f5f9; }
.tab.active { background: var(--text); color: #fff; }
.tab .n { font-size: 11px; background: rgba(148, 163, 184, .25); padding: 0 6px; border-radius: 999px; }
.tab.active .n { background: rgba(255, 255, 255, .2); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafcfd; }
tr.clickable { cursor: pointer; }
.thumb { width: 44px; height: 44px; border-radius: 9px; object-fit: cover; background: #f1f5f9; }
.pname { font-weight: 600; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-input { width: 90px; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 8px; background: #f8fafc; outline: none; font-weight: 600; }
.inline-input:hover { border-color: var(--line); }
.inline-input:focus { border-color: var(--brand); background: #fff; }
.inline-input.low { color: #c2410c; background: #fff7ed; }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.empty-row td { text-align: center; color: var(--muted); padding: 48px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.pager .btns { display: flex; gap: 6px; }

.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-pending { background: #fff7ed; color: #c2410c; }
.st-paid { background: #eff6ff; color: #1d4ed8; }
.st-confirmed { background: #ecfdf5; color: #047857; }
.st-shipped { background: #f5f3ff; color: #6d28d9; }
.st-completed { background: #f1f5f9; color: #334155; }
.st-cancelled { background: #f8fafc; color: #94a3b8; }
.tag { display: inline-flex; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.tag-green { background: var(--brand-50); color: var(--brand-600); }
.tag-gray { background: #f1f5f9; color: #64748b; }
.tag-red { background: #fff1f2; color: var(--danger); }
.tag-blue { background: #eff6ff; color: #1d4ed8; }

/* wallets */
.wallets { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.wallet { padding: 18px 20px; position: relative; }
.wallet.default { border: 1.5px solid var(--brand); box-shadow: 0 6px 20px rgba(38, 161, 123, .12); }
.wallet.disabled { opacity: .62; }
.wallet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.wallet-head .ico { width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; }
.wallet-head b { font-size: 15px; }
.wallet-addr { font-family: var(--mono); font-size: 13px; background: #f8fafc; border-radius: 10px; padding: 9px 12px; word-break: break-all; display: flex; align-items: center; gap: 8px; }
.wallet-addr span { flex: 1; }
.wallet-meta { display: flex; gap: 18px; margin: 12px 0; color: var(--text-2); font-size: 12px; }
.wallet-meta b { color: var(--text); font-size: 14px; }
.wallet-actions { display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid #f1f5f9; padding-top: 12px; }
.icon-copy { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 2px; border-radius: 6px; display: inline-grid; place-items: center; }
.icon-copy:hover { color: var(--brand-600); background: var(--brand-50); }

/* order detail */
.od-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.od-sec { background: #fafbfc; border: 1px solid #f0f2f5; border-radius: 12px; padding: 14px 16px; }
.od-sec h4 { margin: 0 0 10px; font-size: 13px; color: var(--text-2); }
.kv { display: grid; grid-template-columns: 76px 1fr; gap: 6px 10px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.od-item { display: flex; gap: 10px; align-items: center; padding: 6px 0; }
.od-item img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.od-item .n { flex: 1; min-width: 0; }
.timeline { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.timeline div { display: flex; gap: 8px; color: var(--text-2); }
.timeline div span:first-child { width: 72px; color: var(--muted); }
.action-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-radius: 12px; background: #f0fbf7; border: 1px solid #d7f0e6; margin-bottom: 14px; }
.action-bar .tip { font-size: 13px; color: var(--text-2); flex: 1; min-width: 200px; }
.ship-form { display: grid; grid-template-columns: 160px 1fr auto; gap: 8px; width: 100%; margin-top: 4px; }

/* image uploader */
.uploader { display: flex; gap: 12px; align-items: center; }
.uploader .preview { width: 84px; height: 84px; border-radius: 12px; background: #f1f5f9 center/cover no-repeat; border: 1px dashed #cbd5e1; flex-shrink: 0; display: grid; place-items: center; color: var(--muted); font-size: 22px; }
.uploader .col { flex: 1; display: flex; flex-direction: column; gap: 8px; }

/* modal + toast */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); z-index: 100; display: flex; justify-content: center; align-items: flex-start; padding: 6vh 16px; overflow-y: auto; animation: fade .15s; }
.modal { width: 100%; max-width: 520px; background: #fff; border-radius: 18px; box-shadow: var(--shadow-lg); animation: pop .18s ease; }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); gap: 12px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); width: 32px; height: 32px; border-radius: 8px; }
.modal-x:hover { background: #f1f5f9; color: var(--text); }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.toasts { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-lg); animation: pop .2s ease; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--brand); }

/* login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(800px 400px at 80% 0%, rgba(62, 207, 156, .25), transparent 60%), radial-gradient(600px 300px at 0% 100%, rgba(99, 102, 241, .2), transparent 60%), var(--side); }
.login-card { width: 100%; max-width: 380px; padding: 34px; background: #fff; border-radius: 20px; box-shadow: var(--shadow-lg); }
.login-card h1 { margin: 14px 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 22px; color: var(--muted); }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.skeleton { background: linear-gradient(90deg, #eef1f5 25%, #f6f8fa 50%, #eef1f5 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 1200px) { .stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .side-brand { padding: 4px 10px; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { display: none; }
  .main { padding: 18px 14px 40px; }
  .dash-grid, .kpis, .settings-grid, .od-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .ship-form { grid-template-columns: 1fr; }
}

/* language tabs (product form / settings) */
.lang-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 16px; }
.lang-tabs button { border: 0; background: none; padding: 9px 14px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 6px; }
.lang-tabs button:hover { color: var(--text); }
.lang-tabs button.active { color: var(--text); border-bottom-color: var(--brand); }
.lang-tabs small { font-size: 11px; font-weight: 500; color: var(--muted); background: #f1f5f9; padding: 0 6px; border-radius: 6px; }
.lang-tabs .dot { width: 7px; height: 7px; border-radius: 50%; background: #cbd5e1; display: inline-block; }
.lang-tabs .dot.on { background: var(--brand); }
.lang-tag { margin-left: 6px; font-size: 10px; padding: 0 5px; vertical-align: 2px; }
