:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-soft: #f0f5f2;
  --text: #17211e;
  --muted: #63716c;
  --line: #dbe5df;
  --line-strong: #c4d1ca;
  --accent: #0f766e;
  --accent-dark: #0a5f59;
  --accent-soft: #ddf3ef;
  --danger: #b42318;
  --danger-soft: #fde8e5;
  --amber: #b7791f;
  --amber-soft: #fff2d8;
  --green: #18734c;
  --green-soft: #e2f4ea;
  --blue: #2764a7;
  --blue-soft: #e4eff9;
  --shadow: 0 16px 42px rgba(31, 43, 39, 0.08);
  --font-ui-hant: Inter, "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", "Segoe UI", sans-serif;
  --font-ui-hans: Inter, "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "SimHei", "Segoe UI", sans-serif;
  --font-ui: var(--font-ui-hant);
  color: var(--text);
  font-family: var(--font-ui);
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  font-family: var(--font-ui);
  margin: 0;
}

body[data-language="zh-Hans"] {
  --font-ui: var(--font-ui-hans);
  font-synthesis: none;
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
}

body[data-language="zh-Hant"] {
  --font-ui: var(--font-ui-hant);
}

body[data-language="zh-Hans"] .brand-title,
body[data-language="zh-Hans"] .nav-label,
body[data-language="zh-Hans"] h1,
body[data-language="zh-Hans"] h2,
body[data-language="zh-Hans"] h3,
body[data-language="zh-Hans"] .panel-title,
body[data-language="zh-Hans"] .data-table strong,
body[data-language="zh-Hans"] .reconcile-card strong,
body[data-language="zh-Hans"] .message-card strong,
body[data-language="zh-Hans"] .kpi-card strong,
body[data-language="zh-Hans"] .budget-ledger strong,
body[data-language="zh-Hans"] .budget-summary-grid strong,
body[data-language="zh-Hans"] .top-category-row strong,
body[data-language="zh-Hans"] .pending-card strong,
body[data-language="zh-Hans"] .entry-mode-banner strong {
  font-family: var(--font-ui-hans);
}

body[data-language="zh-Hans"] h1,
body[data-language="zh-Hans"] h2,
body[data-language="zh-Hans"] h3,
body[data-language="zh-Hans"] .brand-title,
body[data-language="zh-Hans"] .panel-title {
  font-weight: 800;
}

body[data-language="zh-Hans"] h1 {
  line-height: 1.22;
}

body[data-language="zh-Hans"] .data-table strong,
body[data-language="zh-Hans"] .reconcile-card strong,
body[data-language="zh-Hans"] .message-card strong,
body[data-language="zh-Hans"] .panel-title {
  line-height: 1.42;
}

strong {
  font-weight: 800;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.boot {
  left: 50%;
  line-height: 1.5;
  position: fixed;
  top: 42%;
  transform: translate(-50%, -50%);
}

.boot span {
  color: var(--muted);
  display: block;
  font-size: 13px;
}

.app-shell {
  display: block;
  min-height: 100vh;
}

.login-page {
  align-items: center;
  background:
    linear-gradient(90deg, rgba(13, 31, 27, 0.46), rgba(13, 31, 27, 0.26) 46%, rgba(13, 31, 27, 0.08)),
    url("/assets/login-bg.png") center / cover no-repeat;
  display: grid;
  justify-items: start;
  min-height: 100vh;
  padding: 40px clamp(24px, 8vw, 108px);
}

.login-card {
  display: grid;
  gap: 18px;
  max-width: 520px;
  width: min(520px, 100%);
}

.login-brand-block {
  color: #fff;
  display: grid;
  gap: 10px;
  padding: 0 4px;
  text-shadow: 0 2px 16px rgba(8, 20, 17, 0.25);
}

.login-brand-block span {
  color: #f3c987;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-brand-block h1 {
  color: #fff;
  font-size: clamp(42px, 5vw, 62px);
  line-height: 1.12;
  margin: 0;
}

.login-brand-block p {
  color: rgba(255, 255, 255, 0.88);
  font-size: 16px;
  line-height: 1.6;
  margin: 0;
}

.login-form {
  align-self: center;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(9, 20, 17, 0.22);
  display: grid;
  gap: 13px;
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.login-form h2 {
  font-size: 22px;
  margin: 6px 0 2px;
}

.login-error {
  background: var(--danger-soft);
  border: 1px solid #f3b7af;
  border-radius: 8px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
  padding: 10px 12px;
}

.idle-warning-modal {
  max-width: 460px;
}

.idle-warning-modal p {
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 14px;
}

.top-account-bar {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.account-pill {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
}

.account-pill span {
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  padding: 5px 8px;
}

.account-pill strong {
  font-size: 13px;
}

.sidebar {
  background: #13211d;
  color: #eff8f4;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  left: 0;
  overflow-y: auto;
  padding: 22px 18px;
  position: fixed;
  top: 0;
  width: 252px;
  z-index: 20;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
}

.brand-mark {
  align-items: center;
  background: #d8f2ed;
  border-radius: 8px;
  color: #0b5f59;
  display: grid;
  font-weight: 800;
  height: 38px;
  place-items: center;
  width: 38px;
}

.brand-title {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  text-rendering: optimizeLegibility;
}

.brand-subtitle {
  color: #a9bdb6;
  font-size: 12px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 7px;
}

.nav-item {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #cbdcd5;
  display: flex;
  gap: 10px;
  min-height: 44px;
  padding: 10px 11px;
  text-align: left;
  width: 100%;
}

.nav-label {
  font-family: var(--font-ui);
  font-weight: 800;
}

.nav-item.active {
  background: #f4fbf8;
  color: #10201c;
}

.nav-icon {
  flex: 0 0 auto;
  height: 20px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
  width: 20px;
}

.nav-icon path,
.nav-icon circle {
  fill: none;
}

.nav-label {
  min-width: 0;
}

.sidebar-note {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #c7dbd4;
  display: grid;
  font-size: 12px;
  gap: 6px;
  line-height: 1.55;
  margin-top: auto;
  padding: 14px;
}

.sidebar-note strong {
  color: #fff;
}

.main-shell {
  margin-left: 252px;
  min-width: 0;
  padding: 24px 28px 40px;
}

.page-heading {
  margin: 0 auto 20px;
  max-width: 1540px;
}

.page-heading h1 {
  font-size: clamp(26px, 3vw, 35px);
  font-weight: 800;
  line-height: 1.22;
  margin: 0 0 8px;
}

.page-heading p {
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 14px;
}

.chip,
.attachment-chip {
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
}

.attachment-chip.reconciliation {
  background: var(--blue-soft);
  color: var(--blue);
}

.grid,
.kpi-grid {
  display: grid;
  gap: 16px;
  margin: 0 auto 16px;
  max-width: 1540px;
}

.kpi-grid {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.budget-alert-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.75fr);
}

.chart-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel,
.detail-drawer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: 0 auto 16px;
  max-width: 1540px;
  padding: 18px;
}

.detail-panel {
  margin-top: 16px;
}

.panel-header {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.42;
  margin: 0;
}

.panel-note {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 0;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--text);
  display: grid;
  gap: 10px;
  min-height: 122px;
  padding: 17px;
  text-align: left;
}

.kpi-card span,
.kpi-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.kpi-card strong {
  font-size: clamp(22px, 2.2vw, 32px);
}

.kpi-card.danger {
  border-color: #f5b4ad;
  background: #fff8f7;
}

.kpi-card.success {
  border-color: #b8dfca;
  background: #f6fff9;
}

.budget-ledger {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  overflow: hidden;
}

.budget-ledger div {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  display: grid;
  gap: 6px;
  min-height: 76px;
  padding: 13px;
}

.budget-ledger span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.budget-ledger strong {
  font-size: 17px;
}

.toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.analysis-header .toolbar,
.ledger-toolbar {
  margin-bottom: 0;
}

.input,
.select,
.textarea {
  background: #fbfcfa;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--text);
  min-height: 38px;
  padding: 8px 10px;
}

.input.compact,
.select.compact {
  min-width: 116px;
}

.textarea {
  min-height: 82px;
  resize: vertical;
}

.button {
  align-items: center;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 7px;
  color: #fff;
  display: inline-flex;
  font-weight: 800;
  gap: 8px;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  text-decoration: none;
}

.button:hover {
  background: var(--accent-dark);
}

.button.secondary {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--text);
}

.button.small {
  font-size: 12px;
  min-height: 30px;
  padding: 5px 9px;
}

.button.danger {
  background: var(--danger);
  border-color: var(--danger);
}

.button.danger:hover {
  background: #8f1d14;
  border-color: #8f1d14;
}

.button.success {
  background: var(--green);
  border-color: var(--green);
}

.tabbar {
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
  padding-bottom: 10px;
}

.tab-button {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--text);
  font-weight: 800;
  min-height: 36px;
  padding: 7px 12px;
}

.tab-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chart-box {
  height: 340px;
  min-width: 0;
}

.chart-box.tall {
  height: 390px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

td {
  font-size: 13px;
  line-height: 1.45;
}

td strong,
td span {
  display: block;
}

tbody tr:hover {
  background: #fbfcfa;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.row-actions,
.attachment-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.status-pill {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  min-height: 28px;
  padding: 5px 10px;
  white-space: nowrap;
}

.status-pill.submitted {
  background: var(--blue-soft);
  color: var(--blue);
}

.status-pill.needs_info,
.status-pill.voided {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-pill.reconciled {
  background: var(--green-soft);
  color: var(--green);
}

.risk-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.risk-tags span {
  background: var(--danger-soft);
  border-radius: 999px;
  color: var(--danger);
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
}

.stack-list {
  display: grid;
  gap: 10px;
}

.message-card,
.timeline-item,
.reconcile-card,
.status-card {
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 12px;
  text-align: left;
}

.alert-card {
  width: 100%;
}

.alert-card.danger {
  background: #fff8f7;
  border-color: #f5b4ad;
}

.alert-card.warning {
  background: #fffaf1;
  border-color: #f3d28c;
}

.entry-form {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.entry-mode-form {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px;
  transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.entry-form.entry-mode-form[data-entry-type="expense"],
.entry-edit-modal.entry-mode-form[data-entry-type="expense"] .entry-form {
  background: #fff8f8;
  border-color: #fecaca;
  box-shadow: inset 4px 0 0 #ef4444;
}

.entry-form.entry-mode-form[data-entry-type="income"],
.entry-edit-modal.entry-mode-form[data-entry-type="income"] .entry-form {
  background: #f5faff;
  border-color: #bfdbfe;
  box-shadow: inset 4px 0 0 #3b82f6;
}

.entry-mode-banner {
  align-items: center;
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  line-height: 1.5;
  padding: 10px 12px;
}

.entry-mode-banner strong {
  font-size: 14px;
}

.entry-mode-banner span {
  font-size: 12px;
  font-weight: 800;
}

.entry-mode-banner.expense {
  background: #ffe4e6;
  border: 1px solid #fda4af;
  color: #b42318;
}

.entry-mode-banner.income {
  background: #dbeafe;
  border: 1px solid #93c5fd;
  color: #1d4ed8;
}

.amount-usdt {
  font-weight: 800;
}

.amount-usdt.expense {
  color: #b42318;
}

.amount-usdt.income {
  color: #1d4ed8;
}

.amount-usdt.fee {
  font-weight: 800;
}

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field .input,
.field .select,
.field .textarea {
  width: 100%;
}

.field.wide {
  grid-column: 1 / -1;
}

.detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.detail-grid div {
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 12px;
}

.detail-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.attachment-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.attachment-row {
  align-items: center;
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 10px;
}

.attachment-row > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-file-list {
  display: grid;
  gap: 6px;
  min-width: 180px;
}

.attachment-file-name {
  align-items: center;
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  display: grid;
  gap: 2px;
  max-width: 260px;
  padding: 7px 9px;
  text-decoration: none;
}

.attachment-file-name:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.attachment-file-name small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.attachment-file-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-input-native,
.field .file-input-native {
  border: 0 !important;
  clip-path: inset(50%);
  height: 1px !important;
  min-height: 0 !important;
  opacity: 0;
  overflow: hidden;
  padding: 0 !important;
  position: absolute;
  white-space: nowrap;
  width: 1px !important;
}

.file-picker-ui {
  align-items: center;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 38px;
  width: 100%;
}

.file-picker-button {
  min-height: 34px;
  white-space: nowrap;
}

.file-picker-status {
  color: var(--text);
  font-size: 13px;
  min-width: 0;
}

.file-picker-status.has-files {
  flex: 1 1 240px;
}

.file-empty {
  color: var(--muted);
  font-weight: 700;
}

.selected-file-list {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.selected-file-chip {
  align-items: center;
  background: #f8fbfa;
  border: 1px solid #cbded7;
  border-radius: 8px;
  display: inline-flex;
  gap: 8px;
  max-width: min(360px, 100%);
  min-height: 34px;
  padding: 5px 6px 5px 10px;
}

.selected-file-name {
  font-weight: 800;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-file-remove {
  align-items: center;
  background: #b91c1c;
  border: 0;
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 900;
  height: 24px;
  justify-content: center;
  line-height: 1;
  width: 24px;
}

.selected-file-remove:hover {
  background: #991b1b;
}

.reconcile-card {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1.2fr) minmax(180px, 0.4fr) minmax(260px, 0.8fr);
}

.reconcile-title-block {
  align-content: start;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  min-width: 0;
}

.reconcile-title {
  flex: 0 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.reconcile-meta {
  flex: 0 1 auto;
  margin-top: 2px;
  white-space: nowrap;
}

.admin-pane {
  padding-top: 4px;
}

.admin-form {
  margin-bottom: 14px;
}

.permission-table input[type="checkbox"] {
  height: 18px;
  width: 18px;
}

.status-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.status-card {
  display: grid;
  gap: 8px;
}

.status-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-card.success {
  background: #f6fff9;
  border-color: #b8dfca;
}

.status-card.danger {
  background: #fff8f7;
  border-color: #f5b4ad;
}

.modal-backdrop {
  align-items: center;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 30;
}

.modal {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.24);
  display: grid;
  gap: 12px;
  max-width: 720px;
  padding: 18px;
  width: min(720px, 100%);
}

.modal h3 {
  margin: 0 0 4px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.toast {
  align-items: center;
  background: #ffffff;
  border: 1px solid #b8d8cb;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
  color: #fff;
  display: flex;
  gap: 12px;
  left: 50%;
  max-width: min(620px, calc(100vw - 32px));
  min-width: min(430px, calc(100vw - 32px));
  opacity: 0;
  padding: 18px 20px;
  pointer-events: none;
  position: fixed;
  top: 50%;
  transform: translate(-50%, -44%) scale(0.96);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 60;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.toast-mark {
  align-items: center;
  background: #0f766e;
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 18px;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.toast-message {
  color: #10201c;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.dashboard-main-grid {
  align-items: start;
  grid-template-columns: minmax(0, 2fr) minmax(360px, 1fr);
  width: 100%;
}

.dashboard-main-grid .panel {
  margin-left: 0;
  margin-right: 0;
  max-width: none;
  width: 100%;
}

.budget-overview-panel {
  min-height: 0;
}

.budget-progress {
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 13px;
}

.progress-copy {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.progress-copy span {
  color: var(--muted);
  font-size: 12px;
}

.progress-track {
  background: #e9efeb;
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
}

.progress-bar {
  background: var(--accent);
  border-radius: inherit;
  height: 100%;
}

.progress-bar.warning {
  background: var(--amber);
}

.progress-bar.danger {
  background: var(--danger);
}

.budget-summary-grid {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  margin-bottom: 14px;
  overflow: hidden;
}

.budget-summary-grid div {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  display: grid;
  gap: 6px;
  min-height: 72px;
  padding: 12px;
}

.budget-summary-grid span,
.insight-card > span,
.date-range span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.budget-summary-grid strong {
  font-size: 17px;
}

.budget-insight-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1.25fr) minmax(210px, 0.8fr) minmax(180px, 0.6fr);
}

.insight-card {
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: grid;
  gap: 9px;
  min-height: 104px;
  padding: 12px;
  text-align: left;
}

.insight-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.top-category-row {
  align-items: center;
  border-left: 4px solid var(--line-strong);
  border-radius: 6px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 7px 8px;
}

.top-category-row:nth-child(2) {
  background: #e8f5f2;
  border-left-color: #0f766e;
}

.top-category-row:nth-child(3) {
  background: #fff3dd;
  border-left-color: #b7791f;
}

.top-category-row:nth-child(4) {
  background: #e9f1fb;
  border-left-color: #2764a7;
}

.top-category-row span {
  color: var(--text);
  font-size: 13px;
}

.top-category-row strong {
  font-size: 13px;
  white-space: nowrap;
}

.top-category-row em {
  color: var(--muted);
  font-style: normal;
  font-weight: 700;
  margin-left: 4px;
}

.pending-card {
  border-color: #f5b4ad;
  background: #fff8f7;
}

.pending-card strong {
  color: var(--danger);
}

.pending-card small {
  color: var(--muted);
  font-size: 12px;
}

.date-range {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.date-range label {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.readonly-input {
  background: #fff1f5;
  border-color: #f9a8d4;
  color: #9f1239;
  font-weight: 800;
}

.calc-preview {
  background: #fff1f5;
  border: 1px solid #f9a8d4;
  border-radius: 8px;
  color: #9f1239;
  font-size: 13px;
  font-weight: 800;
  grid-column: 1 / -1;
  line-height: 1.5;
  padding: 10px 12px;
}

.rate-reference {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  display: flex;
  gap: 12px;
  grid-column: 1 / -1;
  justify-content: space-between;
  padding: 10px 12px;
}

.rate-reference-main {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rate-reference-icon {
  align-items: center;
  background: #e0f2fe;
  border-radius: 999px;
  color: #075985;
  display: inline-flex;
  font-weight: 900;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.rate-reference strong,
.rate-reference span {
  display: inline-flex;
}

.rate-reference strong {
  color: #0f172a;
  font-size: 13px;
}

.rate-reference span {
  color: #64748b;
  font-size: 12px;
}

.rate-reference-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.button.small {
  min-height: 32px;
  padding: 6px 10px;
}

.button.icon-button {
  min-height: 32px;
  min-width: 34px;
  padding: 6px 9px;
}

.entry-edit-modal {
  max-height: calc(100vh - 36px);
  max-width: 980px;
  overflow: auto;
  width: min(980px, 100%);
}

.modal-entry-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.detail-modal,
.payee-modal {
  max-height: calc(100vh - 36px);
  max-width: 920px;
  overflow: auto;
  width: min(920px, 100%);
}

.inline-field {
  align-items: center;
  display: flex;
  gap: 8px;
  width: 100%;
}

.inline-field .input {
  flex: 1;
  min-width: 0;
}

.form-hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.pagination-bar {
  align-items: center;
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
}

.attachment-manager {
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
  padding: 12px;
}

.manager-header {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.manager-header span {
  color: var(--muted);
  font-size: 12px;
}

.compact-list {
  margin-bottom: 0;
}

.icon-remove {
  align-items: center;
  background: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  height: 26px;
  justify-content: center;
  width: 26px;
}

.icon-remove:hover {
  background: #8f1d14;
  border-color: #8f1d14;
}

.payee-bank-wrap {
  display: none;
}

.payee-create-form[data-currency="USDT"] .payee-bank-wrap {
  display: none;
}

.payee-create-form[data-currency="RMB"] .payee-usdt-wrap,
.payee-create-form[data-currency="PESO"] .payee-usdt-wrap {
  display: none;
}

.payee-create-form[data-currency="RMB"] .payee-bank-wrap,
.payee-create-form[data-currency="PESO"] .payee-bank-wrap {
  display: grid;
}

.payee-admin {
  display: grid;
  gap: 18px;
}

.payee-create-form {
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  padding: 14px;
}

.payee-form-header,
.payee-list-header,
.payee-card-title,
.payee-actions {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.payee-form-header .button {
  justify-self: end;
  min-width: 96px;
  width: auto;
}

.payee-form-header h3,
.payee-list-header h3 {
  margin: 0;
}

.payee-form-grid,
.payee-card-grid,
.payee-readonly-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.payee-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.payee-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.payee-card.editing {
  border-color: #9ed8cf;
  box-shadow: 0 10px 28px rgba(15, 118, 110, 0.08);
}

.payee-currency {
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
}

.payee-readonly-grid div {
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 10px;
}

.payee-readonly-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.payee-readonly-grid strong {
  overflow-wrap: anywhere;
}

.payee-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.payee-table th,
.payee-table td {
  padding: 9px 10px;
  vertical-align: middle;
}

.payee-table .input,
.payee-table .select {
  min-height: 34px;
}

.payee-table .payee-currency {
  justify-content: center;
  min-width: 58px;
}

.payee-account-cell {
  max-width: 320px;
  overflow-wrap: anywhere;
}

.payee-edit-row {
  background: #f8fcfa;
}

.subject-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
}

.subject-summary span {
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 7px 10px;
}

.subject-manager {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(280px, 0.34fr) minmax(0, 1fr);
}

.subject-primary-panel,
.subject-detail-panel {
  min-width: 0;
}

.subject-primary-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 640px;
  overflow: auto;
  padding-right: 4px;
}

.subject-primary-item {
  align-items: stretch;
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr);
  padding: 10px;
}

.subject-primary-item.active {
  background: #f0f8f6;
  border-color: var(--accent);
}

.subject-select {
  background: transparent;
  border: 0;
  color: inherit;
  display: grid;
  gap: 3px;
  padding: 0;
  text-align: left;
}

.subject-select span {
  color: var(--muted);
  font-size: 12px;
}

.subject-add-secondary {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(160px, 0.35fr) minmax(260px, 1fr) auto;
  margin-bottom: 12px;
}

.subject-table .textarea {
  min-height: 66px;
  resize: vertical;
}

.subject-table th:first-child {
  width: 210px;
}

.audit-log-grid {
  display: grid;
  gap: 18px;
}

.audit-log-grid h3 {
  margin: 0 0 10px;
}

.check-row {
  align-items: center;
  display: flex;
  gap: 8px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.subject-catalog-v2 .panel-header {
  align-items: flex-start;
}

.subject-toolbar {
  justify-content: flex-end;
}

.subject-page {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.subject-page-head {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.subject-page-head h3 {
  margin: 0 0 4px;
}

.subject-add-row {
  align-items: end;
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(180px, 1fr) auto;
  margin-bottom: 14px;
  padding: 12px;
}

.secondary-add-row {
  grid-template-columns: minmax(180px, 0.35fr) minmax(260px, 1fr) auto;
}

.subject-primary-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.subject-tab {
  align-items: center;
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  display: inline-flex;
  font-weight: 800;
  gap: 8px;
  padding: 8px 12px;
}

.subject-tab span {
  color: var(--muted);
  font-size: 12px;
}

.subject-tab.active {
  background: #edf7f5;
  border-color: var(--accent);
  color: var(--accent-strong);
}

.subject-secondary-table th:first-child {
  width: 230px;
}

.subject-detail-text {
  color: var(--text);
  display: block;
  max-width: 760px;
  white-space: pre-wrap;
}

.empty {
  background: #fbfcfa;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  padding: 22px;
  text-align: center;
}

.compact-empty {
  padding: 12px;
}

@media (max-width: 1180px) {
  .kpi-grid,
  .budget-alert-grid,
  .chart-grid,
  .budget-ledger,
  .budget-summary-grid,
  .budget-insight-grid,
  .payee-grid,
  .payee-form-grid,
  .payee-card-grid,
  .payee-readonly-grid,
  .subject-manager,
  .subject-add-secondary,
  .subject-add-row,
  .secondary-add-row,
  .entry-form,
  .detail-grid,
  .reconcile-card,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .reconcile-title-block {
    display: grid;
    gap: 4px;
  }

  .reconcile-meta {
    white-space: normal;
  }
}

@media (max-width: 860px) {
  .login-page {
    padding: 18px;
  }

  .login-card {
    grid-template-columns: 1fr;
    max-width: 100%;
  }

  .login-brand-block h1 {
    font-size: 34px;
  }

  .login-form {
    max-width: none;
  }

  .top-account-bar {
    display: grid;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    left: auto;
    min-height: auto;
    overflow: visible;
    position: sticky;
    top: 0;
    width: auto;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main-shell {
    margin-left: 0;
    padding: 18px 14px 28px;
  }

  .panel-header {
    display: grid;
  }

  .toolbar,
  .date-range,
  .inline-field,
  .pagination-bar,
  .payee-form-header,
  .payee-list-header,
  .payee-card-title,
  .payee-actions,
  .modal-actions {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr;
  }

  .button,
  .input,
  .select,
  .textarea {
    width: 100%;
  }

  .rate-reference {
    align-items: flex-start;
    display: grid;
    grid-template-columns: 1fr;
  }

  .rate-reference-actions {
    justify-content: flex-start;
  }

  .rate-reference .button.icon-button {
    width: auto;
  }

  .payee-form-header .button {
    justify-self: start;
    width: auto;
  }

  .modal-backdrop {
    align-items: stretch;
    padding: 8px;
  }

  .modal,
  .entry-edit-modal,
  .detail-modal,
  .payee-modal {
    max-height: calc(100vh - 16px);
    width: 100%;
  }

  .table-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .data-table {
    min-width: 760px;
  }

  .chart-box,
  .chart-box.tall {
    height: 320px;
  }
}

@media (max-width: 560px) {
  .sidebar {
    padding: 16px 12px;
  }

  .nav {
    grid-template-columns: 1fr;
  }

  .page-heading h1 {
    font-size: 24px;
  }

  .panel,
  .detail-drawer {
    padding: 14px;
  }

  .budget-summary-grid div,
  .payee-card,
  .payee-create-form {
    padding: 12px;
  }
}
