:root {
  color-scheme: light;
  --brand-green: #30ae49;
  --brand-cream: #dddcc4;
  --brand-teal: #4d9698;
  --brand-slate: #344b4c;
  --brand-yellow: #ffc846;
  --brand-orange: #f4512a;
  --bg: #f5f3e8;
  --panel: #ffffff;
  --ink: var(--brand-slate);
  --muted: #687676;
  --line: #d8d7c1;
  --soft: #ece9d3;
  --accent: var(--brand-green);
  --accent-dark: #26883b;
  --secondary: var(--brand-teal);
  --rose: var(--brand-orange);
  --gold: #b97910;
  --good: var(--brand-green);
  --shadow: 0 16px 38px rgba(52, 75, 76, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

a {
  color: inherit;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 2rem;
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
}

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

button,
.button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.button:hover {
  background: var(--brand-slate);
}

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

.ghost {
  background: var(--brand-cream);
  color: var(--brand-slate);
}

.ghost:hover {
  background: #cfccb0;
}

.danger {
  background: #fff0eb;
  color: var(--brand-orange);
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 11px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-teal);
  box-shadow: 0 0 0 3px rgba(77, 150, 152, 0.18);
  outline: 0;
}

textarea {
  min-height: 180px;
  padding: 11px;
  resize: vertical;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.2;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(90deg, var(--brand-green) 0 33.33%, var(--brand-cream) 33.33% 66.66%, var(--brand-teal) 66.66% 100%) top / 100% 50% no-repeat,
    linear-gradient(90deg, var(--brand-slate) 0 33.33%, var(--brand-yellow) 33.33% 66.66%, var(--brand-orange) 66.66% 100%) bottom / 100% 50% no-repeat;
}

.login-panel {
  width: min(430px, 100%);
  display: grid;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.login-logo {
  display: block;
  width: min(190px, 58vw);
  height: auto;
  justify-self: center;
  border-radius: 8px;
}

.brand-logo {
  display: block;
  width: 42px;
  height: 42px;
  object-fit: contain;
  object-position: center;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.login-error,
.notice.error {
  border: 1px solid #f7a98f;
  border-radius: 8px;
  background: #fff0eb;
  color: var(--brand-orange);
  padding: 11px 12px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: rgba(52, 75, 76, 0.97);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  padding: 0 18px;
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
}

.brand strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions,
.button-row,
.period-controls,
.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-actions {
  justify-content: flex-end;
}

.view-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.review-panel .section-head {
  gap: 12px;
  padding-bottom: 6px;
}

.review-panel .button-row {
  gap: 12px;
}

.review-panel .table-wrap {
  margin-top: 12px;
}

.review-panel .panel {
  padding-top: 18px;
}

.review-panel h2 {
  line-height: 1.2;
}

.count-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  background: var(--brand-cream);
  color: var(--brand-slate);
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.logout-link,
.text-link {
  color: var(--brand-teal);
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
}

.logout-link:hover,
.text-link:hover {
  color: var(--brand-orange);
  text-decoration: underline;
}

.app-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: calc(100vh - 62px);
}

.sidebar {
  position: sticky;
  top: 62px;
  align-self: start;
  height: calc(100vh - 62px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 0;
  background: var(--brand-slate);
  padding: 18px;
}

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

.nav-list a,
.mobile-nav a {
  min-height: 42px;
  display: flex;
  align-items: center;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 800;
  padding: 0 12px;
  text-decoration: none;
}

.nav-list a.active,
.mobile-nav a.active {
  background: var(--brand-green);
  color: #fff;
}

.workspace {
  width: 100%;
  margin: 0;
  padding: 32px 48px 90px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 28px;
}

.view-head > div:first-child {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.eyebrow {
  color: var(--brand-teal);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.period-controls {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 14px;
}

.period-controls label {
  min-width: 150px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 8px 22px rgba(52, 75, 76, 0.06);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  border-top: 5px solid var(--brand-green);
}

.metric:nth-child(2) {
  border-top-color: var(--brand-teal);
}

.metric:nth-child(3) {
  border-top-color: var(--brand-yellow);
}

.metric:nth-child(4) {
  border-top-color: var(--brand-orange);
}

.metric strong {
  display: block;
  margin-bottom: 5px;
  font-size: 1.6rem;
}

.metric span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.metric.clickable {
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.metric.clickable:hover,
.metric.clickable:focus {
  border-color: var(--brand-teal);
  box-shadow: var(--shadow);
  outline: 0;
  transform: translateY(-1px);
}

.dashboard-grid,
.reports-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 14px;
  align-items: start;
}

.wide {
  grid-column: span 1;
}

.dashboard-grid > .wide:first-child,
.reports-grid > .wide:first-child {
  grid-column: 1 / -1;
}

.chart-frame {
  min-height: 286px;
  display: flex;
  align-items: end;
  gap: 10px;
  overflow: visible;
  padding: 14px 6px 4px;
}

.chart-frame.tall {
  min-height: 320px;
}

.month-bar {
  flex: 1 1 0;
  min-width: 0;
  display: grid;
  align-content: end;
  gap: 9px;
  height: 248px;
  color: var(--muted);
  text-align: center;
  font-size: 0.74rem;
  font-weight: 800;
}

.month-bar span {
  display: block;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.month-bar div {
  min-height: 4px;
  border-radius: 8px 8px 0 0;
  background: var(--brand-green);
}

.month-bar.clickable {
  cursor: pointer;
  border-radius: 8px;
  transition: background 140ms ease, transform 140ms ease;
}

.month-bar.clickable:hover,
.month-bar.clickable:focus {
  background: #f7f5e8;
  outline: 0;
  transform: translateY(-2px);
}

.month-bar:nth-child(6n+2) div {
  background: var(--brand-teal);
}

.month-bar:nth-child(6n+3) div {
  background: var(--brand-yellow);
}

.month-bar:nth-child(6n+4) div {
  background: var(--brand-orange);
}

.month-bar:nth-child(6n+5) div {
  background: var(--brand-slate);
}

.month-bar:nth-child(6n+6) div {
  background: var(--brand-cream);
}

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

.category-trend {
  min-height: 286px;
  align-content: start;
  padding: 8px 2px 0;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) minmax(120px, 1.1fr) auto;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
}

.bar-row.clickable {
  cursor: pointer;
  border-radius: 8px;
  margin: 0 -6px;
  padding: 2px 6px;
  transition: background 140ms ease, transform 140ms ease;
}

.bar-row.clickable:hover,
.bar-row.clickable:focus {
  background: #f7f5e8;
  outline: 0;
  transform: translateX(2px);
}

.bar-label,
.bar-value {
  font-weight: 800;
}

.bar-track {
  display: block;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #eeecd8;
}

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

.compact-list {
  display: grid;
  gap: 8px;
}

.compact-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.compact-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.compact-row strong {
  overflow-wrap: anywhere;
}

.muted {
  color: var(--muted);
}

.import-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.import-panel {
  display: grid;
  align-content: start;
  gap: 13px;
}

#xlsx-status {
  min-height: 1.2em;
}

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

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

.transaction-grid {
  grid-template-columns:
    minmax(130px, 0.9fr)
    minmax(220px, 1.8fr)
    minmax(88px, 0.75fr)
    minmax(106px, 0.95fr)
    minmax(104px, 0.9fr)
    78px;
  align-items: end;
  gap: 8px;
}

.wealth-grid {
  grid-template-columns:
    minmax(130px, 0.9fr)
    minmax(110px, 0.8fr)
    minmax(120px, 0.8fr)
    minmax(120px, 0.85fr)
    minmax(220px, 1.5fr)
    minmax(110px, 0.8fr)
    78px;
  align-items: end;
  gap: 8px;
}

.wealth-grid-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.wealth-grid-panels .panel[hidden] {
  display: none;
}

.span-two {
  grid-column: span 2;
}

.review-panel,
.transaction-form,
.wealth-form,
.filters-panel {
  margin-top: 14px;
}

.transaction-form,
.wealth-form,
.filters-panel {
  padding: 12px 16px;
}

.transaction-form,
.wealth-form {
  display: grid;
  scroll-margin-top: 78px;
}

.transaction-form[hidden],
.wealth-form[hidden] {
  display: none;
}

.transaction-form label,
.wealth-form label,
.filters-panel label {
  gap: 5px;
  font-size: 0.78rem;
}

.transaction-form input,
.transaction-form select,
.wealth-form input,
.wealth-form select,
.filters-panel input,
.filters-panel select {
  min-height: 38px;
  padding: 0 10px;
}

.filters-grid {
  grid-template-columns: 96px 112px minmax(140px, 1fr) minmax(140px, 1fr) minmax(180px, 1.15fr) 38px;
  gap: 8px 10px;
}

.filter-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  align-self: end;
}

.transaction-actions {
  display: flex;
  align-items: end;
  gap: 6px;
}

.icon-action {
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 1.08rem;
  line-height: 1;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.wealth-table {
  min-width: 520px;
}

.wealth-edit-toggle {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.82rem;
}

.wealth-table th:nth-child(6),
.wealth-table td:nth-child(6) {
  display: none;
}

.wealth-grid-panels .panel.editing .wealth-table th:nth-child(6),
.wealth-grid-panels .panel.editing .wealth-table td:nth-child(6) {
  display: table-cell;
}

.select-col {
  width: 40px;
  text-align: center;
}

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

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

th {
  color: var(--brand-slate);
  background: #f2f0dd;
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

td input,
td select {
  min-height: 38px;
}

.review-panel table th,
.review-panel table td {
  padding: 12px 10px;
}

.review-panel td input,
.review-panel td select {
  min-height: 40px;
}

.review-panel .warning {
  line-height: 1.25;
}

.amount-cell {
  font-weight: 900;
  white-space: nowrap;
  color: var(--brand-slate);
}

.warning {
  color: var(--brand-orange);
  font-size: 0.78rem;
  font-weight: 800;
}

.row-actions {
  display: table-cell;
  gap: 6px;
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
}

.row-actions button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.82rem;
  margin-left: 6px;
  vertical-align: middle;
}

.bulk-actions {
  margin: 12px 0;
}

.bulk-actions-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

#transaction-table th,
#transaction-table td {
  padding: 7px 9px;
}

.sort-header {
  min-height: auto;
  width: 100%;
  justify-content: flex-start;
  gap: 6px;
  border-radius: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
  font-weight: inherit;
  text-align: left;
}

.sort-header:hover,
.sort-header.active {
  background: transparent;
  color: var(--brand-green);
}

.sort-header span {
  min-width: 14px;
  color: var(--brand-teal);
  font-size: 0.9rem;
  line-height: 1;
}

.legacy-summary {
  display: grid;
  gap: 7px;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 60;
  max-width: calc(100vw - 28px);
  transform: translateX(-50%) translateY(16px);
  border-radius: 8px;
  background: var(--brand-slate);
  color: #fff;
  opacity: 0;
  padding: 11px 14px;
  pointer-events: none;
  transition: 160ms ease;
}

#toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.mobile-nav {
  display: none;
}

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

  .dashboard-grid,
  .reports-grid,
  .import-layout,
  .wealth-grid-panels {
    grid-template-columns: 1fr;
  }

  .transaction-grid,
  .wealth-grid,
  .form-grid,
  .filters-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  body {
    overflow-x: hidden;
  }

  .topbar {
    height: 58px;
    padding: 0 12px;
    padding-top: env(safe-area-inset-top);
  }

  .brand strong {
    max-width: 46vw;
  }

  .brand-logo {
    width: 36px;
    height: 36px;
  }

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

  .sidebar {
    display: none;
  }

  .workspace {
    padding: 18px 12px calc(88px + env(safe-area-inset-bottom));
  }

  h1 {
    font-size: 1.65rem;
  }

  .view-head,
  .section-head {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 18px;
  }

  .period-controls,
  .button-row {
    justify-content: stretch;
    flex-wrap: wrap;
  }

  .period-controls label,
  .button-row button,
  .button-row .button {
    flex: 1;
  }

  .metric-grid,
  .form-grid,
  .filters-grid,
  .transaction-grid,
  .wealth-grid {
    grid-template-columns: 1fr;
  }

  #transactions .filters-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 38px;
    gap: 7px;
  }

  #transactions .filters-grid label:nth-child(1),
  #transactions .filters-grid label:nth-child(3) {
    grid-column: 1 / 2;
  }

  #transactions .filters-grid label:nth-child(2),
  #transactions .filters-grid label:nth-child(4) {
    grid-column: 2 / 4;
  }

  #transactions .filters-grid label:nth-child(5) {
    grid-column: 1 / 3;
    padding-right: 0;
  }

  #transactions .filter-actions {
    grid-column: 3 / 4;
    grid-row: auto;
    justify-content: flex-end;
    align-self: end;
  }

  #transactions .transaction-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  #wealth .wealth-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  #wealth .wealth-label-field {
    grid-column: 1 / -1;
  }

  #transactions .transaction-item-field {
    grid-column: auto;
  }

  #transactions .transaction-actions {
    grid-column: auto;
    align-self: end;
    justify-content: flex-start;
  }

  #transactions .transaction-form,
  #wealth .wealth-form,
  #transactions .filters-panel {
    padding: 10px;
  }

  #paste-form .import-period-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #dashboard-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
  }

  #report-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
  }

  .span-two {
    grid-column: span 1;
  }

  .panel,
  .metric {
    padding: 13px;
  }

  .reports-grid {
    gap: 10px;
  }

  #reports .panel {
    padding: 12px;
  }

  .metric strong {
    font-size: 1.32rem;
    overflow-wrap: anywhere;
  }

  #dashboard-metrics .metric {
    min-height: 98px;
    padding: 11px;
  }

  #report-metrics .metric {
    min-height: 98px;
    padding: 11px;
  }

  #dashboard-metrics .metric strong,
  #report-metrics .metric strong {
    margin-bottom: 6px;
    font-size: 1.14rem;
  }

  #dashboard-metrics .metric span,
  #dashboard-metrics .metric p,
  #report-metrics .metric span,
  #report-metrics .metric p {
    font-size: 0.76rem;
    line-height: 1.15;
  }

  .chart-frame {
    width: 100%;
    min-height: 224px;
    gap: 3px;
    overflow: visible;
    padding: 10px 0 4px;
  }

  .chart-frame.tall {
    min-height: 206px;
  }

  .month-bar {
    min-width: 0;
    height: 196px;
    gap: 5px;
    font-size: 0.62rem;
  }

  .chart-frame.tall .month-bar {
    height: 172px;
  }

  .month-bar span:first-child {
    min-height: 52px;
    justify-self: center;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    overflow: visible;
    text-overflow: clip;
  }

  .month-bar div {
    border-radius: 5px 5px 0 0;
    max-height: 130px;
  }

  .chart-frame.tall .month-bar div {
    max-height: 104px;
  }

  .bar-row {
    grid-template-columns: 1fr auto;
    gap: 6px 8px;
  }

  .bar-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .bulk-actions-inner {
    align-items: stretch;
    flex-direction: column;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    overflow: hidden;
  }

  th,
  td,
  #transaction-table th,
  #transaction-table td,
  .review-panel table th,
  .review-panel table td {
    border-bottom: 1px solid var(--line);
    padding: 9px 10px;
  }

  td {
    display: grid;
    grid-template-columns: minmax(84px, 0.34fr) minmax(0, 1fr);
    align-items: center;
    gap: 10px;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
  }

  td > * {
    min-width: 0;
  }

  td[colspan] {
    display: block;
  }

  td[colspan]::before {
    content: none !important;
  }

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

  #transaction-table table {
    display: table;
    min-width: 0;
    table-layout: fixed;
  }

  #transaction-table thead {
    display: table-header-group;
  }

  #transaction-table tbody {
    display: table-row-group;
  }

  #transaction-table tr {
    display: table-row;
    border: 0;
    border-radius: 0;
    background: transparent;
    overflow: visible;
  }

  #transaction-table th,
  #transaction-table td {
    display: table-cell;
    width: auto;
    padding: 5px 3px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
  }

  #transaction-table td {
    font-size: 0.68rem;
    line-height: 1.08;
  }

  #transaction-table td::before {
    content: none !important;
  }

  #transaction-table th {
    font-size: 0.58rem;
  }

  #transaction-table th:nth-child(1),
  #transaction-table td:nth-child(1) {
    width: 24px;
  }

  #transaction-table th:nth-child(2),
  #transaction-table td:nth-child(2) {
    width: 68px;
  }

  #transaction-table th:nth-child(3),
  #transaction-table td:nth-child(3) {
    width: auto;
  }

  #transaction-table th:nth-child(4),
  #transaction-table td:nth-child(4) {
    width: 58px;
  }

  #transaction-table th:nth-child(5),
  #transaction-table td:nth-child(5) {
    width: 64px;
  }

  #transaction-table th:nth-child(6),
  #transaction-table td:nth-child(6) {
    display: none;
  }

  #transaction-table th:nth-child(7),
  #transaction-table td:nth-child(7) {
    width: 52px;
  }

  #transaction-table td:nth-child(3) {
    overflow-wrap: anywhere;
  }

  #transaction-table .warning {
    display: block;
    margin-top: 2px;
    font-size: 0.64rem;
  }

  .select-col {
    width: 100%;
    text-align: left;
  }

  .select-col input[type="checkbox"] {
    width: 14px;
    height: 14px;
    justify-self: start;
  }

  #transaction-table td:nth-child(1)::before {
    content: "Select";
  }

  #transaction-table td:nth-child(2)::before {
    content: "Date";
  }

  #transaction-table td:nth-child(3)::before {
    content: "Item";
  }

  #transaction-table td:nth-child(4)::before {
    content: "Amount";
  }

  #transaction-table td:nth-child(5)::before {
    content: "Category";
  }

  #transaction-table td:nth-child(6)::before {
    content: "Importance";
  }

  #transaction-table td:nth-child(7)::before {
    content: "Actions";
  }

  #review-table td:nth-child(1)::before {
    content: "Save";
  }

  #review-table td:nth-child(2)::before {
    content: "Day";
  }

  #review-table td:nth-child(3)::before {
    content: "Item";
  }

  #review-table td:nth-child(4)::before {
    content: "Amount";
  }

  #review-table td:nth-child(5)::before {
    content: "Category";
  }

  #review-table td:nth-child(6)::before {
    content: "Importance";
  }

  #review-table td:nth-child(7)::before {
    content: "Warnings";
  }

  #report-merchants td:nth-child(1)::before {
    content: "Merchant";
  }

  #report-merchants td:nth-child(2)::before {
    content: "Total";
  }

  #report-merchants td:nth-child(3)::before {
    content: "Count";
  }

  .wealth-table td:nth-child(1)::before {
    content: "Date";
  }

  .wealth-table td:nth-child(2)::before {
    content: "Name";
  }

  .wealth-table td:nth-child(3)::before {
    content: "Owner";
  }

  .wealth-table td:nth-child(4)::before {
    content: "Account";
  }

  .wealth-table td:nth-child(5)::before {
    content: "Amount";
  }

  .wealth-table td:nth-child(6)::before {
    content: "Actions";
  }

  #wealth .panel {
    padding: 12px;
  }

  #wealth .wealth-grid-panels {
    gap: 10px;
  }

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

  .wealth-table {
    display: table;
    min-width: 0;
    table-layout: fixed;
  }

  .wealth-table tbody {
    display: table-row-group;
  }

  .wealth-table tr {
    display: table-row;
    border: 0;
    border-radius: 0;
    background: transparent;
    overflow: visible;
  }

  .wealth-table thead {
    display: table-header-group;
  }

  .wealth-table th,
  .wealth-table td {
    display: table-cell;
    width: auto;
    padding: 5px 5px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
  }

  .wealth-table th {
    font-size: 0.54rem;
  }

  .wealth-table td {
    font-size: 0.66rem;
    line-height: 1.08;
  }

  .wealth-table th:nth-child(1),
  .wealth-table td:nth-child(1) {
    width: 56px;
  }

  .wealth-table th:nth-child(2),
  .wealth-table td:nth-child(2) {
    width: auto;
  }

  .wealth-table th:nth-child(3),
  .wealth-table td:nth-child(3) {
    width: 26px;
    text-align: center;
  }

  .wealth-table th:nth-child(4),
  .wealth-table td:nth-child(4) {
    width: 44px;
  }

  .wealth-table th:nth-child(5),
  .wealth-table td:nth-child(5) {
    width: 74px;
    text-align: right;
  }

  .wealth-table th:nth-child(6),
  .wealth-table td:nth-child(6) {
    width: 52px;
  }

  .wealth-table td::before {
    content: none !important;
  }

  .wealth-table td:nth-child(2) strong {
    overflow-wrap: anywhere;
  }

  .wealth-table .amount-cell {
    white-space: nowrap;
  }

  .wealth-table .row-actions {
    display: flex;
    align-items: center;
    gap: 3px;
    justify-content: stretch;
  }

  .wealth-table .row-actions::before {
    content: none;
  }

  .wealth-table .row-actions button {
    width: 22px;
    min-height: 24px;
    padding: 0;
    margin: 0;
    font-size: 0.78rem;
  }

  .wealth-table .row-actions button + button {
    margin-left: 0;
  }

  .row-actions {
    display: flex;
    justify-content: stretch;
  }

  .row-actions button {
    flex: 1;
    margin-left: 0;
  }

  #transaction-table .row-actions {
    gap: 3px;
  }

  #transaction-table .row-actions button {
    width: 22px;
    min-height: 24px;
    padding: 0;
    font-size: 0.78rem;
    line-height: 1;
  }

  .review-panel td input,
  .review-panel td select,
  td input,
  td select {
    min-height: 38px;
  }

  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    border-top: 1px solid var(--line);
    background: rgba(52, 75, 76, 0.96);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    box-shadow: 0 -10px 28px rgba(52, 75, 76, 0.18);
    backdrop-filter: blur(12px);
  }

  .mobile-nav a {
    justify-content: center;
    min-height: 42px;
    padding: 0 6px;
    font-size: 0.8rem;
  }
}

@media (max-width: 430px) {
  .workspace {
    padding-left: 10px;
    padding-right: 10px;
  }

  #transactions .filters-grid,
  #transactions .transaction-grid {
    gap: 6px;
  }

  #transactions .transaction-form label,
  #wealth .wealth-form label,
  #transactions .filters-panel label {
    font-size: 0.7rem;
  }

  #transactions .transaction-form input,
  #transactions .transaction-form select,
  #wealth .wealth-form input,
  #wealth .wealth-form select,
  #transactions .filters-panel input,
  #transactions .filters-panel select {
    min-height: 34px;
    padding: 0 8px;
    font-size: 0.82rem;
  }

  #transactions .transaction-actions .icon-action {
    width: 34px;
    min-height: 34px;
  }

  #wealth .transaction-actions .icon-action {
    width: 34px;
    min-height: 34px;
  }

  #transaction-table table {
    min-width: 0;
  }

  #transaction-table th,
  #transaction-table td {
    padding: 4px 2px;
  }

  .chart-frame {
    min-height: 206px;
  }

  .chart-frame.tall {
    min-height: 188px;
  }

  .month-bar {
    height: 180px;
    gap: 4px;
    font-size: 0.56rem;
  }

  .chart-frame.tall .month-bar {
    height: 158px;
  }

  .month-bar span:first-child {
    min-height: 46px;
  }

  .month-bar div {
    max-height: 112px;
  }

  .chart-frame.tall .month-bar div {
    max-height: 94px;
  }

  td {
    grid-template-columns: minmax(76px, 0.36fr) minmax(0, 1fr);
    gap: 8px;
  }
}
