:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e4e7ec;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --ok: #15803d;
  --ok-bg: #e8f7ee;
  --warn: #b45309;
  --warn-bg: #fdf3e3;
  --bad: #b91c1c;
  --bad-bg: #fdeceb;
  --info: #1d4ed8;
  --info-bg: #e8f0fe;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  background: #f0f2f5;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.92em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
}

/* ---------- 顶栏 ---------- */
.topbar {
  background: #111827;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  max-width: 1440px;
  margin: 0 auto;
  min-height: 56px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #fff;
  font-weight: 650;
  flex: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}

.brand-text {
  font-size: 15px;
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 2px;
  flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.navlink {
  color: #cbd5e1;
  padding: 6px 12px;
  border-radius: 8px;
  white-space: nowrap;
  font-size: 14px;
}

.navlink:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  text-decoration: none;
}

.navlink.active {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-wrap: wrap;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #e5e7eb;
  font-size: 13px;
}

.userrole {
  color: #9ca3af;
  border: 1px solid #374151;
  border-radius: 999px;
  padding: 0 7px;
  font-size: 12px;
}

/* ---------- 布局 ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

body.wide .container {
  max-width: 1440px;
}

.footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 32px;
  color: var(--muted);
  font-size: 12px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.page-title {
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- 面板 ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfd;
  flex-wrap: wrap;
}

.panel-head h2 {
  font-size: 15px;
  flex: 1 1 auto;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.panel > form,
.panel > p,
.panel > .table-wrap,
.panel > .combo-row,
.panel > .hint-line,
.panel > .plain-list,
.panel > ol,
.panel > .return-list {
  margin: 0;
}

.panel > form,
.panel > p,
.panel > .combo-row,
.panel > .hint-line,
.panel > .plain-list,
.panel > ol,
.panel > .return-list {
  padding: 14px 16px;
}

.panel > form + .table-wrap {
  padding-top: 0;
}

/* ---------- 表格 ---------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table th,
.table td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  white-space: nowrap;
}

.table th {
  background: #f9fafb;
  color: var(--muted);
  font-weight: 600;
  font-size: 12.5px;
}

.table tbody tr:hover {
  background: #fafbfc;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.cell-title {
  font-weight: 600;
}

.cell-sub {
  color: var(--muted);
  font-size: 12px;
  white-space: normal;
}

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 26px 12px !important;
}

.row-alert {
  background: #fff7f7;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.num-in {
  color: var(--ok);
}

.num-out {
  color: var(--bad);
}

.num-alert {
  color: var(--bad);
  font-weight: 600;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  letter-spacing: 0.2px;
}

.table-lines .w-qty {
  width: 84px;
}

.table-lines .w-mode {
  width: 110px;
}

.table-lines .w-price {
  width: 120px;
}

.table-lines .w-num {
  width: 100px;
  text-align: right;
}

/* 整单一个日租金时，逐台的计价方式 / 单价 / 小计没有意义，直接收起 */
.table-lines.per-order .col-mode,
.table-lines.per-order .col-price,
.table-lines.per-order .col-subtotal {
  display: none;
}

.rent-mode-row,
.free-day-row {
  padding: 4px 16px 0;
  max-width: 420px;
}

.cell-zero {
  background: var(--bad-bg);
}

.cell-low {
  background: var(--warn-bg);
}

.table-calendar td {
  white-space: nowrap;
}

/* ---------- 徽章 ---------- */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.7;
  white-space: nowrap;
}

.badge-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-bad {
  background: var(--bad-bg);
  color: var(--bad);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

.badge-muted {
  background: #f1f2f4;
  color: var(--muted);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}

.btn:hover {
  background: #f6f7f9;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-ghost {
  background: transparent;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12.5px;
}

.btn-danger-ghost {
  color: var(--bad);
  border-color: #f3d2d0;
}

.btn-danger-ghost:hover {
  background: var(--bad-bg);
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- 表单 ---------- */
.form {
  display: block;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 16px;
  padding: 14px 16px;
}

.form-compact {
  display: grid;
  gap: 10px;
  padding: 12px;
  min-width: 260px;
  background: #fbfcfd;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 6px;
}

.form-narrow {
  max-width: 420px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field-label {
  font-size: 12.5px;
  color: var(--muted);
}

.field-label em {
  color: var(--bad);
  font-style: normal;
}

.field-hint {
  font-size: 11.5px;
  color: var(--muted);
}

.field-wide {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  width: 100%;
  min-width: 0;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  border-color: var(--primary);
}

textarea {
  resize: vertical;
}

.field-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.field-check input {
  width: auto;
}

.form-actions {
  display: flex;
  gap: 10px;
  padding: 0 16px 16px;
  flex-wrap: wrap;
}

.form-compact .form-actions {
  padding: 0;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  background: rgba(245, 246, 248, 0.95);
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  backdrop-filter: blur(4px);
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.inline-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.input-sm,
.select-sm {
  padding: 4px 8px;
  font-size: 12.5px;
  width: auto;
  min-width: 84px;
}

.input-invalid {
  border-color: var(--bad);
  background: #fffafa;
}

.filter-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  flex-wrap: wrap;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: #fbfcfd;
}

.filter-bar input,
.filter-bar select {
  width: auto;
  min-width: 120px;
}

.filter-bar input[name='q'] {
  min-width: 220px;
  flex: 1 1 220px;
}

.filter-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: none;
}

.filter-tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  white-space: nowrap;
  font-size: 13px;
}

.tab:hover {
  text-decoration: none;
  background: #f6f7f9;
}

.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

.tab-count {
  margin-left: 5px;
  opacity: 0.75;
  font-size: 12px;
}

/* ---------- 统计卡 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 15px;
}

.stat-warn {
  border-color: #f4d9a8;
  background: #fffdf7;
}

.stat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-title {
  font-size: 12.5px;
  color: var(--muted);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.4px;
}

.stat-unit {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 4px;
}

.stat-sub {
  font-size: 12px;
  color: var(--muted);
}

.price-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  flex-wrap: wrap;
}

.price-form label {
  display: flex;
  flex-direction: column;
  font-size: 11.5px;
  color: var(--muted);
  gap: 3px;
}

.price-form input {
  width: 92px;
  padding: 4px 8px;
  font-size: 13px;
}

.combo-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.combo-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  background: #fbfcfd;
  min-width: 120px;
}

.combo-name {
  font-size: 12.5px;
  color: var(--muted);
}

.combo-count {
  font-size: 17px;
  font-weight: 700;
  color: var(--ok);
}

.combo-count.zero {
  color: var(--bad);
}

/* ---------- 提示 ---------- */
.flash {
  padding: 11px 15px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid transparent;
  font-size: 13.5px;
}

.flash-ok {
  background: var(--ok-bg);
  border-color: #c6e8d3;
  color: var(--ok);
}

.flash-error {
  background: var(--bad-bg);
  border-color: #f3d2d0;
  color: var(--bad);
}

.flash-warn {
  background: var(--warn-bg);
  border-color: #f4d9a8;
  color: var(--warn);
}

.flash-info {
  background: var(--info-bg);
  border-color: #c7d7f8;
  color: var(--info);
}

.hint-line {
  font-size: 12.5px;
  color: var(--muted);
}

.plain-list {
  padding-left: 20px !important;
  margin: 0;
}

.plain-list li {
  margin-bottom: 6px;
}

.log-list {
  list-style: none;
  margin: 0;
  padding: 14px 16px;
}

.log-list li {
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}

.log-list li:last-child {
  border-bottom: none;
}

.error-page {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
}

/* ---------- 订单页 ---------- */
.order-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.order-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.order-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.inline-details {
  display: inline-block;
}

.inline-details summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.inline-details summary::-webkit-details-marker {
  display: none;
}

.line-total {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: #fbfcfd;
  font-size: 13.5px;
}

.line-total strong {
  font-variant-numeric: tabular-nums;
}

.preset-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.availability-box {
  padding: 12px 16px;
  font-size: 13px;
}

.availability-box .avail-warn {
  color: var(--bad);
}

.availability-box .avail-ok {
  color: var(--ok);
}

.return-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
}

.return-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.return-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.return-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 14px;
}

/* ---------- 订单附件（免押截图） ---------- */
.attach-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 16px;
}

.attach-item {
  width: 164px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.attach-preview {
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #f6f7f9;
}

.attach-preview:hover {
  border-color: var(--primary);
}

.attach-preview img {
  display: block;
  width: 100%;
  height: 120px;
  object-fit: cover;
}

.attach-meta {
  font-size: 11.5px;
  line-height: 1.5;
}

input[type='file'] {
  padding: 8px 10px;
  background: #fbfcfd;
}

/* ---------- 免押截图自动识别 ---------- */
.scan-box {
  border: 1px dashed #d5dae3;
  border-radius: var(--radius);
  background: #fbfcfd;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.scan-box > .btn {
  margin-top: 8px;
}

.scan-status {
  margin-top: 8px;
  min-height: 17px;
  line-height: 1.6;
}

.scan-status.good {
  color: var(--ok);
}

/* 免押截图区块（现在放在「支付宝免押登记」卡片里） */
.attach-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.attach-head.is-split {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

/* 场次页：复制客户名单 */
.copy-src {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.copy-status.good {
  color: var(--ok);
}

.copy-status.bad {
  color: var(--bad);
}

.scan-status.warn {
  color: var(--warn);
}

.scan-status.bad {
  color: var(--bad);
}

input.is-scanned,
select.is-scanned {
  border-color: var(--primary);
  background: #f2f8ff;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

/* ---------- 登录页 ---------- */
body.bare {
  background: linear-gradient(160deg, #111827 0%, #1e293b 45%, #0f172a 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.bare-wrap {
  width: 100%;
  max-width: 400px;
}

.login-card {
  background: var(--panel);
  border-radius: 14px;
  padding: 26px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.28);
}

.login-brand {
  text-align: center;
  margin-bottom: 18px;
}

.login-brand .brand-mark {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  margin-bottom: 10px;
}

.login-brand h1 {
  font-size: 19px;
}

.login-brand p {
  margin: 4px 0 0;
  font-size: 12.5px;
}

.login-card .form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-card .form-actions {
  padding: 0;
}

/* ---------- 打印 ---------- */
.print-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.print-sheet {
  background: #fff;
  padding: 28px 32px;
  max-width: 820px;
  margin: 0 auto;
}

.print-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 2px solid #111827;
  padding-bottom: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.print-head h1 {
  font-size: 21px;
  letter-spacing: 2px;
}

.print-head-right {
  text-align: right;
  font-size: 13px;
}

.print-info,
.print-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 13px;
}

.print-info th,
.print-info td,
.print-table th,
.print-table td {
  border: 1px solid #999;
  padding: 6px 9px;
  text-align: left;
}

.print-info th,
.print-table th {
  background: #f2f2f2;
  font-weight: 600;
  white-space: nowrap;
  width: 1%;
}

.print-table .num {
  text-align: right;
}

.print-info .strong {
  font-weight: 700;
}

.print-terms {
  font-size: 12.5px;
  color: #333;
  margin-bottom: 22px;
}

.print-terms ol {
  padding-left: 20px;
  margin: 6px 0 0;
}

.print-sign {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 26px;
  font-size: 13px;
  flex-wrap: wrap;
}

.print-contact {
  margin-top: 14px;
  font-size: 12.5px;
  color: #555;
}

@media print {
  body {
    background: #fff;
  }

  .no-print,
  .topbar,
  .footer {
    display: none !important;
  }

  .container {
    padding: 0;
    max-width: none;
  }

  .print-sheet {
    box-shadow: none;
    padding: 0;
    max-width: none;
  }

  .panel,
  .stat-grid {
    display: none !important;
  }
}

/* ---------- 移动端 ---------- */
@media (max-width: 720px) {
  .container {
    padding: 14px 12px 48px;
  }

  .topbar-inner {
    padding: 8px 12px;
    gap: 8px;
  }

  .brand-text {
    display: none;
  }

  .nav {
    order: 3;
    flex-basis: 100%;
  }

  .stat-value {
    font-size: 21px;
  }

  .stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .table th,
  .table td {
    padding: 8px 10px;
  }

  .filter-bar input[name='q'] {
    min-width: 100%;
  }

  .form-actions .btn,
  .sticky-actions .btn {
    flex: 1 1 auto;
  }
}
