* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { font-size: 15px; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; background: #f1f5f9; color: #0f172a; }
.muted { color: #64748b; font-size: .85rem; }
.err { color: #dc2626; font-size: .85rem; min-height: 1.2em; margin: 8px 0 0; }
.hide { display: none !important; }

/* ---- 登录 ---- */
.login-wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg,#0f172a,#1e3a5f); padding: 20px; z-index: 50; }
.login-card { background: #fff; border-radius: 16px; padding: 32px 24px; width: 100%; max-width: 360px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card .logo { font-size: 1.5rem; font-weight: 700; letter-spacing: 2px; }
.login-card input { width: 100%; padding: 12px 14px; font-size: 1.05rem; border: 1.5px solid #cbd5e1; border-radius: 10px; margin: 20px 0 14px; outline: none; }
.login-card input:focus { border-color: #2563eb; }

/* ---- 布局 ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; background: #0f172a; color: #fff; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
.brand { font-weight: 700; font-size: 1.05rem; line-height: 1.25; }
.brand .sub { display: block; font-weight: 400; font-size: .68rem; color: #94a3b8; }
.nav { display: flex; gap: 4px; overflow-x: auto; background: #fff; border-bottom: 1px solid #e2e8f0; padding: 0 8px; position: sticky; top: 0; z-index: 10; }
.nav a { flex: none; padding: 12px 12px 10px; font-size: .95rem; color: #475569; text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; }
.nav a.active { color: #2563eb; border-color: #2563eb; font-weight: 600; }
.main { padding: 14px; max-width: 1120px; margin: 0 auto 60px; }

/* ---- 通用组件 ---- */
.card { background: #fff; border-radius: 14px; padding: 14px; box-shadow: 0 1px 3px rgba(15,23,42,.06); margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: #fff; border-radius: 14px; padding: 14px; box-shadow: 0 1px 3px rgba(15,23,42,.06); }
.stat .label { font-size: .78rem; color: #64748b; }
.stat .value { font-size: 1.35rem; font-weight: 700; margin-top: 4px; }
.stat .value.red { color: #dc2626; }
.stat .value.green { color: #16a34a; }
.btn { border: none; border-radius: 10px; padding: 10px 16px; font-size: .95rem; cursor: pointer; background: #e2e8f0; color: #0f172a; font-weight: 500; }
.btn.primary { background: #2563eb; color: #fff; }
.btn.danger { background: #fee2e2; color: #b91c1c; }
.btn.ghost { background: transparent; color: inherit; }
.btn.small { padding: 6px 10px; font-size: .82rem; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:active { transform: scale(.98); }
.topbar .btn.ghost { color: #cbd5e1; }
input, select, textarea { font-family: inherit; font-size: .95rem; padding: 9px 11px; border: 1.5px solid #cbd5e1; border-radius: 9px; outline: none; background: #fff; color: inherit; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: #2563eb; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 12px 4px; border-bottom: 1px solid #f1f5f9; cursor: pointer; }
.list-item:last-child { border-bottom: none; }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 600; }
.li-sub { font-size: .8rem; color: #64748b; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-amount { font-weight: 700; text-align: right; white-space: nowrap; }
.li-amount.red { color: #dc2626; }
.li-amount.green { color: #16a34a; }
.tag { display: inline-block; font-size: .7rem; background: #eef2ff; color: #4338ca; border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: 1px; }
.tag.hist { background: #fef3c7; color: #92400e; }
h3.sec { font-size: .9rem; color: #64748b; font-weight: 600; margin: 18px 4px 8px; }
.empty { text-align: center; color: #94a3b8; padding: 30px 0; }

/* ---- 表格 ---- */
.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th, .tbl td { padding: 8px 6px; border-bottom: 1px solid #f1f5f9; text-align: left; }
.tbl th { color: #64748b; font-weight: 600; font-size: .8rem; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl tr.total td { font-weight: 700; border-top: 2px solid #e2e8f0; }

/* ---- 记账条目 ---- */
.items-wrap { overflow-x: auto; }
.items-head, #rows .item-row { display: grid; grid-template-columns: 118px 86px minmax(150px,1.5fr) 78px 54px 60px 66px 76px 92px 32px; gap: 6px; align-items: center; min-width: 880px; }
.items-head { font-size: .75rem; color: #64748b; padding: 0 0 6px; text-align: center; }
#rows .item-row { margin-bottom: 6px; }
#rows .item-row input { font-size: .86rem; padding: 6px 8px; }
#rows .item-row .amt-cell { text-align: right; font-weight: 600; font-size: .9rem; white-space: nowrap; }
.item-row .del { color: #b91c1c; font-weight: 700; padding: 4px 6px; cursor: pointer; }
.item-name-cell { position: relative; }
.suggest { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; box-shadow: 0 8px 24px rgba(15,23,42,.14); z-index: 30; max-height: 240px; overflow-y: auto; }
.suggest div { padding: 9px 11px; cursor: pointer; font-size: .9rem; border-bottom: 1px solid #f8fafc; }
.suggest div:hover, .suggest div.on { background: #eff6ff; }
.suggest .sp { color: #94a3b8; font-size: .78rem; }
.amt-cell { text-align: right; font-weight: 600; padding-right: 4px; white-space: nowrap; }
.total-line { display: flex; justify-content: flex-end; gap: 10px; padding: 10px 2px; font-weight: 700; font-size: 1.05rem; }

/* ---- 弹窗 / 提示 ---- */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 40; }
@media (min-width: 640px) { .modal { align-items: center; } }
.modal-box { background: #fff; border-radius: 16px 16px 0 0; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .modal-box { border-radius: 16px; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 1rem; }
.modal-head .btn { color: #64748b; }
.form-row { margin-bottom: 10px; }
.form-row label { display: block; font-size: .8rem; color: #64748b; margin-bottom: 4px; }
.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: .9rem; z-index: 60; box-shadow: 0 8px 30px rgba(0,0,0,.3); max-width: 86vw; }
.toast.ok { background: #15803d; }
.toast.bad { background: #b91c1c; }

/* 手机适配 */
@media (max-width: 640px) {
  .grid3 { grid-template-columns: 1fr 1fr; }
  .tbl { font-size: .82rem; }
}

/* ---- 查价格：左侧客户栏 ---- */
.price-layout { display: flex; gap: 12px; align-items: flex-start; }
.cust-side { width: 190px; flex: none; background: #fff; border-radius: 14px; padding: 8px; box-shadow: 0 1px 3px rgba(15,23,42,.06); position: sticky; top: 62px; max-height: calc(100vh - 90px); overflow-y: auto; }
.cust-item { padding: 9px 10px; border-radius: 9px; cursor: pointer; font-size: .9rem; color: #334155; }
.cust-item:hover { background: #f1f5f9; }
.cust-item.active { background: #2563eb; color: #fff; font-weight: 600; }
.price-main { flex: 1; min-width: 0; }
.li-price { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.li-price .amount { font-weight: 700; white-space: nowrap; }
.hist-btn { border: 1px solid #cbd5e1; border-radius: 8px; padding: 2px 10px; font-size: .74rem; color: #2563eb; background: #fff; }
.hist-btn:hover { background: #eff6ff; border-color: #93c5fd; }
@media (max-width: 720px) {
  .price-layout { flex-direction: column; }
  .cust-side { width: 100%; display: flex; gap: 6px; overflow-x: auto; padding: 8px; position: static; max-height: none; }
  .cust-item { white-space: nowrap; flex: none; }
}
