:root {
  --bg: #f3f6f4;
  --card: #fff;
  --ink: #1a1c1b;
  --muted: #5c635f;
  --seed: #1b4d3e;
  --seed2: #2d6a55;
  --line: #d7e0db;
  --danger: #b42318;
  --ok: #067647;
  /* 内容区随屏幕加宽 */
  --page-max: min(1760px, 100%);
  --page-gutter: clamp(16px, 3vw, 48px);
}
* { box-sizing: border-box; }
html { overflow-x: hidden; }
body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #e8f0ec 0%, var(--bg) 220px);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
a { color: var(--seed); text-decoration: none; }
a:hover { text-decoration: underline; }
.top {
  background: var(--seed);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.top-inner {
  max-width: var(--page-max);
  width: 100%;
  margin: 0 auto;
  padding: 12px var(--page-gutter);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  min-width: 0;
  box-sizing: border-box;
}
.brand { color: #fff; font-weight: 700; font-size: 18px; text-decoration: none; white-space: nowrap; }
.nav { display: flex; flex-wrap: wrap; gap: 8px 14px; flex: 1; min-width: 0; }
.nav a { color: rgba(255,255,255,.85); text-decoration: none; font-size: 14px; }
.nav a.on, .nav a:hover { color: #fff; text-decoration: underline; }
.user { font-size: 13px; color: rgba(255,255,255,.9); max-width: 100%; }
.user a { color: #fff; }
.flash {
  max-width: var(--page-max);
  width: 100%;
  margin: 12px auto 0;
  padding: 10px var(--page-gutter);
  border-radius: 8px;
  overflow-wrap: anywhere;
  box-sizing: border-box;
}
.flash.ok { background: #e8f7ef; color: var(--ok); }
.flash.err { background: #fef3f2; color: var(--danger); }
.wrap {
  max-width: var(--page-max);
  width: 100%;
  margin: 0 auto;
  padding: 20px var(--page-gutter) 48px;
  min-width: 0;
  box-sizing: border-box;
}
.hero h1 { margin: 0 0 6px; font-size: 26px; }
.hero p { margin: 0; color: var(--muted); }

/* 一卡一功能 / 一卡一指标 */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 1px 0 rgba(0,0,0,.03);
  min-width: 0;
  overflow: hidden;
}
.card a.block {
  display: block;
  padding: 16px;
  color: inherit;
  text-decoration: none;
  min-height: 88px;
}
.card a.block:hover { background: #f7faf8; }
.card h3 {
  margin: 0 0 6px;
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  min-width: 0;
  overflow: hidden;
}
.stat b {
  display: block;
  font-size: clamp(14px, 4.2vw, 18px);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin: 12px 0;
  min-width: 0;
}
.toolbar .field { min-width: 0; flex: 1 1 120px; max-width: 100%; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
textarea { min-height: 72px; resize: vertical; }
.btn, button, .btn-link {
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
  background: var(--seed);
  color: #fff;
  white-space: nowrap;
}
.btn.secondary, button.secondary { background: #fff; color: var(--seed); border: 1px solid var(--seed); }
.btn.danger, button.danger { background: var(--danger); }
.btn.ghost, button.ghost, a.btn.ghost {
  background: transparent;
  color: var(--seed);
  border: 1px solid var(--line);
  display: inline-block;
  line-height: 1.2;
}
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.tabs a {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  text-decoration: none;
}
.tabs a.on { background: var(--seed); color: #fff; border-color: var(--seed); }

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}
th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  vertical-align: top;
  overflow: hidden;
  word-break: break-word;
}
th { background: #eef4f1; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.col-date { width: 6.5em; }
.col-amt { width: 7em; }
.col-in, .col-out { width: 6.5em; }
.col-bal { width: 7em; }
.col-act { width: 9.5em; }
.income { color: var(--ok); }
.expense { color: var(--danger); }
.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 流水账本：日期 | 摘要 | 收入 | 支出 | 结余 */
.ledger-book {
  border: 1.5px solid #8fa89a;
  border-radius: 6px;
  background: #fbfaf6;
}
.ledger-book table { min-width: 640px; }
.ledger-book th {
  background: #e7efe9;
  color: var(--ink);
  text-align: center;
  border-bottom: 2px solid #8fa89a;
  border-right: 1px solid #c9d6ce;
  padding: 8px 8px;
  font-size: 13px;
}
.ledger-book th:last-child,
.ledger-book td:last-child { border-right: 0; }
.ledger-book td {
  border-bottom: 1px solid #e4ebe6;
  border-right: 1px solid #e4ebe6;
  padding: 8px 8px;
  font-size: 13px;
  vertical-align: middle;
}
.ledger-book .col-date { text-align: center; white-space: nowrap; }
.ledger-book .col-in,
.ledger-book .col-out,
.ledger-book .col-bal {
  text-align: right;
  font-weight: 600;
}
.ledger-book tbody tr:nth-child(even) td { background: rgba(27, 77, 62, 0.03); }
.ledger-book tbody tr:hover td { background: rgba(27, 77, 62, 0.06); }
.ledger-book .col-act { width: 5.5em; }
.ledger-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.ledger-pin-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  flex-wrap: nowrap;
}
.ledger-pin-inline {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  margin: 0;
}
.ledger-pin-input {
  width: 9em;
  max-width: 140px;
  flex: 0 0 auto;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
}
.row-actions.ledger-actions {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
}
.row-actions.ledger-actions form {
  display: inline-flex;
  flex: 0 0 auto;
  margin: 0;
}
.row-actions.ledger-actions .btn,
.row-actions.ledger-actions button {
  padding: 4px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.auth {
  max-width: 400px;
  margin: 48px auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
}
.auth h1 { margin: 0 0 8px; font-size: 22px; }
.auth .sub { color: var(--muted); margin: 0 0 18px; }
.auth .field { margin-bottom: 12px; }
.auth button { width: 100%; margin-top: 8px; }
.auth .foot { margin-top: 14px; font-size: 13px; color: var(--muted); text-align: center; }
.foot {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 24px var(--page-gutter) 32px;
  max-width: var(--page-max);
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}
.foot .beian {
  margin: 8px 0 0;
}
.foot .beian a {
  color: inherit;
  text-decoration: none;
}
.foot .beian a:hover {
  text-decoration: underline;
}
.row-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}
.row-actions form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 0;
  min-width: 0;
}
.row-actions input[type="password"] {
  width: 100%;
  min-width: 0;
  flex: 1 1 90px;
}
/* 宽带：按钮一排 */
.row-actions.bb-actions {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.row-actions.bb-actions form {
  display: inline-flex;
  flex: 0 0 auto;
  margin: 0;
}
.row-actions.bb-actions .btn,
.row-actions.bb-actions button {
  padding: 6px 10px;
  font-size: 13px;
}
.date-pair {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.date-pair .d-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.date-pair .d-lab {
  color: var(--muted);
  font-size: 12px;
  margin-right: 4px;
}
.col-start, .col-end { width: 7.5em; }
.bb-own-book table { min-width: 1100px; table-layout: auto; }
.bb-own-book th,
.bb-own-book td {
  white-space: nowrap;
  vertical-align: middle;
  padding: 8px 8px;
  font-size: 13px;
}
.bb-own-book .cell-ellip {
  max-width: min(18em, 22vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bb-own-book .col-name { max-width: min(8em, 12vw); overflow: hidden; text-overflow: ellipsis; }
.bb-own-book .col-st { width: 4em; }
.bb-own-book .col-mask { max-width: min(12em, 14vw); overflow: hidden; text-overflow: ellipsis; }
.bb-own-book .col-phone { width: 7.5em; }
.bb-own-book .col-user { max-width: min(7em, 10vw); overflow: hidden; text-overflow: ellipsis; }
.bb-own-book .col-proof { width: 3em; text-align: center; }
.bb-own-book .col-act { width: 11em; }
.bb-own-book .col-act .bb-actions {
  flex-wrap: nowrap;
  gap: 3px;
}
.bb-own-book .col-act .btn,
.bb-own-book .col-act button {
  padding: 3px 6px;
  font-size: 12px;
}
.bb-own-book tr.bb-expired td { color: var(--danger, #b42318); }
.bb-own-book .bb-expired-text { color: var(--danger, #b42318) !important; font-weight: 600; }
.nowrap { white-space: nowrap; }
.sheet-head-row {
  display: flex;
  justify-content: flex-end;
  margin: 4px 0 8px;
}
.bb-pin-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.muted { color: var(--muted); font-size: 13px; }
.sheet {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin: 14px 0;
  min-width: 0;
  overflow: hidden;
}
.clamp2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.silent-batch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.silent-batch textarea {
  min-height: 200px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
}
.silent-table tbody tr td {
  background: transparent;
}
@media (min-width: 720px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stats.stats-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}
.remark-cell {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: none;
}
.tv-batch {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.tv-batch.tv-batch-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.tv-batch.tv-batch-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.tv-batch.tv-batch-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.tv-batch textarea {
  min-height: 140px;
  width: 100%;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
}
@media (max-width: 720px) {
  .tv-batch,
  .tv-batch.tv-batch-3,
  .tv-batch.tv-batch-4,
  .tv-batch.tv-batch-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .tv-batch,
  .tv-batch.tv-batch-3,
  .tv-batch.tv-batch-4,
  .tv-batch.tv-batch-5 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .hero h1 { font-size: 22px; }
  th.hide-sm, td.hide-sm { display: none; }
  table { table-layout: auto; }
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  td { border: 0; padding: 4px 12px; }
  .col-date, .col-amt, .col-in, .col-out, .col-bal, .col-act, .col-start, .col-end { width: auto; }
  .row-actions { flex-direction: column; }
  .row-actions.bb-actions,
  .row-actions.ledger-actions { flex-direction: row; }

  /* 账本 / 自有宽带：保持表格横滑，不拆成卡片 */
  .ledger-book thead,
  .bb-own-book thead { display: table-header-group; }
  .ledger-book table,
  .bb-own-book table { display: table; width: 100%; table-layout: auto; }
  .ledger-book tbody,
  .bb-own-book tbody { display: table-row-group; }
  .ledger-book tr,
  .bb-own-book tr { display: table-row; border: 0; padding: 0; }
  .ledger-book th,
  .ledger-book td,
  .bb-own-book th,
  .bb-own-book td {
    display: table-cell;
    width: auto;
    border-bottom: 1px solid var(--line);
    padding: 8px 6px;
  }
  .ledger-book th,
  .ledger-book td {
    border-bottom: 1px solid #e4ebe6;
    border-right: 1px solid #e4ebe6;
  }
  .ledger-book .col-act .row-actions,
  .bb-own-book .col-act .row-actions { flex-direction: row; flex-wrap: nowrap; }
}
