:root {
  --brand: #FF5500;
  --brand-ink: #C43A00;
  --brand-soft: #FFF6F1;
  --bg: #F6F4F2;
  --card: #ffffff;
  --line: #ECE7E3;
  --text: #1A1512;
  --muted: #968C84;
  --ok: #1a9c5b;
  --warn: #d98600;
  --danger: #e0453a;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; }

/* ===== 登录 ===== */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #fff 0%, #fff7ef 55%, #ffeede 100%);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--card); border-radius: 16px; padding: 32px 28px;
  box-shadow: 0 18px 50px rgba(255, 85, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.04);
}
.login-logo {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; margin-bottom: 16px;
}
.login-card h1 { margin: 0 0 6px; font-size: 20px; }
.login-sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; height: 42px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fafafb;
  outline: none; transition: border-color .15s, background .15s;
}
.field input:focus { border-color: var(--brand); background: #fff; }
.btn {
  height: 42px; padding: 0 18px; border: none; border-radius: 8px;
  background: var(--brand); color: #fff; font-size: 15px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover { filter: brightness(1.04); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.block { width: 100%; margin-top: 8px; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.btn.small { height: 32px; font-size: 13px; padding: 0 12px; border-radius: 6px; }
.btn.danger { background: var(--danger); }
.btn.primary { background: var(--brand); }
.login-err { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }
.login-tip { margin-top: 18px; font-size: 12px; color: var(--muted); line-height: 1.7; border-top: 1px dashed var(--line); padding-top: 14px; }

/* ===== 主框架：侧栏 + 内容 ===== */
.hidden { display: none !important; }
#appView { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; flex-shrink: 0;
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.side-logo {
  width: 38px; height: 38px; border-radius: 10px; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
}
.side-name { font-weight: 700; font-size: 15px; line-height: 1.25; }
.side-name span { font-size: 11px; color: var(--muted); font-weight: 400; }
.nav { padding: 8px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 9px; color: var(--muted);
  font-size: 14px; cursor: pointer; user-select: none; margin-bottom: 2px; position: relative;
}
.nav-item i { width: 18px; text-align: center; font-style: normal; }
.nav-item:hover { background: var(--brand-soft); color: var(--brand-ink); }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 11px; display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.side-foot { padding: 12px 14px; border-top: 1px solid var(--line); }
.side-user { font-size: 12px; color: var(--muted); margin-bottom: 8px; word-break: break-all; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.topbar-inner {
  max-width: 1320px; margin: 0 auto; padding: 0 20px;
  height: 58px; display: flex; align-items: center; gap: 12px;
}
.topbar h2 { margin: 0; font-size: 17px; }
.topbar .spacer { flex: 1; }
.content { max-width: 1320px; width: 100%; margin: 0 auto; padding: 18px 20px 48px; }
.pane { animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ===== 统计 ===== */
.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 14px; border: 1px solid var(--line); }
.stat .n { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.hl .n { color: var(--brand); }

.ov-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; margin-top: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; }
.card h3 { margin: 0 0 4px; font-size: 15px; }
.card .card-sub { color: var(--muted); font-size: 12px; margin-bottom: 14px; }

/* 趋势条 */
.trend { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 8px; }
.trend .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.trend .bar .fill { width: 100%; background: linear-gradient(180deg, #FF7A2E, #FF5500); border-radius: 4px 4px 0 0; min-height: 2px; transition: height .3s; }
.trend .bar .v { font-size: 10px; color: var(--muted); }
.trend .bar .d { font-size: 9px; color: var(--muted); transform: rotate(-45deg); white-space: nowrap; }

/* 分布 */
.dist { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.dist .row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dist .row .name { width: 84px; color: var(--muted); flex-shrink: 0; }
.dist .row .track { flex: 1; height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.dist .row .track i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.dist .row .val { width: 42px; text-align: right; font-variant-numeric: tabular-nums; }

/* ===== 工具条 ===== */
.toolbar {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px;
}
.toolbar .grow { flex: 1; }
.search {
  height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px;
  background: #fafafb; outline: none; min-width: 200px;
}
.search:focus { border-color: var(--brand); background: #fff; }
.select { height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: #fafafb; outline: none; }

/* ===== 表格 ===== */
.table-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #fafafb; color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; position: sticky; top: 0; }
tbody tr:hover { background: #fff8f3; }
tbody tr:last-child td { border-bottom: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); }
.strong { font-weight: 600; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.nowrap { white-space: nowrap; }
.ops { display: flex; gap: 6px; flex-wrap: wrap; }
.link { color: var(--brand); cursor: pointer; font-size: 13px; }
.link.muted { color: var(--muted); }
.link.danger { color: var(--danger); }

/* 状态标签 */
.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px;
  background: #f1f2f5; color: #666; line-height: 18px; white-space: nowrap;
}
.chip.pending { background: #fff4e0; color: #b97400; }
.chip.confirmed { background: #e8f1ff; color: #1a5fd0; }
.chip.in_progress { background: #eaf0ff; color: #5a3fd0; }
.chip.completed { background: #e8f7ee; color: var(--ok); }
.chip.cancelled { background: #f2f2f5; color: #8a8a96; }
.chip.refunded { background: #f2f2f5; color: #8a8a96; }
.chip.paid { background: #e8f7ee; color: var(--ok); }
.chip.unpaid { background: #fdeceb; color: var(--danger); }
.chip.closed { background: #f2f2f5; color: #8a8a96; }
.chip.approved { background: #fff4e0; color: #b97400; }
.chip.rejected { background: #fdeceb; color: var(--danger); }
.chip.mode { background: var(--brand-soft); color: #c25c00; }
.chip.assigned { background: #eef4ff; color: #2856b5; }
.chip.unassign { background: #fdeceb; color: var(--danger); }
.chip.active { background: #e8f7ee; color: var(--ok); }
.chip.disabled { background: #f2f2f5; color: #8a8a96; }
.chip.bound { background: #eef4ff; color: #2856b5; }
.chip.unbound { background: #fdeceb; color: var(--danger); }

/* 分页 */
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 12px; color: var(--muted); font-size: 13px; }
.empty { padding: 48px 0; text-align: center; color: var(--muted); font-size: 13px; }
.loading { padding: 32px 0; text-align: center; color: var(--muted); font-size: 13px; }

/* ===== 弹窗 ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(20, 20, 25, .42);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 100; overflow-y: auto;
}
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 680px; box-shadow: 0 24px 60px rgba(0, 0, 0, .18); }
.modal.wide { max-width: 880px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .x { margin-left: auto; color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1; }
.modal-body { padding: 18px 20px; max-height: 68vh; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 10px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.section-title { font-size: 13px; font-weight: 600; margin: 20px 0 10px; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ''; width: 3px; height: 13px; background: var(--brand); border-radius: 2px; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.photo { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fafafb; }
.photo img { width: 100%; height: 96px; object-fit: cover; display: block; cursor: zoom-in; }
.photo .cap { font-size: 11px; color: var(--muted); padding: 4px 6px; }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  background: #fafafb; outline: none;
}
.form-row textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
.form-row input:focus, .form-row textarea:focus, .form-row select:focus { border-color: var(--brand); background: #fff; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.6; }
.err { color: var(--danger); font-size: 13px; margin-top: 8px; }

/* 提示 */
#toast {
  position: fixed; left: 50%; bottom: 48px; transform: translateX(-50%) translateY(16px);
  background: rgba(30, 30, 36, .92); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .22s; z-index: 300; max-width: 80vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: rgba(200, 50, 40, .95); }

/* 图片查看 */
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .85); z-index: 400; display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .ov-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .table-card { overflow-x: auto; }
  table { min-width: 860px; }
}
