/* Transaction history page */
.ledger-page {
  --ledger-bg: #0b1220;
  --ledger-surface: #111c2d;
  --ledger-surface-raised: #16243a;
  --ledger-surface-soft: #0e192a;
  --ledger-line: rgba(148, 169, 199, 0.15);
  --ledger-line-strong: rgba(148, 169, 199, 0.24);
  --ledger-text: #edf3fc;
  --ledger-muted: #9aacc4;
  --ledger-faint: #70829c;
  --ledger-blue: #9fb0ff;
  --ledger-green: #55d6a0;
  --ledger-red: #ff8296;
  --ledger-amber: #f7c96f;
  color: var(--ledger-text);
  background: var(--ledger-bg) !important;
}

body.ledger-page {
  min-width: 320px;
  background:
    radial-gradient(ellipse at 12% -20%, rgba(92, 115, 214, 0.1), transparent 35rem),
    var(--ledger-bg) !important;
}

body.ledger-page > header.ledger-page-header {
  position: sticky !important;
  inset: 0 0 auto !important;
  z-index: 50 !important;
  width: 100% !important;
  height: auto !important;
  overflow: visible !important;
  border: 0 !important;
  border-bottom: 1px solid var(--ledger-line) !important;
  background: rgba(11, 18, 32, 0.91) !important;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16) !important;
  backdrop-filter: blur(18px);
}

.ledger-page-header .ledger-sidebar-inner {
  display: flex !important;
  width: min(100%, 1480px) !important;
  max-width: none !important;
  height: 70px !important;
  min-height: 0 !important;
  margin: 0 auto !important;
  padding: 0 clamp(18px, 3vw, 42px) !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 1rem !important;
}

.ledger-page-header .ledger-sidebar-brand {
  min-width: 0;
  gap: 0.75rem !important;
}

.ledger-page-header .ledger-sidebar-logo {
  width: 2.55rem !important;
  height: 2.55rem !important;
  flex: 0 0 auto;
  border: 1px solid var(--ledger-line-strong);
  border-radius: 0.9rem !important;
  box-shadow: none !important;
}

.ledger-page-header .ledger-brand-name {
  overflow: hidden;
  color: var(--ledger-text) !important;
  font-size: 0.9rem !important;
  line-height: 1.25 !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger-page-header .ledger-sidebar-brand p {
  margin-top: 0.12rem;
  color: var(--ledger-faint) !important;
  font-size: 0.68rem !important;
}

.ledger-page-header .ledger-sidebar-actions {
  gap: 0.45rem !important;
}

.ledger-page-header .ledger-sidebar-actions > a,
.ledger-page-header .ledger-sidebar-actions > #btnReset {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0 0.8rem !important;
  border: 1px solid var(--ledger-line) !important;
  border-radius: 0.75rem !important;
  background: rgba(22, 36, 58, 0.68) !important;
  color: #c6d2e4 !important;
  font-size: 0.72rem !important;
  font-weight: 700;
  box-shadow: none !important;
}

.ledger-page-header .ledger-sidebar-actions > a:hover,
.ledger-page-header .ledger-sidebar-actions > #btnReset:hover {
  border-color: var(--ledger-line-strong) !important;
  background: #1a2a42 !important;
  color: #fff !important;
}

.ledger-page-header .ledger-sidebar-actions > #btnReset {
  cursor: pointer;
}

body.ledger-page > main.ledger-main {
  display: flex;
  width: min(100%, 1480px) !important;
  max-width: none !important;
  margin: 0 auto !important;
  padding: clamp(24px, 3.3vw, 46px) clamp(18px, 3vw, 42px) 56px !important;
  flex-direction: column;
  gap: 1.35rem;
}

.ledger-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
}

.ledger-eyebrow {
  margin: 0 0 0.45rem;
  color: #9baeff;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.ledger-intro h2 {
  margin: 0;
  color: #f2f6fc;
  font-size: clamp(1.65rem, 3vw, 2.15rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.15;
}

.ledger-intro p:last-child {
  max-width: 42rem;
  margin: 0.55rem 0 0;
  color: var(--ledger-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

.ledger-intro-note {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--ledger-line);
  border-radius: 0.8rem;
  background: rgba(17, 28, 45, 0.72);
  color: #bdc9db;
  font-size: 0.72rem;
  font-weight: 700;
}

.ledger-intro-note i {
  color: var(--ledger-blue);
}

.ledger-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.8rem !important;
  margin: 0 !important;
}

.ledger-kpi-grid .stat-card {
  position: relative;
  min-width: 0;
  min-height: 132px;
  padding: 1rem 1.05rem !important;
  overflow: hidden;
  border: 1px solid var(--ledger-line) !important;
  border-radius: 1rem !important;
  background: linear-gradient(150deg, rgba(22, 36, 58, 0.96), rgba(17, 28, 45, 0.98)) !important;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12) !important;
}

.ledger-kpi-grid .stat-card::before {
  position: absolute;
  inset: auto -28px -45px auto;
  width: 115px;
  height: 115px;
  border-radius: 50%;
  background: var(--kpi-glow, rgba(132, 151, 255, 0.1));
  content: "";
  filter: blur(22px);
  pointer-events: none;
}

.ledger-kpi-grid .stat-card:nth-child(1) { --kpi-glow: rgba(132, 151, 255, 0.15); }
.ledger-kpi-grid .stat-card:nth-child(2) { --kpi-glow: rgba(79, 214, 165, 0.12); }
.ledger-kpi-grid .stat-card:nth-child(3) { --kpi-glow: rgba(255, 125, 145, 0.12); }
.ledger-kpi-grid .stat-card:nth-child(4) { --kpi-glow: rgba(132, 151, 255, 0.13); }
.ledger-kpi-grid .stat-card:nth-child(5) { --kpi-glow: rgba(248, 199, 101, 0.1); }

.ledger-kpi-grid .stat-card > div {
  position: relative;
  z-index: 1;
}

.ledger-kpi-grid .stat-card > div:first-child > span {
  color: #9aacc4 !important;
  font-size: 0.62rem !important;
  letter-spacing: 0.08em;
}

.ledger-kpi-grid .stat-card .icon-box {
  width: 2rem !important;
  height: 2rem !important;
  border: 1px solid var(--ledger-line) !important;
  border-radius: 0.7rem !important;
  background: #1b2b43 !important;
}

.ledger-kpi-grid .stat-card:first-child .icon-box,
.ledger-kpi-grid .stat-card:nth-child(4) .icon-box { color: #aab8ff !important; }
.ledger-kpi-grid .stat-card:nth-child(2) .icon-box { color: var(--ledger-green) !important; }
.ledger-kpi-grid .stat-card:nth-child(3) .icon-box { color: var(--ledger-red) !important; }
.ledger-kpi-grid .stat-card:nth-child(5) .icon-box { color: var(--ledger-amber) !important; }

.ledger-kpi-grid .stat-card > div:last-child {
  margin-top: 1.15rem !important;
}

.ledger-kpi-grid .stat-card > div:last-child > div:first-child {
  overflow-wrap: anywhere;
  font-size: clamp(1.02rem, 1.4vw, 1.32rem) !important;
  line-height: 1.2;
}

.ledger-kpi-grid .stat-card > div:last-child > div:last-child {
  margin-top: 0.3rem !important;
  color: var(--ledger-faint) !important;
  font-size: 0.68rem !important;
}

.ledger-filter-panel,
.ledger-table-section {
  min-width: 0;
  border: 1px solid var(--ledger-line) !important;
  border-radius: 1.15rem !important;
  background: rgba(17, 28, 45, 0.9) !important;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12) !important;
}

.ledger-filter-panel {
  padding: clamp(16px, 2vw, 22px) !important;
}

.ledger-section-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.ledger-section-heading h3 {
  margin: 0;
  color: #eaf0f9;
  font-size: 0.96rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.ledger-section-heading p {
  margin: 0.25rem 0 0;
  color: var(--ledger-faint);
  font-size: 0.72rem;
  line-height: 1.5;
}

.ledger-filter-options {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}

.ledger-filter-group {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.42rem;
}

.ledger-filter-label,
.ledger-control-label {
  color: #8fa1ba;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.ledger-segment-control {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 0.2rem;
  padding: 0.22rem !important;
  border: 1px solid rgba(148, 169, 199, 0.11);
  border-radius: 0.82rem !important;
  background: #0d1727 !important;
}

.ledger-filter-panel .table-filter-btn,
.ledger-filter-panel .table-status-filter-btn {
  min-height: 34px;
  padding: 0.45rem 0.72rem !important;
  border: 1px solid transparent !important;
  border-radius: 0.62rem !important;
  background: transparent !important;
  color: #9aacc4 !important;
  font-size: 0.7rem !important;
  font-weight: 700 !important;
  white-space: nowrap;
}

.ledger-filter-panel .table-filter-btn:hover,
.ledger-filter-panel .table-status-filter-btn:hover {
  background: rgba(148, 169, 199, 0.08) !important;
  color: #e6edf8 !important;
}

.ledger-filter-panel .table-filter-btn.active,
.ledger-filter-panel .table-status-filter-btn.active,
.ledger-filter-panel .table-filter-btn[aria-pressed="true"],
.ledger-filter-panel .table-status-filter-btn[aria-pressed="true"] {
  border-color: rgba(154, 173, 255, 0.18) !important;
  background: #263653 !important;
  color: #dce3ff !important;
  box-shadow: none !important;
}

.ledger-filter-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1.15rem;
}

.ledger-filter-control {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.38rem;
}

.ledger-filter-control.month,
.ledger-filter-control.date,
.ledger-filter-control.payment,
.ledger-filter-control.sort { grid-column: span 2; }
.ledger-filter-control.search { grid-column: span 4; }

.ledger-filter-control .relative {
  min-width: 0;
}

body.ledger-page .ledger-filter-control input,
body.ledger-page .ledger-filter-control select {
  width: 100%;
  min-width: 0;
  min-height: 43px !important;
  padding-top: 0.65rem !important;
  padding-bottom: 0.65rem !important;
  border: 1px solid var(--ledger-line-strong) !important;
  border-radius: 0.72rem !important;
  background-color: #0c1727 !important;
  color: #e1e9f5 !important;
  font-size: 0.72rem !important;
  font-weight: 650;
  box-shadow: none !important;
}

body.ledger-page .ledger-filter-control input::placeholder {
  color: #7587a0 !important;
  font-weight: 500;
}

body.ledger-page .ledger-filter-control input:focus,
body.ledger-page .ledger-filter-control select:focus {
  border-color: rgba(154, 173, 255, 0.65) !important;
  box-shadow: 0 0 0 3px rgba(132, 151, 255, 0.13) !important;
  outline: none !important;
}

.ledger-filter-control > .relative > i {
  color: #7286a3 !important;
}

.ledger-filter-control .relative input[type="text"] {
  padding-right: 2.35rem !important;
}

.ledger-filter-control #btnClearSearch {
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  border: 0;
  background: #263753 !important;
  color: #d5dfef !important;
  font-size: 0.9rem !important;
  line-height: 1;
}

#ledgerSummaryBar {
  display: flex;
  align-items: center;
  gap: 0.5rem !important;
  margin-top: 1rem !important;
  padding-top: 0.85rem;
  border-top: 1px solid var(--ledger-line);
}

#ledgerSummaryBar > div {
  padding: 0.48rem 0.7rem !important;
  border: 1px solid var(--ledger-line) !important;
  border-radius: 0.68rem !important;
  background: #15243a !important;
  color: #b9c7dc !important;
  font-size: 0.68rem !important;
  font-weight: 650;
}

#ledgerSummaryBar > div:first-child strong { color: #68dfb1 !important; }
#ledgerSummaryBar > div:nth-child(2) strong { color: #8cc5ff !important; }
#ledgerSummaryBar > div:last-child strong { color: #d6def0 !important; }

.ledger-table-section {
  overflow: hidden;
}

body.ledger-page .ledger-main .ledger-table-section {
  padding: 0 !important;
}

.ledger-table-heading {
  padding: 1.1rem 1.25rem 0.95rem;
  border-bottom: 1px solid var(--ledger-line);
}

.ledger-table-wrap {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-color: #465a76 transparent;
  scrollbar-width: thin;
}

.ledger-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: separate !important;
  border-spacing: 0;
  color: #d4deed;
  font-size: 0.75rem !important;
}

.ledger-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #16253b !important;
}

.ledger-table thead th {
  padding: 0.82rem 0.7rem !important;
  border-bottom: 1px solid var(--ledger-line-strong);
  color: #9eafc8 !important;
  font-size: 0.61rem !important;
  font-weight: 800 !important;
  letter-spacing: 0.075em;
  white-space: nowrap;
}

.ledger-table tbody {
  background: transparent !important;
}

.ledger-table tbody tr {
  background: rgba(17, 28, 45, 0.48);
  transition: background-color 150ms ease;
}

.ledger-table tbody tr:nth-child(even) {
  background: rgba(22, 36, 58, 0.34);
}

.ledger-table tbody tr:hover {
  background: rgba(132, 151, 255, 0.075) !important;
}

.ledger-table tbody td {
  padding: 0.85rem 0.7rem !important;
  border-bottom: 1px solid rgba(148, 169, 199, 0.09);
  color: #c4d0e1;
  vertical-align: middle;
}

.ledger-table tbody tr:last-child td {
  border-bottom: 0;
}

.ledger-table .history-entry-date {
  color: #dce5f2 !important;
  white-space: nowrap;
}

.ledger-table .history-entry-time {
  color: #8fa1ba !important;
  white-space: nowrap;
}

.ledger-table .history-entry-type {
  white-space: nowrap;
}

.history-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid rgba(148, 169, 199, 0.12);
  border-radius: 999px;
  background: rgba(148, 169, 199, 0.06);
  font-size: 0.67rem;
}

.history-entry-type.text-emerald-400 .history-type-badge { border-color: rgba(85, 214, 160, 0.2); background: rgba(85, 214, 160, 0.08); }
.history-entry-type.text-rose-400 .history-type-badge { border-color: rgba(255, 130, 150, 0.2); background: rgba(255, 130, 150, 0.08); }

.ledger-table .history-entry-amount {
  color: #e4ebf5;
  font-size: 0.76rem !important;
  white-space: nowrap;
}

.ledger-table .history-entry-note {
  max-width: 220px;
  overflow-wrap: anywhere;
}

.ledger-table .history-entry-receipt a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #79d9bd !important;
  font-size: 0.68rem;
  text-decoration: none;
  white-space: nowrap;
}

.ledger-table .history-entry-receipt a:hover {
  color: #b2f3df !important;
  text-decoration: underline;
}

.ledger-table .payment-method-badge,
.ledger-table .history-entry-source > span,
.ledger-table .history-entry-verification > span {
  font-size: 0.61rem !important;
  white-space: nowrap;
}

.ledger-table .history-entry-actions > div {
  justify-content: center;
  gap: 0.35rem;
}

.ledger-table .history-entry-actions button {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--ledger-line);
  border-radius: 0.65rem;
}

#emptyState {
  padding: 3.5rem 1rem !important;
  background: #101a2a !important;
  color: var(--ledger-muted) !important;
}

.ledger-empty-icon {
  display: grid;
  width: 3.25rem;
  height: 3.25rem;
  margin: 0 auto 0.9rem;
  place-items: center;
  border: 1px solid var(--ledger-line);
  border-radius: 1rem;
  background: #17263c;
  color: #91a4c0;
  font-size: 1.1rem;
}

#emptyState h3 {
  margin: 0;
  color: #dce5f2;
  font-size: 0.95rem;
  font-weight: 800;
}

#emptyState p {
  margin: 0.35rem 0 0;
  color: var(--ledger-faint);
  font-size: 0.76rem;
}

#historyPagination {
  min-height: 64px;
  padding: 0.8rem 1.15rem !important;
  border-top: 1px solid var(--ledger-line) !important;
  background: #101a2a;
}

#historyPagination button {
  min-height: 38px;
  border: 1px solid var(--ledger-line-strong) !important;
  border-radius: 0.7rem !important;
  background: #18273d !important;
  color: #cbd7e8 !important;
}

#historyPagination button:hover:not(:disabled) {
  border-color: rgba(154, 173, 255, 0.35) !important;
  background: #223451 !important;
}

#historyPagination button:disabled {
  opacity: 0.38;
}

#historyPageNumber { color: #bbc9dc !important; }

#transactionImageModal > div,
#editTransactionModal > div,
#deleteTransactionModal > div {
  border: 1px solid var(--ledger-line-strong) !important;
  border-radius: 1.15rem !important;
  background: #111c2d !important;
  color: var(--ledger-text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48) !important;
}

#editTransactionModal > div {
  display: flex;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  flex-direction: column;
  overflow: hidden;
}

#editTransactionModal > div > div:first-child,
#deleteTransactionModal > div > div {
  border-color: var(--ledger-line) !important;
}

#editTransactionModal > div > div:first-child {
  flex: 0 0 auto;
}

#editTransactionModal form {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#editTransactionActions {
  flex: 0 0 auto;
  border-color: var(--ledger-line) !important;
  background: #111c2d;
}

#editTransactionModal .text-slate-600,
#editTransactionModal .text-slate-500,
#deleteTransactionModal .text-slate-700 {
  color: #a9b8cc !important;
}

#editTransactionModal .hover\:bg-slate-100:hover,
#deleteTransactionModal .hover\:bg-slate-100:hover {
  background: #1d2b40 !important;
}

#transactionImageModal img {
  background: #0b1220;
}

@media (max-width: 767px) {
  #editTransactionModal {
    z-index: 100 !important;
    padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)) !important;
  }

  #editTransactionModal > div {
    width: min(100%, 34rem);
    max-height: calc(100vh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    max-height: calc(100dvh - max(12px, env(safe-area-inset-top)) - max(12px, env(safe-area-inset-bottom)));
  }

  #editTransactionActions {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    box-shadow: 0 -10px 22px rgba(5, 10, 18, 0.5);
  }

  #editTransactionActions button {
    min-height: 44px;
  }
}

@media (max-width: 1100px) {
  .ledger-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ledger-filter-control.month,
  .ledger-filter-control.date,
  .ledger-filter-control.payment,
  .ledger-filter-control.sort { grid-column: span 3; }
  .ledger-filter-control.search { grid-column: span 12; }
}

@media (max-width: 767px) {
  body.ledger-page > header.ledger-page-header {
    position: fixed !important;
    inset: auto auto calc(10px + env(safe-area-inset-bottom)) 50% !important;
    z-index: 70 !important;
    width: min(calc(100% - 20px), 460px) !important;
    height: auto !important;
    transform: translateX(-50%);
    border: 1px solid rgba(157, 176, 208, 0.2) !important;
    border-radius: 1.15rem !important;
    background: rgba(13, 23, 38, 0.96) !important;
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.42) !important;
    backdrop-filter: blur(20px);
  }

  .ledger-page-header .ledger-sidebar-inner {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 6px !important;
    flex-direction: row !important;
    gap: 0 !important;
  }

  .ledger-page-header .ledger-sidebar-brand {
    display: none !important;
  }

  .ledger-page-header .ledger-sidebar-actions {
    display: grid !important;
    width: 100% !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    justify-content: stretch !important;
    gap: 5px !important;
  }

  body.ledger-page .ledger-page-header .ledger-sidebar-actions > a,
  body.ledger-page .ledger-page-header .ledger-sidebar-actions > button {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 52px !important;
    max-height: none !important;
    flex: 1 1 0% !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.28rem !important;
    padding: 0.4rem 0.2rem !important;
    border: 1px solid rgba(148, 169, 199, 0.14) !important;
    border-radius: 0.82rem !important;
    background: rgba(22, 36, 58, 0.76) !important;
    color: #c6d3e6 !important;
    font-size: 0.62rem !important;
    font-weight: 750 !important;
    line-height: 1.1;
    text-align: center;
    white-space: nowrap;
  }

  body.ledger-page .ledger-page-header .ledger-sidebar-actions > a:hover,
  body.ledger-page .ledger-page-header .ledger-sidebar-actions > button:hover {
    border-color: rgba(154, 173, 255, 0.32) !important;
    background: #223451 !important;
    color: #f0f4ff !important;
  }

  body.ledger-page .ledger-page-header .ledger-sidebar-actions > a > span,
  body.ledger-page .ledger-page-header .ledger-sidebar-actions > button > span {
    display: block !important;
    max-width: 100%;
    overflow: hidden;
    font-size: 0.56rem !important;
    font-weight: 750 !important;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.ledger-page .ledger-page-header .ledger-sidebar-actions > a > i,
  body.ledger-page .ledger-page-header .ledger-sidebar-actions > button > i {
    display: block;
    margin: 0 !important;
    font-size: 0.95rem !important;
  }

  body.ledger-page .ledger-page-header .ledger-sidebar-actions > #btnReset {
    cursor: pointer;
  }

  body.ledger-page > main.ledger-main {
    gap: 1rem;
    padding: 1.3rem 14px calc(112px + env(safe-area-inset-bottom)) !important;
  }

  .ledger-intro {
    align-items: flex-start;
  }

  .ledger-intro h2 { font-size: 1.55rem; }
  .ledger-intro p:last-child { margin-top: 0.42rem; font-size: 0.76rem; }
  .ledger-intro-note { display: none; }

  .ledger-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.62rem !important;
  }

  .ledger-kpi-grid .stat-card {
    min-height: 112px;
    padding: 0.82rem !important;
    border-radius: 0.9rem !important;
  }

  .ledger-kpi-grid .stat-card:first-child { grid-column: span 2; min-height: 100px; }
  .ledger-kpi-grid .stat-card > div:first-child > span { font-size: 0.57rem !important; }
  .ledger-kpi-grid .stat-card .icon-box { width: 1.75rem !important; height: 1.75rem !important; }
  .ledger-kpi-grid .stat-card > div:last-child { margin-top: 0.9rem !important; }
  .ledger-kpi-grid .stat-card > div:last-child > div:first-child { font-size: clamp(0.9rem, 4.2vw, 1.08rem) !important; }

  .ledger-filter-panel { padding: 1rem !important; border-radius: 1rem !important; }
  .ledger-section-heading h3 { font-size: 0.9rem; }
  .ledger-section-heading p { font-size: 0.68rem; }
  .ledger-filter-options { align-items: stretch; flex-direction: column; gap: 0.75rem; margin-top: 0.9rem; }
  .ledger-segment-control { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .ledger-segment-control::-webkit-scrollbar { display: none; }
  .ledger-filter-panel .table-filter-btn,
  .ledger-filter-panel .table-status-filter-btn { min-height: 36px; padding: 0.45rem 0.65rem !important; font-size: 0.66rem !important; }
  .ledger-filter-grid { grid-template-columns: minmax(0, 1fr); gap: 0.7rem; margin-top: 0.95rem; }
  .ledger-filter-control.month,
  .ledger-filter-control.date,
  .ledger-filter-control.payment,
  .ledger-filter-control.sort,
  .ledger-filter-control.search { grid-column: 1; }
  .ledger-control-label { font-size: 0.6rem; }
  body.ledger-page .ledger-filter-control input,
  body.ledger-page .ledger-filter-control select { min-height: 44px !important; font-size: 0.75rem !important; }

  #ledgerSummaryBar { align-items: stretch; gap: 0.42rem !important; }
  #ledgerSummaryBar > div { flex: 1 1 calc(50% - 0.42rem); padding: 0.48rem 0.55rem !important; font-size: 0.62rem !important; }
  #ledgerSummaryBar > div:last-child { margin-left: 0 !important; }

  .ledger-table-section { border-radius: 1rem !important; }
  .ledger-table-heading { padding: 1rem 1rem 0.8rem; }
  .ledger-table-wrap { overflow: visible; }
  .ledger-table,
  .ledger-table tbody { display: block; width: 100%; min-width: 0; }
  .ledger-table thead { display: none; }
  .ledger-table tbody { padding: 0.7rem; }
  .ledger-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 0.55rem;
    margin: 0 0 0.6rem;
    padding: 0.45rem 0.68rem;
    border: 1px solid var(--ledger-line) !important;
    border-left-width: 3px !important;
    border-left-color: rgba(148, 169, 199, 0.24) !important;
    border-radius: 0.82rem !important;
    background: linear-gradient(145deg, #142238, #101b2c) !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12) !important;
  }
  .ledger-table tbody tr.entry-income { border-left-color: rgba(85, 214, 160, 0.75) !important; }
  .ledger-table tbody tr.entry-expense { border-left-color: rgba(255, 130, 150, 0.75) !important; }
  .ledger-table tbody tr.entry-transfer { border-left-color: rgba(247, 201, 111, 0.75) !important; }
  body.ledger-page .ledger-main #ledgerTableBody tr.history-entry-card {
    border: 1px solid var(--ledger-line) !important;
    border-left-width: 3px !important;
    background: linear-gradient(145deg, #142238, #101b2c) !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12) !important;
  }
  body.ledger-page .ledger-main #ledgerTableBody tr.entry-income { border-left-color: rgba(85, 214, 160, 0.75) !important; }
  body.ledger-page .ledger-main #ledgerTableBody tr.entry-expense { border-left-color: rgba(255, 130, 150, 0.75) !important; }
  body.ledger-page .ledger-main #ledgerTableBody tr.entry-transfer { border-left-color: rgba(247, 201, 111, 0.75) !important; }
  .ledger-table tbody tr:last-child { margin-bottom: 0; }
  .ledger-table tbody td {
    display: block;
    min-width: 0;
    padding: 0.34rem 0.05rem !important;
    border: 0 !important;
    text-align: left !important;
    overflow-wrap: anywhere;
  }
  .ledger-table tbody td::before {
    display: block;
    margin-bottom: 0.16rem;
    color: #7f92ad;
    content: attr(data-label);
    font-size: 0.5rem;
    font-weight: 800;
    letter-spacing: 0.055em;
    text-transform: uppercase;
  }
  .ledger-table tbody td:first-child { display: none; }
  .ledger-table .history-entry-date { grid-column: 1; grid-row: 1; font-size: 0.74rem !important; }
  .ledger-table .history-entry-time { grid-column: 2; grid-row: 1; text-align: right !important; }
  .ledger-table .history-entry-type { grid-column: 1; grid-row: 2; }
  .ledger-table .history-entry-type::before,
  .ledger-table .history-entry-amount::before { display: none; }
  .ledger-table .history-entry-type .history-type-badge { padding: 0.28rem 0.5rem; font-size: 0.64rem; }
  .ledger-table .history-entry-amount { grid-column: 2; grid-row: 2; align-self: center; text-align: right !important; font-size: 0.88rem !important; }
  .ledger-table .history-entry-source { grid-column: 1; grid-row: 3; }
  .ledger-table .history-entry-category { grid-column: 2; grid-row: 3; }
  .ledger-table .history-entry-receipt { grid-column: 1 / -1; grid-row: 4; }
  .ledger-table .history-entry-receipt.receipt-empty { display: none; }
  .ledger-table .history-entry-receipt:not(.receipt-empty) {
    margin-top: 0.12rem;
    padding-top: 0.48rem !important;
    border-top: 1px solid rgba(148, 169, 199, 0.1) !important;
  }
  .ledger-table .history-entry-receipt a {
    display: inline-flex;
    min-height: 32px;
    padding: 0.35rem 0.55rem;
    border: 1px solid rgba(85, 214, 160, 0.18);
    border-radius: 0.62rem;
    background: rgba(85, 214, 160, 0.06);
    font-size: 0.65rem;
  }
  .ledger-table .history-entry-verification { grid-column: 1; grid-row: 5; }
  .ledger-table .history-entry-verification,
  .ledger-table .history-entry-actions {
    margin-top: 0.1rem;
    padding-top: 0.5rem !important;
    box-shadow: inset 0 1px rgba(148, 169, 199, 0.1);
  }
  .ledger-table .history-entry-verification > span { padding: 0.3rem 0.48rem !important; }
  .ledger-table .history-entry-actions { grid-column: 2; grid-row: 5; align-self: center; text-align: right !important; }
  .ledger-table .history-entry-actions::before { text-align: right; }
  .ledger-table .history-entry-actions > div { justify-content: flex-end; }
  .ledger-table .history-entry-note { grid-column: 1 / -1; grid-row: 6; color: #aab8cb !important; }
  .ledger-table .history-entry-note.note-empty { display: none !important; }
  .ledger-table .history-entry-note.note-present {
    margin-top: 0.1rem;
    padding-top: 0.48rem !important;
    border-top: 1px solid rgba(148, 169, 199, 0.1) !important;
  }
  .ledger-table .history-entry-note::before { content: "Ghi chú"; }
  .ledger-table .history-entry-source > span,
  .ledger-table .history-entry-verification > span { white-space: normal; }
  #historyPagination { align-items: flex-start !important; flex-direction: column; gap: 0.7rem; padding: 0.85rem !important; }
  #historyPagination .pagination-controls { width: 100%; justify-content: space-between; }
  #emptyState { padding: 2.8rem 1rem !important; }
}

@media (max-width: 380px) {
  body.ledger-page .ledger-page-header .ledger-sidebar-actions > a > span,
  body.ledger-page .ledger-page-header .ledger-sidebar-actions > button > span { font-size: 0.52rem !important; }
  .ledger-kpi-grid .stat-card > div:first-child > span { font-size: 0.52rem !important; }
  .ledger-filter-panel .table-filter-btn,
  .ledger-filter-panel .table-status-filter-btn { padding-right: 0.5rem !important; padding-left: 0.5rem !important; }
}
