/* 通用 CRUD 界面样式：卡片化 / 蓝色主色 / 大圆角 / 轻阴影
 * ≤760px 时表格自动转为「卡片流」（依赖 td 上的 data-label 显示字段名） */
:root {
  --brand: #2563eb;
  --brand-600: #1d4ed8;
  --brand-50: #eff6ff;
  --bg: #f1f5f9;
  --card: #ffffff;
  --line: #e5e7eb;
  --line-soft: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #dc2626;
  --danger-600: #b91c1c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .16);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}

/* ---------- 顶部条 ---------- */
.top {
  background: linear-gradient(90deg, var(--brand-600), var(--brand));
  color: #fff;
  min-height: 54px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 10px rgba(29, 78, 216, .25);
}
.top a {
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .28);
  padding: 6px 14px;
  border-radius: 999px;
  transition: background .15s;
}
.top a:hover { background: rgba(255, 255, 255, .28); }
.top strong { font-size: 16px; font-weight: 600; letter-spacing: .3px; }

.wrap { padding: 16px; max-width: 1600px; margin: 0 auto; }

/* ---------- 工具条 ---------- */
.bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
  background: var(--card);
  padding: 10px 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.bar > input { flex: 1 1 200px; min-width: 150px; }

input, select, textarea {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

button {
  padding: 9px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--brand);
  color: #111;
  cursor: pointer;
  transition: transform .08s, filter .15s, box-shadow .15s;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .1);
}
button:hover { filter: brightness(1.07); }
button:active { transform: translateY(1px); }
button.sec {
  background: #fff;
  color: #111;
  border: 1px solid var(--line);
  box-shadow: none;
}
button.sec:hover { background: #f8fafc; border-color: #cbd5e1; }
button.danger { background: var(--danger); }
button.danger:hover { background: var(--danger-600); }

/* ---------- 表格（PC） ---------- */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
/* PC：长列表在表格内部滚动，表头吸顶 */
@media (min-width: 761px) {
  .table-scroll { max-height: calc(100vh - 220px); overflow: auto; }
}
/* 空列表提示（不支持 :has 的浏览器自动忽略） */
.table-scroll:has(tbody:empty)::after {
  content: '暂无数据';
  display: block;
  padding: 36px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: transparent;
  font-size: 13px;
}
th, td {
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
  word-break: break-word;
  border-bottom: 1px solid var(--line-soft);
}
th {
  background: #f8fafc;
  font-weight: 600;
  color: #475569;
  font-size: 13px;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody tr:nth-child(even) { background: #fcfdfe; }
tbody tr:hover { background: var(--brand-50); }
tbody tr:last-child td { border-bottom: none; }
td input[type=checkbox], th input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }

.row-ops { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-ops button { padding: 6px 12px; font-size: 12px; white-space: nowrap; }
.hidden-price { color: #cbd5e1; letter-spacing: 2px; }

/* ---------- 分页 ---------- */
.pager {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--card);
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.pager button { padding: 8px 16px; }
.pager #pg { color: var(--muted); font-size: 13px; }
.page-size-label { font-size: 13px; color: var(--muted); margin-left: auto; }
.page-size {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: #fff;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  display: none;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  z-index: 50;
  padding: 24px 0;
}
.modal .box {
  background: #fff;
  margin: 24px auto;
  padding: 0 0 18px;
  border-radius: 16px;
  width: 92vw;
  max-width: 1100px;
  box-shadow: var(--shadow-lg);
  box-sizing: border-box;
  overflow: hidden;
}
.modal .box h3 {
  margin: 0;
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 600;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 3;
}
.modal .box > *:not(h3) { margin-left: 20px; margin-right: 20px; }
.modal .box label { display: block; font-size: 13px; margin: 12px 0 5px; color: #475569; font-weight: 500; }
.modal .box .half { display: inline-block; width: 48%; vertical-align: top; margin-right: 2%; }
.modal .box input, .modal .box select, .modal .box textarea { width: 100%; }
.modal .box textarea { min-height: 64px; resize: vertical; }
.modal .box .actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}
.modal .box .actions button { padding: 10px 20px; }

/* ---------- 移动端：表格 → 卡片流 ---------- */
@media (max-width: 760px) {
  .wrap { padding: 10px; }
  .top { padding: 0 12px; min-height: 50px; }
  .top strong { font-size: 15px; }

  .bar { padding: 10px; gap: 8px; }
  .bar > input { flex: 1 1 100%; min-width: 0; font-size: 16px; padding: 11px 12px; }
  .bar > select { flex: 1 1 46%; min-width: 0; font-size: 16px; }
  .bar > button { flex: 1 1 auto; min-width: 0; font-size: 15px; padding: 11px 12px; }

  /* 表格容器改为透明，行变成一张张卡片 */
  .table-scroll {
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
  }
  table { display: block; width: 100%; }
  thead { display: none; }
  tbody { display: block; }
  tbody tr {
    display: block;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 10px;
    padding: 10px 12px;
  }
  tbody tr:nth-child(even) { background: #fff; }
  tbody tr:hover { background: #fff; }
  tbody td {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 6px 0;
    border: none;
    font-size: 14px;
    line-height: 1.5;
  }
  tbody td + td { border-top: 1px dashed var(--line-soft); }
  /* 字段名（来自 data-label） */
  tbody td::before {
    content: attr(data-label);
    flex: 0 0 82px;
    color: var(--muted);
    font-size: 12px;
    padding-top: 2px;
  }
  tbody td:empty::before { content: none; }
  /* 选择框：独立一行靠右，不占字段名 */
  tbody td[data-label="选择"] {
    border: none;
    padding: 0 0 4px;
    justify-content: flex-end;
  }
  tbody td[data-label="选择"]::before { content: none; }
  /* 操作按钮：整行均分，热区加大 */
  tbody td[data-label="操作"] { padding-top: 10px; }
  tbody td[data-label="操作"]::before { content: none; }
  .row-ops { display: flex; width: 100%; gap: 8px; }
  .row-ops button { flex: 1; padding: 11px 0; font-size: 15px; }

  /* 弹窗：全屏卡片 */
  .modal { padding: 0; align-items: stretch; }
  .modal .box {
    margin: 0;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    border-radius: 0;
    padding-bottom: 84px;
  }
  .modal .box h3 { padding: 14px 16px; font-size: 16px; }
  .modal .box > *:not(h3) { margin-left: 16px; margin-right: 16px; }
  .modal .box .half { display: block; width: 100%; margin-right: 0; }
  .modal .box label { font-size: 14px; margin: 14px 0 6px; }
  .modal .box input, .modal .box select, .modal .box textarea { font-size: 16px; padding: 12px 12px; }
  .modal .box .actions {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: #fff;
    margin: 0;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 14px rgba(15, 23, 42, .08);
    z-index: 30;              /* 始终浮在最上层，确保「保存」按钮可见可点 */
    display: flex;
    gap: 10px;
  }
  .modal .box .actions button { flex: 1; padding: 13px 0; font-size: 16px; }

  .pager { padding: 10px; }
  .pager button { flex: 1; padding: 11px 0; font-size: 15px; }
  .pager #pg { flex: 1 1 100%; text-align: center; }
  .page-size-label { margin-left: 0; }
}
