:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #6b7280;
  --line: #d9dee5;
  --soft-line: #eef1f4;
  --surface: #ffffff;
  --page: #f6f7f4;
  --panel: #fbfcfd;
  --teal: #0f766e;
  --teal-dark: #0b4f49;
  --blue: #2563eb;
  --amber: #b7791f;
  --red: #b42318;
  --green: #15803d;
  --violet: #6d28d9;
  --radius: 8px;
  --shadow: 0 16px 32px rgba(27, 37, 49, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  min-width: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #fdfdfb;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #a4d4cb;
  background: #e9f7f4;
  color: var(--teal-dark);
  border-radius: var(--radius);
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3,
.entry-form h3 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.1;
}

.brand p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.nav-list {
  min-width: 0;
  max-width: 100%;
  display: grid;
  gap: 6px;
}

.nav-item {
  min-height: 40px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #3f4651;
  text-align: left;
  padding: 0 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.nav-item:hover,
.nav-item:focus-visible,
.nav-link:hover {
  background: #edf4f2;
  outline: none;
}

.nav-item.active {
  background: var(--teal);
  color: white;
  font-weight: 700;
}

.content {
  min-width: 0;
  padding: 24px;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

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

.topbar h2 {
  font-size: 28px;
  line-height: 1.15;
}

.topbar-actions,
.table-tools,
.export-grid {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.primary-button,
.ghost-button,
.danger-button {
  min-height: 40px;
  min-width: 0;
  border-radius: var(--radius);
  padding: 0 14px;
  border: 1px solid transparent;
  font-weight: 700;
  white-space: nowrap;
}

.primary-button {
  background: var(--teal);
  color: white;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--teal-dark);
  outline: none;
}

.ghost-button {
  color: #2f3744;
  background: white;
  border-color: var(--line);
}

.ghost-button:hover,
.ghost-button:focus-visible {
  border-color: #8fb3ad;
  background: #f7fbfa;
  outline: none;
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.kpi-card {
  min-height: 122px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  align-content: space-between;
  gap: 12px;
}

.kpi-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.kpi-card strong {
  display: block;
  font-size: 25px;
  line-height: 1.15;
}

.kpi-card small {
  color: var(--muted);
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 16px;
  margin-bottom: 16px;
  min-width: 0;
}

.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel.wide {
  grid-column: span 1;
}

.panel-header {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header h3,
.entry-form h3 {
  font-size: 16px;
}

.panel-header span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.bar-chart {
  max-width: 100%;
  min-width: 0;
  min-height: 260px;
  display: grid;
  grid-template-columns: repeat(12, minmax(32px, 1fr));
  align-items: end;
  gap: 8px;
  border-top: 1px solid var(--soft-line);
  padding-top: 14px;
  overflow-x: auto;
}

.bar-month {
  min-width: 32px;
  display: grid;
  grid-template-rows: 180px auto auto;
  gap: 6px;
  text-align: center;
}

.bar-stack {
  display: grid;
  align-items: end;
  gap: 3px;
}

.bar-income,
.bar-expense {
  width: 100%;
  min-height: 3px;
  border-radius: 4px 4px 0 0;
}

.bar-income {
  background: var(--green);
}

.bar-expense {
  background: var(--red);
}

.bar-label,
.bar-value {
  color: var(--muted);
  font-size: 11px;
}

#ledgerCashflowChart {
  display: block;
  min-height: 320px;
  border-top: 1px solid var(--soft-line);
  padding: 12px 0 0;
  overflow-x: auto;
}

.cashflow-legend {
  min-width: max-content;
  display: flex;
  gap: 14px;
  padding: 0 2px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.cashflow-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cashflow-legend i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.cashflow-income-dot {
  background: var(--green);
}

.cashflow-expense-dot {
  background: var(--red);
}

.cashflow-net-dot {
  background: var(--blue);
}

.cashflow-scroll {
  min-width: max-content;
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 0 2px 6px;
}

.cashflow-month {
  width: 74px;
  display: grid;
  grid-template-rows: 190px auto auto;
  gap: 7px;
  text-align: center;
}

.cashflow-bars {
  height: 190px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 7px;
  padding: 8px 6px 0;
  border-bottom: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background:
    linear-gradient(to top, rgba(217, 222, 229, 0.55) 1px, transparent 1px) 0 0 / 100% 25%,
    #fbfcfd;
}

.cashflow-bar {
  width: 21px;
  height: var(--bar-height);
  min-height: 4px;
  border-radius: 6px 6px 0 0;
  transform-origin: bottom;
  animation: cashflowGrow 560ms ease-out both;
}

.cashflow-bar.income {
  background: linear-gradient(180deg, #22c55e, var(--green));
}

.cashflow-bar.expense {
  background: linear-gradient(180deg, #ef4444, var(--red));
  animation-delay: 80ms;
}

.cashflow-label {
  color: #374151;
  font-size: 12px;
  font-weight: 900;
}

.cashflow-net {
  justify-self: center;
  max-width: 100%;
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.cashflow-net.positive {
  color: #166534;
  background: #dcfce7;
}

.cashflow-net.negative {
  color: #991b1b;
  background: #fee2e2;
}

@keyframes cashflowGrow {
  from {
    opacity: 0.45;
    transform: scaleY(0.08);
  }
  to {
    opacity: 1;
    transform: scaleY(1);
  }
}

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

.comparison-row {
  display: grid;
  grid-template-columns: minmax(92px, 0.8fr) minmax(0, 2fr) minmax(86px, 0.7fr);
  align-items: center;
  gap: 10px;
}

.comparison-row span,
.comparison-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comparison-track {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.comparison-bar {
  height: 12px;
  border-radius: 999px;
  background: #d9dee5;
  overflow: hidden;
}

.comparison-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--teal);
}

.comparison-fill.secondary {
  background: var(--amber);
}

.line-chart {
  min-height: 210px;
  border-top: 1px solid var(--soft-line);
  padding-top: 14px;
  overflow-x: auto;
}

.line-svg {
  display: block;
  min-width: 420px;
  width: 100%;
  height: 190px;
}

.compact-bars {
  min-height: 180px;
  grid-template-columns: repeat(6, minmax(58px, 1fr));
}

.donut-layout {
  display: grid;
  grid-template-columns: 152px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.donut {
  width: 152px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--line) 0deg 360deg);
  position: relative;
  border: 1px solid var(--line);
}

.donut::after {
  content: "";
  position: absolute;
  inset: 34px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--soft-line);
}

.legend,
.check-list,
.mini-list,
.mapping-list,
.source-list {
  display: grid;
  gap: 8px;
}

.legend-row,
.check-row,
.mini-row,
.mapping-row,
.source-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
  border-bottom: 1px solid var(--soft-line);
  color: #333b46;
}

.legend-row:last-child,
.check-row:last-child,
.mini-row:last-child,
.mapping-row:last-child,
.source-row:last-child {
  border-bottom: 0;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.legend-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.legend-name span:last-child,
.source-row span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  color: #1f2937;
  background: #eef2f7;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.good {
  background: #dcfce7;
  color: #166534;
}

.status-pill.warn {
  background: #fef3c7;
  color: #92400e;
}

.status-pill.bad {
  background: #fee2e2;
  color: #991b1b;
}

.entry-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  align-items: end;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.entry-form.compact {
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  align-content: start;
  margin-bottom: 0;
}

.entry-form h3 {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span,
.field > span {
  color: #4b5563;
  font-size: 12px;
  font-weight: 800;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cfd7df;
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  padding: 0 10px;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
  outline: none;
}

input[readonly] {
  background: #f2f4f7;
  color: var(--muted);
}

.category-picker-field {
  position: relative;
  z-index: 4;
}

.category-picker-button {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid #cfd7df;
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  text-align: left;
  font-weight: 800;
}

.category-picker-button:hover,
.category-picker-button:focus-visible,
.category-picker-button[aria-expanded="true"] {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
  outline: none;
}

.category-picker-button.is-placeholder {
  color: var(--muted);
  font-weight: 700;
}

.category-picker-button.has-error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.13);
}

#categoryPickerText {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#categoryPickerText span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-chip-icon,
.category-choice-icon {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  background: #eef6f4;
  color: var(--teal-dark);
  flex: 0 0 auto;
  font-size: 16px;
  line-height: 1;
}

.category-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: auto;
  z-index: 20;
  width: min(640px, calc(100vw - 32px));
  max-height: min(520px, 70vh);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 18px 46px rgba(27, 37, 49, 0.18);
}

.category-popover[hidden] {
  display: none;
}

.category-popover-head {
  padding: 12px;
  border-bottom: 1px solid var(--soft-line);
  background: #fbfcfd;
}

.category-picker-options {
  display: grid;
  gap: 14px;
  padding: 12px;
  overflow: auto;
}

.category-choice-group h4 {
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #374151;
  font-size: 13px;
}

.category-choice-group h4 span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.category-choice {
  min-width: 0;
  min-height: 54px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 8px;
  text-align: left;
}

.category-choice:hover,
.category-choice:focus-visible {
  border-color: #8fb3ad;
  background: #f7fbfa;
  outline: none;
}

.category-choice.selected {
  border-color: var(--teal);
  background: #e9f7f4;
}

.category-choice-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}

.category-choice-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

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

.toggle-label {
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 40px;
}

.toggle-label input {
  width: 24px;
  height: 24px;
  min-height: 24px;
}

.table-tools {
  justify-content: space-between;
  margin: 0 0 10px;
}

.table-tools input {
  max-width: 360px;
}

.table-size-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.table-size-control select {
  width: 112px;
}

.data-table-wrap {
  width: 100%;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stacked-table {
  margin-bottom: 16px;
}

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

#transactionTable {
  min-width: 980px;
}

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

.data-table th {
  background: #f0f3f5;
  color: #364152;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.data-table td.num,
.data-table th.num {
  text-align: right;
}

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

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

.icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--red);
  font-weight: 800;
}

.actions-col {
  width: 72px;
  text-align: right;
}

.delete-row-button {
  width: auto;
  min-width: 54px;
  padding: 0 9px;
  color: var(--red);
}

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

.sync-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.sync-copy {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.sync-copy h3,
.sync-copy p {
  margin: 0;
}

.sync-copy h3 {
  font-size: 15px;
}

.sync-copy p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.sync-pill {
  min-width: 68px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 10px;
  background: #eef2f7;
  color: #374151;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.sync-pill.syncing {
  background: #dbeafe;
  color: #1d4ed8;
}

.sync-pill.synced {
  background: #dcfce7;
  color: #166534;
}

.sync-pill.error {
  background: #fee2e2;
  color: #991b1b;
}

.sync-pill.sent {
  background: #fef3c7;
  color: #92400e;
}

.sync-form,
.sync-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-form[hidden],
.sync-code-form[hidden],
.sync-actions[hidden] {
  display: none;
}

.sync-form input {
  width: 240px;
}

.sync-form input[type="password"] {
  width: 180px;
}

.sync-code-form input {
  width: 180px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.sync-clear-button {
  justify-self: end;
}

.summary-item {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px;
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
}

.summary-item strong {
  font-size: 20px;
}

.split-panel {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
}

.asset-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
  min-width: 0;
}

.ledger-layout,
.deduction-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
  margin-bottom: 16px;
  min-width: 0;
}

.ledger-form {
  margin-bottom: 0;
}

.record-entry-area {
  margin-bottom: 16px;
}

.entry-form-wide {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.control-panel {
  margin-bottom: 16px;
}

.control-panel .ledger-controls {
  margin: 0;
}

.ledger-controls {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: -4px 0 16px;
  flex-wrap: wrap;
}

.control-group {
  display: grid;
  gap: 6px;
}

.month-control {
  min-width: 170px;
}

.year-control {
  min-width: 150px;
}

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

.segmented-control {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.segment-button {
  min-height: 40px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: #3f4651;
  padding: 0 14px;
  font-weight: 800;
}

.segment-button:last-child {
  border-right: 0;
}

.segment-button.active {
  background: #e9f7f4;
  color: var(--teal-dark);
}

.import-status {
  max-width: 520px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.subtab-bar {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--line);
}

.subtab-button {
  min-height: 38px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  font-weight: 900;
}

.subtab-button.active {
  border-bottom-color: var(--blue);
  color: var(--blue);
}

.ledger-tab {
  display: none;
}

.ledger-tab.active {
  display: block;
}

.category-report-header {
  align-items: flex-start;
}

.category-report-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.category-report-controls select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  font-weight: 800;
}

.category-report-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(0, 1.15fr);
  align-items: start;
  gap: 18px;
}

.category-report-chart {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 320px;
}

.category-report-donut {
  width: min(260px, 100%);
}

.category-report-donut::after {
  inset: 64px;
}

.category-report-total {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 1;
  display: grid;
  gap: 4px;
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.category-report-total span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.category-report-total strong {
  color: var(--ink);
  font-size: 25px;
  line-height: 1.1;
}

.category-report-list {
  display: grid;
  border-top: 1px solid var(--soft-line);
}

.category-report-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px minmax(110px, auto);
  align-items: center;
  gap: 12px;
  min-height: 54px;
  border-bottom: 1px solid var(--soft-line);
  color: #333b46;
}

.category-report-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 800;
}

.category-report-name span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-report-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
  line-height: 1;
}

.category-report-percent {
  color: var(--muted);
  font-weight: 800;
  text-align: right;
}

.category-report-row strong {
  text-align: right;
  font-size: 18px;
}

.trend-panel {
  margin-bottom: 16px;
}

.trend-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.trend-chart {
  overflow-x: auto;
  border-top: 1px solid var(--soft-line);
  padding-top: 12px;
}

.trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.trend-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.trend-legend i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.legend-income {
  background: var(--green);
}

.legend-expense {
  background: var(--red);
}

.legend-net {
  background: var(--blue);
}

.trend-svg {
  width: 100%;
  min-width: 720px;
  height: auto;
  overflow: visible;
}

.trend-svg polyline {
  fill: none;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  animation: trendLineIn 620ms ease-out forwards;
}

.line-income {
  stroke: var(--green);
}

.line-expense {
  stroke: var(--red);
  animation-delay: 90ms;
}

.line-net {
  stroke: var(--blue);
  animation-delay: 180ms;
}

.trend-svg circle {
  stroke: #fff;
  stroke-width: 2;
  opacity: 0;
  transform-origin: center;
  animation: pointIn 520ms ease-out forwards;
  animation-delay: 260ms;
}

.point-income {
  fill: var(--green);
}

.point-expense {
  fill: var(--red);
}

.point-net {
  fill: var(--blue);
}

.axis-zero {
  stroke: #9ca3af;
  stroke-width: 1.2;
}

.axis-grid {
  stroke: #eef1f4;
  stroke-width: 1;
}

.axis-label,
.month-labels text {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

@keyframes trendLineIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pointIn {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.trend-table {
  min-width: 620px;
}

.year-panel {
  padding-bottom: 10px;
}

.year-sections {
  display: grid;
  gap: 10px;
}

.year-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.year-summary {
  display: grid;
  grid-template-columns: 24px minmax(100px, 0.45fr) minmax(90px, 0.3fr) minmax(320px, 1.25fr);
  align-items: center;
  gap: 12px;
  padding: 12px;
  cursor: pointer;
  list-style: none;
}

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

.year-summary::before {
  content: "+";
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--teal-dark);
  font-weight: 900;
}

.year-section[open] .year-summary::before {
  content: "-";
}

.year-title {
  font-size: 18px;
  font-weight: 900;
}

.year-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.year-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.year-kpis span {
  display: grid;
  gap: 2px;
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  background: #fbfcfd;
  padding: 8px;
  font-weight: 800;
  min-width: 0;
}

.year-kpis b {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.year-transaction-list {
  display: grid;
  border-top: 1px solid var(--soft-line);
}

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

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

.year-row-note {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.year-row-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.year-row-main strong,
.year-row-main span,
.year-row-main small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.year-row-main span,
.year-row-main small {
  color: var(--muted);
  font-size: 12px;
}

.year-row-date {
  color: #334155;
  font-weight: 800;
}

.amount-income {
  color: var(--green);
}

.amount-expense {
  color: var(--red);
}

.inline-form {
  margin-bottom: 12px;
  box-shadow: none;
  border-color: var(--soft-line);
}

.export-grid {
  align-items: stretch;
}

.export-grid button {
  flex: 1 1 190px;
}

.settings-form {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.empty-state {
  padding: 18px;
  color: var(--muted);
}

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

  .overview-grid,
  .asset-layout,
  .ledger-layout,
  .deduction-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .split-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    overflow-x: hidden;
  }

  .sidebar {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    position: sticky;
    z-index: 5;
    top: 0;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px;
    gap: 12px;
  }

  .brand {
    grid-template-columns: 36px minmax(0, 1fr);
  }

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

  .nav-list {
    display: flex;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-item {
    flex: 0 0 auto;
    text-align: center;
  }

  .content {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    padding: 16px 12px 24px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .entry-form,
  .entry-form.compact,
  .settings-form {
    grid-template-columns: 1fr;
  }

  .category-popover {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 14px;
    top: auto;
    width: auto;
    max-height: 72vh;
  }

  .category-choice-grid {
    grid-template-columns: 1fr;
  }

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

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

  .sync-panel {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .sync-copy {
    align-items: flex-start;
  }

  .sync-form,
  .sync-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .sync-form input,
  .sync-form button,
  .sync-actions button,
  .sync-clear-button {
    flex: 1 1 180px;
  }

  .sync-clear-button {
    width: 100%;
    justify-self: stretch;
  }

  .donut-layout {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .category-report-header {
    flex-direction: column;
  }

  .category-report-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .category-report-layout {
    grid-template-columns: 1fr;
  }

  .category-report-chart {
    justify-self: center;
  }

  .year-summary {
    grid-template-columns: 24px minmax(0, 1fr);
    align-items: start;
  }

  .year-count,
  .year-kpis {
    grid-column: 2;
  }

  .year-kpis {
    grid-template-columns: 1fr;
  }

  .year-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .year-row > strong {
    justify-self: start;
  }

  .trend-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .kpi-grid,
  .taxpack-grid,
  .asset-kpi-grid,
  .summary-strip {
    grid-template-columns: 1fr;
  }

  .comparison-row {
    grid-template-columns: 1fr;
  }

  .bar-chart {
    grid-template-columns: repeat(12, 48px);
  }

  .topbar-actions,
  .table-tools {
    width: 100%;
  }

  .topbar-actions button,
  .table-tools button,
  .table-tools input,
  .table-size-control {
    flex: 1 1 100%;
    max-width: none;
  }

  .table-size-control {
    justify-content: space-between;
  }

  .table-size-control select {
    width: 140px;
  }

  .cashflow-month {
    width: 68px;
  }

  .ledger-controls,
  .control-group,
  .segmented-control {
    width: 100%;
  }

  .segment-button {
    flex: 1 1 50%;
    padding: 0 8px;
  }

  .subtab-button {
    flex: 1 1 50%;
    padding: 0 8px;
  }

  .category-report-donut {
    width: min(230px, 100%);
  }

  .category-report-donut::after {
    inset: 56px;
  }

  .category-report-chart {
    min-height: 280px;
  }

  .category-report-total strong {
    font-size: 21px;
  }

  .category-report-row {
    grid-template-columns: minmax(0, 1fr) 58px minmax(92px, auto);
    gap: 8px;
  }

  .category-report-row strong {
    font-size: 15px;
  }
}
