/* 订单管理后台样式：只用本站资源，不加载外部字体和库 */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e3e6eb;
  --text: #1f2329;
  --muted: #6b7280;
  --primary: #2f6fed;
  --primary-hover: #245bd0;
  --primary-soft: #e8efff;
  --danger: #d93838;
  --danger-soft: #fdeceb;
  --success: #1f9d55;
  --success-soft: #e6f6ed;
  --warning: #c97a00;
  --warning-soft: #fff4e0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h2 { font-size: 17px; }
.sub-title { font-size: 14px; margin: 20px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); font-size: 13px; }

/* ---------- 按钮 / 表单 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
  white-space: nowrap; transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-outline { color: var(--danger); border-color: #f2b8b5; }
.btn.danger-outline:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0, 0, 0, .05); }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }

input, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input { height: 38px; }
textarea { min-height: 180px; resize: vertical; line-height: 1.6; }
input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input.invalid, textarea.invalid { border-color: var(--danger); }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-weight: 500; }
.field-error { min-height: 18px; margin: 4px 0 0; color: var(--danger); font-size: 12px; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }

/* ---------- 登录页 ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; padding: 32px 28px 24px; background: var(--surface);
  border-radius: 14px; box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand h1 { font-size: 20px; margin: 8px 0 4px; }
.login-brand .brand-mark { font-size: 32px; }

/* ---------- 顶栏 ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }

/* ---------- 布局 ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

/* 分段选择 */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px; gap: 2px; }
.segmented.wrap { flex-wrap: wrap; margin: 10px 0 14px; }
.segmented button {
  border: 0; background: transparent; color: var(--muted); font: inherit; padding: 5px 12px;
  border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 500; }

/* ---------- 统计 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-card h3 { font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 10px; }
.stat-numbers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat-numbers .num { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-numbers .label { font-size: 12px; color: var(--muted); }
.stat-extra { margin-top: 10px; font-size: 12px; color: var(--muted); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.table th { font-weight: 500; color: var(--muted); font-size: 12px; background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

/* ---------- 订单筛选 ---------- */
.search { display: flex; gap: 6px; }
.search input { width: 220px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
  padding: 4px 12px; border-radius: 999px; cursor: pointer;
}
.chip .count { color: var(--muted); margin-left: 4px; }
.chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chip.active .count { color: var(--primary); }

/* ---------- 订单列表 ---------- */
.order-list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.order-row {
  display: grid; grid-template-columns: 170px 120px 150px minmax(0, 1fr) 70px 100px 130px;
  gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.order-row:last-child { border-bottom: 0; }
.order-row.head { background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 500; }
.order-row.item { cursor: pointer; transition: background .12s; }
.order-row.item:hover { background: #f5f8ff; }
.order-row .cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-row .cell.num { text-align: right; font-variant-numeric: tabular-nums; }
.order-row .cell-label { display: none; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge.s0 { background: var(--primary-soft); color: var(--primary); }
.badge.s1 { background: var(--warning-soft); color: var(--warning); }
.badge.s2 { background: var(--success-soft); color: var(--success); }
.badge.s3 { background: #eef0f3; color: var(--muted); }

.pager { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.pager .info { color: var(--muted); margin: 0 6px; }

/* ---------- 弹窗 ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fade .15s ease-out;
}
.modal {
  width: 100%; max-width: 640px; max-height: calc(100vh - 32px); background: var(--surface);
  border-radius: 14px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: pop .18s ease-out;
}
.modal.wide { max-width: 860px; }
.modal.narrow { max-width: 420px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-close { width: 32px; height: 32px; border: 0; background: transparent; border-radius: 8px; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--border); }
.confirm-message { margin: 0; white-space: pre-wrap; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* 订单详情 */
.detail-grid { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px 14px; margin: 0; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; word-break: break-all; }
.content-box { margin-top: 16px; }
.content-box-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; color: var(--muted); }
.content-text {
  margin: 0; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  white-space: pre-wrap; word-break: break-all; font-family: var(--mono); font-size: 13px; max-height: 260px; overflow: auto;
}

/* 回单表单 */
.reply-types { margin-bottom: 14px; }
.counter { text-align: right; font-size: 12px; color: var(--muted); margin-top: 4px; }
.counter.over { color: var(--danger); }
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 26px 16px; text-align: center;
  color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.dropzone strong { color: var(--text); }
.file-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.file-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; }
.file-item img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; flex: none; background: var(--surface-2); }
.file-item .file-icon { width: 44px; height: 44px; border-radius: 6px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; flex: none; font-size: 20px; }
.file-item .meta { flex: 1; min-width: 0; }
.file-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .size { font-size: 12px; color: var(--muted); }
.file-item.bad { border-color: #f2b8b5; background: var(--danger-soft); }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 14px; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.progress-label { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* 回单查看：相册 */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.gallery-item {
  position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--surface-2);
  border: 1px solid var(--border); cursor: zoom-in; padding: 0;
}
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.gallery-item:hover img { transform: scale(1.04); }
.gallery-item .placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); padding: 8px; text-align: center; }
.reply-text { margin: 0; white-space: pre-wrap; word-break: break-word; padding: 14px; background: var(--surface-2); border-radius: 8px; border: 1px solid var(--border); }
.doc-list { display: grid; gap: 8px; }
.doc-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
.doc-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 大图查看 */
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, .92); display: flex; align-items: center; justify-content: center; animation: fade .15s; }
.lightbox img { max-width: calc(100vw - 120px); max-height: calc(100vh - 100px); object-fit: contain; border-radius: 4px; user-select: none; }
.lightbox .lb-btn {
  position: absolute; border: 0; background: rgba(255, 255, 255, .12); color: #fff; width: 44px; height: 44px;
  border-radius: 50%; font-size: 22px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.lightbox .lb-btn:hover { background: rgba(255, 255, 255, .24); }
.lightbox .lb-btn:disabled { opacity: .25; cursor: default; }
.lightbox .lb-prev { left: 20px; top: 50%; transform: translateY(-50%); }
.lightbox .lb-next { right: 20px; top: 50%; transform: translateY(-50%); }
.lightbox .lb-close { right: 20px; top: 20px; }
.lightbox .lb-counter { position: absolute; bottom: 22px; left: 0; right: 0; text-align: center; color: rgba(255, 255, 255, .8); font-size: 13px; }
.lightbox .lb-msg { color: rgba(255, 255, 255, .8); }

/* ---------- 提示条 ---------- */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 300; display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--surface);
  box-shadow: var(--shadow-lg); border-left: 4px solid var(--primary); animation: slide .2s ease-out; word-break: break-word;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast .toast-icon { flex: none; }
.toast .toast-text { flex: 1; }
.toast .toast-close { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }
.toast.leaving { opacity: 0; transform: translateX(16px); transition: opacity .2s, transform .2s; }
@keyframes slide { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

.loading { padding: 30px; text-align: center; color: var(--muted); }

/* ---------- 手机 ---------- */
@media (max-width: 900px) {
  .order-row.head { display: none; }
  .order-row.item {
    grid-template-columns: 1fr auto; grid-template-areas: "no status" "project points" "user time" "content content";
    gap: 4px 12px; padding: 12px 14px;
  }
  .order-row .c-no { grid-area: no; font-weight: 500; }
  .order-row .c-status { grid-area: status; text-align: right; }
  .order-row .c-project { grid-area: project; }
  .order-row .c-points { grid-area: points; text-align: right; }
  .order-row .c-user { grid-area: user; color: var(--muted); font-size: 13px; }
  .order-row .c-time { grid-area: time; color: var(--muted); font-size: 13px; text-align: right; }
  .order-row .c-content { grid-area: content; color: var(--muted); font-size: 13px; }
  .order-row .cell-label { display: inline; color: var(--muted); }
}
@media (max-width: 640px) {
  .container { padding: 10px; gap: 10px; }
  .panel { padding: 14px; }
  .stat-grid { grid-template-columns: minmax(0, 1fr); }
  .search { width: 100%; }
  .search input { width: auto; flex: 1; min-width: 0; }
  .admin-id { display: none; }
  .segmented { max-width: 100%; overflow-x: auto; }
  .overlay { padding: 0; align-items: flex-end; }
  .modal, .modal.wide, .modal.narrow { max-width: none; max-height: 92vh; border-radius: 14px 14px 0 0; }
  .detail-grid { grid-template-columns: 84px minmax(0, 1fr); }
  .lightbox img { max-width: 100vw; max-height: calc(100vh - 120px); }
  .lightbox .lb-prev { left: 8px; }
  .lightbox .lb-next { right: 8px; }
  .toasts { top: 10px; right: 10px; left: 10px; width: auto; }
}
