/* 物业收费台账 —— 样式表 */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warn: #d97706;
  --warn-light: #fffbeb;
  --text: #1f2937;
  --text-soft: #6b7280;
  --text-mute: #9ca3af;
  --line: #e5e7eb;
  --line-soft: #f3f4f6;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --side-bg: #1e293b;
  --side-bg2: #172033;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; cursor: pointer; }
table { border-collapse: collapse; width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }
[hidden] { display: none !important; }
.muted { color: var(--text-soft); }
.mono { font-family: "SF Mono", Consolas, Monaco, monospace; }

/* ---------------- 登录页 ---------------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #334155 55%, #1e40af 100%);
  padding: 20px;
}
.login-card {
  width: 380px; max-width: 100%; background: #fff; border-radius: 14px;
  padding: 40px 34px 28px; box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
}
.login-logo {
  width: 52px; height: 52px; border-radius: 13px; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: #fff; font-size: 26px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.login-card h1 { font-size: 21px; text-align: center; font-weight: 600; letter-spacing: 1px; }
.login-sub { text-align: center; color: var(--text-soft); font-size: 13px; margin: 8px 0 26px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--text-soft); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--radius); outline: none; transition: .15s;
  background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.field textarea { resize: vertical; min-height: 64px; }
.login-err { color: var(--danger); font-size: 13px; min-height: 20px; margin-bottom: 6px; }
.login-foot { text-align: center; color: var(--text-mute); font-size: 12px; margin-top: 22px; }

/* ---------------- 主布局 ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 208px; flex: 0 0 208px; background: var(--side-bg); color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px;
  font-size: 15px; font-weight: 600; color: #fff; border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-icon {
  width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, #3b82f6, #6366f1);
  display: flex; align-items: center; justify-content: center; font-size: 13px;
}
#nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.nav-group {
  padding: 14px 18px 6px; font-size: 11px; color: #64748b; letter-spacing: .5px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 18px;
  color: #cbd5e1; font-size: 14px; border-left: 3px solid transparent; transition: .12s;
}
.nav-item .ic { width: 16px; text-align: center; opacity: .75; font-style: normal; }
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: var(--side-bg2); color: #fff; border-left-color: #3b82f6; font-weight: 500; }
.side-foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.07); }
.me-name { color: #fff; font-size: 13px; font-weight: 500; }
.me-role { color: #64748b; font-size: 12px; margin: 3px 0 10px; }
.logout { color: #94a3b8; font-size: 13px; }
.logout:hover { color: #f87171; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.content { padding: 20px 22px 40px; flex: 1; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 15px; border-radius: var(--radius); border: 1px solid var(--line);
  background: #fff; color: var(--text); cursor: pointer; transition: .15s;
  white-space: nowrap; font-size: 13px;
}
.btn:hover { border-color: #cbd5e1; background: #fafafa; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; font-weight: 500; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--line-soft); color: var(--text); }
.btn-link { border: none; background: none; color: var(--primary); padding: 2px 6px; }
.btn-link:hover { text-decoration: underline; background: none; }
.btn-link.danger { color: var(--danger); }

/* ---------------- 卡片 / 面板 ---------------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 16px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap;
}
.panel-head h3 { font-size: 14px; font-weight: 600; }
.panel-head .tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-body { padding: 16px 18px; }
.panel-body.flush { padding: 0; }

/* ---------------- 统计卡片 ---------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .k { font-size: 12px; color: var(--text-soft); margin-bottom: 8px; }
.stat .v { font-size: 23px; font-weight: 600; letter-spacing: -.5px; }
.stat .v small { font-size: 13px; font-weight: 400; color: var(--text-soft); margin-left: 3px; }
.stat .s { font-size: 12px; color: var(--text-mute); margin-top: 6px; }
.stat.blue .v { color: var(--primary); }
.stat.green .v { color: var(--success); }
.stat.red .v { color: var(--danger); }
.stat.orange .v { color: var(--warn); }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
table.grid { font-size: 13px; }
table.grid th {
  background: #f8fafc; color: var(--text-soft); font-weight: 500; text-align: left;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
  position: sticky; top: 0;
}
table.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); }
table.grid tbody tr:hover { background: #fafbfc; }
table.grid tbody tr.sel { background: var(--primary-light); }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.money { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
table.grid tfoot td { padding: 10px 12px; background: #f8fafc; font-weight: 600; border-top: 2px solid var(--line); }
.empty { text-align: center; color: var(--text-mute); padding: 46px 0; font-size: 13px; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 11px; font-size: 12px; line-height: 18px; }
.tag-unpaid { background: var(--danger-light); color: var(--danger); }
.tag-partial { background: var(--warn-light); color: var(--warn); }
.tag-paid { background: var(--success-light); color: var(--success); }
.tag-void { background: var(--line-soft); color: var(--text-mute); }
.tag-info { background: var(--primary-light); color: var(--primary); }

/* ---------------- 工具条 / 筛选 ---------------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.search-box { position: relative; }
.search-box input {
  padding: 8px 12px 8px 32px; border: 1px solid var(--line); border-radius: var(--radius);
  width: 260px; outline: none; background: #fff;
}
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.search-box::before { content: "⌕"; position: absolute; left: 11px; top: 7px; color: var(--text-mute); font-size: 15px; }
select.ipt, input.ipt {
  padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; outline: none; min-width: 120px;
}
select.ipt:focus, input.ipt:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 12px; border-radius: 15px; border: 1px solid var(--line); background: #fff;
  cursor: pointer; font-size: 13px; color: var(--text-soft);
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------------- 分页 ---------------- */
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; gap: 12px; flex-wrap: wrap; }
.pager .pages { display: flex; gap: 4px; }
.pager button {
  min-width: 32px; height: 30px; border: 1px solid var(--line); background: #fff;
  border-radius: 6px; cursor: pointer; color: var(--text-soft);
}
.pager button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 12px; width: 560px; max-width: 100%;
  box-shadow: var(--shadow-lg); animation: pop .16s ease-out;
}
.modal.wide { width: 880px; }
.modal.narrow { width: 420px; }
@keyframes pop { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft);
}
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-close { font-size: 22px; color: var(--text-mute); line-height: 1; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; max-height: 68vh; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px;
  border-top: 1px solid var(--line-soft); background: #fafbfc; border-radius: 0 0 12px 12px;
}
.form-row { display: flex; gap: 14px; }
.form-row > .field { flex: 1; }
.hint { font-size: 12px; color: var(--text-mute); margin-top: 5px; line-height: 1.6; }
.alert { padding: 11px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; line-height: 1.7; }
.alert-info { background: var(--primary-light); color: #1e40af; }
.alert-warn { background: var(--warn-light); color: #92400e; }
.alert-err { background: var(--danger-light); color: #991b1b; }
.alert-ok { background: var(--success-light); color: #166534; }
.alert ul { margin: 6px 0 0 18px; }

/* ---------------- 提示条 ---------------- */
.toast {
  position: fixed; top: 22px; left: 50%; transform: translateX(-50%); z-index: 999;
  background: #1f2937; color: #fff; padding: 11px 20px; border-radius: 8px;
  font-size: 13px; box-shadow: var(--shadow-lg); max-width: 80vw;
}
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }

/* ---------------- 收费台 ---------------- */
.counter { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.room-list { max-height: 640px; overflow-y: auto; }
.room-item { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.room-item:hover { background: #fafbfc; }
.room-item.active { background: var(--primary-light); border-left: 3px solid var(--primary); }
.room-item .l1 { display: flex; justify-content: space-between; align-items: baseline; }
.room-item .rn { font-weight: 600; }
.room-item .ow { color: var(--danger); font-size: 13px; font-weight: 500; }
.room-item .l2 { font-size: 12px; color: var(--text-soft); margin-top: 4px; }
.room-item .zero { color: var(--success); }
.pay-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 13px 18px; background: var(--primary-light); border-radius: var(--radius);
  margin-top: 14px; flex-wrap: wrap;
}
.pay-summary .big { font-size: 22px; font-weight: 600; color: var(--primary); }
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }

/* ---------------- 收据（屏幕预览 + A4 打印） ---------------- */
.receipt {
  background: #fff; border: 1px solid var(--line); padding: 26px 30px;
  font-family: "SimSun", "Songti SC", serif; color: #000;
}
.receipt h2 { text-align: center; font-size: 21px; letter-spacing: 6px; margin-bottom: 4px; font-weight: 600; }
.receipt .rc-sub { text-align: center; font-size: 12px; color: #444; margin-bottom: 16px; letter-spacing: 1px; }
.receipt .rc-meta { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 10px; }
.receipt table { width: 100%; border-collapse: collapse; font-size: 13px; }
.receipt table th, .receipt table td { border: 1px solid #333; padding: 7px 9px; }
.receipt table th { background: #f2f2f2; text-align: center; font-weight: 500; }
.receipt table td.num { text-align: right; }
.receipt .rc-total { font-size: 14px; font-weight: 600; }
.receipt .rc-chinese { font-size: 13px; margin-top: 10px; letter-spacing: 1px; }
.receipt .rc-sign { display: flex; justify-content: space-between; margin-top: 26px; font-size: 13px; }
.receipt .rc-note { margin-top: 18px; font-size: 11px; color: #666; border-top: 1px dashed #999; padding-top: 8px; }
.receipt.voided { position: relative; }
.receipt.voided::after {
  content: "已 作 废"; position: absolute; top: 42%; left: 50%;
  transform: translate(-50%, -50%) rotate(-18deg);
  font-size: 62px; color: rgba(220, 38, 38, .22); letter-spacing: 14px; font-weight: 700;
  border: 5px solid rgba(220, 38, 38, .18); padding: 8px 26px; border-radius: 10px; white-space: nowrap;
}

@media print {
  @page { size: A4 portrait; margin: 14mm 12mm; }
  body { background: #fff; }
  .app, .login-wrap, .modal-mask, .toast, .sidebar, .topbar { display: none !important; }
  #print-area { display: block !important; }
  .receipt { border: none; padding: 0; }
  .receipt table th { background: #f2f2f2 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
#print-area { display: none; }

/* ---------------- 其他 ---------------- */
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 8px 12px; font-size: 13px; }
.kv .k { color: var(--text-soft); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { padding: 9px 16px; cursor: pointer; color: var(--text-soft); border-bottom: 2px solid transparent; font-size: 14px; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13px; }
.bar-row .nm { width: 76px; color: var(--text-soft); flex: 0 0 76px; }
.bar-row .bar { flex: 1; height: 16px; background: var(--line-soft); border-radius: 8px; overflow: hidden; }
.bar-row .bar > i { display: block; height: 100%; background: linear-gradient(90deg, #60a5fa, #2563eb); border-radius: 8px; }
.bar-row .vl { width: 108px; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }

@media (max-width: 1100px) {
  .counter { grid-template-columns: 1fr; }
  .sidebar { width: 62px; flex: 0 0 62px; }
  .brand span:not(.brand-icon), .nav-item span, .nav-item, .side-foot { font-size: 0; }
  .nav-item .ic { font-size: 15px; }
  .nav-group { display: none; }
}
