:root {
  --bg: #f4f6fb; --card: #fff; --line: #e3e8f0; --text: #1f2937; --muted: #6b7280;
  --brand: #2563eb; --brand-dark: #1d4ed8; --ok: #067647; --ok-bg: #e9f8ef;
  --warn: #b54708; --warn-bg: #fef6e7; --err: #b42318; --err-bg: #fdecea; --head: #f1f5fb;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.6 "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { background: #101828; color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1500px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; font-size: 16px; }
.nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.nav a { color: #d0d5dd; } .nav a:hover { color: #fff; text-decoration: none; }
.who { color: #98a2b3; } .logout { color: #fda29b !important; }
.refresh-btn { color: #7dd3fc !important; font-weight: 600; }
.refresh-btn:hover { color: #fff !important; }

.wrap { max-width: 1500px; margin: 0 auto; padding: 16px; }
.foot { text-align: center; color: var(--muted); padding: 20px; font-size: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card h2 { margin: 0 0 12px; font-size: 15px; }
.card h3 { margin: 0 0 10px; font-size: 14px; color: var(--muted); }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 20px; font-weight: 700; margin-top: 4px; word-break: break-all; }
.stat.hl { border-color: #bfd3f8; background: #f5f8ff; }

.table-scroll { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
table { border-collapse: collapse; width: 100%; background: #fff; font-size: 13px; white-space: nowrap; }
th, td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 7px 10px; text-align: left; }
th { background: var(--head); font-weight: 600; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.group-row td { background: #f0f6ff; font-weight: 600; }
tr.subtotal td { background: #fafbff; color: var(--muted); font-style: italic; white-space: normal; }
tr:hover td { background: #fbfcfe; }
tr.group-row:hover td { background: #e8f1ff; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid transparent; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.err { background: var(--err-bg); color: var(--err); }
.tag.info { background: #eef2ff; color: #3538cd; }

.btn { display: inline-block; background: var(--brand); color: #fff !important;
  border: 1px solid var(--brand); border-radius: 8px; padding: 7px 14px; cursor: pointer; font-size: 13px; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--brand) !important; }
.btn.gray { background: #fff; color: var(--text) !important; border-color: var(--line); }
.btn.danger { background: #fff; color: var(--err) !important; border-color: #f3c3bd; }
.btn.small { padding: 4px 9px; font-size: 12px; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #d0d5dd; border-radius: 8px;
  font: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfd3f8; border-color: var(--brand); }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 10px; }
.row-inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row-inline .field { flex: 1 1 160px; margin-bottom: 0; }

.flash { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; border: 1px solid; }
.flash.ok { background: var(--ok-bg); border-color: #a9dfc1; color: var(--ok); }
.flash.error { background: var(--err-bg); border-color: #f3c3bd; color: var(--err); }
.flash.message { background: #eef2ff; border-color: #c7d2fe; color: #3538cd; }

.muted { color: var(--muted); } .small { font-size: 12px; }
.mono { font-family: Consolas, "Courier New", monospace; }
.linkbox { background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 10px; padding: 10px;
  word-break: break-all; font-family: Consolas, "Courier New", monospace; font-size: 13px; }
.keybox { font-size: 20px; font-weight: 700; letter-spacing: 2px; color: var(--brand); }
.center-card { max-width: 460px; margin: 8vh auto; }
.center-card .card { padding: 22px; }
h1.page-title { font-size: 20px; margin: 0 0 6px; }
.sub-title { color: var(--muted); margin: 0 0 16px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
details summary { cursor: pointer; color: var(--brand); font-size: 13px; margin-bottom: 10px; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; white-space: normal; }
.readonly-badge { background: var(--ok-bg); color: var(--ok); border: 1px solid #a9dfc1;
  padding: 2px 10px; border-radius: 999px; font-size: 12px; }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-family: Consolas, monospace; }

/* ==================== 美化弹窗（电脑 + 手机自适应） ==================== */
body.jz-locked { overflow: hidden; }

.jz-mask {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(15, 23, 42, .55);
  -webkit-backdrop-filter: blur(4px) saturate(120%);
  backdrop-filter: blur(4px) saturate(120%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0; visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
}
.jz-mask.show { opacity: 1; visibility: visible; }

.jz-modal {
  width: 100%; max-width: 470px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 32px 68px rgba(15, 23, 42, .3), 0 4px 14px rgba(15, 23, 42, .1);
  transform: translateY(18px) scale(.96);
  opacity: .6;
  transition: transform .24s cubic-bezier(.2, .85, .3, 1.08), opacity .24s ease;
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 48px);
}
.jz-mask.show .jz-modal { transform: translateY(0) scale(1); opacity: 1; }

/* 顶部的彩色标题条 */
.jz-modal::before {
  content: ''; display: block; height: 4px;
  background: linear-gradient(90deg, #2563eb, #22d3ee 60%, #34d399);
}
.jz-mask.danger .jz-modal::before,
.jz-mask.show .jz-modal.danger::before { background: linear-gradient(90deg, #d92d20, #f97066); }

.jz-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 18px 22px 6px;
}
.jz-modal-title { font-size: 17px; font-weight: 700; color: #0f172a; letter-spacing: .2px; }
.jz-modal-x {
  flex: none; width: 30px; height: 30px; margin: -4px -6px 0 0;
  border: 0; border-radius: 9px; background: #f2f4f7; cursor: pointer;
  font-size: 20px; line-height: 1; color: #667085;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease, transform .1s ease;
}
.jz-modal-x:hover { background: #e4e7ec; color: #344054; }
.jz-modal-x:active { transform: scale(.92); }

.jz-modal-body {
  padding: 2px 22px 18px;
  color: #475467; font-size: 14.5px; line-height: 1.8;
  overflow: auto; -webkit-overflow-scrolling: touch;
}
.jz-modal-body b { color: #0f172a; }
.jz-modal-body .jz-hint {
  display: block; margin-top: 10px; padding: 10px 12px;
  background: #f8fafc; border: 1px solid #eef2f6; border-left: 3px solid #2563eb;
  border-radius: 8px; color: #475467; font-size: 13px;
}

.jz-modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 22px 20px;
  background: #fafbfc; border-top: 1px solid #eef2f6;
}
.jz-modal-foot .btn { min-width: 92px; justify-content: center; }

/* ==================== 按钮交互效果 ==================== */
.btn {
  position: relative;
  transition: transform .12s ease, box-shadow .18s ease, background .18s ease,
              border-color .18s ease, color .18s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37, 99, 235, .18); }
.btn:active { transform: translateY(0) scale(.985); box-shadow: 0 1px 3px rgba(15, 23, 42, .16); }
.btn:focus-visible { outline: 2px solid #84caff; outline-offset: 2px; }
.btn.danger:hover { box-shadow: 0 6px 16px rgba(217, 45, 32, .22); }
.btn.gray:hover { box-shadow: 0 6px 16px rgba(15, 23, 42, .1); }
.btn-danger, .btn.danger-solid { background: #d92d20; border-color: #d92d20; color: #fff !important; }
.btn.danger-solid:hover, .btn.danger-solid:active { background: #b42318; border-color: #b42318; }
.btn.strong { font-weight: 600; }
.btn.refresh { background: #fff; color: #175cd3 !important; border-color: #b2ccff; font-weight: 600; }
.btn.refresh:hover { background: #eff4ff; }

/* 表单里的小按钮排布 */
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions form { margin: 0; }

/* ==================== 手机适配 ==================== */
@media (max-width: 640px) {
  .jz-mask { padding: 0; align-items: flex-end; }
  .jz-modal {
    max-width: 100%; width: 100%;
    border-radius: 18px 18px 0 0;
    max-height: 88vh;
    transform: translateY(100%);
    opacity: 1;
  }
  .jz-mask.show .jz-modal { transform: translateY(0); }
  .jz-modal-head { padding: 16px 18px 6px; }
  .jz-modal-title { font-size: 16px; }
  .jz-modal-body { padding: 2px 18px 16px; font-size: 15px; }
  .jz-modal-foot {
    padding: 14px 18px calc(16px + env(safe-area-inset-bottom, 0px));
    flex-direction: column-reverse;
  }
  .jz-modal-foot .btn { width: 100%; min-height: 46px; font-size: 15px; }
  .topbar-inner { flex-wrap: wrap; gap: 8px; }
  .nav { flex-wrap: wrap; gap: 8px !important; }
  .nav a { font-size: 13px; }
  .grid.cols-4, .grid.cols-3 { grid-template-columns: 1fr !important; }
  .row-inline { flex-direction: column; align-items: stretch; }
  .row-inline .btn { width: 100%; }
  .card { padding: 14px !important; }
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { font-size: 13px; }
  .btn { min-height: 40px; display: inline-flex; align-items: center; }
}

/* 动态行（下户登记表单：添加 / 删除行） */
table tbody tr[data-jz-row]:nth-child(even) { background: #fcfdff; }
.jz-row-no { color: #98a2b3; text-align: center; }
tr[data-jz-row] input[data-field] { min-width: 118px; }
tr[data-jz-row] .btn.small { padding: 4px 9px; font-size: 12px; }
