/* ==========================================================================
   服装订货收款 · PHP 版样式
   手写 CSS，零构建。组件类沿用 Node 版的命名（card/btn/input/table/badge…），
   布局用少量语义化的 grid/flex 类。
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background: #f8fafc;
  color: #0f172a;
  font-size: 15px;
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', 'Microsoft YaHei', sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------------------------------------------------------------- 顶栏 */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
}
.brand { font-weight: 600; letter-spacing: -0.01em; }
.nav { display: flex; flex-wrap: wrap; gap: 2px; }
.nav a {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  text-decoration: none;
  color: #475569;
}
.nav a:hover { background: #f1f5f9; }
.nav a.active { background: #0f172a; color: #fff; }
.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: #475569;
}
.inline { display: inline; }

.page { max-width: 1200px; margin: 0 auto; padding: 18px 16px 72px; }

/* ---------------------------------------------------------------- 登录页 */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-form { width: 100%; max-width: 380px; }
.login-title { font-size: 18px; margin: 0; }

/* ---------------------------------------------------------------- 卡片与排版 */

.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
}
.card-flush { padding: 0; }

h2 { font-size: 17px; margin: 0; }
h3 { font-size: 14px; margin: 0 0 12px; color: #334155; }

.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 20px; }

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}
.row-tight { gap: 6px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }
.row-between { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; }
.row-center { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.grow { flex: 1 1 200px; min-width: 160px; }

.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.muted { color: #94a3b8; }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.danger-text { color: #b91c1c; }
.good-text { color: #15803d; }
.amber-text { color: #b45309; }
.void-row { color: #94a3b8; }
.empty { padding: 40px 16px; text-align: center; color: #94a3b8; }
.divider { border: 0; border-top: 1px solid #e5e7eb; margin: 16px 0; }
.divider-dash { border: 0; border-top: 1px dashed #cbd5e1; margin: 8px 0; }
.hidden { display: none !important; }

.flash { padding: 8px 12px; border-radius: 8px; font-size: 14px; margin: 0; }
.flash-error { background: #fef2f2; color: #dc2626; }
.flash-notice { background: #f0fdf4; color: #15803d; }

/*
 * 页内提示条：一旦有内容就浮在顶部居中。
 * 这样它既不占文档流、不推动页面，也不需要用户此刻正滚在页首就能看到 ——
 * 局部刷新后不会打断用户的滚动位置。
 */
#flash:not(:empty) {
  position: fixed;
  top: 62px; /* 让开约 50px 高的 sticky 顶栏，别压住导航 */
  left: 50%;
  transform: translateX(-50%);
  z-index: 60; /* 要盖过 .modal-mask 的 50 */
  width: max-content;
  max-width: min(92vw, 560px);
  box-shadow: 0 6px 20px rgb(15 23 42 / 0.14);
}
.notice-box { background: #fffbeb; color: #92400e; padding: 24px 16px; border-radius: 8px; font-size: 14px; }

/* ---------------------------------------------------------------- 控件 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #fff;
  font-size: 14px;
  line-height: 1.2;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: #f9fafb; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #111827; color: #fff; border-color: #111827; }
.btn-primary:hover { background: #1f2937; }
.btn-danger { color: #b91c1c; border-color: #fca5a5; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 16px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-group { display: flex; flex-wrap: wrap; gap: 4px; }

.input, .select, .textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: inherit;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: #111827;
  box-shadow: 0 0 0 3px rgb(17 24 39 / 0.08);
}
.input:disabled, .select:disabled { background: #f8fafc; }

.label { display: block; font-size: 13px; color: #374151; margin-bottom: 4px; }
.input-sm, .select-sm { padding: 4px 8px; font-size: 13px; border-radius: 6px; }

/* ---------------------------------------------------------------- 表格 */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  padding: 8px 10px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
  white-space: nowrap;
}
.table td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tbody tr:hover { background: #fafafa; }
.table .truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #f3f4f6;
  color: #374151;
  white-space: nowrap;
}
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }

/* ---------------------------------------------------------------- 指标卡 */

.metrics { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 760px) { .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.metric { border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px; background: #fff; }
.metric-label { font-size: 12px; color: #64748b; margin: 0; }
.metric-value { margin: 4px 0 0; font-size: 18px; font-weight: 600; }
.metric-highlight { background: #0f172a; color: #fff; border-color: #0f172a; }
.metric-highlight .metric-label { color: #cbd5e1; }
.metric-good { background: #f0fdf4; }
.metric-warn { background: #fffbeb; }

/* ---------------------------------------------------------------- 弹窗 */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgb(15 23 42 / 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow: auto;
  z-index: 50;
}
.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 720px;
  padding: 20px;
}
.modal-wide { max-width: 1000px; }
.modal-sm { max-width: 460px; }
.modal-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.modal-actions { margin-left: auto; display: flex; gap: 8px; }
.modal-title { font-size: 18px; font-weight: 600; margin: 0; }
.modal-body { margin-top: 16px; }
.modal-body > * + * { margin-top: 16px; }

/* ---------------------------------------------------------------- 小票 */

.receipt { border: 1px dashed #cbd5e1; border-radius: 8px; padding: 16px; font-size: 14px; line-height: 1.7; }
.receipt-shop { text-align: center; font-weight: 600; }
.receipt-title { text-align: center; font-weight: 600; }
.kv { display: flex; justify-content: space-between; gap: 12px; }
.kv-total { font-size: 16px; font-weight: 600; }
.receipt table { width: 100%; border-collapse: collapse; font-size: 14px; }
.receipt th { text-align: left; font-weight: 600; padding: 2px 0; }
.receipt td { padding: 2px 0; vertical-align: top; }

/* ---------------------------------------------------------------- 收款码 */

.qr-thumb {
  height: 64px;
  width: 64px;
  object-fit: contain;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #fff;
}
.qr-print {
  display: inline-block;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  text-align: center;
}
.qr-print img { width: 224px; max-width: 100%; display: block; margin: 0 auto; }
.qr-amount { margin: 8px 0 0; font-size: 18px; font-weight: 600; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------------------------------------------------------------- 开单页明细表 */

.items-table .input-sm { min-width: 72px; }
.items-table td { padding: 6px 6px; }
.items-table th { padding: 6px 6px; }

/* ---------------------------------------------------------------- 打印 */

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    width: 80mm;
    margin: 0 auto;
    padding: 4mm;
    border: none !important;
    box-shadow: none !important;
    font-family: 'Courier New', monospace;
  }
  .modal-mask { position: static; background: none; padding: 0; }
  .modal { box-shadow: none; max-width: none; padding: 0; border-radius: 0; }
}

/* ==========================================================================
   移动端（H5）补丁 —— 实测（375/360/430 三种宽度真实渲染）后按需修正，
   都不改动桌面端表现：
   1) iOS Safari 对字号 <16px 的输入框，聚焦时会自动放大整个页面，
      填单过程中反复缩放极其难受 —— 窄屏下统一提到 16px
   2) 行内按钮原高 26px（.btn-sm），手指点按容易误触，
      尤其订单列表里「标为已收」与「作废」紧挨着 —— 补齐触控高度
   3) #flash 的 top:62px 是按桌面顶栏（约 50px）定的，窄屏下顶栏会换行到
      140px，提示条被压在导航上 —— 窄屏改为底部浮层，彻底避开
   4) 顶栏导航窄屏下换行会吃掉近 1/5 屏高 —— 改为横向滚动，保持单行
   ========================================================================== */
@media (max-width: 620px) {
  /* 1) 输入控件：16px 是 iOS 触发自动缩放的阈值 */
  .input, .select, .textarea, .input-sm, .select-sm { font-size: 16px; }

  /* 2) 触控目标：主按钮 44px、行内按钮 40px（苹果 HIG 建议 ≥44，40 是表格内的折中） */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 40px; }
  .btn-group { gap: 6px; }

  /* 3) 提示条移到屏幕底部，不再与顶栏打架 */
  #flash:not(:empty) {
    top: auto;
    bottom: 16px;
    max-width: 92vw;
  }

  /* 4) 顶栏收窄：导航改为横向滚动，不换行 */
  .topbar-inner { padding: 8px 12px; gap: 4px 12px; }
  .nav { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
  .nav a { padding: 8px 10px; }

  /* 页面留白同步收紧，多给内容一点横向空间 */
  .page { padding: 12px 12px 72px; }
  .card { padding: 14px 12px; }
}
