:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --surface-3: #eef0f7;
  --sidebar: #ffffff;
  --ink: #161a23;
  --ink-2: #3c4453;
  --muted: #6f7787;
  --muted-2: #98a0af;
  --line: #e6e8f0;
  --line-strong: #d6dae6;
  --brand: #4f46e5;
  --brand-strong: #4338ca;
  --brand-soft: #eef0ff;
  --green: #0f9d67;
  --green-soft: #e7f7f0;
  --amber: #b26a00;
  --amber-soft: #fdf3e2;
  --rose: #d13c3c;
  --rose-soft: #fdecec;
  --shadow-sm: 0 1px 2px rgba(16, 22, 38, .06);
  --shadow: 0 8px 26px rgba(16, 22, 38, .08);
  --shadow-lg: 0 24px 60px rgba(16, 22, 38, .18);
  --radius: 12px;
  --radius-lg: 16px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --paper-bg: #ffffff;
  --canvas-bg: #e9ebf2;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f1116;
  --surface: #171a21;
  --surface-2: #1c2029;
  --surface-3: #232833;
  --sidebar: #12141a;
  --ink: #e8ebf2;
  --ink-2: #c3c9d6;
  --muted: #9aa3b2;
  --muted-2: #77808f;
  --line: #262b36;
  --line-strong: #333a47;
  --brand: #7c83ff;
  --brand-strong: #9aa0ff;
  --brand-soft: #23264a;
  --green: #4bd39f;
  --green-soft: #133328;
  --amber: #f0b45c;
  --amber-soft: #332614;
  --rose: #ff8585;
  --rose-soft: #3a1c1c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, .6);
  --paper-bg: #f7f7f5;
  --canvas-bg: #0b0d11;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
::selection { background: var(--brand-soft); }

/* ---------------- 顶栏 ---------------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; object-fit: contain;
  background: #fff; padding: 2px; border: 1px solid var(--line); flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: 14.5px; }
.brand-text small { color: var(--muted-2); font-size: 10.5px; }
.topbar-spacer { flex: 1; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; font-size: 15px; color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-2); }
.wallet {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap;
}
.wallet:hover { border-color: var(--line-strong); }
.user { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-strong); font-size: 12px; font-weight: 650;
}
.user-role { font-size: 11px; color: var(--muted-2); }

/* ---------------- 基础控件 ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 500;
  white-space: nowrap; transition: .14s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.danger { color: var(--rose); border-color: var(--line); }
.btn.danger:hover { background: var(--rose-soft); border-color: var(--rose); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.input, select.input, textarea.input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink); font-size: 13px; outline: none;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.55; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.divider { height: 1px; background: var(--line); margin: 14px 0; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
}
.chip.brand { background: var(--brand-soft); border-color: transparent; color: var(--brand-strong); }
.chip.green { background: var(--green-soft); border-color: transparent; color: var(--green); }
.chip.amber { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.chip.rose { background: var(--rose-soft); border-color: transparent; color: var(--rose); }

/* ---------------- 外壳与侧栏 ---------------- */

.shell { display: flex; min-height: calc(100vh - 56px); align-items: stretch; }
.sidebar {
  width: 216px; flex: none; background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 14px 10px; position: sticky; top: 56px; height: calc(100vh - 56px); overflow: auto;
}
.nav-section { margin-bottom: 18px; }
.nav-label { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-2); padding: 0 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border-radius: 9px; color: var(--ink-2); font-size: 13px;
  border: 1px solid transparent; background: transparent; text-align: left;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; opacity: .85; }
.nav-badge { margin-left: auto; font-size: 11px; background: var(--surface-3); border-radius: 999px; padding: 1px 7px; color: var(--muted); }
.nav-item.active .nav-badge { background: var(--surface); color: var(--brand-strong); }


.main { flex: 1; min-width: 0; }
.page { max-width: 1280px; margin: 0 auto; padding: 20px 24px 60px; }
.page.tight { max-width: 1120px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.page-head .spacer { flex: 1; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin: 22px 0 10px; }
.section-head h2 { font-size: 15.5px; }
.section-head .hint { margin-left: auto; }

.layout-2 { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.layout-2 > .rail { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 14px; }

/* ---------------- 面板与表格 ---------------- */

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 14px; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 16px; }
.panel-body.tight { padding: 10px 16px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 9px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted-2); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.mono { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }

.empty { border: 1px dashed var(--line-strong); background: var(--surface-2); border-radius: var(--radius); padding: 40px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); margin-bottom: 6px; font-size: 15px; }

.status { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.status.UNPAID { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.status.WAIT_ACCEPT { background: var(--brand-soft); border-color: transparent; color: var(--brand-strong); }
.status.ACCEPTED, .status.PRINTING { background: var(--brand-soft); border-color: transparent; color: var(--brand-strong); }
.status.READY_PICKUP, .status.COMPLETED { background: var(--green-soft); border-color: transparent; color: var(--green); }
.status.CANCELLED, .status.CLOSED, .status.REJECTED { color: var(--muted-2); }
.status.PRINT_EXCEPTION { background: var(--rose-soft); border-color: transparent; color: var(--rose); }

.urgency { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.urgency.overdue { background: var(--rose); color: #fff; }
.urgency.urgent { background: var(--rose-soft); color: var(--rose); }
.urgency.soon { background: var(--amber-soft); color: var(--amber); }
.urgency.normal { background: var(--surface-2); color: var(--muted); }

/* ---------------- 价目小窗 ---------------- */

.price-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.price-card .head { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.price-card .head h3 { font-size: 13px; }
.price-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 62px 62px; align-items: center; gap: 6px;
  padding: 6px 12px; border-bottom: 1px solid var(--line); font-size: 11.5px;
}
.price-row:last-child { border-bottom: 0; }
.price-row .p-name { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.price-row .p-bw, .price-row .p-color { white-space: nowrap; text-align: right; color: var(--muted); font-size: 10.5px; }
.price-row .p-bw b, .price-row .p-color b { color: var(--ink); font-size: 11.5px; font-weight: 650; }
.price-note { padding: 8px 12px; font-size: 10.5px; color: var(--muted-2); background: var(--surface-2); line-height: 1.55; }

/* ---------------- 文件表 ---------------- */

.file-name { display: flex; align-items: center; gap: 9px; min-width: 0; }
.file-ico {
  width: 30px; height: 36px; border-radius: 5px; flex: none; display: grid; place-items: end center;
  padding-bottom: 4px; font-size: 8px; font-weight: 700; letter-spacing: .03em;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
}
.file-ico.pdf { background: var(--rose-soft); border-color: transparent; color: var(--rose); }
.file-ico.md { background: var(--brand-soft); border-color: transparent; color: var(--brand-strong); }
.file-name b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34ch; }
.file-name span { font-size: 11px; color: var(--muted-2); }
.expiry { font-size: 11.5px; color: var(--muted); }
.expiry.warn { color: var(--amber); }

/* ---------------- KPI 与图表 ---------------- */

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { font-size: 11.5px; color: var(--muted); }
.kpi .value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.kpi .sub { font-size: 11px; color: var(--muted-2); margin-top: 2px; }

.bars { display: flex; align-items: flex-end; gap: 10px; height: 130px; padding: 10px 4px 0; }
.bars .bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .bar { width: 100%; max-width: 34px; background: var(--brand-soft); border-radius: 6px 6px 2px 2px; position: relative; min-height: 3px; }
.bars .bar i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--brand); border-radius: 6px 6px 2px 2px; }
.bars .label { font-size: 10px; color: var(--muted-2); }

.suggest { background: var(--brand-soft); color: var(--brand-strong); border-radius: var(--radius); padding: 12px 14px; font-size: 12.5px; line-height: 1.6; }
.priority-list { display: flex; flex-direction: column; gap: 8px; }
.priority-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.priority-item .no { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.priority-item .who { font-size: 12.5px; }
.priority-item .reason { font-size: 11.5px; color: var(--muted); margin-left: auto; text-align: right; }

/* ---------------- 打印页 ---------------- */

.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.pick-item {
  display: flex; gap: 9px; align-items: center; padding: 10px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); text-align: left; width: 100%;
}
.pick-item:hover { border-color: var(--line-strong); }
.pick-item.active { border-color: var(--brand); background: var(--brand-soft); }
.pick-item b { display: block; font-size: 12.5px; }
.pick-item span { font-size: 11px; color: var(--muted-2); }
.spec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.spec-grid .span2 { grid-column: span 2; }
.price-box { border-top: 1px solid var(--line); padding: 14px 16px; }
.price-line { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); padding: 3px 0; }
.price-line b { color: var(--ink-2); }
.price-line.discount b { color: var(--green); }
.price-total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); margin-top: 10px; padding-top: 12px; }
.price-total b { font-size: 26px; letter-spacing: -.02em; }
.price-total b small { font-size: 13px; color: var(--muted); margin-right: 2px; }
.notice { display: flex; gap: 9px; padding: 10px 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.55; }
.notice.info { background: var(--brand-soft); color: var(--brand-strong); }
.notice.warn { background: var(--amber-soft); color: var(--amber); }
.notice.rose { background: var(--rose-soft); color: var(--rose); }
.steps { display: flex; gap: 6px; flex-wrap: wrap; }
.step { font-size: 11px; color: var(--muted-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; }
.step.done { color: var(--green); border-color: transparent; background: var(--green-soft); }
.step.active { color: var(--brand-strong); border-color: transparent; background: var(--brand-soft); }

/* ---------------- 编辑器 ---------------- */

.editor { display: grid; grid-template-rows: 52px 1fr; height: calc(100vh - 56px); }
.editor-bar { display: flex; align-items: center; gap: 10px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.editor-title { font-weight: 650; font-size: 13.5px; max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.save-pill.dirty { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.save-pill.saved { background: var(--green-soft); color: var(--green); border-color: transparent; }
.editor-bar .spacer { flex: 1; }
.editor-main { display: grid; grid-template-columns: 220px minmax(0, 1fr) 300px; min-height: 0; }
.editor-left, .editor-right { background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.editor-left { border-right: 1px solid var(--line); }
.editor-right { border-left: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; padding: 8px 10px 0; }
.tabs button { border: 0; background: transparent; padding: 6px 9px; border-radius: 7px; color: var(--muted); font-size: 12.5px; }
.tabs button.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.tab-body { padding: 10px; overflow: auto; flex: 1; min-height: 0; }
.canvas-area { background: var(--canvas-bg); display: flex; flex-direction: column; min-width: 0; }
.canvas-tools { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }
.canvas-scroll { flex: 1; overflow: auto; padding: 24px 0 60px; display: flex; justify-content: center; }
.paper {
  width: 794px; min-height: 1123px; background: var(--paper-bg); color: #16181d;
  box-shadow: var(--shadow-lg); position: relative; padding: 94px; transform-origin: top center;
}
.paper[data-paper="A3"] { width: 1123px; min-height: 1587px; }
.paper[data-paper="B5"] { width: 665px; min-height: 945px; }
.paper-foot { position: absolute; bottom: 24px; right: 94px; font-size: 10.5px; color: #9aa0aa; }
.blk { outline: none; min-height: 1.55em; margin: 0 0 5px; white-space: pre-wrap; border-radius: 4px; padding: 1px 6px; margin-left: -6px; border-left: 2px solid transparent; }
.blk:hover { border-left-color: #cdd2e0; }
.blk:focus { border-left-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, transparent); }
.blk[data-type="heading"] { font-weight: 700; margin-top: 14px; }
.blk[data-type="heading"][data-level="1"] { font-size: 24pt; }
.blk[data-type="heading"][data-level="2"] { font-size: 18pt; }
.blk[data-type="heading"][data-level="3"] { font-size: 15pt; }
.blk[data-type="heading"][data-level="4"] { font-size: 13pt; }
.blk[data-type="listItem"] { padding-left: 22px; position: relative; }
.blk[data-type="listItem"]::before { content: "·"; position: absolute; left: 8px; color: #6b7280; }
.blk[data-type="pageBreak"] { height: 22px; margin: 10px 0; border-top: 1px dashed #c4c9d4; display: grid; place-items: center; color: #9aa0aa; font-size: 9.5px; }
.blk[data-type="pageBreak"]::after { content: "分页"; }
.blk.issue { background: rgba(210, 160, 60, .14); }

.mini-item { display: flex; align-items: center; gap: 7px; padding: 6px 8px; border-radius: 7px; font-size: 12px; color: var(--ink-2); border: 1px solid transparent; background: transparent; width: 100%; text-align: left; }
.mini-item:hover { background: var(--surface-2); }
.mini-item.active { background: var(--brand-soft); color: var(--brand-strong); }
.mini-item .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--muted-2); flex: none; }
.mini-item .right { margin-left: auto; font-size: 10.5px; color: var(--muted-2); }
.issue-item { border: 1px solid var(--line); border-radius: 9px; padding: 9px; margin-bottom: 7px; }
.issue-item .top { display: flex; gap: 6px; align-items: center; margin-bottom: 3px; }
.issue-item .type { font-size: 12px; font-weight: 600; }
.issue-item .desc { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.issue-item .actions { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.sev { font-size: 9.5px; font-weight: 700; padding: 1px 5px; border-radius: 4px; }
.sev.BLOCKER { background: var(--rose-soft); color: var(--rose); }
.sev.WARNING { background: var(--amber-soft); color: var(--amber); }
.sev.INFO { background: var(--brand-soft); color: var(--brand-strong); }

/* ---------------- 订单 ---------------- */

.order-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.order-card + .order-card { margin-top: 10px; }
.order-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.order-head .no { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.order-head .spacer { flex: 1; }
.order-body { padding: 14px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.order-kv { display: flex; justify-content: space-between; font-size: 12.5px; padding: 2px 0; }
.order-kv span { color: var(--muted); }
.timeline { display: flex; flex-direction: column; gap: 7px; }
.timeline .row { display: flex; gap: 8px; font-size: 12px; color: var(--muted); }
.timeline .row i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); margin-top: 6px; flex: none; }
.timeline .row.done i { background: var(--green); }
.timeline .row.done { color: var(--ink-2); }
.pickup-code { font-family: var(--mono); font-size: 28px; letter-spacing: 7px; text-align: center; padding: 14px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-strong); margin: 10px 0; }

/* ---------------- 弹层 / 提示 / 登录 ---------------- */

.modal-root { position: fixed; inset: 0; z-index: 80; display: none; }
.modal-root.open { display: block; }
.modal-mask { position: absolute; inset: 0; background: rgba(10, 14, 22, .5); }
.modal { position: relative; margin: 6vh auto 0; width: min(760px, 94vw); max-height: 86vh; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; }
.modal.wide { width: min(1000px, 96vw); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 15px; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 18px; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); }
.preview-frame { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

.dropzone { border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 30px; text-align: center; background: var(--surface-2); color: var(--muted); cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--brand); color: var(--brand-strong); }
.dropzone b { display: block; color: var(--ink); margin-bottom: 4px; }

.toast-stack { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
.toast { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--brand); padding: 10px 14px; border-radius: 9px; box-shadow: var(--shadow); font-size: 12.5px; max-width: 360px; animation: toast-in .18s ease-out; }
.toast.ok { border-left-color: var(--green); }
.toast.error { border-left-color: var(--rose); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.auth { min-height: calc(100vh - 56px); display: grid; place-items: center; padding: 30px 18px; }
.auth-card { width: min(400px, 94vw); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 26px; box-shadow: var(--shadow); }
.auth-logo {
  width: 46px; height: 46px; border-radius: 12px; object-fit: contain;
  background: #fff; padding: 3px; border: 1px solid var(--line); margin-bottom: 12px;
}
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 18px; }
.auth-tabs { display: flex; background: var(--surface-2); padding: 3px; border-radius: 9px; margin-bottom: 14px; }
.auth-tabs button { flex: 1; border: 0; background: transparent; padding: 7px; border-radius: 7px; color: var(--muted); font-size: 12.5px; }
.auth-tabs button.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }
.auth-error { color: var(--rose); font-size: 12px; min-height: 18px; margin: 6px 0; }
.auth-demo { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); line-height: 1.9; }
.auth-demo code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-family: var(--mono); font-size: 11px; }

/* ---------------- 响应式 ---------------- */

@media (max-width: 1080px) {
  .layout-2 { grid-template-columns: 1fr; }
  .layout-2 > .rail { position: static; }
  .editor-main { grid-template-columns: 190px minmax(0, 1fr); }
  .editor-right { display: none; }
}
@media (max-width: 820px) {
  .sidebar { display: none; }
  .page { padding: 16px 14px 48px; }
  .brand-text small { display: none; }
  .spec-grid { grid-template-columns: 1fr; }
  .spec-grid .span2 { grid-column: auto; }
  .order-body { grid-template-columns: 1fr; }
  .editor-main { grid-template-columns: 1fr; }
  .editor-left { display: none; }
}

/* 校徽与校名标注 */
.site-foot {
  position: fixed; left: 14px; bottom: 10px; z-index: 25; pointer-events: none;
  display: flex; flex-direction: column; gap: 1px;
  color: var(--muted-2); font-size: 10.5px; line-height: 1.45; opacity: .9;
}
.site-foot .version { font-size: 10px; opacity: .78; }
.site-foot .sep { opacity: .6; }

/* 可点击表头排序 */
th.sortable { cursor: pointer; user-select: none; }
th.sortable button {
  border: 0; background: transparent; padding: 0; font: inherit; color: inherit;
  display: inline-flex; align-items: center; gap: 4px; text-transform: inherit; letter-spacing: inherit;
}
th.sortable button:hover { color: var(--ink-2); }
th.sortable .caret { font-size: 9px; opacity: .7; }
th.sorted .caret { opacity: 1; color: var(--brand); }


/* ---------------- 手机端适配 ---------------- */

@media (max-width: 820px) {
  .shell { flex-direction: column; min-height: 0; }

  /* 侧栏改为底部导航 */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: auto; height: auto; max-height: none;
    display: flex; align-items: center; gap: 4px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line);
    background: var(--surface); z-index: 40;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .nav-section { display: contents; }
  .nav-label { display: none; }
  .nav-item {
    flex: 0 0 auto; flex-direction: column; gap: 2px;
    padding: 6px 10px; font-size: 10.5px; border-radius: 10px;
    white-space: nowrap;
  }
  .nav-item .ico { font-size: 15px; line-height: 1; }
  .nav-badge { position: absolute; margin: -2px 0 0 16px; padding: 0 4px; font-size: 9.5px; }

  .main { padding-bottom: 68px; }
  .page { padding: 14px 12px 36px; max-width: none; }
  .page-head { gap: 8px; margin-bottom: 12px; }
  .page-head h1 { font-size: 18px; }
  .page-head .sub { font-size: 12px; }

  .topbar { height: 52px; padding: 0 10px; gap: 6px; }
  .brand-mark { width: 26px; height: 26px; }
  .brand-text b { font-size: 13px; }
  .brand-text small { display: none; }
  .user-name, .user-role { display: none; }
  .wallet { padding: 4px 8px; font-size: 11.5px; }
  .btn.primary, .btn { padding: 7px 10px; font-size: 12.5px; }

  .site-foot { display: none; }
  .toast-stack { left: 10px; right: 10px; bottom: 78px; }
  .toast { max-width: none; }

  .kpi-grid { gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi .value { font-size: 19px; }

  .panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 560px; font-size: 12px; }
  .table th, .table td { padding: 8px 8px; }
  .file-name b { max-width: 42vw; }
  .order-head { flex-wrap: wrap; gap: 6px; }
  .order-body { grid-template-columns: 1fr; }

  .modal { width: 96vw; margin: 3vh auto 0; max-height: 92vh; }
  .modal.wide { width: 96vw; }
  .modal-body { padding: 12px; }
  .preview-frame { height: 56vh; }

  .auth { min-height: calc(100vh - 140px); padding: 18px 12px; }

  /* 编辑器：画布横向可滚，属性面板移到下方 */
  .editor { height: auto; grid-template-rows: auto auto; }
  .editor-bar { height: auto; flex-wrap: wrap; padding: 8px 10px; gap: 6px; }
  .editor-title { max-width: 100%; font-size: 12.5px; }
  .editor-main { grid-template-columns: 1fr; }
  .editor-left { display: none; }
  .editor-right { display: flex; border-left: 0; border-top: 1px solid var(--line); max-height: 52vh; }
  .canvas-scroll { height: 58vh; padding: 12px 0 20px; justify-content: flex-start; }
  .paper { flex: 0 0 auto; zoom: 0.7; }
  .canvas-tools { flex-wrap: wrap; gap: 6px; padding: 6px 10px; }

  .spec-grid { grid-template-columns: 1fr; }
  .spec-grid .span2 { grid-column: auto; }
  .pick-list { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .brand-text { display: none; }
  .price-row { grid-template-columns: minmax(0, 1fr) 54px 54px; padding: 6px 10px; }
  .table { min-width: 520px; }
  .page-head h1 { font-size: 17px; }
  .editor-right { max-height: 46vh; }
  .paper { zoom: 0.6; }
}

/* 平板：编辑器属性面板移到画布下方，而不是隐藏 */
@media (max-width: 1080px) and (min-width: 821px) {
  .editor { height: auto; }
  .editor-main { grid-template-columns: 190px minmax(0, 1fr); grid-template-rows: auto auto; }
  .editor-right {
    display: flex; grid-column: 1 / -1;
    border-left: 0; border-top: 1px solid var(--line);
    max-height: 32vh;
  }
  .canvas-scroll { height: 58vh; }
}

/* ---------------- 移动端视觉重构 ---------------- */
@media (max-width: 820px) {
  .sidebar { display: none; }
  .main { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }

  .topbar { height: 50px; padding: 0 12px; gap: 8px; }
  #theme-toggle, #btn-logout { display: none; }
  .topbar .btn.primary { font-size: 0; padding: 8px 11px; border-radius: 12px; }
  .topbar .btn.primary::after { content: '＋'; font-size: 18px; line-height: 1; }
  .wallet { padding: 5px 9px; font-size: 11px; }
  .avatar { width: 30px; height: 30px; }
  .user { gap: 0; }

  .page { padding: 14px 14px 8px; }
  .page-head { margin-bottom: 12px; align-items: flex-start; }
  .page-head h1 { font-size: 20px; }
  .page-head .sub { font-size: 11.5px; line-height: 1.5; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 13px; border-radius: 14px; }
  .kpi .label { font-size: 11px; }
  .kpi .value { font-size: 21px; margin-top: 2px; }
  .kpi .sub { font-size: 10.5px; }

  .panel { border-radius: 14px; overflow: visible; }
  .panel-head { padding: 12px 14px; }
  .panel-body { padding: 12px 14px; }

  .table.cards { min-width: 0; font-size: 13px; }
  .table.cards thead { display: none; }
  .table.cards tbody { display: block; padding: 4px 0 6px; }
  .table.cards tr {
    display: block; margin: 0 12px 10px; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  }
  .table.cards tbody tr:hover td { background: transparent; }
  .table.cards td {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 5px 0; border: 0; white-space: normal; text-align: right;
  }
  .table.cards td::before {
    content: attr(data-label); color: var(--muted); font-size: 11.5px; font-weight: 500;
    flex: none; text-align: left;
  }
  .table.cards td:first-child {
    display: block; text-align: left; padding-bottom: 8px; margin-bottom: 4px;
    border-bottom: 1px dashed var(--line);
  }
  .table.cards td:first-child::before { display: none; }
  .table.cards td:first-child .file-name b { max-width: none; white-space: normal; }
  .table.cards td:last-child { padding-top: 8px; justify-content: flex-end; }
  .table.cards td:last-child::before { display: none; }
  .table.cards td .actions { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .table.cards td:empty { display: none; }
  .table.cards.plain td { display: block; text-align: left; }
  .table.cards.plain td::before { display: none; }

  .m-tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    display: flex; align-items: center; gap: 2px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .m-tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 2px; border: 0; border-radius: 12px; background: none;
    color: var(--muted); font-size: 10.5px; line-height: 1;
  }
  .m-tab .ico { font-size: 17px; }
  .m-tab.active { color: var(--brand-strong); background: var(--brand-soft); font-weight: 650; }

  .m-sheet { position: fixed; inset: 0; z-index: 70; display: none; }
  .m-sheet.open { display: block; }
  .m-sheet-mask { position: absolute; inset: 0; background: rgba(8, 10, 16, .45); }
  .m-sheet-panel {
    position: absolute; left: 0; right: 0; bottom: 0;
    background: var(--surface); border-radius: 20px 20px 0 0;
    padding: 8px 14px calc(14px + env(safe-area-inset-bottom));
    max-height: 80vh; overflow: auto;
    animation: sheet-up .2s ease-out;
  }
  .m-sheet-handle { width: 40px; height: 4px; border-radius: 999px; background: var(--line-strong); margin: 6px auto 10px; }
  .m-sheet h4 { font-size: 11.5px; color: var(--muted); font-weight: 600; margin: 12px 4px 8px; }
  .m-sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .m-sheet-item {
    display: flex; align-items: center; gap: 8px; padding: 12px;
    border: 1px solid var(--line); border-radius: 13px; background: var(--surface);
    color: var(--ink-2); font-size: 13px; text-align: left;
  }
  .m-sheet-item span:first-child { font-size: 16px; width: 20px; text-align: center; }
  .m-sheet-item.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
  @keyframes sheet-up { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }

  .modal-root.open { display: flex; align-items: flex-end; }
  .modal, .modal.wide {
    width: 100%; max-height: 90vh; margin: 0; border-radius: 20px 20px 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, .25);
  }
  .modal-head { padding: 12px 16px; }
  .modal-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .toast-stack { bottom: calc(90px + env(safe-area-inset-bottom)); }

  .price-card { border-radius: 14px; }
  .price-row { padding: 8px 12px; }
  .pick-item { padding: 12px; border-radius: 12px; }
  .order-card { border-radius: 14px; }
  .empty { border-radius: 14px; padding: 28px 16px; }
}
