:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --text: #172033;
  --muted: #667085;
  --line: #d7dee8;
  --blue: #1d6fd6;
  --blue-2: #e8f1ff;
  --green: #10734f;
  --amber: #965400;
  --red: #c0392b;
  --blue-soft: #f3f7ff;
  --green-soft: #f1faf6;
  --amber-soft: #fff9ed;
  --red-soft: #fff6f4;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}
button, input, select, textarea { font: inherit; }
button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 7px;
  padding: 9px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--blue); color: var(--blue); }
button:focus-visible, [role="button"]:focus-visible { outline: 3px solid rgba(29, 111, 214, 0.22); outline-offset: 2px; }
.ledger-mobile-list { display: none; }
.overdue-followup-cell { min-width: 170px; max-width: 260px; white-space: normal; }
.overdue-followup-edit { display: block; width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid #d9e4f1; background: #f3f7fc; color: #24364b; font-size: 13px; font-weight: 500; line-height: 1.6; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; }
.overdue-followup-edit:hover { color: #174b86; background: #eaf2fc; border-color: #acc8e9; }
#overdueFollowupForm small { color: var(--muted); font-size: 12px; }
@media(max-width:700px) {
  #overduePageRows .overdue-followup-cell { min-width: 0; max-width: none; }
  .overdue-followup-edit { min-height: 44px; }
}
.log-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 0 0 16px; }
.log-filters label { flex: 1 1 150px; }
.log-filters button { min-height: 42px; }
.modal-body:has(> .modal-edit-form) { display: flex; min-height: 0; overflow: hidden; padding-bottom: 0; }
.modal-body:has(> #applicationBasicEditForm) { display: block; overflow: auto; }
#applicationBasicEditForm.modal-edit-form { overflow: visible; min-height: auto; }
#applicationBasicEditForm textarea { resize: vertical; line-height: 1.5; min-height: 96px; }
.modal-edit-form { display: flex; flex-direction: column; width: 100%; min-height: 0; gap: 0; overflow: hidden; }
.edit-fields { overflow: auto; min-height: 0; padding: 0 4px 18px 0; }
.edit-section { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px 18px; min-width: 0; margin: 0 0 22px; padding: 12px 0 0; border: 0; }
.edit-section legend { width: 100%; padding: 0 0 10px; border-bottom: 1px solid var(--line); color: var(--text); font-size: 15px; font-weight: 700; }
.edit-section > * { min-width: 0; }
.edit-section small, .edit-save-hint { color: var(--muted); font-size: 12px; line-height: 1.6; }
.edit-wide { grid-column: 1 / -1; }
#installmentFields { display: flex; flex-direction: column; gap: 10px; }
.installment-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
@media (max-width: 700px) {
  .installment-row { grid-template-columns: 1fr; gap: 12px; }
}
.modal-edit-form .edit-save-bar { flex-shrink: 0; flex-direction: row; justify-content: flex-end; margin: 0; padding: 12px 0 max(12px,env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.edit-save-bar button { min-height: 44px; }
.edit-save-bar .customer-analysis-entry { margin: 0; background: #edf6ff; border-color: #bcd8f0; color: #226eaa; }
.customer-report-actions a, .customer-report-row > a { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--blue); background: var(--blue-soft); text-decoration: none; font-size: 13px; white-space: nowrap; }
.customer-report-actions a:first-child { color: white; background: var(--blue); border-color: var(--blue); }
.customer-report-actions a:hover, .customer-report-row > a:hover { filter: brightness(.96); }
@media(max-width:700px) {
  .edit-section { grid-template-columns: 1fr; gap: 12px; }
  .modal-edit-form .edit-save-bar button { flex: 1; }
  .customer-report-actions a, .customer-report-row > a { min-height: 44px; }
  #ledgerPage .table-wrap:has(#ledgerRows) { display: none; }
  .ledger-mobile-list { display: grid; gap: 10px; }
  .ledger-mobile-entry { padding: 14px; border: 1px solid var(--line); border-radius: 10px; }
  .ledger-entry-head, .ledger-entry-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
  .ledger-entry-head strong { font-size: 16px; }
  .ledger-entry-meta { margin-top: 8px; color: var(--muted); font-size: 12px; }
  .ledger-mobile-entry details { margin-top: 10px; font-size: 12px; color: var(--muted); }
  .ledger-mobile-entry summary { cursor: pointer; min-height: 28px; padding-top: 4px; }
  .ledger-mobile-entry dl { margin: 0; }
  .ledger-mobile-entry dl > div { display: flex; justify-content: space-between; padding: 6px 0; }
  .ledger-mobile-entry dd { margin: 0; color: var(--text); }
  .repayment-plan-wrap { border: 0; overflow: visible; }
  .repayment-plan-table, .repayment-plan-table tbody { display: block; min-width: 0; width: 100%; }
  .repayment-plan-table thead { display: none; }
  .repayment-plan-table tbody { display: grid; gap: 9px; }
  .repayment-plan-table tr { display: grid; grid-template-columns: 1fr 1fr; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
  .repayment-plan-table td { min-width: 0; padding: 5px 0; border: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .repayment-plan-table td:nth-child(even) { text-align: right; }
  .repayment-plan-table td:nth-child(3)::before { content: '应还 '; color: var(--muted); font-size: 12px; }
  .repayment-plan-table td:nth-child(4)::before { content: '已还 '; color: var(--muted); font-size: 12px; }
  .repayment-plan-table td:nth-child(5)::before { content: '剩余 '; color: var(--muted); font-size: 12px; }
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.field-message { color: var(--red); font-size: 12px; line-height: 1.45; }

.rejected-customer-notice {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 1px solid #fecaca;
  border-radius: 14px;
  background: #fff7f7;
  color: #991b1b;
}
.rejected-customer-notice strong { font-size: 16px; }
.rejected-customer-notice small { color: #7f1d1d; }
input.field-error { border-color: var(--red); background: var(--red-soft); }
h1, h2, h3, p { margin: 0; }
.hidden { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
}
.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--blue);
  font-weight: 700;
  margin-bottom: 18px;
}
.brand-mark.small {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  margin: 0;
}
.login-panel h1 { font-size: 24px; margin-bottom: 8px; }
.login-panel p { color: var(--muted); margin-bottom: 24px; }
.login-form { display: grid; gap: 16px; }
.login-form button {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  margin-top: 4px;
}
.login-tip { margin-top: 18px; color: var(--muted); font-size: 13px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.app-title { display: flex; gap: 12px; align-items: center; }
.app-title strong { display: block; font-size: 16px; }
.app-title span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.nav { display: grid; gap: 16px; }
.nav-group { display: grid; gap: 4px; }
.nav-group-title {
  padding: 0 12px 4px;
  color: #98a2b3;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}
.nav button {
  position: relative;
  text-align: left;
  border-color: transparent;
  background: transparent;
  min-height: 38px;
}
.nav button.active, .nav button:hover { background: var(--blue-2); color: var(--blue); border-color: transparent; }
.nav button.active::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--blue);
}
.nav-group-admin { border-top: 1px solid var(--line); padding-top: 14px; }
.logout-btn { margin-top: auto; color: var(--red); border-top-color: #f1d8d4; }
.main { min-width: 0; padding: 26px 30px 36px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.last-refresh { color: var(--muted); font-size: 12px; white-space: nowrap; }
.topbar h2 { font-size: 22px; margin-bottom: 4px; }
.topbar p { color: var(--muted); font-size: 13px; }
.page { display: none; }
.page.active { display: block; }
.dashboard-section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 10px;
}
.dashboard-section-title span { font-size: 14px; font-weight: 700; }
.dashboard-section-title small { color: var(--muted); font-size: 12px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.metric-grid-tasks { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.metric-grid-overview { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Keep numeric validation, but remove mouse-operated increment controls. */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.metric-grid-risk { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  min-height: 94px;
}
.metric-card::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 16px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #cbd5e1;
}
.metric-card-blue { background: var(--blue-soft); border-color: #d4e4ff; }
.metric-card-blue::after { background: var(--blue); }
.metric-card-warn { background: var(--amber-soft); border-color: #f3dfb7; }
.metric-card-warn::after { background: var(--amber); }
.metric-card-danger { background: var(--red-soft); border-color: #f1d0cb; }
.metric-card-danger::after { background: var(--red); }
.metric-card span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.metric-card strong { display: block; font-size: 26px; color: var(--text); line-height: 1.1; }
#ledgerPage .metric-card { min-height: 104px; }
#ledgerPage .ledger-metric-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
#ledgerPage .ledger-metric-grid-limited { grid-template-columns: repeat(5, minmax(0, 1fr)); }
#ledgerPage .ledger-metric-grid-five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
#ledgerPage .ledger-metric-grid-five.ledger-metric-grid-limited { grid-template-columns: repeat(4, minmax(0, 1fr)); }
#ledgerPage .metric-card { min-width: 0; }
#ledgerPage .metric-card strong { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
@media (max-width: 1100px) {
  #ledgerPage .ledger-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #ledgerPage .ledger-metric-grid > .metric-card:last-child { grid-column: 1 / -1; }
}
.metric-card-link { cursor: pointer; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.metric-card-link:hover { transform: translateY(-2px); border-color: #adc9ef; box-shadow: 0 8px 20px rgba(23, 32, 51, 0.08); }
.panel-head p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.due-list { display: grid; gap: 8px; }
.empty-state { display: grid; place-items: center; min-height: 120px; color: var(--muted); font-size: 13px; text-align: center; }
.empty-state.compact { min-height: 58px; padding: 10px; border: 1px dashed var(--line); border-radius: 8px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.panel h3 { font-size: 16px; margin-bottom: 14px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.info-list { display: grid; gap: 12px; }
.info-list div { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.info-list span, .plain-list { color: var(--muted); }
.plain-list { margin: 0; padding-left: 18px; line-height: 1.9; }
.workspace-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.form-panel { display: grid; gap: 12px; }
.funding-plan-text { margin: 8px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; white-space: pre-wrap; font: inherit; color: var(--text); }
.ledger-form { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; }
.ledger-form label { display: grid; gap: 6px; min-width: 0; }
#ledgerFormHint { grid-column: 1 / -1; color: var(--muted); }
#ledgerPage .panel > p { color: var(--muted); line-height: 1.7; margin: 10px 0; }
#ledgerRows td { max-width: 260px; overflow-wrap: anywhere; white-space: normal; }
#ledgerPage > .panel { margin-bottom: 20px; }
#ledgerLoanOverview .panel-head > small { color: var(--muted); font-size: 12px; }
#ledgerPage table { min-width: 1050px; }
#ledgerRows td:nth-child(2), #ledgerRows td:nth-child(5), #ledgerRows td:nth-child(6), #ledgerRows td:nth-child(7) { white-space: nowrap; overflow-wrap: normal; }
@media (max-width: 640px) { .ledger-form { grid-template-columns: 1fr; } }
.application-form-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
#applicationForm { grid-template-columns: 1fr; }
.application-form-panel > h3, .application-form-panel > .form-panel-heading, .application-form-panel > textarea, .application-form-panel > button { grid-column: 1 / -1; }
.form-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 2px; }
.form-panel-heading h3 { margin-bottom: 4px; }
.form-panel-heading p { color: var(--muted); font-size: 12px; line-height: 1.5; }
.form-required-note { color: var(--muted); font-size: 12px; white-space: nowrap; }
.form-panel input[readonly] { background: var(--surface-2); color: #475467; font-weight: 600; }
.form-panel button { background: var(--blue); color: #fff; border-color: var(--blue); }
.form-panel button[type="submit"] { min-height: 42px; font-weight: 600; }
.form-narrow { max-width: 480px; }
.table-panel { min-width: 0; }
.table-panel.full { width: 100%; }
.application-side-panel { display: grid; gap: 22px; padding: 20px; }
.application-plan-section { min-width: 0; }
.application-guide-section { border-top: 1px solid var(--line); padding-top: 20px; }
.application-guide-section:first-child { border-top: 0; padding-top: 0; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-heading h3 { margin: 3px 0 0; }
.section-kicker { display: block; color: var(--blue); font-size: 10px; font-weight: 700; letter-spacing: 1px; }
.section-status { color: var(--green); background: #e8f7f0; border-radius: 999px; padding: 4px 9px; font-size: 12px; white-space: nowrap; }
.application-guide-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.application-guide-list li { display: flex; align-items: flex-start; gap: 10px; }
.application-guide-list li > span { flex: 0 0 24px; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: #eaf2ff; color: var(--blue); font-size: 12px; font-weight: 700; }
.application-guide-list strong, .application-guide-list small { display: block; }
.application-guide-list strong { color: var(--text); font-size: 13px; line-height: 1.4; }
.application-guide-list small { color: var(--muted); font-size: 12px; line-height: 1.6; margin-top: 2px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h3 { margin: 0; }
.panel-head input { max-width: 260px; }
.panel-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.panel-tools input { min-width: 200px; }
.panel-tools select { width: auto; min-width: 130px; }
.panel-tools button { min-width: 62px; white-space: nowrap; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 7px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
th { background: var(--surface-2); color: var(--muted); font-weight: 600; white-space: nowrap; position: sticky; top: 0; z-index: 1; }
td { color: var(--text); }
tbody tr:hover td { background: #fbfdff; }
tr:last-child td { border-bottom: none; }
.table-action { padding: 6px 9px; font-size: 12px; white-space: nowrap; }
#logsPage table { table-layout: fixed; }
#logsPage th:nth-child(1), #logsPage .log-time { width: 160px; }
#logsPage th:nth-child(2), #logsPage .log-actor { width: 110px; overflow-wrap: anywhere; }
#logsPage th:nth-child(3), #logsPage .log-action { width: 130px; }
#logsPage th:nth-child(4), #logsPage .log-target { width: 100px; white-space: nowrap; }
.log-detail { min-width: 0; line-height: 1.6; overflow-wrap: anywhere; }
.log-customer { display: block; margin-bottom: 4px; font-weight: 600; }
.log-changes { margin: 0; }
.log-changes > div { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 8px; margin-top: 3px; }
.log-changes dt { color: var(--muted); }
.log-changes dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.log-before, .log-change-arrow { color: var(--muted); }
.log-raw-details { margin-top: 7px; }
.log-raw-details summary { width: fit-content; color: var(--blue); cursor: pointer; font-size: 12px; }
.log-raw-details pre { max-height: 260px; max-width: 100%; overflow: auto; margin: 8px 0 0; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); font-size: 11px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 700px) {
  #logsPage .log-time, #logsPage .log-actor, #logsPage .log-action, #logsPage .log-target { width: auto; }
  #logsPage .log-details-cell { display: block; text-align: left; }
  #logsPage .log-details-cell::before { display: block; margin-bottom: 7px; }
}
.table-action[data-approve-application] { color: var(--green); background: var(--green-soft); border-color: #bfe4d1; }
.table-action[data-reject-application] { color: var(--red); background: var(--red-soft); border-color: #efc9c3; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 8px; font-size: 12px; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: #e8f7f0; color: var(--green); }
.badge.warn { background: #fff4df; color: var(--amber); }
.badge.danger { background: #fff0ed; color: var(--red); }
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #1f2937;
  color: #fff;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  max-width: min(460px, calc(100vw - 24px));
  overflow-wrap: anywhere;
  pointer-events: none;
  z-index: 60;
}

.table-action.danger { color: var(--red); }
.table-action.danger:hover { border-color: var(--red); background: #fff0ed; }
.table-action:hover { background: var(--blue-2); border-color: var(--blue); }
.table-action.danger { color: var(--red); }
.table-action.danger:hover { background: #fff0ed; border-color: var(--red); }

.form-actions { display: flex; gap: 10px; }
.form-actions button { flex: 1; }
button.secondary { background: #fff; color: var(--text); border-color: var(--line); }
button.secondary:hover { border-color: var(--blue); color: var(--blue); }

.permission-group {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}
.permission-group legend {
  font-size: 13px;
  color: var(--muted);
  padding: 0 6px;
}
.permission-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}
.permission-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

.overdue-panel { margin-bottom: 16px; border-color: #f3c1bb; }
.overdue-panel .panel-head h3 { color: var(--red); }
.overdue-stats { display: flex; gap: 20px; color: var(--muted); font-size: 13px; }
.overdue-stats b { color: var(--red); font-size: 16px; }
.repaying-stats b { color: var(--blue); }

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 30;
}
.modal {
  width: min(920px, 100%);
  max-height: 90vh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { min-width: 0; margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.modal-close {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  border: none;
  background: transparent;
  color: var(--muted);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 20px; overflow: auto; }
.modal-body h4 { margin: 18px 0 10px; font-size: 15px; }
.modal-body h4:first-child { margin-top: 0; }

.password-dialog { width: min(460px, 100%); }
.password-form { display: grid; gap: 16px; }
.password-form > p { margin: 0; font-size: 13px; line-height: 1.65; color: var(--muted); }
.password-form .password-error { color: var(--red); }
.password-actions { display: flex; justify-content: flex-end; gap: 10px; }
.password-actions button { min-height: 44px; }
#passwordSubmitBtn { background: var(--blue); border-color: var(--blue); color: #fff; }
.login-message { margin: 0 0 16px; padding: 10px 12px; border-radius: 8px; background: var(--blue-2); color: var(--blue); font-size: 13px; line-height: 1.6; }

.detail-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 4px;
}
.detail-summary .metric-card { padding: 14px; }
.detail-summary .metric-card strong { font-size: 20px; }
.detail-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 14px;
}
.detail-fields div { min-width: 0; font-size: 13px; overflow-wrap: anywhere; }
.detail-fields span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.detail-fields .detail-note { grid-column: 1 / -1; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
button:disabled { cursor: not-allowed; opacity: 0.6; }
form[aria-busy="true"] button[type="submit"] { cursor: progress; }

.cell-paid { color: var(--green); }
.cell-overdue { color: var(--red); font-weight: 600; }
.cell-pending { color: var(--muted); }
.quick-repay { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.quick-repay label { flex: 1; min-width: 120px; }
.quick-repay input, .quick-repay select, .quick-repay button { height: 44px; min-height: 44px; }
.customer-select-hint { margin-top: -4px; padding: 10px 12px; border-radius: 7px; background: var(--blue-soft); color: #315d93; font-size: 12px; line-height: 1.55; }

.customer-material-panel {
  grid-column: 1 / -1;
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 14px;
  margin-top: 16px;
  border: 1px solid #d7e5f6;
  border-radius: 10px;
  background: #f8fbff;
}
.customer-material-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.customer-material-head strong { color: #1d4f91; font-size: 14px; }
.customer-material-head small { white-space: nowrap; font-variant-numeric: tabular-nums; }
.customer-material-panel > p, .customer-material-panel > small, .customer-material-head small { color: var(--muted); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.customer-material-tools { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.customer-material-tools label { flex: 1; min-width: 0; max-width: 420px; font-size: 12px; }
.customer-material-tools input[type="file"] { min-width: 0; max-width: 100%; padding: 7px; background: var(--surface); font-size: 12px; }
.customer-material-tools button { min-height: 38px; white-space: nowrap; }
.customer-material-panel .customer-material-status { color: #315d93; }
.customer-material-status:empty, .customer-material-retry:not(:has(button:not(.hidden))) { display: none; }
.customer-material-failures { margin: 0; padding-left: 20px; font-size: 12px; color: var(--red); line-height: 1.6; overflow-wrap: anywhere; }
.customer-material-retry { display: flex; gap: 8px; flex-wrap: wrap; }
.customer-material-retry button { font-size: 12px; }
.customer-material-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; min-width: 0; }
.customer-material-card { min-width: 0; border: 1px solid #dfe7f1; border-radius: 8px; background: #fff; overflow: hidden; }
button.customer-material-preview { display: block; width: 100%; padding: 0; border: 0; border-radius: 0; background: #edf2f7; }
button.customer-material-preview:hover { background: #e5edf7; }
.customer-material-preview img { display: block; width: 100%; height: 130px; object-fit: contain; }
.customer-material-caption { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 5px 8px; padding: 9px; }
.customer-material-caption > span { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text); }
.customer-material-caption > small { color: var(--muted); font-size: 11px; }
button.customer-material-delete { padding: 5px 8px; min-height: 30px; border: 1px solid #f1dfdc; color: var(--red); font-size: 11px; background: #fff; }
button.customer-material-delete:hover { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.customer-material-empty { grid-column: 1 / -1; padding: 18px 12px; border: 1px dashed #d7e2ef; border-radius: 7px; color: var(--muted); font-size: 12px; text-align: center; }
.customer-material-viewer { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: rgba(15, 23, 42, .78); }
.customer-material-viewer-dialog { width: min(1200px, 100%); height: 90vh; height: 90dvh; min-width: 0; display: flex; flex-direction: column; background: #f1f4f8; border-radius: 12px; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, .2); }
.customer-material-viewer-head { display: flex; align-items: center; gap: 9px; padding: 12px 14px; background: #fff; border-bottom: 1px solid var(--line); }
.customer-material-viewer-head h3 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.customer-material-viewer-head button { flex-shrink: 0; min-height: 36px; padding: 7px 10px; font-size: 12px; }
.customer-material-viewer-body { flex: 1; min-width: 0; min-height: 0; display: flex; overflow: auto; overscroll-behavior: contain; padding: 10px; }
.customer-material-viewer-body img { display: block; max-width: 100%; max-height: calc(90vh - 86px); max-height: calc(90dvh - 86px); object-fit: contain; margin: auto; }
.customer-material-viewer.is-zoomed .customer-material-viewer-body { display: block; }
.customer-material-viewer.is-zoomed img { max-width: none; max-height: none; margin: 0; }

.decision-dialog {
  width: min(640px, 100%);
  padding: 24px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.25);
}
.decision-dialog h3 { margin-bottom: 8px; font-size: 18px; }
.decision-dialog { max-height: 85vh; max-height: 85dvh; overflow-y: auto; }
#decisionMessage { white-space: pre-line; overflow-wrap: anywhere; }
.decision-dialog > p { color: var(--muted); font-size: 14px; line-height: 1.65; }
.decision-dialog label { margin-top: 16px; }
.decision-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.decision-actions button { min-width: 92px; }
.decision-actions #decisionConfirmBtn { border-color: var(--blue); background: var(--blue); color: #fff; }
.decision-actions #decisionConfirmBtn.danger-button { border-color: var(--red); background: var(--red); color: #fff; }

@media (max-width: 1280px) {
  .metric-grid-tasks { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .detail-summary, .detail-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; gap: 12px; }
  .nav { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
  .nav-group { display: flex; gap: 6px; flex: 0 0 auto; align-items: center; }
  .nav-group-title { display: none; }
  .nav-group-admin { border-top: 0; padding-top: 0; }
  .nav button { min-height: 36px; white-space: nowrap; }
  .logout-btn { margin-top: 0; align-self: flex-end; }
  .main { padding: 20px 18px 30px; }
  .workspace-grid, .two-col { grid-template-columns: 1fr; }
  .metric-grid, .metric-grid-overview, .metric-grid-tasks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .application-form-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { align-items: flex-start; }
}

@media (max-width: 560px) {
  .app-title { justify-content: space-between; }
  .app-title span { font-size: 11px; }
  .topbar { display: block; }
  .topbar-actions { justify-content: space-between; margin-top: 14px; }
  .last-refresh { font-size: 11px; }
  .metric-grid, .metric-grid-overview, .metric-grid-risk, .application-form-panel { grid-template-columns: 1fr; }
  .dashboard-section-title { display: block; }
  .dashboard-section-title small { display: block; margin-top: 3px; }
  .panel { padding: 15px; }
  .panel-head { align-items: stretch; flex-direction: column; }
  .panel-head input { max-width: none; }
  .panel-tools { width: 100%; }
  .panel-tools input { min-width: 0; flex: 1; }
  .form-panel-heading { display: block; }
  .form-required-note { display: block; margin-top: 8px; }
  .modal-mask { padding: 10px; }
  .modal { max-height: 94vh; border-radius: 10px; }
  .modal-body { padding: 14px; }
  .detail-summary, .detail-fields { grid-template-columns: 1fr 1fr; gap: 8px; }
  .quick-repay { display: grid; grid-template-columns: 1fr 1fr; }
  .quick-repay button { grid-column: 1 / -1; }
  .customer-material-tools { align-items: stretch; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* Mobile navigation and touch layout. Desktop styles above 980px stay unchanged. */
.mobile-menu-btn { display: none; }

@media (max-width: 980px) {
  .app-shell { display: block; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 18;
    display: block;
    padding: max(11px, env(safe-area-inset-top)) 14px 11px;
    background: rgba(255, 255, 255, 0.98);
    border-right: 0;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 6px 18px rgba(23, 32, 51, 0.06);
  }
  .app-title { min-height: 42px; justify-content: flex-start; }
  .app-identity { min-width: 0; }
  .app-identity strong, .app-identity span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-menu-btn {
    display: inline-flex;
    width: 42px;
    height: 42px;
    margin-left: auto;
    padding: 0;
    border: 0;
    background: var(--surface-2);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
  }
  .mobile-menu-btn span { width: 18px; height: 2px; border-radius: 2px; background: var(--text); transition: transform .18s ease, opacity .18s ease; }
  .sidebar.mobile-open .mobile-menu-btn span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .sidebar.mobile-open .mobile-menu-btn span:nth-child(2) { opacity: 0; }
  .sidebar.mobile-open .mobile-menu-btn span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
  .nav, .logout-btn { display: none; }
  .sidebar.mobile-open .nav {
    display: grid;
    gap: 14px;
    max-height: calc(100dvh - 128px);
    overflow-y: auto;
    overflow-x: hidden;
    margin-top: 12px;
    padding: 12px 0 4px;
    border-top: 1px solid var(--line);
  }
  .sidebar.mobile-open .logout-btn { display: block; width: 100%; margin: 12px 0 0; min-height: 44px; }
  .nav-group { display: grid; gap: 5px; width: 100%; }
  .nav-group-title { display: block; padding: 0 10px 3px; }
  .nav-group-admin { border-top: 1px solid var(--line); padding-top: 13px; }
  .nav button { width: 100%; min-height: 44px; padding: 10px 12px; white-space: normal; }
  .main { padding: 18px 16px calc(30px + env(safe-area-inset-bottom)); }
  .workspace-grid, .two-col { grid-template-columns: 1fr; }
  .topbar { margin-bottom: 18px; }
}

@media (max-width: 700px) {
  button { min-height: 42px; }
  .modal-close { width: 44px; height: 44px; }
  input, select, textarea { min-height: 44px; font-size: 16px; }
  textarea { min-height: 96px; }
  .main { padding: 15px 12px calc(24px + env(safe-area-inset-bottom)); }
  .topbar { display: block; }
  .topbar h2 { font-size: 20px; }
  .topbar p { margin-top: 3px; line-height: 1.45; }
  .topbar-actions { width: 100%; justify-content: space-between; margin-top: 12px; }
  .topbar-actions button { min-width: 96px; }
  .panel { padding: 14px; border-radius: 12px; }
  .panel-head { align-items: stretch; flex-direction: column; }
  .panel-head input { max-width: none; }
  .panel-tools { align-items: stretch; }
  .panel-tools .overdue-stats { flex: 1 0 100%; }
  .panel-tools select { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .panel-tools input { flex: 1 1 220px; min-width: 0; }
  .panel-tools button { flex: 0 0 auto; }
  .application-form-panel { grid-template-columns: 1fr; }
  .permission-group { grid-template-columns: 1fr; }
  .overdue-stats { gap: 8px 14px; flex-wrap: wrap; }

  .table-panel { padding: 0; border: 0; background: transparent; }
  .table-panel > .panel-head { padding: 0 2px; }
  .table-panel .table-wrap { overflow: visible; border: 0; border-radius: 0; background: transparent; }
  .table-panel table, .table-panel tbody { display: block; width: 100%; min-width: 0; }
  .table-panel thead { display: none; }
  .table-panel tbody { display: grid; gap: 10px; }
  .table-panel tbody tr {
    display: block;
    padding: 5px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(23, 32, 51, 0.04);
  }
  .table-panel tbody td {
    display: flex;
    min-height: 38px;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid #edf1f5;
    text-align: right;
    overflow-wrap: anywhere;
  }
  .table-panel tbody td::before {
    content: attr(data-label);
    flex: 0 0 88px;
    margin-right: auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    text-align: left;
  }
  .table-panel tbody td:last-child { border-bottom: 0; flex-wrap: wrap; }
  .table-panel tbody td.application-followup-cell { min-width: 0; overflow: hidden; }
  .table-panel tbody td.application-followup-cell .application-followup-edit { flex: 1 1 0; width: 0; min-width: 0; max-width: none; }
  .table-panel tbody td[colspan] { display: block; padding: 18px 0; text-align: center; color: var(--muted); }
  .table-panel tbody td[colspan]::before { display: none; }
  .table-action { min-height: 36px; padding: 7px 10px; }
  .application-plan-section table { min-width: 0; }
  .application-plan-section th, .application-plan-section td { padding: 9px 8px; font-size: 12px; }
}

@media (max-width: 560px) {
  .login-shell { padding: 16px; }
  .login-panel { padding: 24px 20px; border-radius: 16px; }
  .metric-grid, .metric-grid-overview, .metric-grid-risk, .metric-grid-tasks {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }
  .metric-card { min-height: 86px; padding: 13px 12px; border-radius: 11px; }
  .metric-card::after { right: 12px; top: 12px; }
  .metric-card span { min-height: 32px; margin-bottom: 5px; padding-right: 10px; font-size: 12px; line-height: 1.35; }
  .metric-card strong { font-size: 21px; overflow-wrap: anywhere; }
  .dashboard-section-title { margin-bottom: 8px; }
  .dashboard-section-title small { line-height: 1.45; }
  .form-panel-heading { display: block; }
  .form-required-note { display: block; margin-top: 7px; }
  .form-actions { flex-direction: column; }
  .modal-mask { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: 92dvh; border-radius: 16px 16px 0 0; }
  .modal-head { flex: 0 0 auto; padding: 14px 16px; background: var(--surface); }
  .modal-body { padding: 14px 12px calc(18px + env(safe-area-inset-bottom)); }
  .detail-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-fields { grid-template-columns: 1fr; }
  .quick-repay { grid-template-columns: 1fr; }
  .quick-repay button { grid-column: auto; }
  .customer-material-panel { padding: 11px; }
  .customer-material-tools { display: grid; grid-template-columns: minmax(0, 1fr); }
  .customer-material-tools label { max-width: none; }
  .customer-material-tools button, button.customer-material-delete { min-height: 38px; }
  .customer-material-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .customer-material-preview img { height: 112px; }
  .customer-material-viewer { padding: 8px; }
  .customer-material-viewer-dialog { height: 94vh; height: 94dvh; border-radius: 10px; }
  .customer-material-viewer-head { gap: 6px; padding: 10px; }
  .customer-material-viewer-head button { padding: 7px 8px; }
  .customer-material-viewer-body img { max-height: calc(94vh - 80px); max-height: calc(94dvh - 80px); }
  .decision-dialog { width: calc(100% - 24px); padding: 20px; border-radius: 14px; }
  .decision-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .toast { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); text-align: center; }
}

/* Home workspace: actions first, one set of account metrics, no duplicate totals. */
#dashboardPage { --dashboard-radius: 12px; }
#dashboardPage .metric-grid-tasks { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
#dashboardPage .metric-card { min-width: 0; min-height: 102px; padding: 14px; border-radius: var(--dashboard-radius); text-align: left; }
#dashboardPage .metric-card::after { display: none; }
#dashboardPage .metric-card span { min-height: 0; padding: 0; margin-bottom: 8px; color: #475467; font-size: 13px; white-space: nowrap; }
#dashboardPage .metric-card strong { display: inline; font-size: 26px; font-variant-numeric: tabular-nums; }
#dashboardPage .metric-card > small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }
#dashboardPage .metric-card:disabled { cursor: default; transform: none; box-shadow: none; border-color: var(--line); }
#dashboardPage .metric-card:disabled > span { color: var(--muted); }
.dashboard-risk { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 10px; background: #f1f4f8; color: var(--muted); font-size: 13px; line-height: 1.5; }
.dashboard-risk .risk-copy { display: flex; align-items: center; gap: 9px; min-width: 0; }
.risk-indicator { width: 7px; height: 7px; border-radius: 50%; background: #8092a9; flex: 0 0 7px; }
.dashboard-risk.is-overdue { border-color: #f2d4cd; background: var(--red-soft); color: #a23427; }
.dashboard-risk.is-overdue .risk-indicator { background: var(--red); }
.dashboard-risk button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-width: 0; border: 0; padding: 0; background: transparent; color: inherit; font: inherit; text-align: left; }
.dashboard-risk button:disabled { opacity: 1; cursor: default; }
.dashboard-risk button:focus-visible { outline: 2px solid currentColor; outline-offset: 5px; border-radius: 4px; }
#dashboardRiskLinkLabel { flex-shrink: 0; font-size: 12px; }
#dashboardPage .panel { min-width: 0; border-radius: var(--dashboard-radius); padding: 20px; box-shadow: 0 2px 8px rgba(23, 32, 51, .025); }
#dashboardPage .panel-head { margin-bottom: 18px; }
#dashboardPage .panel-head p { line-height: 1.6; }
.due-panel { margin-bottom: 20px; }
.due-panel { scroll-margin-top: 90px; }
.due-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: 14px; }
.due-card { min-width: 0; border: 1px solid #dfe6ef; border-radius: 10px; background: #fff; overflow: hidden; scroll-margin-top: 90px; }
.due-card:focus { outline: 3px solid rgba(29, 111, 214, .2); outline-offset: 3px; }
.due-card-head { padding: 14px 14px 12px; border-bottom: 1px solid #e7edf5; background: #f7f9fc; }
.due-card-head h4 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 12px; font-size: 14px; line-height: 1.4; }
.due-card-title { min-width: 0; }
.due-card-date { display: inline-block; font-size: 12px; font-weight: 500; white-space: nowrap; }
.due-card-head .due-card-count { flex-shrink: 0; padding: 3px 7px; border-radius: 5px; background: #e9eef5; color: #59677c; font-size: 11px; font-weight: 400; white-space: nowrap; }
.due-card-head h4 b { font-weight: 600; font-variant-numeric: tabular-nums; }
.due-card-total { display: flex; align-items: baseline; gap: 5px; min-width: 0; }
.due-card-total > span { margin-right: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.due-card-total strong { min-width: 0; font-size: 19px; line-height: 1.3; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.due-card-total small { color: var(--muted); font-size: 11px; }
.due-card-today { border-color: #d0dff3; }
.due-card-today .due-card-head { background: #f0f6ff; }
.due-card-today h4, .due-card-today .due-card-total strong { color: var(--blue); }
.due-card-today .due-card-count { color: var(--blue); background: #e0ebfc; }
.due-card-reminder { border-color: #d8e9e4; }
.due-card-reminder .due-card-head { background: #f2f9f7; border-bottom-color: #e1eee9; }
.due-card-reminder h4 { color: #13786a; }
.due-card-reminder .due-card-count { color: #13786a; background: #e0f0ea; }
.due-card-reminder .reminder-setup-title { width: auto; min-height: 0; padding: 0; border: 0; border-radius: 0; background: transparent; color: inherit; font: inherit; text-align: left; }
.due-card-reminder .reminder-setup-title:disabled { opacity: 1; cursor: default; }
.due-card-reminder .reminder-setup-title:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
/* Keep every customer visible in page screenshots; cards grow independently. */
.dashboard-due-list { gap: 0; padding: 0 14px; }
.dashboard-due-list:focus-visible { outline: 2px solid #adc9ef; outline-offset: 2px; border-radius: 4px; }
.due-task-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: baseline; gap: 12px; padding: 14px 0; border-bottom: 1px solid #edf1f6; }
.due-task-row:last-child { border-bottom: 0; }
.due-task-row > * { min-width: 0; overflow-wrap: anywhere; }
button.due-task-action { width: 100%; border: 0; border-bottom: 1px solid #edf1f6; border-radius: 0; background: transparent; color: var(--text); text-align: left; }
button.due-task-action:last-child { border-bottom: 0; }
button.due-task-action:hover { background: var(--blue-soft); color: var(--text); }
button.due-task-action:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.due-task-name { color: var(--text); font-size: 14px; font-weight: 500; line-height: 1.5; }
.due-task-amount { text-align: right; }
.due-task-amount b { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.due-task-amount small { margin-left: 4px; color: var(--muted); font-size: 11px; }
.dashboard-empty { min-height: 76px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 18px 8px; }
.dashboard-empty strong { font-size: 13px; font-weight: 500; color: #475467; }
.reminder-task-row { grid-template-columns: minmax(0, 1fr) max-content; row-gap: 4px; }
.reminder-task-date { display: contents; text-align: right; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.reminder-task-date time { grid-column: 2; grid-row: 1; }
.reminder-task-date small { grid-column: 2; grid-row: 2; color: var(--muted); font-size: 11px; font-weight: 400; }
.reminder-task-row.is-today .reminder-task-date, .reminder-task-row.is-today .reminder-task-date small { color: #9a5b06; font-weight: 650; }
.reminder-task-row.is-today { background: #fffbef; }
.reminder-task-row.is-overdue .due-task-name, .reminder-task-row.is-overdue .reminder-task-date, .reminder-task-row.is-overdue .reminder-task-date small { color: var(--red); }
.reminder-task-note { grid-column: 1; grid-row: 2; color: var(--muted); font-size: 12px; line-height: 1.5; white-space: pre-wrap; }
.reminder-empty { flex-direction: column; gap: 8px; }
.reminder-empty small { color: var(--muted); font-size: 12px; }
.repayment-reminder-section { margin: 22px 0; padding: 16px; border: 1px solid #d8e9e4; border-radius: 10px; background: #f8fbfa; }
.repayment-reminder-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.repayment-reminder-heading h4 { margin: 0; color: #13786a; }
.repayment-reminder-heading > span { color: #59677c; font-size: 12px; }
.repayment-reminder-hint { margin: 8px 0 16px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.repayment-reminder-form { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(0, 1fr) minmax(0, 2fr); align-items: start; gap: 12px; }
.repayment-reminder-form label { min-width: 0; }
.repayment-reminder-form textarea { resize: vertical; line-height: 1.5; }
.repayment-reminder-actions { display: flex; flex-wrap: wrap; gap: 8px; grid-column: 1 / -1; }
.repayment-reminder-feedback { grid-column: 1 / -1; margin: 0; color: #59677c; font-size: 13px; line-height: 1.6; }
.repayment-reminder-readonly { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 700px) {
  .repayment-reminder-section { padding: 14px 12px; }
  .repayment-reminder-form { grid-template-columns: minmax(0, 1fr); }
}
.dashboard-ledger-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; background: #e6ecf3; border: 1px solid #e6ecf3; border-radius: 10px; overflow: hidden; }
.dashboard-ledger-grid > div { min-width: 0; display: flex; flex-direction: column; justify-content: space-between; gap: 16px; padding: 16px; background: #fff; }
.dashboard-ledger-grid span { font-size: 12px; color: var(--muted); }
.dashboard-ledger-grid b { text-align: right; font-size: 21px; font-weight: 650; line-height: 1.3; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dashboard-ledger-grid .ledger-pending { background: #f6f9ff; }
.dashboard-ledger-grid .ledger-pending b { color: var(--blue); }
@media (max-width: 1099px) {
  .due-card-grid { grid-template-columns: 1fr; }
  .dashboard-ledger-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-ledger-grid > div:last-child { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  #dashboardPage .dashboard-section-title { display: block; }
  #dashboardPage .dashboard-section-title small { display: block; margin-top: 4px; }
  #dashboardPage .metric-grid-tasks { gap: 8px; }
  #dashboardPage .metric-card { min-height: 88px; padding: 10px 8px; }
  #dashboardPage .metric-card span { margin-bottom: 6px; font-size: 12px; }
  #dashboardPage .metric-card strong { font-size: 24px; }
  #dashboardPage .metric-card > small { margin-top: 4px; font-size: 10px; }
  #dashboardPage .panel { padding: 16px 12px; }
  .dashboard-risk { align-items: flex-start; flex-direction: column; gap: 6px; padding: 12px; margin-bottom: 14px; font-size: 12px; }
  .dashboard-risk button { align-items: flex-start; flex-direction: column; gap: 6px; min-height: 30px; }
  #dashboardRiskLinkLabel { align-self: flex-end; }
  .due-panel { margin-bottom: 14px; }
  .due-card-grid { gap: 12px; }
  .dashboard-ledger-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-ledger-grid > div { padding: 14px 12px; }
  .dashboard-ledger-grid b { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  #dashboardPage .metric-card-link { transition: none; }
}

/* View-local row numbers follow the current filtering and sort order. */
/* Match the homepage account cards to its standalone task cards. */
#dashboardPage .dashboard-ledger { padding: 0; border: 0; box-shadow: none; background: transparent; }
#dashboardPage .dashboard-ledger-grid { gap: 10px; border: 0; border-radius: 0; background: transparent; overflow: visible; }
#dashboardPage .dashboard-ledger-grid > div { min-height: 102px; padding: 14px; gap: 0; justify-content: flex-start; border: 1px solid var(--line); border-radius: var(--dashboard-radius); background: var(--surface); }
#dashboardPage .dashboard-ledger-grid span { margin-bottom: 8px; color: #475467; font-size: 13px; }
#dashboardPage .dashboard-ledger-grid b { color: var(--text); text-align: left; font-size: 26px; font-weight: 700; line-height: 1.1; }
@media (max-width: 700px) {
  #dashboardPage .dashboard-ledger-grid { gap: 8px; }
  #dashboardPage .dashboard-ledger-grid > div { min-height: 88px; padding: 10px 8px; }
  #dashboardPage .dashboard-ledger-grid span { margin-bottom: 6px; font-size: 12px; }
  #dashboardPage .metric-card strong,
  #dashboardPage .dashboard-ledger-grid b { font-size: 20px; }
}

.row-number { width: 58px; color: var(--muted); text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 700px) {
  .table-panel td.row-number { width: auto; text-align: right; }
}
.list-pagination { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 16px; color: #667085; font-size: 13px; }
.table-panel .table-wrap table { scroll-margin-top: 24px; }
.list-pagination label { display: flex; align-items: center; gap: 6px; margin: 0; }
.list-pagination select { width: auto; min-height: 36px; padding: 6px 8px; }
.pagination-buttons { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.pagination-buttons button { padding: 8px 12px; background: white; color: #344054; border: 1px solid #d0d5dd; border-radius: 8px; }
.pagination-buttons button:disabled { opacity: .4; cursor: not-allowed; }
@media (max-width: 600px) {
  .list-pagination { gap: 8px; justify-content: space-between; }
  .pagination-buttons { width: 100%; margin-left: 0; justify-content: space-between; gap: 6px; }
}
.customer-report-panel { margin-top: 24px; padding-top: 20px; border-top: 1px solid #dce3ef; }
.customer-report-panel .customer-material-head { flex-wrap: wrap; }

/* Shared workspace styling; business layouts and independent due-card heights stay intact. */
.topbar-actions button, .panel-tools button { min-height: 40px; }
.panel-tools select, .panel-head > input { min-height: 40px; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]), select { min-height: 42px; }
.list-title { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px !important; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.panel-head > .list-title + .panel-tools { flex: 1; }
.panel-head > .list-title + input { margin-left: auto; }
.panel-head.list-heading-only { margin: 0; min-height: 0; }
#appView .table-cell-money, #modalBody .table-cell-money { text-align: right; white-space: nowrap; overflow-wrap: normal; font-variant-numeric: tabular-nums; }
#appView .table-cell-date, #modalBody .table-cell-date { white-space: nowrap; overflow-wrap: normal; font-variant-numeric: tabular-nums; }

.ca-workspace { color: var(--text); }
.ca-workspace .overview { gap: 12px; margin-bottom: 20px; }
.ca-workspace .metric, .ca-workspace .card { background: var(--surface); border-color: var(--line); border-radius: var(--radius); box-shadow: none; }
.ca-workspace .metric { padding: 16px 18px; }
.ca-workspace .metric span, .ca-workspace .card-heading p, .ca-workspace .flow-step p, .ca-workspace .flow-foot { color: var(--muted); }
.ca-workspace .metric strong { color: var(--text); font-size: 26px; line-height: 1.1; }
.ca-workspace .metric small { color: var(--muted); }
.ca-workspace .card { padding: 20px; }
.ca-workspace .card-heading { gap: 12px; margin-bottom: 16px; }
.ca-workspace .card h2 { color: var(--text); font-size: 16px; letter-spacing: normal; margin: 4px 0; }
.ca-workspace .card-heading p { font-size: 12px; }
.ca-workspace label { color: var(--muted); font-weight: 500; margin: 14px 0 6px; }
.ca-workspace input:not([type="file"]), .ca-workspace .history-toolbar select { border-color: var(--line); border-radius: 7px; min-height: 42px; height: 42px; color: var(--text); font-size: 13px; }
.ca-workspace input:focus { border-color: var(--blue); box-shadow: none; }
.ca-workspace .submit-row button, .ca-workspace .download-button { min-height: 42px; padding: 10px 16px; border: 1px solid var(--blue); border-radius: 7px; background: var(--blue); box-shadow: none; font-weight: 600; }
.ca-workspace .submit-row button:hover, .ca-workspace .download-button:hover { background: #195fb8; }
.ca-workspace .text-button, .ca-workspace .action-link { color: var(--blue); }
.ca-workspace .private-pill { padding: 5px 9px; border-color: var(--line); background: var(--surface-2); color: var(--muted); }
.ca-workspace .identity-scan-panel { border-color: var(--line); border-radius: var(--radius); background: var(--blue-soft); }
.ca-workspace .identity-scan-panel button { border-color: var(--line); border-radius: 7px; color: var(--blue); font-weight: 500; }
.ca-workspace .dropzone { border-radius: var(--radius); background: var(--blue-soft); }
.ca-workspace th { color: var(--muted); background: var(--surface-2); font-size: 13px; padding: 10px 12px; }
.ca-workspace td { color: var(--text); border-color: var(--line); padding: 10px 12px; }
.ca-workspace .customer-name { color: var(--text); font-weight: 600; }
.ca-workspace .status { font-size: 12px; padding: 3px 8px; font-weight: 500; }
.ca-workspace .status.completed, .ca-workspace .status.completed_partial, .ca-workspace .status.completed_warning { color: var(--green); background: #e8f7f0; }
.ca-workspace .status.failed { color: var(--red); background: var(--red-soft); }
@media (max-width: 720px) {
  .ca-workspace .overview { gap: 8px; }
  .ca-workspace .metric { padding: 13px; }
  .ca-workspace .metric strong { font-size: 22px; }
  .ca-workspace .card { padding: 16px; border-radius: 12px; }
  .ca-workspace input:not([type="file"]), .ca-workspace .history-toolbar select { min-height: 44px; height: 44px; font-size: 16px; }
  .ca-workspace .case-table td { padding: 9px 0; }
}
@media (max-width: 700px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]), select { min-height: 44px; }
  #appView .table-panel td.table-cell-money, #appView .table-panel td.table-cell-date { text-align: right; }
}
.customer-report-panel .customer-material-head small { white-space: normal; }
.customer-report-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #e4e7ec; }
.customer-report-row > div:first-child { min-width: 0; flex: 1 1 180px; overflow-wrap: anywhere; }
.customer-report-row small { display: block; margin-top: 4px; color: #667085; }
.customer-report-actions { display: flex; align-items: center; gap: 12px; }
.refresh-warning { margin-bottom: 16px; padding: 14px 16px; color: #854d0e; background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; line-height: 1.6; }
.refresh-warning button { margin: 8px 0 0 12px; }

/* Customer workflow navigation: historical stages remain available, but collapsed. */
.nav-history summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 38px; padding: 9px 12px; border-radius: 7px; color: var(--muted); cursor: pointer; list-style: none; }
.nav-history summary::-webkit-details-marker { display: none; }
.nav-history summary::after { content: '⌄'; font-size: 14px; }
.nav-history[open] summary::after { transform: rotate(180deg); }
.nav-history summary:hover { color: var(--blue); background: var(--blue-soft); }
.nav-history summary:focus-visible { outline: 3px solid rgba(29, 111, 214, .22); outline-offset: 2px; }
.nav-history-items { display: grid; gap: 4px; margin: 4px 0 0 12px; padding-left: 10px; border-left: 1px solid var(--line); }

/* Tabs move no form nodes when selected, preserving unsaved repayment/reminder input. */
.customer-detail-tabs { position: sticky; top: -20px; z-index: 3; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin: -20px -20px 20px; padding: 12px 20px 0; border-bottom: 1px solid var(--line); background: var(--surface); }
.customer-detail-tabs button { min-width: 0; min-height: 42px; padding: 10px 8px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); background: transparent; font-size: 14px; white-space: nowrap; }
.customer-detail-tabs button[aria-selected="true"] { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.customer-detail-tabs button:hover { background: var(--blue-soft); color: var(--blue); }
.customer-detail-panel[hidden] { display: none !important; }
.detail-stage-note, .detail-empty { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.detail-stage-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.customer-detail-panel .detail-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.customer-file-section { margin-top: 20px; }
.customer-photo-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.customer-photo-link { display: grid; gap: 6px; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--text); }
.customer-photo-link img { width: 100%; height: 130px; object-fit: contain; border-radius: 4px; background: var(--surface-2); }
.customer-photo-link span { font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.mobile-row-toggle { display: none; }
@media (max-width: 980px) {
  .nav-history summary { min-height: 44px; padding: 10px 12px; }
}
@media (max-width: 700px) {
  .table-panel tbody tr:not([data-mobile-expanded="true"]) td.mobile-secondary-cell { display: none !important; }
  .table-panel td.row-number { min-height: 30px; align-items: center; padding: 6px 0; }
  .mobile-row-toggle { display: inline-flex; align-items: center; min-height: 30px; margin-left: 8px; padding: 4px 8px; color: var(--blue); font-size: 12px; font-weight: 500; }
  .mobile-row-toggle::after { content: '更多资料'; }
  .mobile-row-toggle[aria-expanded="true"]::after { content: '收起资料'; }
  .customer-detail-tabs { top: -14px; margin: -14px -12px 16px; padding: 8px 12px 0; }
  .customer-detail-tabs button { font-size: 13px; }
  .customer-detail-panel .detail-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .customer-photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .customer-photo-link img { height: 110px; }
}

/* Name/mobile registration keeps optional identity fields out of the first step. */
.application-optional-fields{border-top:1px solid var(--line);margin-top:2px;padding-top:3px}
.application-optional-fields>summary{cursor:pointer;color:#59758f;font-size:13px;padding:12px 0;line-height:1.6}
.application-optional-fields>div{display:grid;gap:16px;padding:6px 0 12px}
.application-optional-fields input,.application-optional-fields textarea{min-width:0}

/* Keep the page visible while validating its most recent in-memory snapshot. */
.page-load-status{padding:10px 14px;margin:0 0 14px;border:1px solid #d8e5f8;border-radius:10px;background:#f1f6ff;color:#375c89;font-size:13px;line-height:1.5}
.page-load-status.load-failed{background:#fff8ef;border-color:#eedbbd;color:#835318}
.list-loading{text-align:center;padding:28px!important;color:#64748b}
.page[aria-busy="true"] .list-pagination,.page[aria-busy="true"] tbody,.page[aria-busy="true"] #ledgerMobileRows{pointer-events:none;opacity:.65}


/* CRM application note — high-visibility callout */
.crm-application-note {
  margin: 0 0 14px;
  padding: 12px 14px 12px 16px;
  background: linear-gradient(180deg, #fff3cd 0%, #ffe8a3 100%);
  border: 1px solid #e6b800;
  border-left: 5px solid #d48806;
  border-radius: 10px;
  color: #5c3d00;
  font-size: 15px;
  line-height: 1.65;
  font-weight: 600;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 2px 8px rgba(212, 136, 6, 0.18);
}
.crm-application-note strong {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #d48806;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  vertical-align: 1px;
}

.review-record-header { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.review-record-meta { margin: 0; }
.review-record-meta.detail-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.review-record-reason { margin: 0; padding: 0 2px; color: var(--text); }
.crm-application-note--wide,
.review-record-header .crm-application-note {
  display: block;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  margin: 0;
  padding: 14px 16px 14px 18px;
  font-size: 16px;
  line-height: 1.7;
  font-weight: 600;
}
.crm-application-note--wide p,
.review-record-header .crm-application-note p {
  display: block;
  margin: 8px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-weight: 600;
}
.crm-application-note--wide strong,
.review-record-header .crm-application-note strong {
  display: inline-block;
  margin: 0 0 2px;
}



.application-disenforcement-box {
  grid-column: 1 / -1;
  padding: 10px 12px;
  border: 1px solid var(--border, #d8e5ef);
  border-radius: 10px;
  background: #f7fbff;
}
.application-disenforcement-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.application-disenforcement-head strong { font-size: 13px; color: var(--text, #234057); }
.application-disenforcement-overall {
  margin-bottom: 8px;
}
.application-disenforcement-status {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted, #6b7c8f);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.application-disenforcement-modules {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.application-disenforcement-module {
  padding: 8px 10px;
  border: 1px solid var(--border, #d8e5ef);
  border-radius: 8px;
  background: #fff;
}
.application-disenforcement-module-title {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text, #234057);
}
.application-disenforcement-module.is-querying .application-disenforcement-status,
.application-disenforcement-box.is-querying .application-disenforcement-overall { color: #17679f; }
.application-disenforcement-module.is-clear .application-disenforcement-status,
.application-disenforcement-box.is-clear .application-disenforcement-overall { color: #1f7a3f; }
.application-disenforcement-module.is-hit .application-disenforcement-status,
.application-disenforcement-box.is-hit .application-disenforcement-overall { color: var(--red, #c0392b); font-weight: 600; }
.application-disenforcement-module.is-error .application-disenforcement-status,
.application-disenforcement-box.is-error .application-disenforcement-overall { color: #a15c00; }
.application-disenforcement-module.is-hit {
  border-color: #f0b4ad;
  background: #fff7f6;
}
.application-disenforcement-module.is-clear {
  border-color: #b7dfc4;
  background: #f5fcf7;
}
.application-disenforcement-module.is-error {
  border-color: #efd0a0;
  background: #fffaf0;
}
@media (max-width: 720px) {
  .application-disenforcement-modules { grid-template-columns: 1fr; }
}

.login-entry-label,
.book-entry-label {
  display: inline-block;
  margin: 0;
  color: #1d6fd6;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.login-entry-label { margin: 0 0 12px; }
.app-identity .book-entry-label { display: block; font-size: 12px; }

.application-book-field {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}
.application-book-field select {
  font-size: 16px;
  font-weight: 700;
}
.application-book-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}
.application-book-field.is-unset {
  border-color: #c5d0de;
  background: #f3f6fa;
}
.application-book-field.is-xin {
  border-color: #9ad0b8;
  background: var(--green-soft);
  color: var(--green);
}
.application-book-field.is-xin select {
  border-color: #8fcbb0;
  background: #fff;
  color: var(--green);
}
.application-book-field.is-xin .application-book-hint { color: var(--green); }
.application-book-field.is-jiu {
  border-color: #efd0a0;
  background: var(--amber-soft);
  color: var(--amber);
}
.application-book-field.is-jiu select {
  border-color: #e8c48a;
  background: #fff;
  color: var(--amber);
}
.application-book-field.is-jiu .application-book-hint { color: var(--amber); }
.application-book-field option[value="xin"] { color: var(--green); }
.application-book-field option[value="jiu"] { color: var(--amber); }


/* visual-desktop-20261112: book identity, alert amounts, user table, fixed detail modal. */
:root, [data-book="zong"] { --book-color: #3b4fd1; --book-soft: #eef1ff; --book-line: #c9d1fb; }
[data-book="xin"] { --book-color: #10734f; --book-soft: #e8f7f0; --book-line: #b9e3cf; }
[data-book="jiu"] { --book-color: #b45309; --book-soft: #fff4df; --book-line: #f3d6a4; }
.book-badge, .login-entry-label.book-badge, .app-identity .book-entry-label {
  display: inline-flex; align-items: center; width: fit-content; margin: 0; padding: 3px 10px;
  border: 1px solid var(--book-line); border-radius: 999px; background: var(--book-soft); color: var(--book-color);
  font-size: 12px; font-weight: 700; line-height: 1.4; letter-spacing: .04em; white-space: nowrap;
}
.book-badge:empty, .app-identity .book-entry-label:empty { display: none; }
.book-badge-sm { padding: 2px 8px; font-weight: 600; letter-spacing: 0; }
.login-panel { border-top: 5px solid var(--book-color); }
.login-book-head { display: grid; gap: 10px; margin-bottom: 22px; }
.login-panel .login-book-head h1 { margin: 0; color: var(--text); }
.sidebar { border-top: 4px solid var(--book-color); }
.sidebar .brand-mark.small { background: var(--book-color); }
.app-identity { display: grid; gap: 3px; min-width: 0; }
.app-identity .book-entry-label { margin-top: 2px; }
.app-identity #currentUserText { margin-top: 0; }
.sidebar-head { display: grid; gap: 10px; }
.book-switch {
  display: flex;
  width: 100%;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--book-line);
  border-radius: 9px;
  background: var(--book-soft);
}
.book-switch.hidden { display: none !important; }
.book-switch-item {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 5px 4px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--book-color);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: .04em;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.book-switch-item:hover { background: rgba(255, 255, 255, 0.72); }
.book-switch-item.is-active {
  background: #fff;
  box-shadow: 0 0 0 1px var(--book-line);
  cursor: default;
}
.book-switch-item:focus-visible { outline: 3px solid rgba(29, 111, 214, 0.22); outline-offset: 1px; }
@media (max-width: 980px) {
  .book-switch { margin-top: 2px; }
  .book-switch-item { min-height: 34px; padding: 6px 4px; }
}
.application-book-notice:not(.hidden) {
  display: inline-flex; align-items: center; gap: 6px; width: fit-content; margin: 8px 0 0; padding: 4px 12px;
  border: 1px solid var(--book-line); border-radius: 999px; background: var(--book-soft); color: var(--book-color);
  font-size: 13px; font-weight: 700;
}
.application-book-notice::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* Important amounts: red, same tone as the overdue banner and detail overdue amounts. No unit added. */
.amount-negative, #ledgerPage .metric-card strong.amount-negative { color: var(--red); }
#dashboardPage .dashboard-ledger-grid > .ledger-overdue.is-alert { background: var(--red-soft); border-color: #f1d0cb; }
#dashboardPage .dashboard-ledger-grid > .ledger-overdue.is-alert span { color: #9f2d20; }
#dashboardPage .dashboard-ledger-grid > .ledger-overdue.is-alert b, .dashboard-ledger-grid > .ledger-overdue.is-alert b { color: var(--red); }
.metric-card.ledger-overdue-card.is-alert { background: var(--red-soft); border-color: #f1d0cb; }
.metric-card.ledger-overdue-card.is-alert::after { background: var(--red); }
.metric-card.ledger-overdue-card.is-alert strong { color: var(--red); }

/* User list: one line per status/role, compact page permissions. */
#usersPage #userRows td { vertical-align: middle; }
#usersPage .user-cell-nowrap, #usersPage .user-cell-actions { white-space: nowrap; }
#usersPage .user-cell-nowrap .badge { white-space: nowrap; }
#usersPage .user-cell-name { max-width: 9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#usersPage .user-cell-actions .table-action { display: inline-flex; margin: 0; }
#usersPage .user-cell-actions .table-action + .table-action { margin-left: 6px; }
#usersPage .user-cell-perms { min-width: 8em; }
.user-perm-all { color: var(--text); white-space: nowrap; }
.user-perm-none { color: var(--muted); white-space: nowrap; }
.user-perm-details summary { width: fit-content; color: var(--blue); cursor: pointer; white-space: nowrap; font-size: 13px; }
.user-perm-details summary:hover { text-decoration: underline; }
.user-perm-list { display: flex; flex-wrap: wrap; gap: 4px; max-width: 22em; margin-top: 6px; }
.user-perm-list span { padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: #475467; font-size: 12px; white-space: nowrap; }

/* Customer detail keeps one size across tabs; only the body scrolls. */
@media (min-width: 701px) {
  .modal:has(> .modal-body > .customer-detail) { height: 90vh; height: 90dvh; }
  .modal:has(> .modal-body > .customer-detail) > .modal-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
}

/* Customer list filters: left aligned, one row on desktop. */
@media (min-width: 1100px) {
  #customersPage .panel-head .panel-tools { flex-wrap: nowrap; }
}
@media (min-width: 1100px) {
  #customersPage .table-panel > .panel-head, #customersPage .panel-head { justify-content: flex-start; }
  #customersPage .panel-head .panel-tools { justify-content: flex-start; }
}
#usersPage #userRows td, #usersPage .table-panel th { padding-left: 10px; padding-right: 10px; }
.metric-card strong.cell-overdue { color: var(--red); }

/* Overdue list: fill the card on desktop, keep 跟进进度 boxes compact, pin 详情 to the right. */
@media (min-width: 701px) {
  #overduePage .table-wrap table {
    width: 100%;
  }
  #overduePage th, #overduePage td {
    white-space: nowrap;
    padding: 8px 10px;
    vertical-align: middle;
  }
  #overduePage th:nth-child(8),
  #overduePage .overdue-followup-cell {
    width: 100%;
    max-width: none;
    min-width: 280px;
    white-space: normal;
  }
  #overduePage .overdue-followup-edit {
    width: 280px;
    max-width: 100%;
    min-height: 0;
    padding: 5px 8px;
    line-height: 1.45;
  }
  #overduePage th:last-child,
  #overduePage td:last-child {
    width: 1%;
    white-space: nowrap;
    text-align: right;
  }
}

/* book-access-20261116: three independent book checkboxes in user management. */
.book-access-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.book-access-group legend { padding: 0 4px; color: var(--muted); font-size: 13px; }
.book-access-group label { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer; }
.book-access-group input[type="checkbox"] { width: 16px; height: 16px; margin: 0; }
.book-access-group input[type="checkbox"]:disabled + * , .book-access-group input[type="checkbox"]:disabled { cursor: not-allowed; }
.book-access-hint { flex-basis: 100%; color: var(--muted); font-size: 12px; line-height: 1.5; }
.book-access-hint.is-error { color: var(--red); font-weight: 600; }
.user-book-badges { display: inline-flex; flex-wrap: nowrap; gap: 4px; }





/* cloud-links-dblclick-20261116: double-click logo opens a small cloud-link dialog. */
.brand-cloud { position: relative; flex: 0 0 auto; user-select: none; }
.cloud-link-dialog { width: min(420px, 100%); }
.cloud-link-dialog .modal-body { display: grid; gap: 10px; }
.cloud-link-item {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.cloud-link-item strong { font-size: 15px; font-weight: 700; }
.cloud-link-item span { color: var(--blue); font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.cloud-link-item:hover,
.cloud-link-item:focus-visible {
  border-color: var(--blue);
  background: var(--blue-2);
}

/* copy-ledger-20261117: subtle copy-name button in the application review list. */
.name-with-copy { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
.copy-name-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted, #8a94a6);
  opacity: .55;
  cursor: pointer;
  box-shadow: none;
}
.copy-name-btn:hover,
.copy-name-btn:focus-visible { opacity: 1; color: var(--blue, #2563eb); background: var(--blue-2, #eef4ff); }
.copy-name-btn.copied { opacity: 1; color: var(--green, #16a34a); background: var(--green-soft, #e8f7ee); }

/* qr-repay-20261117: company-borne channel fee field on the repayment form. */
#repaymentChannelFeeLabel small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.5; }

/* 确认放款弹窗：复制给财务 */
.finance-copy { margin: 12px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; }
.finance-copy h4 { margin: 0 0 4px; font-size: 15px; }
.finance-copy small { display: block; margin-bottom: 10px; color: var(--muted); font-size: 12px; }
.finance-copy-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.finance-copy-grid .finance-copy-wide { grid-column: 1 / -1; }
.finance-copy-preview { width: 100%; margin-top: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font: inherit; line-height: 1.6; resize: none; box-sizing: border-box; }
.finance-copy-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.finance-copy-tip { color: var(--green, #16a34a); font-size: 13px; }
.finance-copy-tip.fail { color: #b45309; }
@media (max-width: 700px) { .finance-copy-grid { grid-template-columns: 1fr; } }
