body.deposits-page {
  max-width: none;
  width: fit-content;
  min-width: min(100%, 40rem);
  max-width: 100%;
}

body.deposits-page:has(#timeline-section:not(.hidden)) {
  width: 100%;
  max-width: 100%;
}

.deposits-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.toolbar-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.view-toggle {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.2rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.view-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.save-status {
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 4.5rem;
}

.save-status.saved { color: var(--success); }
.save-status.error { color: var(--danger); }

.deposits-panel {
  padding: 0;
  overflow: hidden;
  width: fit-content;
  max-width: 100%;
}

.view-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  font-size: 0.85rem;
}

.view-summary[hidden] {
  display: none !important;
}

.view-summary-title {
  font-weight: 700;
  color: var(--text);
}

.view-summary-metric {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.view-summary-metric strong {
  color: var(--text);
  font-weight: 700;
}

.group-header-row td {
  background: #eef2ff !important;
  font-weight: 700;
  padding: 0.55rem 0.65rem !important;
  border-bottom: 1px solid var(--border);
  opacity: 1 !important;
}

.group-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1.25rem;
}

.group-header-name {
  font-size: 0.9rem;
}

.group-header-metrics {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.group-header-metrics strong {
  color: var(--text);
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 12rem);
  max-width: 100%;
}

.deposits-table {
  width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8rem;
}

.deposits-table th,
.deposits-table td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 0.35rem 0.45rem;
  vertical-align: middle;
  white-space: nowrap;
}

.deposits-table th:last-child,
.deposits-table td:last-child {
  border-right: none;
}

.deposits-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: left;
  box-shadow: 0 1px 0 var(--border);
}

.deposits-table thead th.calc {
  color: #64748b;
  font-weight: 600;
}

.deposits-table tbody tr:hover td {
  background: var(--surface-hover);
}

.deposits-table tbody tr.is-closed td {
  opacity: 0.55;
}

.deposits-table tfoot td {
  background: var(--bg-subtle);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  position: sticky;
  bottom: 0;
  box-shadow: 0 -1px 0 var(--border);
}

.cell-input {
  width: 100%;
  min-width: 4.5rem;
  max-width: 8rem;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font: inherit;
  padding: 0.25rem 0.3rem;
  color: var(--text);
}

.cell-input.num {
  min-width: 5rem;
  max-width: 7rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.cell-input.date {
  min-width: 8.2rem;
  max-width: 9.5rem;
}

.subtitle {
  margin-bottom: 0.65rem;
}

.active-summary-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem 1rem;
  margin: 0.35rem 0 0.15rem;
}

.active-by-name {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.55rem;
  margin: 0;
  flex: 1 1 auto;
}

.active-by-name[hidden] {
  display: none !important;
}

.active-summary-row > #btn-history {
  flex: 0 0 auto;
  margin-top: 0.15rem;
}

.active-by-name-card {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  min-width: 8.5rem;
}

.active-by-name-label {
  font-size: 0.78rem;
  font-weight: 750;
  color: var(--text);
}

.active-by-name-metrics {
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.active-by-name-metrics strong {
  color: var(--text);
  font-weight: 700;
}

.active-by-name-card.is-total {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.active-by-name-card.is-total .active-by-name-label {
  font-weight: 800;
}

.history-overlay {
  border: none;
  padding: 0;
  background: transparent;
  max-width: min(920px, calc(100vw - 1.5rem));
  width: 100%;
}

.history-overlay::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
}

.history-overlay-panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.22);
  overflow: hidden;
  max-height: min(90vh, 840px);
  display: flex;
  flex-direction: column;
}

.history-overlay-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.history-overlay-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.history-overlay-sub {
  margin: 0.25rem 0 0;
}

.history-overlay-body {
  padding: 1rem 1.15rem 1.25rem;
  overflow: auto;
}

.history-note {
  margin: 0 0 0.85rem;
}

.history-chart-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
  padding: 0.75rem 0.85rem 0.55rem;
  margin-bottom: 1.1rem;
}

.history-chart {
  width: 100%;
  height: auto;
  display: block;
}

.history-chart-legend {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.history-chart-legend i {
  display: inline-block;
  width: 0.85rem;
  height: 3px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 0.3rem;
}

.history-chart-legend .lg-amount { background: #2563eb; }
.history-chart-legend .lg-perday { background: #db2777; }

.history-section {
  margin-top: 1rem;
}

.history-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.92rem;
}

.history-today-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.history-today-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: #fff;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.history-today-item time {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.history-delta-pos { color: #047857; font-weight: 700; }
.history-delta-neg { color: #b91c1c; font-weight: 700; }
.history-delta-zero { color: var(--muted); }

.history-table-wrap {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.history-table th,
.history-table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.history-table th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.history-table tr.is-today {
  background: #eff6ff;
}

.name-select,
.bank-select {
  min-width: 7.5rem;
  max-width: 11rem;
  cursor: pointer;
}

.cell-input:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.cell-input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.calc-val {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
}

.calc-val.muted { color: var(--muted); font-weight: 500; }

.closed-check {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.btn-row-del {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  line-height: 1;
}

.btn-row-del:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.empty-hint {
  padding: 1rem 1.25rem;
  margin: 0;
}

.hidden { display: none !important; }

.btn.btn-sm {
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
}

/* Timeline — Notion-style board */
.timeline-panel {
  padding: 0.75rem 0.85rem 1rem;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}

.timeline-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.timeline-panel .view-summary {
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  margin-bottom: 0;
}

.timeline-panel .view-summary + .timeline-root {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.timeline-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.timeline-zoom-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.timeline-zoom {
  width: auto;
  min-width: 8rem;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
}

.timeline-root {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 15.5rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f8fafc;
  overflow: hidden;
}

.tl-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.tl-header-row {
  display: flex;
  flex: 0 0 auto;
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
  z-index: 5;
}

.tl-corner {
  flex: 0 0 var(--lane-label-w, 148px);
  width: var(--lane-label-w, 148px);
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  padding: 0.55rem 0.65rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  box-sizing: border-box;
}

.tl-x-rail {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  background: #fff;
}

.tl-header-canvas {
  min-height: 2.9rem;
}

.tl-y-rail {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
}

.tl-group-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 1rem;
  padding: 0.45rem 0.7rem;
  background: #eef2ff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 3;
}

.tl-group-banner-name {
  font-size: 0.85rem;
  font-weight: 750;
  color: var(--text);
}

.tl-group-banner-metrics {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tl-group-banner-metrics strong {
  color: var(--text);
}

.tl-board {
  position: relative;
  min-width: 100%;
}

.tl-months {
  display: flex;
  height: 1.55rem;
  border-bottom: 1px solid var(--border);
}

.tl-month {
  flex: 0 0 auto;
  box-sizing: border-box;
  border-right: 1px solid var(--border);
  padding: 0.25rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
  background: #eef2ff;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tl-month:nth-child(even) {
  background: #e0e7ff;
}

.tl-days {
  display: flex;
  height: 1.35rem;
  background: #fff;
}

.tl-day {
  flex: 0 0 auto;
  box-sizing: border-box;
  border-right: 1px solid #f1f5f9;
  text-align: center;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.35rem;
  font-variant-numeric: tabular-nums;
}

.tl-day.is-weekend {
  background: #f8fafc;
  color: #94a3b8;
}

.tl-day.is-today {
  background: #fee2e2;
  color: var(--danger);
  font-weight: 800;
}

.tl-body {
  position: relative;
}

.tl-today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--danger);
  z-index: 3;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.15);
}

.tl-lane-canvas-clip {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.tl-lane {
  display: flex;
  border-bottom: 1px solid var(--border);
  min-height: 4rem;
}

.tl-lane:nth-child(even) .tl-lane-head,
.tl-lane:nth-child(even) .tl-lane-canvas {
  background: #f8fafc;
}

.tl-lane-head {
  flex: 0 0 var(--lane-label-w, 148px);
  width: var(--lane-label-w, 148px);
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 0.65rem 0.7rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
}

.tl-lane-title {
  font-size: 0.85rem;
  font-weight: 750;
  color: var(--text);
}

.tl-lane-count {
  align-self: flex-start;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  background: #e2e8f0;
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
}

.tl-lane-canvas-wrap {
  flex: 1;
  overflow: hidden;
}

.tl-lane-canvas {
  position: relative;
  min-height: 3.5rem;
}

.tl-grid-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #e2e8f0;
  pointer-events: none;
}

.tl-grid-line.is-month {
  background: #cbd5e1;
}

.tl-card {
  position: absolute;
  height: 44px;
  border: none;
  border-radius: 8px;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  overflow: hidden;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.08),
    inset 0 0 0 1px rgba(15, 23, 42, 0.08);
  color: #0f172a;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.tl-card:hover {
  transform: translateY(-1px);
  box-shadow:
    0 4px 12px rgba(15, 23, 42, 0.12),
    inset 0 0 0 1px rgba(15, 23, 42, 0.1);
  z-index: 2;
}

.tl-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  z-index: 2;
}

.tl-card.is-closed {
  opacity: 0.55;
  filter: grayscale(0.25);
}

.tl-card-body {
  position: absolute;
  top: 0;
  bottom: 0;
  max-width: 100%;
  padding: 0.28rem 0.5rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.05rem;
  pointer-events: none;
}

.tl-card-bank {
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl-card-main {
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.tl-card-meta {
  font-size: 0.62rem;
  font-weight: 600;
  color: rgba(15, 23, 42, 0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Deposit editor */
.deposit-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(28rem, 94vw);
  box-shadow: var(--shadow-lg);
}

.deposit-editor::backdrop {
  background: rgba(15, 23, 42, 0.4);
}

.deposit-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.15rem 1.25rem 1.25rem;
}

.deposit-form h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.deposit-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.deposit-form .field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.deposit-form .field-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.deposit-form .field-input {
  width: 100%;
  box-sizing: border-box;
}

.field-check {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem !important;
  font-size: 0.9rem;
}

.form-error {
  margin: 0;
  font-size: 0.8rem;
  color: var(--danger);
}

.deposit-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.deposit-form-actions-end {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.btn.danger {
  background: var(--danger-bg, #fef2f2);
  border-color: #fecaca;
  color: var(--danger);
}

.btn.danger:hover:not(:disabled) {
  background: #fee2e2;
  border-color: var(--danger);
}

.btn-row-edit {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}

.btn-row-edit:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

@media (max-width: 520px) {
  .deposit-form-grid {
    grid-template-columns: 1fr;
  }
}
