:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #e5e9f0;
  --line-soft: #eef1f6;
  --text: #1e2633;
  --text-2: #55606f;
  --muted: #8b94a3;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --primary-soft: #edf3ff;
  --ok: #0f7b5f;
  --ok-bg: #e8f6f1;
  --warn: #9a6206;
  --warn-bg: #fdf6e5;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

input, select, textarea, button { font-family: inherit; font-size: 14px; color: inherit; }
a { color: var(--primary); text-decoration: none; }
.hidden, [hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- 登录 */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 15% 0%, #eaf1ff 0%, rgba(234, 241, 255, 0) 60%),
    radial-gradient(700px 420px at 100% 100%, #eef4ff 0%, rgba(238, 244, 255, 0) 55%),
    #f7f9fc;
}
.login-card {
  width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 30px 30px 24px;
  box-shadow: 0 12px 40px -18px rgba(16, 24, 40, .18);
}
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 24px; }
.login-title { font-size: 17px; font-weight: 700; letter-spacing: .2px; }
.login-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.mark {
  width: 38px; height: 38px; border-radius: 9px;
  background: linear-gradient(150deg, #3b7bf6, #1d4ed8);
  color: #fff; font-size: 17px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #9dbcfb; box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}
.field textarea { resize: vertical; min-height: 62px; }
.login-err { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-bottom: 8px; }
.login-hint { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.7; }

/* ---------------------------------------------------------------- 布局 */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 218px; flex: none; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 14px; font-weight: 700; }
.brand-text span { font-size: 11.5px; color: var(--muted); letter-spacing: 1px; }

.nav { padding: 6px 10px; flex: 1; overflow-y: auto; }
.nav-group { font-size: 11px; color: #a3abba; padding: 14px 10px 6px; letter-spacing: .8px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--text-2); cursor: pointer; margin-bottom: 2px; font-size: 13.5px; font-weight: 500;
  transition: background .12s, color .12s;
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .75; }
.nav-item:hover { background: #f5f7fb; color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-d); font-weight: 600; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto; background: var(--danger-bg); color: var(--danger);
  font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 20px; min-width: 18px; text-align: center;
}
.side-foot { border-top: 1px solid var(--line-soft); padding: 12px 16px; font-size: 11.5px; color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px; flex: none; background: rgba(255, 255, 255, .88); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center;
  justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.topbar h1 { font-size: 16px; margin: 0; font-weight: 650; letter-spacing: .2px; }
.page-sub { font-size: 12.5px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.page-actions { display: flex; gap: 8px; }
.who { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); padding-left: 12px; border-left: 1px solid var(--line); }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-d);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}
.content { padding: 20px 24px 40px; flex: 1; }

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 13px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--text-2); cursor: pointer; font-size: 13px; font-weight: 500;
  transition: all .14s; white-space: nowrap;
}
.btn:hover { border-color: #cdd5e2; color: var(--text); background: #fbfcfe; }
.btn:active { transform: translateY(.5px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); color: #fff; }
.btn-danger { color: var(--danger); border-color: #f2cfcb; background: #fff; }
.btn-danger:hover { background: var(--danger-bg); border-color: #e9b3ad; color: var(--danger); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #0c6650; color: #fff; }
.btn-block { width: 100%; height: 38px; }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12.5px; border-radius: 7px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link-btn {
  background: none; border: none; padding: 0; cursor: pointer; color: var(--primary);
  font-size: 12.5px; font-weight: 500;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }
.link-btn.muted { color: var(--muted); }
.row-actions { display: flex; gap: 10px; align-items: center; }

/* ---------------------------------------------------------------- 卡片 / KPI */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--line-soft);
}
.card-title { font-size: 13.5px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card-title small { font-weight: 400; color: var(--muted); font-size: 12px; }
.card-body { padding: 16px; }
.card-body.flush { padding: 0; }

.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.kpi.click { cursor: pointer; transition: border-color .15s, transform .15s; }
.kpi.click:hover { border-color: #c9d6ee; transform: translateY(-1px); }
.kpi-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 24px; font-weight: 680; letter-spacing: -.4px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.kpi-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.kpi-value.danger { color: var(--danger); }
.kpi-value.warn { color: var(--warn); }

.grid-2 { display: grid; grid-template-columns: 1.25fr 1fr; gap: 16px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- 表格 */
.table-wrap { width: 100%; overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th {
  background: #fafbfd; color: #6b7688; font-weight: 600; font-size: 12px;
  padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
table.table td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.table tbody tr:last-child td { border-bottom: none; }
table.table tbody tr:hover { background: #fafbfe; }
table.table td.r, table.table th.r { text-align: right; }
table.table .code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; color: var(--text-2); }
table.table .strong { font-weight: 600; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 21px; padding: 0 8px;
  border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.info { background: var(--primary-soft); color: var(--primary-d); }
.badge.mute { background: #f2f4f8; color: var(--text-2); }

.progress { display: flex; align-items: center; gap: 8px; min-width: 118px; }
.progress-track { flex: 1; height: 6px; background: #eef1f6; border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 4px; }
.progress-bar.done { background: var(--ok); }
.progress-txt { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }

.empty { padding: 44px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.empty strong { display: block; color: var(--text-2); font-weight: 600; margin-bottom: 4px; font-size: 13.5px; }

/* ---------------------------------------------------------------- 工具栏 */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft); background: #fff;
}
.toolbar .spacer { flex: 1; }
.search-box {
  position: relative; display: flex; align-items: center;
}
.search-box input {
  width: 220px; height: 32px; padding: 0 10px 0 30px; border: 1px solid var(--line);
  border-radius: 8px; outline: none; background: #fbfcfe;
}
.search-box input:focus { border-color: #9dbcfb; background: #fff; box-shadow: 0 0 0 3px rgba(37,99,235,.09); }
.search-box svg { position: absolute; left: 9px; width: 14px; height: 14px; color: var(--muted); }
select.mini, input.mini {
  height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; outline: none; font-size: 13px; color: var(--text-2);
}
select.mini:focus, input.mini:focus { border-color: #9dbcfb; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.check input { accent-color: var(--primary); }

.pill-tabs { display: inline-flex; background: #f2f4f8; border-radius: 9px; padding: 3px; gap: 2px; }
.pill {
  padding: 5px 14px; border-radius: 7px; font-size: 13px; color: var(--text-2);
  cursor: pointer; font-weight: 500; transition: all .14s;
}
.pill.active { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(16,24,40,.08); font-weight: 600; }
.pill .cnt { color: var(--muted); font-size: 11.5px; margin-left: 3px; }

.sum-bar {
  display: flex; gap: 22px; flex-wrap: wrap; padding: 10px 16px;
  border-top: 1px solid var(--line-soft); background: #fcfdff; font-size: 12.5px; color: var(--text-2);
}
.sum-bar b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .38); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 48px 20px 40px;
  overflow-y: auto; animation: fade .16s ease-out;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes slide { from { transform: translateY(8px); opacity: .6 } to { transform: none; opacity: 1 } }
.modal {
  background: #fff; border-radius: 12px; width: 520px; max-width: 100%;
  box-shadow: 0 24px 60px -20px rgba(16, 24, 40, .35); animation: slide .18s ease-out;
}
.modal.wide { width: 860px; }
.modal.xwide { width: 1000px; }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 16px 20px 12px; border-bottom: 1px solid var(--line-soft);
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 650; }
.modal-head .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.modal-body { padding: 18px 20px; max-height: calc(100vh - 220px); overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px;
  border-top: 1px solid var(--line-soft); background: #fcfdff; border-radius: 0 0 12px 12px;
}
.x-btn { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; padding: 0 2px; }
.x-btn:hover { color: var(--text); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--muted); margin: -6px 0 12px; }
.callout {
  background: var(--primary-soft); border: 1px solid #d7e4fd; color: #1e40af;
  border-radius: 8px; padding: 9px 12px; font-size: 12.5px; line-height: 1.6; margin-bottom: 14px;
}
.callout.warn { background: var(--warn-bg); border-color: #f3e2b8; color: #8a5a08; }

/* 订单明细行编辑 */
.line-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 4px; }
.line-table th {
  font-size: 11.5px; color: var(--muted); font-weight: 600; text-align: left;
  padding: 6px 6px; border-bottom: 1px solid var(--line);
}
.line-table td { padding: 5px 4px; }
.line-table input, .line-table select {
  width: 100%; height: 32px; padding: 0 8px; border: 1px solid var(--line);
  border-radius: 7px; outline: none; background: #fff;
}
.line-table input:focus, .line-table select:focus { border-color: #9dbcfb; }
.line-table .col-item { width: 42%; }
.line-table .col-qty { width: 15%; }
.line-table .col-price { width: 17%; }
.line-table .col-amt { width: 18%; text-align: right; padding-right: 8px; font-variant-numeric: tabular-nums; }
.line-table .col-del { width: 34px; text-align: center; }
.line-total { display: flex; justify-content: flex-end; gap: 18px; padding: 10px 8px 0; font-size: 13px; color: var(--text-2); }
.line-total b { font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; }

/* 上手引导 */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.step {
  display: flex; gap: 11px; padding: 14px; border: 1px solid var(--line-soft);
  border-radius: 10px; background: #fcfdff; align-items: flex-start;
}
.step-body { display: flex; flex-direction: column; flex: 1; }
.step-act { margin-top: auto; padding-top: 2px; }
.step-no {
  width: 25px; height: 25px; border-radius: 50%; background: var(--primary-soft);
  color: var(--primary-d); font-weight: 700; font-size: 12.5px; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.step-title { font-weight: 650; font-size: 13.5px; }
.step-desc { font-size: 12.5px; color: var(--text-2); line-height: 1.65; margin: 4px 0 10px; }
.step-act { display: flex; gap: 8px; flex-wrap: wrap; }

/* 系统公告条 */
.sys-notice {
  padding: 9px 26px; font-size: 13px; line-height: 1.5;
  background: var(--warn-bg); color: #8a5a08; border-bottom: 1px solid #f3e2b8;
}

/* 编码预览 */
.code-preview {
  border: 1px solid var(--line-soft); background: #f8fafd; border-radius: 8px;
  padding: 9px 12px; font-size: 14px; min-height: 38px; font-family: Consolas, Menlo, monospace;
}

/* toast */
#toasts { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #1e2633; color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); animation: slide .18s ease-out; max-width: 80vw;
}
.toast.err { background: #b42318; }
.toast.ok { background: #0f7b5f; }

/* 详情展示 */
.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 18px; }
.detail-grid .dt { font-size: 11.5px; color: var(--muted); }
.detail-grid .dd { font-size: 13.5px; margin-top: 2px; font-weight: 500; }
.sec-title { font-size: 12.5px; font-weight: 650; color: var(--text-2); margin: 20px 0 8px; display: flex; align-items: center; justify-content: space-between; }
.sec-title:first-child { margin-top: 0; }

/* 报表条形 */
.barrow { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.barrow .lbl { width: 150px; font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barrow .track { flex: 1; height: 18px; background: #f2f5fa; border-radius: 4px; overflow: hidden; }
.barrow .fill { height: 100%; background: linear-gradient(90deg, #6f9bf5, #2563eb); border-radius: 4px; }
.barrow .val { width: 92px; text-align: right; font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text-2); }

@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .content { padding: 14px 14px 40px; }
  .topbar { padding: 0 14px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .search-box input { width: 150px; }
  .steps { grid-template-columns: 1fr; }
}
