:root {
  --paper: #f4f7f5;
  --paper-alt: #ffffff;
  --ink: #17211d;
  --ink-soft: #5d6c65;
  --border: #d7e0da;
  --border-soft: #e7eeea;
  --gold: #0f766e;
  --gold-soft: #dff4ef;
  --income: #2f7d52;
  --income-soft: #e2f3e8;
  --expense: #b64b3d;
  --expense-soft: #f6ded9;
  --warning: #b7791f;
  --critical: #b64b3d;
  --good: #2f7d52;
  --shadow: 0 12px 28px rgba(23, 33, 29, 0.08);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  background: var(--paper);
  color: var(--ink);
  line-height: 1.45;
  margin: 0;
  min-height: 100%;
}

body.auth-pending .topbar,
body.auth-pending .layout,
body.auth-locked .topbar,
body.auth-locked .layout {
  display: none;
}

.auth-view {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 24px;
}

.auth-view[hidden] {
  display: none;
}

.auth-card {
  background: var(--paper-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  margin: 0 auto;
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.auth-card .brand-mark {
  height: 46px;
  width: 46px;
}

.auth-card h1 {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  letter-spacing: 0;
  line-height: 1.05;
  margin: 0;
}

.auth-card p {
  color: var(--ink-soft);
  margin: 0;
}

.auth-card p[data-kind="error"] {
  color: var(--critical);
  font-weight: 800;
}

.google-signin {
  min-height: 44px;
}

button,
input,
select {
  font: inherit;
}

button {
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  min-height: 82px;
  padding: 18px 28px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1 {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.05;
  margin: 3px 0 0;
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.topbar .secondary-button {
  width: auto;
}

.user-badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink-soft);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  max-width: 220px;
  overflow: hidden;
  padding: 8px 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-badge[hidden],
#logoutBtn[hidden] {
  display: none;
}

.top-action,
.refresh-button {
  min-height: 38px;
  padding: 0 12px;
}

.eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

.layout {
  display: grid;
  gap: 24px;
  grid-template-columns: 318px minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1480px;
  padding: 24px;
}

.sidebar {
  align-self: start;
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 126px);
  overflow-y: auto;
  padding-right: 4px;
  position: sticky;
  scrollbar-color: var(--border) transparent;
  top: 104px;
}

.content {
  display: grid;
  gap: 18px;
  min-width: 0;
}

section[id] {
  scroll-margin-top: 112px;
}

.brand-card {
  align-items: center;
  background: var(--paper-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  padding: 14px;
}

.brand-mark {
  align-items: center;
  background: var(--gold);
  border-radius: 8px;
  color: #fffdf7;
  display: inline-flex;
  flex: 0 0 38px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 700;
  height: 38px;
  justify-content: center;
}

.brand-card strong {
  color: var(--ink);
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.1;
}

.brand-card span {
  color: var(--ink-soft);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.side-nav {
  background: var(--paper-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 4px;
  padding: 8px;
}

.side-nav a {
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 800;
  padding: 10px 12px;
  text-decoration: none;
}

.side-nav a:hover {
  background: var(--gold-soft);
  color: var(--gold);
}

.side-nav a.active {
  background: var(--gold-soft);
  color: var(--gold);
}

.panel,
.kpi {
  background: var(--paper-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 0;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.action-panel {
  overflow: hidden;
  padding: 0;
}

.action-panel summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  list-style: none;
  min-height: 58px;
  padding: 14px 18px;
}

.action-panel summary::-webkit-details-marker {
  display: none;
}

.action-panel summary::after {
  align-items: center;
  background: var(--gold-soft);
  border-radius: 8px;
  color: var(--gold);
  content: "+";
  display: inline-flex;
  flex: 0 0 30px;
  font-weight: 900;
  height: 30px;
  justify-content: center;
}

.action-panel[open] summary {
  border-bottom: 1px solid var(--border-soft);
}

.action-panel[open] summary::after {
  content: "-";
}

.action-panel summary span {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  font-weight: 700;
}

.action-panel summary small {
  color: var(--ink-soft);
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-left: auto;
}

.panel-body {
  padding: 16px 18px 18px;
}

.panel h2,
.section-title h2,
.expense-content h3 {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: 0;
}

.panel h2 {
  font-size: 18px;
  margin: 0 0 14px;
}

.section-title {
  align-items: flex-start;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.section-title h2 {
  font-size: 19px;
  margin: 0;
}

.section-title span {
  color: var(--ink-soft);
  font-size: 13px;
  white-space: nowrap;
}

label {
  color: var(--ink-soft);
  display: grid;
  font-size: 12px;
  font-weight: 800;
  gap: 6px;
  margin-bottom: 12px;
}

input,
select {
  background: #fffdf7;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 11px;
  width: 100%;
}

input::placeholder {
  color: rgba(91, 102, 83, 0.62);
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(185, 134, 47, 0.22);
  outline-offset: 2px;
}

.primary-button,
.secondary-button,
.icon-button {
  align-items: center;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 42px;
}

.compact-button {
  min-height: 34px;
  padding: 0 11px;
  width: auto;
}

.primary-button {
  background: var(--ink);
  border: 1px solid var(--ink);
  color: var(--paper-alt);
  padding: 0 14px;
  width: 100%;
}

.primary-button:hover {
  background: #314329;
}

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

.danger-button:hover {
  background: #8d432d;
}

.secondary-button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-soft);
  padding: 0 14px;
  width: 100%;
}

.secondary-button:hover,
.icon-button:hover,
.tab-button:hover,
.quick-ranges button:hover,
.row-action:hover,
.nav-button:hover,
.text-action:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}

.icon-button {
  background: var(--gold-soft);
  border: 1px solid var(--border);
  color: var(--gold);
  font-size: 18px;
  width: 44px;
}

.status-pill {
  background: var(--gold-soft);
  border: 1px solid rgba(185, 134, 47, 0.26);
  border-radius: 999px;
  color: var(--gold);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 8px 12px;
  white-space: nowrap;
}

.hint {
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.5;
  margin: 10px 0 0;
}

.filter-panel {
  display: grid;
}

.main-ranges {
  margin: 0 0 12px;
}

.manual-form {
  display: grid;
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  align-items: center;
  background: rgba(23, 33, 29, 0.42);
  display: grid;
  inset: 0;
  justify-items: center;
  padding: 24px;
  position: fixed;
  z-index: 20;
}

.modal-backdrop[hidden] {
  display: none;
}

.entry-modal {
  background: var(--paper-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 28px 70px rgba(23, 33, 29, 0.26);
  max-height: min(88vh, 760px);
  overflow: auto;
  width: min(620px, 100%);
}

.modal-head {
  align-items: flex-start;
  background: var(--paper-alt);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 18px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.modal-head h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  line-height: 1.1;
  margin: 2px 0 0;
}

.close-button {
  flex: 0 0 40px;
  min-height: 40px;
  width: 40px;
}

.entry-form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

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

.form-grid label,
.entry-form > label {
  margin-bottom: 0;
}

.segmented-control {
  background: #fffdf7;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
}

.segmented-control button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--ink-soft);
  cursor: pointer;
  font-weight: 800;
  min-height: 38px;
}

.segmented-control button.active {
  background: var(--gold);
  color: var(--paper-alt);
}

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

.modal-actions .primary-button,
.modal-actions .secondary-button {
  min-width: 118px;
  width: auto;
}

.period-command {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.period-command h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  line-height: 1.12;
  margin: 2px 0 3px;
  text-transform: capitalize;
}

.period-command span {
  color: var(--ink-soft);
  display: block;
  font-size: 13px;
}

.period-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.nav-button {
  background: #fffdf7;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  font-size: 24px;
  font-weight: 900;
  height: 38px;
  line-height: 1;
  width: 42px;
}

.kpi-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(220px, 1.25fr) repeat(3, minmax(145px, 0.85fr));
}

.kpi {
  min-height: 108px;
  padding: 18px;
}

.kpi:nth-child(3) {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper-alt);
  grid-column: auto;
  min-height: 118px;
  order: -1;
  padding: 22px;
}

.kpi span {
  color: var(--ink-soft);
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.kpi:nth-child(3) span {
  color: #c9d3c0;
}

.kpi strong {
  color: var(--ink);
  display: block;
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.kpi:nth-child(3) strong {
  color: var(--paper-alt);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 36px;
}

#incomeKpi {
  color: var(--income);
}

#expenseKpi {
  color: var(--expense);
}

#netKpi {
  color: var(--paper-alt);
}

.analysis-panel {
  border-left: 5px solid var(--gold);
}

.cash-overview {
  border-left: 5px solid var(--income);
}

.pension-overview {
  border-left: 5px solid #4f46e5;
  display: grid;
  gap: 14px;
}

.pension-overview[hidden] {
  display: none;
}

.pension-fill {
  background: #4f46e5;
}

.cash-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.expense-strip {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
}

.cash-grid article,
.expense-strip div {
  background: #fffdf7;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  min-height: 90px;
  padding: 14px;
}

.cash-grid span,
.expense-strip span {
  color: var(--ink-soft);
  display: block;
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.cash-grid strong,
.expense-strip strong {
  color: var(--ink);
  display: block;
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 19px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.expense-explorer {
  display: grid;
  gap: 14px;
}

.tab-menu,
.quick-ranges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-button,
.quick-ranges button,
.row-action {
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
}

.tab-button {
  background: transparent;
  color: var(--ink-soft);
  min-height: 38px;
  padding: 0 13px;
}

.tab-button.active,
.quick-ranges button.active,
.main-ranges button.active {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}

.expense-toolbar {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) minmax(170px, 0.7fr);
}

.expense-toolbar label {
  margin-bottom: 0;
}

.toolbar-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.quick-ranges button {
  background: #fffdf7;
  color: var(--ink-soft);
  min-height: 34px;
  padding: 0 12px;
}

.expense-content {
  display: grid;
  gap: 14px;
}

.split-view {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
}

.mini-chart {
  display: grid;
  gap: 10px;
}

.mini-chart-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(140px, 0.9fr) minmax(0, 1fr) minmax(100px, auto);
}

button.mini-chart-row {
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: inherit;
  padding: 8px;
  text-align: left;
  width: 100%;
}

.mini-chart-row strong,
.mini-chart-row span {
  font-size: 13px;
}

.mini-chart-row span {
  color: var(--ink-soft);
  text-align: right;
}

.bar-track {
  background: var(--border-soft);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.bar-fill {
  background: var(--gold);
  height: 100%;
}

.category-table tbody tr,
.period-table tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: rgba(239, 224, 188, 0.28);
}

.row-action {
  background: transparent;
  color: var(--gold);
  min-height: 30px;
  padding: 0 11px;
}

.expense-content h3 {
  font-size: 16px;
  margin: 0 0 8px;
}

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

.insight {
  background: #fffdf7;
  border: 1px solid var(--border-soft);
  border-left: 4px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 5px;
  padding: 12px 13px;
}

.insight h3 {
  font-size: 15px;
  margin: 0;
}

.insight p {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.45;
  margin: 0;
}

.text-action {
  align-self: start;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--gold);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  margin-top: 4px;
  min-height: 32px;
  padding: 0 10px;
}

.insight.critical {
  border-left-color: var(--critical);
  background: var(--expense-soft);
}

.insight.warning {
  border-left-color: var(--warning);
  background: #fff7df;
}

.insight.good {
  border-left-color: var(--good);
  background: var(--income-soft);
}

.insight.info {
  border-left-color: var(--gold);
}

.charts-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
}

.chart-control-panel {
  display: grid;
  gap: 12px;
}

.chart-control-panel .section-title {
  margin-bottom: 0;
}

.chart-filter-grid {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
}

.chart-filter-grid label {
  margin-bottom: 0;
}

.chart-custom-range[hidden] {
  display: none;
}

.chart-reset-button {
  min-height: 42px;
}

.chart-panel {
  min-width: 0;
}

.cashflow-panel {
  grid-column: 1 / -1;
}

.cashflow-panel canvas {
  max-height: 460px;
}

canvas {
  display: block;
  max-height: 320px;
  touch-action: manipulation;
  width: 100%;
}

.chart-tooltip {
  background: rgba(23, 33, 29, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(23, 33, 29, 0.24);
  color: var(--paper-alt);
  display: grid;
  font-size: 12px;
  gap: 4px;
  max-width: min(260px, calc(100vw - 20px));
  padding: 10px 12px;
  pointer-events: none;
  position: fixed;
  z-index: 30;
}

.chart-tooltip[hidden] {
  display: none;
}

.chart-tooltip strong {
  color: var(--paper-alt);
  font-size: 13px;
}

.chart-tooltip span {
  color: #dfe9e4;
  white-space: nowrap;
}

.chart-tooltip span:last-child {
  color: #f3f7f4;
}

.legend {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-top: 12px;
}

.legend-item {
  align-items: center;
  color: var(--ink-soft);
  display: flex;
  font-size: 13px;
  gap: 8px;
}

.swatch {
  border-radius: 3px;
  display: inline-block;
  height: 12px;
  width: 12px;
}

.rank-list {
  display: grid;
  gap: 6px;
}

.rank-row {
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: inherit;
  display: grid;
  gap: 7px;
  padding: 8px;
  text-align: left;
  width: 100%;
}

.rank-row > div:first-child {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.rank-row:hover,
.mini-chart-row:hover {
  background: var(--gold-soft);
  transform: none;
}

.rank-row strong {
  color: var(--ink);
}

.rank-row span {
  color: var(--ink-soft);
  font-size: 13px;
  white-space: nowrap;
}

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

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

th,
td {
  border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--paper-alt);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
  position: sticky;
  top: 0;
  text-transform: uppercase;
  z-index: 1;
}

td span {
  color: var(--ink-soft);
}

.transaction-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.number {
  text-align: right;
}

.category-chip {
  background: var(--gold-soft);
  border-radius: 999px;
  color: var(--gold);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
  white-space: nowrap;
}

.amount-income {
  color: var(--income);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-weight: 800;
}

.amount-expense {
  color: var(--expense);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-weight: 800;
}

.amount-cash {
  color: var(--gold);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-weight: 800;
}

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

.file-row {
  align-items: center;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 8px 0;
}

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

.file-row span {
  color: var(--ink-soft);
  font-size: 13px;
}

.notice {
  background: #fff7df;
  border: 1px solid var(--gold);
  border-radius: 8px;
  color: var(--ink);
  font-weight: 700;
  padding: 12px 14px;
}

.notice[data-kind="success"] {
  background: var(--income-soft);
  border-color: var(--income);
}

.notice[data-kind="error"] {
  background: var(--expense-soft);
  border-color: var(--expense);
}

.empty {
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0;
  padding: 28px 14px;
  text-align: center;
}

@media (max-width: 1120px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    max-height: none;
    overflow: visible;
    padding-right: 0;
    position: static;
  }

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

  .kpi:nth-child(3) {
    grid-column: 1 / -1;
  }

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

  .expense-toolbar,
  .split-view {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
  }

  .topbar-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .layout {
    padding: 14px;
  }

  .content {
    order: -1;
  }

  .sidebar,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .kpi:nth-child(3) {
    min-height: 132px;
    padding: 22px;
  }

  .kpi:nth-child(3) strong {
    font-size: 36px;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .section-actions {
    justify-content: flex-start;
  }

  section[id] {
    scroll-margin-top: 196px;
  }

  .period-command {
    align-items: stretch;
    flex-direction: column;
  }

  .period-actions {
    justify-content: flex-start;
  }

  .modal-backdrop {
    align-items: end;
    padding: 10px;
  }

  .entry-modal {
    max-height: 94vh;
  }

  .form-grid,
  .modal-actions {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    display: grid;
  }

  .modal-actions .primary-button,
  .modal-actions .secondary-button {
    width: 100%;
  }

  .section-title span {
    white-space: normal;
  }

  .expense-strip,
  .cash-grid {
    grid-template-columns: 1fr;
  }

  .toolbar-actions {
    grid-template-columns: 1fr;
  }

  .mini-chart-row {
    align-items: start;
    grid-template-columns: 1fr;
  }

  .mini-chart-row span {
    text-align: left;
  }

  .table-wrap {
    border: 0;
    overflow: visible;
  }

  table {
    min-width: 0;
  }

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

  thead {
    display: none;
  }

  tbody tr {
    background: var(--paper-alt);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 8px;
  }

  td {
    align-items: flex-start;
    border-bottom: 0;
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(86px, 0.36fr) minmax(0, 1fr);
    padding: 7px 6px;
    text-align: right;
  }

  td::before {
    color: var(--ink-soft);
    content: attr(data-label);
    font-size: 11px;
    font-weight: 800;
    text-align: left;
    text-transform: uppercase;
  }

  td:first-child {
    padding-top: 2px;
  }

  td:last-child {
    padding-bottom: 2px;
  }

  td span {
    max-width: 100%;
    overflow-wrap: anywhere;
    text-align: right;
  }

  td > * {
    justify-self: end;
    max-width: 100%;
    min-width: 0;
  }

  .category-chip {
    text-align: right;
    white-space: normal;
  }

  .transaction-copy {
    text-align: right;
  }
}
