:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #1f2937;
  --ink-soft: #6b7280;
  --line: #e5e7eb;
  --brand: #2563eb;
  --brand-soft: #eff6ff;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 6px 18px rgba(0,0,0,.05);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px;
}
.hidden { display: none !important; }

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { font-size: 26px; }
.brand h1 { font-size: 18px; margin: 0; }
.brand-sub { font-size: 12px; color: var(--ink-soft); }
.top-right { display: flex; align-items: center; gap: 10px; }
.badge { font-size: 12px; padding: 4px 10px; border-radius: 999px; font-weight: 600; }
.badge.local { background: #fef3c7; color: #92400e; }
.badge.cloud { background: #dcfce7; color: #166534; }
.badge.check { background: #e0e7ff; color: #3730a3; }

button { cursor: pointer; font-family: inherit; font-size: 13px; }
.primary { background: var(--brand); color: #fff; border: none; padding: 9px 16px; border-radius: 8px; font-weight: 600; }
.primary:hover { background: #1d4ed8; }
.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); padding: 7px 12px; border-radius: 8px; }
.ghost:hover { background: var(--brand-soft); border-color: var(--brand); }

/* 布局 */
.layout { display: grid; grid-template-columns: 380px 1fr; gap: 16px; padding: 16px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.panel-title { font-size: 15px; margin: 0 0 12px; }

/* 拖拽区 */
.drop-zone { border: 2px dashed #cbd5e1; border-radius: 12px; padding: 26px 16px; text-align: center; transition: .15s; background: #fafcff; }
.drop-zone.drag { border-color: var(--brand); background: var(--brand-soft); }
.dz-icon { font-size: 30px; }
.dz-hint { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }
.link { color: var(--brand); cursor: pointer; }

.pending-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.pending-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.pending-item.sel { border-color: var(--brand); background: var(--brand-soft); }
.pending-item .fi-icon { font-size: 20px; }
.pending-item .fi-name { flex: 1; font-size: 13px; word-break: break-all; }
.pending-item .fi-size { font-size: 11px; color: var(--ink-soft); }
.pending-item .fi-x { color: var(--danger); cursor: pointer; font-weight: 700; }

/* 表单 */
.meta-form { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 14px; }
.form-title { font-size: 14px; margin: 0 0 10px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid label { display: flex; flex-direction: column; font-size: 12px; color: var(--ink-soft); gap: 4px; }
.grid label.full { grid-column: 1 / -1; }
.grid input, .grid select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; color: var(--ink); font-family: inherit; }
.form-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.next-no { font-size: 12px; color: var(--ink-soft); }
.next-no b { color: var(--brand); }

/* 台账 */
.ledger-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.ledger-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.ledger-tools input, .ledger-tools select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; font-family: inherit; }
.ledger-tools input { flex: 1; min-width: 180px; }
.table-wrap { max-height: 64vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { position: sticky; top: 0; background: #f1f5f9; text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
tbody tr:hover { background: #f8fafc; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }
td .op { color: var(--brand); cursor: pointer; margin-right: 8px; }
td .op.del { color: var(--danger); }
.tag { display: inline-block; background: var(--brand-soft); color: var(--brand); border-radius: 4px; padding: 1px 6px; font-size: 11px; margin: 1px 2px 1px 0; }

/* 弹窗 */
.mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.login-card, .stats-card { background: #fff; border-radius: 14px; padding: 24px; width: 340px; box-shadow: var(--shadow); }
.login-card h2 { margin: 0 0 4px; }
.login-card .sub { color: var(--ink-soft); font-size: 12px; margin: 0 0 16px; }
.login-card input { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.login-card button { width: 100%; }
.tip { font-size: 12px; color: var(--danger); min-height: 16px; margin: 8px 0 0; }
.stats-card { width: 460px; max-height: 80vh; overflow: auto; }
.stats-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.stats-head h3 { margin: 0; }
.stats-body h4 { margin: 14px 0 6px; font-size: 13px; color: var(--ink-soft); }
.bar-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 13px; }
.bar-row .bar { height: 14px; background: var(--brand); border-radius: 3px; }
.bar-row .bn { width: 90px; }
.bar-row .bc { color: var(--ink-soft); width: 50px; text-align: right; }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px; z-index: 60; box-shadow: var(--shadow); }
.toast.ok { background: #166534; }
.toast.err { background: #991b1b; }

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

/* 门店 / 定制条目 */
.items-block { margin-top: 12px; }
.items-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.items-title { font-size: 12px; color: var(--ink-soft); }
.items-editor { display: flex; flex-direction: column; gap: 6px; }
.item-row { display: grid; grid-template-columns: 1.1fr 1.4fr 1.4fr auto; gap: 6px; align-items: center; }
.item-row input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; font-family: inherit; }
.item-x { color: var(--danger); cursor: pointer; font-weight: 700; padding: 0 4px; }
button.ghost.sm { padding: 5px 10px; font-size: 12px; }

/* 明细弹窗 */
.detail-card { background: #fff; border-radius: 14px; padding: 22px; width: 560px; max-width: 92vw; max-height: 86vh; overflow: auto; box-shadow: var(--shadow); }
.detail-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.detail-head h3 { margin: 0; font-size: 16px; }
.detail-meta { font-size: 13px; color: var(--ink-soft); margin-bottom: 12px; padding: 10px 12px; background: var(--bg); border-radius: 8px; }
.detail-actions { margin-top: 14px; display: flex; justify-content: flex-end; }
