:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel-border: #dbe3f0;
  --text: #15233b;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --primary-soft-border: #93c5fd;
  --success: #2d7d62;
  --saving: #76927b;
  --saving-strong: #5c7661;
  --saving-soft: #f4f8f4;
  --danger: #b05252;
  --warning: #d97706;
  --teal: #0f766e;
  --teal-soft: #ccfbf1;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);

  --type-ingres: #7bbda4;
  --type-ingres-soft: #e8f3ee;
  --type-ingres-strong: #4f8e76;
  --type-estalvi: #76927b;
  --type-estalvi-soft: #f4f8f4;
  --type-estalvi-strong: #5c7661;
  --type-despesa-fixa: #8497ad;
  --type-despesa-fixa-soft: #eceff4;
  --type-despesa-fixa-strong: #5d6f86;
  --type-despesa-necesaria: #9085b8;
  --type-despesa-necesaria-soft: #eeebf4;
  --type-despesa-necesaria-strong: #695f95;
  --type-despesa-discrecional: #a799c7;
  --type-despesa-discrecional-soft: #f1edf6;
  --type-despesa-discrecional-strong: #7e6ea5;
  --type-especial: #7da6c1;
  --type-especial-soft: #ebf2f7;
  --type-especial-strong: #557e98;
  --type-unknown: #a3b6c6;
  --type-unknown-soft: #f0f3f6;
  --type-unknown-strong: #7a8c9d;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #eef4ff 0%, var(--bg) 20%, var(--bg) 100%);
  color: var(--text);
}

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

button {
  appearance: none;
}

.app-shell {
  width: 100%;
  padding: 32px 0 48px;
}

.hero,
.panel,
.status-card,
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 26px 28px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
}

.hero-copy {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p,
summary {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2.2rem, 4.2vw, 3.4rem);
  line-height: 1.02;
}

.subtitle,
.panel-header p,
.status-card p,
label span,
.empty-state,
small,
.muted,
.accordion-meta,
.summary-metric,
.table-note {
  color: var(--muted);
}

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

.button {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 700;
}

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

.button.secondary {
  background: white;
  border-color: var(--panel-border);
  color: var(--text);
}

.icon-button,
.icon-ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 14px;
}

.button-icon {
  font-size: 16px;
  line-height: 1;
}

.button-label {
  white-space: nowrap;
}

.icon-ghost-button {
  background: #f8fbff;
  border: 1px solid var(--panel-border);
  color: var(--muted);
  box-shadow: none;
}

.status-card,
.app-menu,
.filters-panel,
.view-panel,
.kpi-grid,
.grid {
  margin-top: 20px;
}

.status-card {
  padding: 18px 20px;
}

.status-card-link {
  cursor: pointer;
}

.status-card-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.compact-cache {
  margin-top: 0;
  padding: 14px;
  min-width: 300px;
  max-width: 350px;
  display: grid;
  gap: 12px;
  border-width: 1px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}

.compact-cache-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compact-cache-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.compact-cache-tag>span:last-child {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  white-space: nowrap;
}

.compact-cache-body {
  min-width: 0;
}

.compact-refresh {
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
}

.status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.9em;
  min-width: 0.9em;
  height: 0.9em;
  font-size: 12px;
  line-height: 1;
  flex: 0 0 auto;
}

.compact-cache strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.compact-cache p {
  margin: 0;
  font-size: 13px;
  line-height: 1.3;
}

.status-card.success {
  border-color: #9fd4c3;
  background: linear-gradient(180deg, #f2faf7 0%, #e8f4f0 100%);
}

.status-card.success .status-icon,
.status-card.success .compact-cache-tag {
  color: var(--success);
}

.status-card.warning {
  border-color: #fde68a;
  background: linear-gradient(180deg, #fffef7 0%, #fffbeb 100%);
}

.status-card.warning .status-icon,
.status-card.warning .compact-cache-tag {
  color: var(--warning);
}

.status-card.error {
  border-color: #e8b8b8;
  background: linear-gradient(180deg, #fdf7f7 0%, #f7edee 100%);
}

.status-card.error .status-icon,
.status-card.error .compact-cache-tag {
  color: var(--danger);
}

.app-menu {
  padding: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  position: sticky;
  top: 12px;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.menu-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
}

.menu-button.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-soft-border);
}

.panel {
  padding: 22px;
}

.panel-header {
  margin-bottom: 18px;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: end;
}

.panel-range-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.panel-range-button {
  padding: 7px 12px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: #51657f;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.panel-range-button:hover {
  border-color: rgba(96, 165, 250, 0.42);
  background: #f8fbff;
  color: #2e4a68;
}

.panel-range-button.active {
  border-color: rgba(96, 165, 250, 0.52);
  background: #eaf2ff;
  color: #1f4e8c;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.compact-header {
  align-items: start;
}

.filters-panel {
  padding: 0;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
  overflow: hidden;
}

.filters-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
}

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

.filters-summary-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.filters-summary-text {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filters-body {
  padding: 0 18px 18px;
  border-top: 1px solid rgba(219, 227, 240, 0.8);
}

.filters-helper-text {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.filters-actions {
  display: flex;
  justify-content: end;
  min-width: fit-content;
}

.filters-actions .icon-ghost-button {
  padding: 10px;
  min-width: 42px;
  justify-content: center;
}

.filters-actions .button-label {
  display: none;
}

.filters-grid,
.kpi-grid,
.grid,
.annual-grid,
.expenses-content-grid,
.summary-pill-grid,
.inline-filters {
  display: grid;
  gap: 16px;
}

.inline-filters {
  grid-auto-flow: column;
  align-items: center;
}

.inline-filters select {
  min-width: 160px;
}

.filters-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

select,
input,
textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid #d7e3f3;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.9);
  min-width: 0;
  font-size: max(16px, 1rem);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

select {
  color: var(--text);
}

select:focus,
input:focus {
  outline: none;
  border-color: var(--primary-soft-border);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
  background: #fff;
}

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

.kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.kpi-card {
  padding: 20px;
}

.kpi-label {
  color: var(--muted);
  font-size: 14px;
}

.kpi-value {
  margin: 8px 0 4px;
  font-size: 2rem;
  font-weight: 800;
}

.kpi-meta.positive {
  color: var(--success);
}

.kpi-meta.negative {
  color: var(--danger);
}

.grid {
  margin-top: 20px;
}

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

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

.insights-list,
.bars-list,
.member-grid,
.accordion-list {
  display: grid;
  gap: 12px;
}

.budget-list {
  display: grid;
  gap: 14px;
}

.insight-item,
.member-card,
.annual-card,
.expenses-panel,
.summary-pill {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 14px;
  background: #fafcff;
}

.insight-item strong,
.summary-pill strong {
  display: block;
  margin-bottom: 4px;
}

.bar-row {
  display: grid;
  gap: 8px;
}

.bar-row.clickable {
  cursor: pointer;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 10px 12px 12px;
  background: #fafcff;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.bar-row.clickable:hover,
.bar-row.clickable:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(216, 58, 82, 0.34);
  background: #fff7f9;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  outline: none;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  align-items: baseline;
}

.bar-label .bar-name {
  font-weight: 700;
  min-width: 0;
}

.bar-label>span {
  white-space: nowrap;
}

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

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
}

.bar-fill.warning {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.bar-fill.danger {
  background: linear-gradient(90deg, #b05252, #c97878);
}

.monthly-chart,
.expense-chart-block {
  display: grid;
  gap: 14px;
}

.monthly-svg,
.expense-line-svg {
  width: 100%;
  display: block;
  overflow: visible;
}

.monthly-trend-point {
  cursor: default;
  outline: none;
}

.monthly-trend-marker {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 140ms ease, filter 140ms ease, opacity 140ms ease;
}

.monthly-trend-point:hover .monthly-trend-marker,
.monthly-trend-point:focus .monthly-trend-marker,
.monthly-trend-point:focus-visible .monthly-trend-marker {
  transform: scale(1.08);
  filter: drop-shadow(0 4px 10px rgba(15, 23, 42, 0.16));
}

.monthly-trend-point:focus,
.monthly-trend-point:focus-visible {
  outline: none;
}

.monthly-trend-hit {
  cursor: pointer;
}

.monthly-trend-halo {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(0.75);
  transition: opacity 140ms ease, transform 160ms ease;
}

.monthly-trend-point:hover .monthly-trend-halo,
.monthly-trend-point:focus .monthly-trend-halo,
.monthly-trend-point:focus-visible .monthly-trend-halo {
  opacity: 1;
  transform: scale(1);
}

.monthly-trend-tooltip {
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 160ms ease;
}

.monthly-trend-tooltip-inner {
  transform: translateY(6px);
  transition: transform 160ms ease;
}

.monthly-trend-point:hover .monthly-trend-tooltip,
.monthly-trend-point:focus .monthly-trend-tooltip,
.monthly-trend-point:focus-visible .monthly-trend-tooltip {
  opacity: 1;
}

.monthly-trend-point:hover .monthly-trend-tooltip-inner,
.monthly-trend-point:focus .monthly-trend-tooltip-inner,
.monthly-trend-point:focus-visible .monthly-trend-tooltip-inner {
  transform: translateY(0);
}

.monthly-trend-tooltip-box {
  fill: rgba(255, 255, 255, 0.98);
  stroke: rgba(99, 114, 130, 0.14);
  stroke-width: 1;
  filter: drop-shadow(0 10px 22px rgba(15, 23, 42, 0.16));
}

.monthly-trend-tooltip-title {
  fill: #1f2f46;
  font-size: 30px;
  font-weight: 700;
}

.monthly-trend-tooltip-series {
  fill: #36506f;
  font-size: 22px;
  font-weight: 600;
}

.monthly-trend-tooltip-meta {
  fill: #5a6f88;
  font-size: 22px;
  font-weight: 500;
}

.expense-line-svg {
  height: 180px;
}

.monthly-legend,
.annual-badges,
.chart-caption {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 14px;
  justify-content: center;
  align-items: center;
}

.legend-chip,
.year-badge {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

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

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

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

.legend-dot.category {
  background: var(--teal);
}

.legend-dot.income-comparison-dot.is-reference {
  background: rgba(45, 125, 98, 0.5);
}

.legend-dot.income-comparison-dot.is-current {
  background: #2d7d62;
}

.income-year-toggle-list {
  justify-content: center;
  margin-top: 12px;
}

.income-year-toggle {
  appearance: none;
  cursor: pointer;
  color: inherit;
  font: inherit;
  padding: 7px 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
  opacity: 0.5;
}

.income-year-toggle.is-active {
  opacity: 1;
  border-color: rgba(45, 125, 98, 0.25);
  background: rgba(232, 244, 240, 0.96);
  box-shadow: 0 10px 24px rgba(34, 197, 94, 0.08);
}

.income-area-chart .monthly-svg {
  overflow: visible;
}

.income-area-hover-zone,
.income-annual-hover-zone {
  cursor: default;
  pointer-events: all;
}

.income-area-hover-zone:hover+.income-area-hover-zone,
.income-annual-hover-zone:hover {
  cursor: pointer;
}

.income-annual-bar {
  cursor: default;
  outline: none;
}

.income-annual-bar:focus,
.income-annual-bar:focus-visible {
  outline: none;
}

.income-annual-tooltip {
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 160ms ease;
}

.income-annual-tooltip-inner {
  transform: translateY(6px);
  transition: transform 160ms ease;
}

.income-annual-bar:hover .income-annual-tooltip,
.income-annual-bar:focus .income-annual-tooltip,
.income-annual-bar:focus-visible .income-annual-tooltip {
  opacity: 1;
}

.income-annual-bar:hover .income-annual-tooltip-inner,
.income-annual-bar:focus .income-annual-tooltip-inner,
.income-annual-bar:focus-visible .income-annual-tooltip-inner {
  transform: translateY(0);
}

.income-annual-tooltip-box {
  fill: rgba(255, 255, 255, 0.98);
  stroke: rgba(99, 114, 130, 0.14);
  stroke-width: 1;
  filter: drop-shadow(0 10px 22px rgba(15, 23, 42, 0.16));
}

.income-annual-tooltip-title {
  fill: #1f2f46;
  font-size: 11px;
  font-weight: 800;
}

.income-annual-tooltip-value {
  fill: #36506f;
  font-size: 10px;
  font-weight: 700;
}

.income-annual-tooltip-meta {
  fill: #5a6f88;
  font-size: 10px;
  font-weight: 600;
}

.income-annual-tooltip-detail {
  fill: #5a6f88;
  font-size: 10px;
  font-weight: 600;
}

.income-area-dot.is-reference {
  background: rgba(45, 125, 98, 0.42);
}

.income-area-dot.is-current {
  background: #2d7d62;
}

.member-card h3,
.accordion-summary h3,
.annual-card h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.metric-line {
  display: flex;
  justify-content: space-between;
  margin: 6px 0;
  gap: 12px;
  font-size: 14px;
}

.table-wrapper {
  overflow: auto;
  max-width: 100%;
  scrollbar-gutter: stable both-edges;
  overscroll-behavior-inline: contain;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid #e8eef7;
  font-size: 14px;
  white-space: nowrap;
}

.matrix-wrapper {
  overflow: auto;
  max-width: 100%;
  scrollbar-gutter: stable both-edges;
  overscroll-behavior-inline: contain;
}

.matrix-table {
  width: max-content;
  min-width: 100%;
}

.matrix-table thead th {
  position: sticky;
  top: 0;
  background: #f8fbff;
  z-index: 1;
}

.matrix-table tbody tr:hover,
table tbody tr:hover {
  background: #f8fbff;
}

.amount-positive {
  color: var(--success);
  font-weight: 700;
}

.amount-negative {
  color: var(--danger);
  font-weight: 700;
}

.amount-neutral {
  color: var(--text);
  font-weight: 700;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--panel-border);
  border-radius: 14px;
  text-align: center;
}

.accordion-item {
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: #fbfdff;
  overflow: hidden;
}

.accordion-item[open] {
  box-shadow: var(--shadow);
}

.accordion-summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.accordion-title-group {
  min-width: 0;
}

.accordion-title-group h3 {
  margin: 0 0 6px;
}

.accordion-summary-metrics {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: end;
}

.summary-metric strong {
  display: block;
  color: var(--text);
}

.accordion-body {
  padding: 0 20px 20px;
}

.budget-card {
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  overflow: hidden;
}

.budget-card[open] {
  box-shadow: var(--shadow);
}

.budget-summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

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

.budget-title h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.budget-subtitle {
  color: var(--muted);
  font-size: 14px;
}

.budget-metrics {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  justify-content: end;
  align-items: center;
}

.budget-body {
  padding: 0 20px 20px;
  display: grid;
  gap: 16px;
}

.progress-panel {
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px;
  background: #fbfdff;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.progress-title {
  font-weight: 700;
}

.progress-track {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: #e8eef7;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), #14b8a6);
}

.progress-footnote {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.budget-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.budget-stat {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 14px;
  background: #fafcff;
}

.budget-stat-label {
  color: var(--muted);
  font-size: 13px;
}

.budget-stat-value {
  margin-top: 6px;
  font-size: 1.2rem;
  font-weight: 800;
}

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

.month-card {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px;
  background: #ffffff;
}

.month-card.is-current {
  border-color: var(--primary-soft-border);
  background: #f8fbff;
}

.month-card-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.month-card-name {
  font-weight: 700;
  font-size: 14px;
}

.month-card-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: 999px;
  padding: 4px 8px;
}

.month-card-main {
  font-weight: 800;
  font-size: 1rem;
  margin-bottom: 4px;
}

.month-card-sub {
  color: var(--muted);
  font-size: 12px;
}

.month-card-variance {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
}

.month-card-variance.over {
  color: var(--danger);
}

.month-card-variance.under {
  color: var(--success);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.status-pill.success {
  background: #e8f4f0;
  color: #1e5e47;
}

.status-pill.warning {
  background: #fef3c7;
  color: #b45309;
}

.status-pill.danger {
  background: #fee2e2;
  color: #b91c1c;
}

.audit-pill {
  white-space: normal;
  line-height: 1.35;
  justify-content: flex-start;
  text-align: left;
  min-width: 0;
  max-width: 100%;
}

.expenses-content-grid {
  grid-template-columns: 2fr 1fr;
  align-items: start;
}

.annual-grid {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.annual-card {
  background: linear-gradient(180deg, #f8fbff 0%, #eef6ff 100%);
}

.annual-card .year-number {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.annual-card .year-value {
  font-size: 1.3rem;
  font-weight: 800;
  margin-top: 8px;
}

.summary-pill-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.subcategory-stack {
  display: grid;
  gap: 10px;
}

.expense-category-card {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px;
  background: #ffffff;
}

.subcategory-stack .bar-track {
  height: 10px;
}

.tag-inline {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
}

.sticky-header-lite {
  position: sticky;
  left: 0;
}

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

@media (max-width: 1100px) {

  .two-columns,
  .income-top-grid,
  .expenses-content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .hero {
    display: grid;
  }

  .hero-actions,
  .accordion-summary-metrics,
  .budget-metrics {
    justify-content: start;
  }

  .app-menu {
    top: 0;
  }

  .accordion-summary,
  .budget-summary,
  .filters-summary,
  .compact-cache {
    display: grid;
  }

  .inline-filters {
    grid-auto-flow: row;
  }
}

.bar-fill.success {
  background: linear-gradient(90deg, var(--success), #4ade80);
}

.bar-fill.saving,
.bar-fill.teal {
  background: linear-gradient(90deg, var(--saving-strong), #4ade80);
}

.amount-saving {
  color: var(--saving-strong);
  font-weight: 700;
}

.amount-warning {
  color: #b45309;
  font-weight: 700;
}

.donut-block {
  min-height: 320px;
}

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

.donut-svg {
  width: 100%;
  max-width: 280px;
  display: block;
  margin: 0 auto;
}

.donut-legend {
  display: grid;
  gap: 10px;
}

.donut-legend-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: #fafcff;
  font-size: 14px;
}

.monthly-review-grid {
  align-items: stretch;
}

.monthly-review-panel {
  display: grid;
  align-content: start;
}

.monthly-review-grid>.monthly-review-panel {
  height: 100%;
}

.monthly-review-panel .panel-header {
  align-items: start;
  margin-bottom: 14px;
}

.monthly-review-panel .panel-header h2,
.monthly-highlight-panel .panel-header h2 {
  white-space: nowrap;
}

.monthly-review-panel .panel-header p,
.monthly-highlight-panel .panel-header p {
  text-align: right;
  max-width: 420px;
}

.monthly-review-panel .donut-block {
  min-height: 0;
}

.monthly-review-panel .donut-layout {
  min-height: 0;
  align-items: start;
}

.monthly-review-panel .donut-svg {
  max-width: 240px;
}

.monthly-review-panel .donut-legend {
  align-content: start;
}

.monthly-type-trend-panel {
  display: grid;
  align-content: start;
  min-height: 0;
}

.monthly-type-trend-panel .panel-header p {
  text-align: left;
  max-width: none;
}

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

.monthly-flow-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 12px;
  align-items: stretch;
}

.monthly-kpi-main {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  border-radius: 16px;
  padding: 16px 18px;
  cursor: pointer;
  color: #fff;
  min-width: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.monthly-kpi-main.clickable:hover,
.monthly-kpi-main.clickable:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  outline: none;
}

.monthly-kpi-main-income {
  background: linear-gradient(135deg, var(--type-ingres-strong) 0%, var(--type-ingres) 100%);
}

.monthly-kpi-main-expense {
  background: linear-gradient(135deg, #5b3a3a 0%, #b05252 100%);
}

.monthly-kpi-main-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
}

.monthly-kpi-main-label {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.9;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.monthly-kpi-main-value {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1.05;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.monthly-kpi-main-meta {
  font-size: 11.5px;
  opacity: 0.85;
  line-height: 1.3;
}

.monthly-kpi-secondary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.monthly-kpi-pill {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fbfdff;
  cursor: pointer;
  min-width: 0;
  transition: box-shadow 0.15s ease, background 0.15s ease;
}

.monthly-kpi-pill:hover,
.monthly-kpi-pill:focus-visible {
  background: #f5f8ff;
  box-shadow: var(--shadow);
  outline: none;
}

.monthly-kpi-pill-saving {
  background: var(--type-estalvi-soft);
  border-color: rgba(118, 146, 123, 0.32);
}

.monthly-kpi-pill-saving:hover,
.monthly-kpi-pill-saving:focus-visible {
  background: var(--type-estalvi-soft);
  box-shadow: 0 8px 22px rgba(118, 146, 123, 0.14);
}

.monthly-kpi-pill-positive {
  background: #f4fbf7;
  border-color: rgba(45, 125, 98, 0.22);
}

.monthly-kpi-pill-negative {
  background: #fdf5f5;
  border-color: rgba(176, 82, 82, 0.22);
}

.monthly-kpi-pill-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.monthly-kpi-pill-value {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.monthly-kpi-pill-saving .monthly-kpi-pill-value { color: var(--type-estalvi-strong); }
.monthly-kpi-pill-positive .monthly-kpi-pill-value { color: var(--type-ingres-strong); }
.monthly-kpi-pill-negative .monthly-kpi-pill-value { color: #b05252; }

.monthly-kpi-pill-meta {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}

@media (max-width: 900px) {
  .monthly-flow-strip {
    grid-template-columns: 1fr 1fr;
  }
  .monthly-kpi-secondary {
    grid-column: 1 / -1;
  }
}

@media (max-width: 540px) {
  .monthly-flow-strip {
    grid-template-columns: 1fr;
  }
  .monthly-kpi-secondary {
    grid-column: auto;
  }
}

#monthlyMemberSummary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.monthly-member-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: #fbfdff;
}

.monthly-member-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.monthly-member-name strong {
  font-size: 14px;
  color: var(--text);
}

.monthly-member-name .muted {
  font-size: 12px;
  color: var(--muted);
}

.monthly-member-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.monthly-member-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.monthly-member-stat-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.monthly-member-stat-value {
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 720px) {
  .monthly-member-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .monthly-member-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.flow-summary-card {
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  display: grid;
  gap: 10px;
}

.flow-summary-card.success {
  background: linear-gradient(180deg, #ffffff 0%, #f2fcf5 100%);
}

.flow-summary-card.danger {
  background: linear-gradient(180deg, #ffffff 0%, #fff5f5 100%);
}

.flow-summary-card.saving,
.flow-summary-card.teal {
  background: linear-gradient(180deg, #ffffff 0%, var(--saving-soft) 100%);
  border-color: #dde7dd;
}

.flow-summary-card.saving.clickable:hover,
.flow-summary-card.saving.clickable:focus-visible,
.flow-summary-card.teal.clickable:hover,
.flow-summary-card.teal.clickable:focus-visible {
  border-color: rgba(118, 146, 123, 0.34);
}

.flow-summary-head {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.flow-summary-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(21, 35, 59, 0.08);
  font-size: 16px;
}

.flow-summary-value {
  font-size: 2rem;
  font-weight: 800;
}

.flow-summary-meta {
  color: var(--muted);
  font-size: 14px;
}

.monthly-visual-grid {
  align-items: start;
}

.member-flow-grid {
  display: grid;
  gap: 14px;
}

.member-flow-card {
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  display: grid;
  gap: 14px;
}

.member-flow-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.member-flow-head h3 {
  margin: 0;
}

.member-flow-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.member-flow-stat {
  border-radius: 16px;
  padding: 12px;
  display: grid;
  gap: 4px;
  border: 1px solid var(--panel-border);
  background: #ffffff;
}

.member-flow-stat span:first-child {
  font-size: 14px;
}

.member-flow-stat strong {
  font-size: 1rem;
}

.member-flow-stat small {
  color: var(--muted);
}

.member-flow-stat.success {
  background: #e8f4f0;
}

.member-flow-stat.danger {
  background: #f7edee;
}

.member-flow-stat.saving,
.member-flow-stat.teal {
  background: var(--saving-soft);
}

.monthly-type-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.type-pocket-card {
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 18px;
  display: grid;
  gap: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
  align-self: start;
}

.type-pocket-card.success {
  background: linear-gradient(180deg, #ffffff 0%, #f2fcf5 100%);
}

.type-pocket-card.danger {
  background: linear-gradient(180deg, #ffffff 0%, #fff5f5 100%);
}

.type-pocket-card.saving,
.type-pocket-card.teal {
  background: linear-gradient(180deg, #ffffff 0%, var(--saving-soft) 100%);
}

.type-pocket-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.type-pocket-head>strong {
  font-size: 1.05rem;
  white-space: nowrap;
}

.type-pocket-title {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-width: 0;
}

.type-pocket-title h3 {
  margin: 0 0 2px;
  font-size: 1.05rem;
}

.type-pocket-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.type-pocket-icon {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(21, 35, 59, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.type-pocket-list {
  display: grid;
  gap: 12px;
}

.type-pocket-item {
  display: grid;
  gap: 10px;
  padding: 12px 13px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(219, 227, 240, 0.95);
}

.type-pocket-item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.type-pocket-item-head strong {
  display: block;
  font-size: 0.98rem;
  line-height: 1.15;
}

.type-pocket-item-head small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.type-pocket-item-head>span {
  display: block;
  font-weight: 700;
  white-space: nowrap;
}

.range-summary-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.range-summary-row span:nth-child(2) {
  text-align: center;
}

.range-summary-row span:last-child {
  text-align: right;
}

.range-track-wrap {
  position: relative;
  height: 22px;
  padding: 0 8px;
}

.range-track-line {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 10px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(21, 35, 59, 0.14), rgba(21, 35, 59, 0.24));
}

.range-average-marker {
  position: absolute;
  top: 4px;
  width: 2px;
  height: 16px;
  margin-left: -1px;
  border-radius: 999px;
  background: rgba(21, 35, 59, 0.45);
}

.range-current-marker {
  position: absolute;
  top: 4px;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  border-radius: 999px;
  border: 2px solid #fff;
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
}

.type-pocket-card.danger .range-current-marker {
  background: var(--danger);
}

.type-pocket-card.success .range-current-marker {
  background: var(--success);
}

.type-pocket-card.saving .range-current-marker {
  background: var(--saving);
}

.type-pocket-card.teal .range-current-marker {
  background: var(--saving);
}

.range-current-marker.over,
.range-current-marker.under {
  transform: scale(1.05);
}

.range-caption {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

@media (max-width: 900px) {
  .monthly-type-grid {
    grid-template-columns: 1fr;
  }
}

.monthly-summary-members {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(219, 227, 240, 0.8);
  display: grid;
  gap: 14px;
}

.monthly-summary-members-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.monthly-summary-members-head h3 {
  margin: 0;
  font-size: 1.1rem;
}

.monthly-summary-members-head p {
  margin: 0;
  color: var(--muted);
}

.expense-type-annual-sections {
  display: grid;
  gap: 24px;
}

.expense-type-annual-group {
  margin: 0;
}

.expense-type-annual-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.expense-type-annual-head h3 {
  margin: 0;
  font-size: 1.1rem;
}

.expense-type-annual-head p {
  margin: 0;
  color: var(--muted);
}

.expense-type-annual-section-grid {
  margin-top: 0;
}

.expense-type-annual-group .accordion-body {
  padding-top: 4px;
}

.expense-member-type-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.expense-member-type-row {
  padding: 10px 12px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: #fafcff;
}

.expense-member-type-row {
  height: 100%;
}

.expense-member-type-row .table-note {
  margin: 4px 0 8px;
}

.expense-member-type-row.type-variant-fixed {
  background: linear-gradient(180deg, #ffffff 0%, var(--type-despesa-fixa-soft) 100%);
  border-color: rgba(132, 151, 173, 0.28);
}

.expense-member-type-row.type-variant-needed {
  background: linear-gradient(180deg, #ffffff 0%, var(--type-despesa-necesaria-soft) 100%);
  border-color: rgba(144, 133, 184, 0.28);
}

.expense-member-type-row.type-variant-discretionary {
  background: linear-gradient(180deg, #ffffff 0%, var(--type-despesa-discrecional-soft) 100%);
  border-color: rgba(167, 153, 199, 0.32);
}

@media (max-width: 900px) {
  .expense-member-type-list {
    grid-template-columns: 1fr;
  }
}

.monthly-visual-grid {
  display: block;
}

.member-flow-grid {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.member-flow-card {
  padding: 14px;
  gap: 10px;
}

.member-flow-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.member-flow-stat {
  padding: 10px 10px 9px;
  gap: 3px;
  border-radius: 14px;
}

.member-flow-stat span:first-child {
  font-size: 12px;
}

.member-flow-stat strong {
  font-size: 0.95rem;
  line-height: 1.1;
}

.member-flow-stat small {
  font-size: 12px;
}

@media (max-width: 1100px) {
  .member-flow-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .monthly-summary-members-head {
    display: grid;
  }

  .member-flow-stats {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 900px) {
  .monthly-type-grid {
    grid-template-columns: 1fr;
  }
}

.type-pocket-item {
  display: grid;
  gap: 10px;
}

.type-pocket-item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.range-summary-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.range-summary-row span:nth-child(2) {
  text-align: center;
}

.range-summary-row span:last-child {
  text-align: right;
}

.range-track-wrap {
  position: relative;
  height: 18px;
}

.range-track-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 8px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(21, 35, 59, 0.12), rgba(21, 35, 59, 0.24));
}

.range-average-marker {
  position: absolute;
  top: 3px;
  width: 2px;
  height: 13px;
  margin-left: -1px;
  border-radius: 999px;
  background: rgba(21, 35, 59, 0.5);
}

.range-current-marker {
  position: absolute;
  top: 2px;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  border-radius: 999px;
  border: 2px solid #fff;
  background: var(--primary);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
}

.type-pocket-card.danger .range-current-marker {
  background: var(--danger);
}

.type-pocket-card.success .range-current-marker {
  background: var(--success);
}

.type-pocket-card.saving .range-current-marker {
  background: var(--saving);
}

.type-pocket-card.teal .range-current-marker {
  background: var(--saving);
}

.range-current-marker.over::after,
.range-current-marker.under::after {
  content: '';
  position: absolute;
  top: 3px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #fff;
}

.range-current-marker.over::after {
  right: -5px;
}

.range-current-marker.under::after {
  left: -5px;
}

.range-caption {
  font-size: 12px;
  color: var(--muted);
}

/* Monthly type cards - collapsible */
.monthly-type-grid {
  margin-top: 20px;
}

.type-pocket-card {
  overflow: hidden;
  height: fit-content;
}

.type-pocket-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

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

.type-pocket-card:not([open]) .type-pocket-summary {
  margin-bottom: 0;
}

.type-pocket-body {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(219, 227, 240, 0.9);
}

.type-pocket-summary-right {
  display: grid;
  justify-items: end;
  gap: 4px;
  white-space: nowrap;
}

.type-pocket-summary-right strong {
  font-size: 1.05rem;
}

.type-pocket-toggle {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.type-pocket-card[open] .type-pocket-toggle::after {
  content: ' · amaga';
}

.type-pocket-card:not([open]) .type-pocket-toggle::after {
  content: ' · mostra';
}

.type-pocket-card .empty-state {
  padding: 14px;
}

.type-pocket-item {
  gap: 8px;
}

.range-summary-row {
  font-size: 10px;
  letter-spacing: 0.01em;
}

.range-track-wrap {
  height: 18px;
  padding: 0 4px;
}

.range-track-line {
  left: 4px;
  right: 4px;
  top: 8px;
  height: 3px;
}

.range-average-marker {
  top: 2px;
  height: 14px;
}

.range-current-marker {
  top: 2px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
}

.range-caption {
  font-size: 11px;
}

@media (max-width: 700px) {
  .type-pocket-summary {
    display: grid;
  }

  .type-pocket-summary-right {
    justify-items: start;
  }
}

.type-category-card {
  border: 1px solid rgba(219, 227, 240, 0.95);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  overflow: hidden;
}

.type-category-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 13px;
}

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

.type-category-summary strong {
  display: block;
  font-size: 0.98rem;
}

.type-category-summary small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.type-category-summary>span {
  display: block;
  font-weight: 700;
  white-space: nowrap;
}

.type-category-body {
  display: grid;
  gap: 10px;
  padding: 0 13px 13px;
  border-top: 1px solid rgba(219, 227, 240, 0.9);
}

.type-category-card:not([open]) .type-category-body {
  display: none;
}

/* Monthly hierarchy spacing + progressive range visibility */
.monthly-type-grid {
  gap: 20px;
  align-items: start;
}

.type-pocket-card {
  gap: 0;
  padding: 16px;
}

.type-pocket-summary {
  display: grid;
  gap: 12px;
  margin: 0;
}

.type-pocket-summary-main {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.type-pocket-summary-right {
  gap: 2px;
}

.type-pocket-body {
  margin-top: 12px;
  padding-top: 12px;
}

.type-pocket-list {
  gap: 12px;
}

.type-category-card {
  border-radius: 18px;
}

.type-category-summary {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  margin: 0;
}

.type-category-summary-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.type-category-summary-main>span {
  display: block;
  font-weight: 700;
  white-space: nowrap;
}

.type-category-body {
  gap: 10px;
  padding: 0 14px 14px;
}

.type-pocket-item {
  gap: 8px;
  padding: 12px 14px;
}

.type-pocket-item-head {
  align-items: center;
}

.hierarchy-range-card {
  display: grid;
  gap: 8px;
}

.type-range-card {
  margin-top: 0;
  padding-top: 10px;
  border-top: 1px solid rgba(219, 227, 240, 0.9);
}

.category-range-card {
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid rgba(219, 227, 240, 0.9);
}

.subcategory-range-card {
  margin-top: 2px;
}

.type-pocket-card[open] .type-range-card,
.type-category-card[open] .category-range-card {
  display: none;
}

.range-summary-row {
  font-size: 11px;
  line-height: 1.2;
}

.range-track-wrap {
  padding: 0 2px;
}

.range-track-line {
  left: 2px;
  right: 2px;
}

.range-caption {
  line-height: 1.35;
}

@media (max-width: 700px) {
  .monthly-type-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .type-pocket-card {
    padding: 14px;
  }

  .type-pocket-summary-main,
  .type-category-summary-main {
    display: grid;
  }

  .type-category-summary,
  .type-pocket-item {
    padding-left: 12px;
    padding-right: 12px;
  }

  .type-category-body {
    padding-left: 12px;
    padding-right: 12px;
    padding-bottom: 12px;
  }

  .category-range-card {
    margin-left: 12px;
    margin-right: 12px;
    margin-bottom: 12px;
  }
}

/* Final polish for monthly hierarchy cards */
.monthly-type-grid {
  display: block;
  column-count: 2;
  column-gap: 20px;
  margin-top: 20px;
}

.type-pocket-card {
  display: inline-block;
  width: 100%;
  margin: 0 0 20px;
  vertical-align: top;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  border-radius: 22px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05);
}

.type-pocket-card[open] {
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
}

.type-pocket-summary {
  width: 100%;
  box-sizing: border-box;
  gap: 10px;
}

.type-pocket-summary-main {
  width: 100%;
  align-items: flex-start;
}

.type-pocket-title {
  flex: 1 1 auto;
  min-width: 0;
}

.type-pocket-title h3 {
  line-height: 1.15;
}

.type-pocket-title p {
  margin-bottom: 0;
  line-height: 1.3;
}

.type-pocket-summary-right {
  flex: 0 0 auto;
  align-self: flex-start;
}

.type-pocket-summary-right strong {
  font-size: 1.1rem;
  line-height: 1.1;
}

.type-pocket-toggle {
  letter-spacing: 0.01em;
}

.type-range-card,
.category-range-card,
.subcategory-range-card {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.type-range-card {
  padding-top: 12px;
}

.type-pocket-body {
  margin-top: 10px;
  padding-top: 12px;
}

.type-pocket-list {
  gap: 14px;
}

.type-category-card {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
}

.type-category-card[open] {
  border-color: rgba(98, 154, 255, 0.35);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.03);
}

.type-category-summary {
  width: 100%;
  box-sizing: border-box;
  gap: 8px;
}

.type-category-summary-main {
  width: 100%;
  align-items: flex-start;
}

.activity-inline-copy {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.type-category-summary strong,
.type-pocket-item-head strong {
  line-height: 1.18;
}

.activity-collapsed-copy {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.type-pocket-card[open] .type-pocket-title .activity-collapsed-copy,
.type-category-card[open] .type-category-summary .activity-collapsed-copy {
  display: none;
}

.type-pocket-card[open] .type-pocket-title .activity-inline-copy {
  display: none;
}

.type-category-summary small,
.type-pocket-item-head small {
  display: block;
  line-height: 1.25;
}

.type-category-body {
  gap: 16px;
  padding-top: 14px;
}

.type-pocket-item {
  margin: 0;
  padding: 14px 16px;
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.type-pocket-item-head {
  gap: 10px;
}

.type-pocket-item-head>span {
  font-size: 1rem;
  line-height: 1.1;
}

.hierarchy-range-card {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  gap: 7px;
}

.range-summary-row {
  width: 100%;
  gap: 12px;
  font-size: 11px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.range-track-wrap {
  width: 100%;
  min-width: 0;
  height: 16px;
  padding: 0;
  margin-top: 1px;
}

.range-track-line {
  left: 0;
  right: 0;
  top: 7px;
}

.range-average-marker {
  top: 1px;
  height: 14px;
}

.range-current-marker {
  top: 1px;
}

.range-caption {
  width: 100%;
  margin-top: 1px;
  font-size: 11px;
  line-height: 1.35;
}

@media (max-width: 1100px) {
  .monthly-type-grid {
    column-count: 1;
  }
}

@media (max-width: 700px) {
  .monthly-type-grid {
    column-count: 1;
    margin-top: 16px;
  }

  .type-pocket-card {
    margin-bottom: 16px;
    border-radius: 18px;
  }

  .type-pocket-summary-main,
  .type-category-summary-main {
    display: grid;
    gap: 8px;
  }

  .type-pocket-summary-right,
  .type-category-summary-main>span {
    justify-items: start;
  }
}

/* Force full-width summaries inside details */
details.type-pocket-card,
details.type-category-card {
  display: block;
  width: 100%;
  box-sizing: border-box;
}

summary.type-pocket-summary,
summary.type-category-summary {
  display: block !important;
  width: 100% !important;
  max-width: none !important;
  box-sizing: border-box;
}

.type-pocket-summary-main,
.type-category-summary-main,
.type-pocket-body,
.type-category-body,
.type-pocket-summary .hierarchy-range-card,
.type-category-summary .hierarchy-range-card {
  display: block;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}

.type-pocket-summary-main,
.type-category-summary-main {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.type-pocket-summary .hierarchy-range-card,
.type-category-summary .hierarchy-range-card {
  margin-top: 10px;
}

.subcategory-range-card {
  margin-top: 8px;
}

.type-pocket-summary .range-summary-row,
.type-category-summary .range-summary-row,
.type-pocket-summary .range-track-wrap,
.type-category-summary .range-track-wrap,
.type-pocket-summary .range-caption,
.type-category-summary .range-caption {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}

@media (max-width: 700px) {

  .type-pocket-summary-main,
  .type-category-summary-main {
    display: grid;
    gap: 8px;
  }
}

/* Restore spacing for nested bodies after full-width summary overrides */
.type-pocket-body {
  display: block;
  width: 100%;
  box-sizing: border-box;
}

.type-category-body {
  display: grid;
  width: 100%;
  box-sizing: border-box;
  gap: 18px;
  padding-top: 16px;
}

.type-pocket-item {
  padding: 14px 16px;
}

.type-category-body>.type-pocket-item+.type-pocket-item {
  margin-top: 0;
}

.subcategory-range-card {
  margin-top: 8px;
}

.type-pocket-item-clickable {
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.type-pocket-item-clickable:hover,
.type-pocket-item-clickable:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(98, 154, 255, 0.42);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  outline: none;
}

.detail-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: calc(24px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  overflow: hidden;
}

.detail-modal[hidden] {
  display: none !important;
}

.detail-modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(4px);
}

.detail-modal-panel {
  position: relative;
  z-index: 1;
  width: min(880px, calc(100vw - 32px));
  height: auto;
  min-height: min(320px, calc(100dvh - 48px));
  max-height: min(78dvh, calc(100dvh - 48px), 860px);
  margin: 0;
  padding: 20px;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 28px 64px rgba(15, 23, 42, 0.2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.detail-modal-head h2 {
  margin: 2px 0 4px;
}

.detail-modal-eyebrow,
.detail-modal-meta {
  margin: 0;
  color: var(--muted);
}

.detail-modal-eyebrow {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.detail-modal-list {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
  padding-bottom: 4px;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.detail-modal-list>* {
  flex: 0 0 auto;
}

body.detail-modal-open {
  overflow: hidden;
}

/* Llista lineal de moviments dins el modal de detall: data · concepte · import en una
   sola fila, amb separadors en comptes de targetes. Prioritza densitat perquè un
   sumatori de 10-20 moviments es llegeixi sense scroll. */
.detail-row-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(219, 227, 240, 0.95);
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel);
}

.detail-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: baseline;
  padding: 7px 12px;
  border-bottom: 1px solid #eef2f8;
  font-size: 13px;
}

.detail-row:nth-child(even) {
  background: #fafcff;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-row-date {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.detail-row-body {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.detail-row-concept {
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.detail-row-meta {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.3;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.detail-row-meta::before {
  content: '· ';
}

.detail-row-amount {
  text-align: right;
  white-space: nowrap;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.monthly-radar-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-content: start;
  align-items: stretch;
}

.mini-section {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  align-content: start;
  min-height: 0;
}

.type-share-section {
  min-height: 0;
}

.type-share-trend-section {
  min-height: 0;
  grid-column: 1 / -1;
}

.type-share-trend-host {
  display: flex;
  align-items: flex-start;
  width: 100%;
  min-width: 0;
  min-height: 260px;
}

.type-share-trend-host .monthly-chart {
  flex: 1 1 auto;
  align-content: start;
  min-width: 0;
  width: 100%;
  min-height: 260px;
  gap: 10px;
  padding: 16px 16px 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 251, 255, 0.96) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.type-share-trend-host .monthly-svg {
  width: 100%;
  height: 100%;
}

.type-share-trend-host .monthly-legend {
  gap: 10px 14px;
  font-size: 13px;
  justify-content: center;
  width: 100%;
}

.type-share-trend-host .legend-chip {
  padding: 7px 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.type-share-trend-legend-chip {
  appearance: none;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.type-share-trend-legend-chip.is-active {
  border-color: rgba(59, 130, 246, 0.28);
  background: rgba(239, 246, 255, 0.96);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.08);
}

.type-share-trend-legend-chip.is-muted {
  opacity: 0.45;
}

.type-share-trend-host .legend-dot {
  width: 11px;
  height: 11px;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.78);
}

.type-share-trend-svg {
  overflow: visible;
}

.type-share-trend-band {
  fill: rgba(148, 163, 184, 0.04);
}

.type-share-trend-band.is-alt {
  fill: rgba(37, 99, 235, 0.04);
}

.type-share-trend-line,
.type-share-trend-hitline,
.type-share-trend-guide,
.type-share-trend-halo,
.type-share-trend-marker,
.type-share-trend-point,
.type-share-trend-tooltip,
.type-share-trend-tooltip-inner {
  transition: opacity 140ms ease, transform 160ms ease, stroke-width 160ms ease, filter 160ms ease;
}

.type-share-trend-series {
  opacity: 0.92;
}

.type-share-trend-chart:not(.has-selection) .type-share-trend-svg:has(.type-share-trend-point:hover) .type-share-trend-series:not(:has(.type-share-trend-point:hover)),
.type-share-trend-chart:not(.has-selection) .type-share-trend-svg:has(.type-share-trend-point:focus) .type-share-trend-series:not(:has(.type-share-trend-point:focus)) {
  opacity: 0.28;
}

.type-share-trend-chart:not(.has-selection) .type-share-trend-series:has(.type-share-trend-point:hover) .type-share-trend-line,
.type-share-trend-chart:not(.has-selection) .type-share-trend-series:has(.type-share-trend-point:focus) .type-share-trend-line,
.type-share-trend-series.is-active .type-share-trend-line {
  stroke-width: 4.5;
  filter: drop-shadow(0 6px 14px rgba(15, 23, 42, 0.16));
}

.type-share-trend-series.is-active {
  opacity: 1;
}

.type-share-trend-series.is-muted {
  opacity: 0.14;
}

.type-share-trend-line {
  pointer-events: none;
}

.type-share-trend-line.is-smoothed {
  opacity: 0.72;
  stroke-dasharray: 6 5;
}

.type-share-trend-hitline {
  pointer-events: stroke;
  cursor: pointer;
}

.type-share-trend-guide {
  stroke: rgba(71, 85, 105, 0.32);
  stroke-width: 1.2;
  stroke-dasharray: 4 4;
  opacity: 0;
}

.type-share-trend-hit {
  fill: transparent;
}

.type-share-trend-point {
  cursor: pointer;
  outline: none;
}

.type-share-trend-point .type-share-trend-marker {
  transform-box: fill-box;
  transform-origin: center;
}

.type-share-trend-point .type-share-trend-halo {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(0.7);
}

.type-share-trend-point:hover .type-share-trend-marker,
.type-share-trend-point:focus .type-share-trend-marker {
  transform: scale(1.18);
  filter: drop-shadow(0 4px 10px rgba(15, 23, 42, 0.18));
}

.type-share-trend-point:hover .type-share-trend-halo,
.type-share-trend-point:focus .type-share-trend-halo,
.type-share-trend-point:hover .type-share-trend-guide,
.type-share-trend-point:focus .type-share-trend-guide {
  opacity: 1;
  transform: scale(1);
}

.type-share-trend-series.is-active .type-share-trend-marker {
  filter: drop-shadow(0 4px 10px rgba(15, 23, 42, 0.16));
}

.type-share-trend-tooltip {
  opacity: 0;
  pointer-events: none;
}

.type-share-trend-tooltip-inner {
  transform: translateY(6px);
}

.type-share-trend-point:hover .type-share-trend-tooltip,
.type-share-trend-point:focus .type-share-trend-tooltip {
  opacity: 1;
}

.type-share-trend-point:hover .type-share-trend-tooltip-inner,
.type-share-trend-point:focus .type-share-trend-tooltip-inner {
  transform: translateY(0);
}

.type-share-trend-tooltip-box {
  fill: rgba(255, 255, 255, 0.98);
  stroke: rgba(99, 114, 130, 0.14);
  stroke-width: 1;
  filter: drop-shadow(0 10px 22px rgba(15, 23, 42, 0.16));
}

.type-share-trend-tooltip-title {
  fill: #1f2f46;
  font-size: 11px;
  font-weight: 800;
}

.type-share-trend-tooltip-series {
  fill: #36506f;
  font-size: 10px;
  font-weight: 700;
}

.type-share-trend-tooltip-meta {
  fill: #5a6f88;
  font-size: 10px;
  font-weight: 600;
}

.type-share-trend-hint {
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.mini-section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}

.mini-section-head h3 {
  margin: 0;
  font-size: 1rem;
}

.mini-section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.expense-radar-list,
.detail-snapshot-list {
  display: grid;
  gap: 12px;
}

.expense-radar-item,
.snapshot-item {
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px 16px;
  background: #fafcff;
}

.expense-radar-list {
  gap: 8px;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.expense-radar-item {
  padding: 8px 12px;
  border-radius: 14px;
}

.donut-legend-row.clickable,
.snapshot-item.clickable {
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.donut-legend-row.clickable:hover,
.donut-legend-row.clickable:focus-visible,
.snapshot-item.clickable:hover,
.snapshot-item.clickable:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(98, 154, 255, 0.42);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  outline: none;
}

.donut-slice.clickable {
  cursor: pointer;
  transition: opacity 120ms ease;
}

.donut-slice.clickable:hover,
.donut-slice.clickable:focus {
  opacity: 0.86;
  outline: none;
}

.expense-radar-row,
.snapshot-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.expense-radar-copy {
  display: flex;
  gap: 8px;
  align-items: baseline;
  min-width: 0;
  flex-wrap: wrap;
}

.expense-radar-copy strong,
.snapshot-item strong {
  display: block;
  line-height: 1.2;
}

.expense-radar-copy span,
.snapshot-item small {
  color: var(--muted);
  line-height: 1.2;
  font-size: 12px;
}

.expense-radar-values {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.expense-radar-track {
  position: relative;
  height: 8px;
  margin-top: 6px;
  border-radius: 999px;
  background: #e8eef7;
  overflow: hidden;
}

.expense-radar-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
}

.expense-radar-fill.danger {
  background: linear-gradient(90deg, #b05252, #c97878);
}

.expense-radar-marker {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 2px;
  margin-left: -1px;
  background: rgba(21, 35, 59, 0.55);
  border-radius: 999px;
}

.expense-radar-item .status-pill {
  padding: 4px 10px;
  font-size: 11px;
  line-height: 1.1;
}

.expense-radar-item .expense-radar-values>strong {
  font-size: 0.98rem;
  line-height: 1.1;
}

.compact-donut-block {
  min-height: 0;
}

.compact-donut-block .donut-layout {
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}

.compact-donut-block .donut-svg {
  max-width: 220px;
}

.compact-donut-block .donut-legend {
  gap: 8px;
}

.compact-donut-block .donut-legend-row {
  padding: 8px 10px;
  font-size: 13px;
}

#monthlyExpenseTypeMix.compact-donut-block .donut-layout {
  grid-template-columns: minmax(280px, 2fr) minmax(180px, 1fr);
  gap: 16px;
  align-items: center;
}

#monthlyExpenseTypeMix.compact-donut-block .donut-svg {
  max-width: 280px;
}

#monthlyExpenseTypeMix.compact-donut-block .donut-legend-row {
  padding: 7px 9px;
  font-size: 12px;
  gap: 10px;
}

#monthlyExpenseTypeMix.compact-donut-block .donut-legend {
  align-content: start;
}

.pie-layout {
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.pie-svg {
  max-width: 280px;
  overflow: visible;
}

.pie-slice {
  stroke: #ffffff;
  stroke-width: 2;
  transition: opacity 120ms ease, transform 120ms ease, filter 120ms ease;
  transform-origin: 90px 90px;
  transform-box: fill-box;
}

.pie-slice.clickable {
  cursor: pointer;
}

.pie-slice-group:hover .pie-slice.clickable,
.pie-slice-group:focus-within .pie-slice.clickable {
  opacity: 0.92;
  filter: brightness(1.05);
}

.pie-slice:focus {
  outline: none;
}

.pie-slice-percent {
  fill: #1f2f46;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 3px;
  paint-order: stroke fill;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -0.01em;
  pointer-events: none;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.45));
}

.pie-slice-label {
  pointer-events: none;
}

.pie-slice-label-line {
  fill: none;
  stroke-width: 1.2px;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.78;
}

.pie-hover-bubble {
  opacity: 0;
  transform-origin: center;
  transform: scale(0.86);
  transition: opacity 160ms ease, transform 180ms cubic-bezier(.2, .8, .2, 1);
  pointer-events: none;
}

.pie-hover-bubble-box {
  fill: rgba(255, 255, 255, 0.98);
  stroke: rgba(99, 114, 130, 0.14);
  stroke-width: 1;
  filter: drop-shadow(0 10px 22px rgba(15, 23, 42, 0.16));
}

.pie-hover-bubble-title {
  fill: #1f2f46;
  font-size: 11px;
  font-weight: 800;
}

.pie-hover-bubble-meta {
  fill: #5a6f88;
  font-size: 10px;
  font-weight: 600;
}

.pie-hover-layer {
  pointer-events: none;
}

.pie-legend {
  gap: 8px;
  align-content: start;
}

.pie-legend-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: #fafcff;
  font-size: 13px;
}

.pie-legend-row.clickable {
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.pie-legend-row.clickable:hover,
.pie-legend-row.clickable:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(98, 154, 255, 0.42);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  outline: none;
}

.detail-other-summary {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.detail-other-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: #fafcff;
}

.detail-other-row strong {
  font-size: 13px;
}

.detail-other-row span {
  font-weight: 800;
  color: #1f2f46;
}

.detail-other-row small {
  grid-column: 1 / -1;
  color: #64748b;
  font-size: 11px;
}

.detail-group-section {
  display: block;
  border: 1px solid rgba(219, 227, 240, 0.95);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  overflow: hidden;
}

.detail-group-section-hierarchy {
  border-left: 4px solid transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.detail-group-section-low {
  border-left-color: #8fd3ff;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.detail-group-section-mid {
  border-left-color: #2f6fae;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
}

.detail-group-section-high {
  border-left-color: #d83a52;
  background: linear-gradient(180deg, #ffffff 0%, #fff8fa 100%);
}

.detail-group-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 13px;
  background: rgba(255, 255, 255, 0.78);
}

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

.detail-group-summary-main,
.detail-group-summary-side {
  display: grid;
  gap: 4px;
}

.detail-group-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.detail-group-badge {
  border: 1px solid rgba(216, 227, 240, 0.95);
  background: rgba(248, 250, 252, 0.98);
  color: #48617f;
}

.detail-group-badge-low {
  border-color: rgba(143, 211, 255, 0.55);
  background: #eef8ff;
  color: #2d6b9e;
}

.detail-group-badge-mid {
  border-color: rgba(47, 111, 174, 0.32);
  background: #edf4fb;
  color: #24507d;
}

.detail-group-badge-high {
  border-color: rgba(216, 58, 82, 0.28);
  background: #fdecef;
  color: #b4233a;
}

.detail-group-summary-main strong {
  display: block;
  font-size: 0.98rem;
}

.detail-group-summary-main small,
.detail-group-summary-side small {
  color: var(--muted);
  font-size: 12px;
}

.detail-group-summary-side {
  justify-items: end;
  white-space: nowrap;
}

.detail-group-summary-side span {
  font-weight: 800;
  color: #1f2f46;
}

.detail-group-toggle::after {
  content: 'Amaga moviments';
}

.detail-group-section:not([open]) .detail-group-toggle::after {
  content: 'Mostra moviments';
}

.detail-group-body {
  display: grid;
  gap: 8px;
  padding: 0 13px 13px;
  border-top: 1px solid rgba(219, 227, 240, 0.9);
  background: rgba(255, 255, 255, 0.78);
}

.detail-group-section:not([open]) .detail-group-body {
  display: none;
}

.detail-group-body-head {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  align-items: center;
  padding: 12px 4px 2px;
}

.detail-group-body-head small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.detail-other-divider {
  height: 1px;
  margin: 10px 0 14px;
  background: rgba(148, 163, 184, 0.35);
}

.detail-other-note {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(191, 219, 254, 0.55);
  border-radius: 12px;
  background: #f8fbff;
  color: #4b647d;
  font-size: 12px;
  line-height: 1.45;
}

.full-width-snapshot-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 16px;
}

.full-width-snapshot-list .snapshot-item {
  padding: 10px 12px;
  border-radius: 14px;
}

.monthly-highlight-panel .panel-header {
  margin-bottom: 10px;
}

.monthly-highlight-panel {
  margin-top: 20px;
}

.monthly-highlight-panel .snapshot-item strong {
  font-size: 0.98rem;
}

.monthly-highlight-panel .snapshot-item small {
  font-size: 12px;
}

@media (max-width: 700px) {
  .detail-modal-panel {
    width: calc(100vw - 20px);
    height: auto;
    min-height: min(240px, calc(100dvh - 20px));
    max-height: min(84dvh, calc(100dvh - 20px), 860px);
    padding: 16px;
    border-radius: 20px;
  }

  /* A mòbil la data passa a sobre i l'import es manté a la dreta del concepte,
     per no forçar tres columnes en amplades estretes. */
  .detail-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 8px;
    padding: 8px 10px;
  }

  .detail-row-date {
    grid-column: 1 / -1;
    order: -1;
  }

  .detail-group-summary {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .detail-group-summary-side {
    justify-items: start;
    white-space: normal;
  }

  .detail-group-body-head {
    justify-content: flex-start;
  }

  .mini-section-head,
  .snapshot-item,
  .expense-radar-row {
    display: grid;
  }

  .monthly-radar-stack {
    grid-template-columns: 1fr;
  }

  .type-share-trend-host .monthly-svg {
    height: 100%;
  }

  .expense-radar-copy {
    gap: 4px;
  }

  .expense-radar-values {
    justify-content: flex-start;
  }

  .full-width-snapshot-list {
    grid-template-columns: 1fr;
  }

  .monthly-review-panel .panel-header p,
  .monthly-highlight-panel .panel-header p {
    text-align: left;
    max-width: none;
  }

  .panel-range-toggle {
    justify-content: flex-start;
  }
}

/* Sidebar navigation refactor */
.app-shell {
  width: min(1480px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.app-content {
  min-width: 0;
}

.app-sidebar {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 18px;
  align-content: start;
  min-height: calc(100dvh - 32px);
  padding: 18px 14px;
  border-radius: 24px;
  border: 1px solid rgba(59, 130, 246, 0.14);
  background: linear-gradient(180deg, #11243d 0%, #152b49 100%);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
}

.sidebar-top {
  display: grid;
  gap: 14px;
}

.sidebar-toggle {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(191, 219, 254, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: #dbeafe;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

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

.sidebar-brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  color: #eff6ff;
  font-size: 20px;
}

.sidebar-brand-copy {
  min-width: 0;
  color: #eff6ff;
}

.sidebar-brand-copy strong,
.sidebar-brand-copy small {
  display: block;
}

.sidebar-brand-copy small {
  margin-top: 2px;
  color: rgba(219, 234, 254, 0.72);
}

.app-sidebar .app-menu {
  margin-top: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  position: static;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.app-sidebar .menu-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  color: rgba(219, 234, 254, 0.82);
  background: transparent;
  border: 1px solid transparent;
  text-align: left;
}

.app-sidebar .menu-button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #eff6ff;
}

.app-sidebar .menu-button.active {
  background: rgba(37, 99, 235, 0.18);
  color: #eff6ff;
  border-color: rgba(147, 197, 253, 0.28);
}

.menu-icon {
  width: 22px;
  min-width: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.menu-label {
  white-space: nowrap;
}

.sidebar-collapsed.app-shell {
  grid-template-columns: 88px minmax(0, 1fr);
}

.sidebar-collapsed .app-sidebar {
  padding-left: 10px;
  padding-right: 10px;
}

.sidebar-collapsed .sidebar-brand-copy,
.sidebar-collapsed .menu-label {
  display: none;
}

.sidebar-collapsed .sidebar-brand {
  justify-content: center;
}

.sidebar-collapsed .sidebar-toggle {
  margin: 0 auto;
}

.sidebar-collapsed .app-sidebar .menu-button {
  justify-content: center;
  padding-left: 10px;
  padding-right: 10px;
}

@media (max-width: 980px) {

  .app-shell,
  .sidebar-collapsed.app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    position: static;
    min-height: 0;
    padding: 14px;
  }

  .sidebar-top {
    grid-template-columns: auto 1fr;
    align-items: center;
  }

  .sidebar-brand-copy,
  .menu-label {
    display: block;
  }

  .app-sidebar .app-menu {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .app-sidebar .menu-button {
    justify-content: flex-start;
  }
}

/* Final sidebar layout: attached to left edge, less floating */
.app-shell,
.sidebar-collapsed.app-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
}

.app-content {
  padding: 28px 28px 48px 20px;
}

.app-sidebar {
  top: 0;
  min-height: 100dvh;
  border-radius: 0 24px 24px 0;
  border-left: 0;
  box-shadow: none;
}

.sidebar-collapsed.app-shell {
  grid-template-columns: 92px minmax(0, 1fr);
}

.sidebar-collapsed .app-sidebar {
  border-radius: 0 20px 20px 0;
}

@media (max-width: 980px) {

  .app-shell,
  .sidebar-collapsed.app-shell {
    grid-template-columns: 1fr;
  }

  .app-content {
    padding: 20px 16px 40px;
  }

  .app-sidebar,
  .sidebar-collapsed .app-sidebar {
    min-height: 0;
    border-radius: 0 0 20px 20px;
  }
}

/* ── Mobile overrides — loaded last, always wins ─────────────────────── */
.mobile-nav-overlay {
  display: none;
}

.mobile-menu-fab {
  display: none;
}

.mobile-drawer-close {
  display: none;
}

@media (max-width: 980px) {

  /* main: disable grid on mobile */
  main {
    display: block !important;
    min-width: 0 !important;
  }

  /* App shell: plain block, no grid columns */
  .app-shell {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    grid-template-columns: none !important;
    gap: 0 !important;
  }

  /* Content: full width, no right padding for desktop filter strip */
  .app-content,
  body:has(.filters-sidebar) .app-content,
  body:has(.filters-sidebar[open]) .app-content {
    padding: 64px 16px 40px !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  /* Filters sidebar: inline, not fixed right strip */
  .filters-sidebar,
  .filters-sidebar[open] {
    position: static !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    z-index: auto !important;
    transition: none !important;
  }

  /* Sidebar: off-canvas drawer */
  .app-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 280px !important;
    height: 100dvh !important;
    min-height: 0 !important;
    padding: 20px 16px !important;
    border-radius: 0 !important;
    border-right: 1px solid #d8e3f3 !important;
    border-left: none !important;
    background: linear-gradient(180deg, #f5f8ff 0%, #eef4ff 100%) !important;
    z-index: 210 !important;
    overflow-y: auto !important;
    transform: translateX(-100%) !important;
    transition: transform 300ms cubic-bezier(0.25, 0.8, 0.25, 1),
      box-shadow 300ms cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
  }

  body.mobile-drawer-open .app-sidebar {
    transform: translateX(0) !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18) !important;
  }

  body.mobile-drawer-open {
    overflow: hidden;
  }

  /* Nav items: vertical list */
  .app-sidebar .app-menu {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    grid-template-columns: none !important;
  }

  .app-sidebar .menu-button {
    justify-content: flex-start !important;
    padding: 12px 14px !important;
    border-radius: 12px !important;
    width: 100% !important;
  }

  /* Overlay */
  .mobile-nav-overlay {
    display: block !important;
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: 209 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 300ms ease !important;
  }

  body.mobile-drawer-open .mobile-nav-overlay {
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  /* Hamburger FAB */
  .mobile-menu-fab {
    display: flex !important;
    position: fixed !important;
    top: 12px !important;
    left: 12px !important;
    z-index: 208 !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 10px !important;
    border: 1px solid #d8e3f3 !important;
    background: #fff !important;
    color: #2563eb !important;
    font-size: 16px !important;
    box-shadow: 0 1px 6px rgba(15, 23, 42, 0.12) !important;
    cursor: pointer;
    transition: opacity 250ms ease !important;
  }

  body.mobile-drawer-open .mobile-menu-fab {
    opacity: 0 !important;
    pointer-events: none !important;
  }

  /* Close button inside drawer */
  .mobile-drawer-close {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 8px !important;
    border: 1px solid #d8e3f3 !important;
    background: #edf3fe !important;
    color: #2563eb !important;
    font-size: 14px !important;
    cursor: pointer;
    margin-left: auto !important;
    flex-shrink: 0 !important;
  }

  /* Hide desktop toggle, always show labels */
  .sidebar-toggle {
    display: none !important;
  }

  .sidebar-brand-copy,
  .menu-label {
    display: block !important;
  }

  .sidebar-cache {
    margin-top: auto !important;
  }

  /* Panel headers: wrap title + nav buttons vertically */
  .panel-header {
    flex-wrap: wrap !important;
    gap: 10px !important;
    align-items: flex-start !important;
  }

  .panel-header>*:first-child {
    flex: 1 1 100% !important;
  }

  .date-navigation-row,
  .panel-date-navigation,
  .panel-range-toggle {
    width: 100% !important;
    margin-left: 0 !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  .date-shift-button,
  .date-current-button,
  .panel-range-button {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    white-space: nowrap !important;
    font-size: 13px !important;
    padding: 8px 10px !important;
  }

  /* Charts: scrollable, not overflowing */
  .chart-block,
  .expense-chart-block,
  .type-share-trend-host,
  .cashflow-line-chart-shell,
  .matrix-wrapper,
  .cashflow-matrix-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Tables: allow wrap, reduce padding */
  th,
  td {
    white-space: normal !important;
    font-size: 13px !important;
    padding: 10px 8px !important;
  }

  /* 4-col stats → 2 cols */
  .member-flow-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* Range summary: 2 cols */
  .range-summary-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    font-size: 12px !important;
  }

  /* Compact cache: no fixed min-width */
  .compact-cache {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Hero: full bleed */
  .hero {
    border-radius: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  /* Cards: smaller radius */
  .panel,
  .status-card,
  .kpi-card {
    border-radius: 12px !important;
  }

  /* Member flow grid: single column */
  .member-flow-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ── Narrow phones (≤ 430px) ─────────────────────────────────────────── */
@media (max-width: 430px) {

  /* KPI grid: 2 cols */
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* Range summary: 1 col */
  .range-summary-row {
    grid-template-columns: 1fr !important;
  }

  /* No child overflows viewport */
  .app-content>* {
    max-width: 100% !important;
    box-sizing: border-box;
  }

  /* Inline filters: stack */
  .inline-filters {
    grid-auto-flow: row !important;
    grid-template-columns: minmax(0, 1fr) !important;
    justify-items: stretch !important;
    gap: 8px !important;
  }

  .inline-filters select,
  .inline-filters input {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Hero text sizes */
  .hero-title {
    font-size: clamp(18px, 5vw, 28px) !important;
  }

  .hero-subtitle {
    font-size: 13px !important;
  }

  /* Date range controls */
  .date-range-controls {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  .member-flow-stats,
  .monthly-type-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ─── Mobile drawer override — loaded last, always wins ─── */
.mobile-nav-overlay {
  display: none;
}

.mobile-menu-fab {
  display: none;
}

.mobile-drawer-close {
  display: none;
}

@media (max-width: 980px) {

  /* 1. App shell becomes a plain block — no grid column for the sidebar */
  .app-shell {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    grid-template-columns: none !important;
    gap: 0 !important;
  }

  /* 2. Content area — full width, no desktop right-padding for filter strip */
  .app-content {
    padding: 64px 16px 40px !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  body:has(.filters-sidebar[open]) .app-content {
    padding-right: 16px !important;
  }

  /* 3. Filters sidebar — inline block, not fixed right strip */
  .filters-sidebar,
  .filters-sidebar[open] {
    position: static !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    z-index: auto !important;
    transition: none !important;
  }

  /* 4. Sidebar — off-canvas drawer */
  .app-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 280px !important;
    height: 100dvh !important;
    min-height: 0 !important;
    padding: 20px 16px !important;
    border-radius: 0 !important;
    border-right: 1px solid #d8e3f3 !important;
    border-left: none !important;
    background: linear-gradient(180deg, #f5f8ff 0%, #eef4ff 100%) !important;
    z-index: 210 !important;
    overflow-y: auto !important;
    transform: translateX(-100%) !important;
    transition: transform 300ms cubic-bezier(0.25, 0.8, 0.25, 1),
      box-shadow 300ms cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
  }

  body.mobile-drawer-open .app-sidebar {
    transform: translateX(0) !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18) !important;
  }

  body.mobile-drawer-open {
    overflow: hidden;
  }

  /* 5. Nav items — full-width vertical list */
  .app-sidebar .app-menu {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    grid-template-columns: none !important;
  }

  .app-sidebar .menu-button {
    justify-content: flex-start !important;
    padding: 12px 14px !important;
    border-radius: 12px !important;
    width: 100% !important;
  }

  /* 6. Overlay */
  .mobile-nav-overlay {
    display: block !important;
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: 209 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 300ms ease !important;
  }

  body.mobile-drawer-open .mobile-nav-overlay {
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  /* 7. Hamburger FAB */
  .mobile-menu-fab {
    display: flex !important;
    position: fixed !important;
    top: 12px !important;
    left: 12px !important;
    z-index: 208 !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 10px !important;
    border: 1px solid #d8e3f3 !important;
    background: #fff !important;
    color: #2563eb !important;
    font-size: 16px !important;
    box-shadow: 0 1px 6px rgba(15, 23, 42, 0.12) !important;
    cursor: pointer;
    transition: opacity 250ms ease !important;
  }

  body.mobile-drawer-open .mobile-menu-fab {
    opacity: 0 !important;
    pointer-events: none !important;
  }

  /* 8. Close button inside drawer */
  .mobile-drawer-close {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 8px !important;
    border: 1px solid #d8e3f3 !important;
    background: #edf3fe !important;
    color: #2563eb !important;
    font-size: 14px !important;
    cursor: pointer;
    margin-left: auto !important;
    flex-shrink: 0 !important;
  }

  /* 9. Hide desktop toggle */
  .sidebar-toggle {
    display: none !important;
  }

  /* 10. Always show labels in drawer */
  .sidebar-brand-copy,
  .menu-label {
    display: block !important;
  }

  /* 11. Status cache at bottom */
  .sidebar-cache {
    margin-top: auto !important;
  }
}

/* (mobile drawer rules moved to end of file) */

/* Final override: rectangular sidebars + right filter drawer */
.hero,
.compact-cache {
  border-radius: 12px;
}

.app-sidebar,
.sidebar-collapsed .app-sidebar {
  border-radius: 0;
  border-right: 1px solid rgba(59, 130, 246, 0.14);
}

.sidebar-top {
  padding-bottom: 2px;
  border-bottom: 1px solid rgba(191, 219, 254, 0.08);
}

.sidebar-toggle,
.sidebar-brand-mark,
.app-sidebar .menu-button,
.app-sidebar .menu-button.active {
  border-radius: 12px;
}

.app-content {
  padding-right: 92px;
}

.filters-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 72px;
  height: 100dvh;
  margin-top: 0;
  padding: 0;
  border-radius: 0;
  border-left: 1px solid rgba(59, 130, 246, 0.14);
  border-right: 0;
  background: linear-gradient(180deg, #11243d 0%, #152b49 100%);
  box-shadow: none;
  overflow: hidden;
  z-index: 30;
  transition: width 160ms ease;
}

.filters-sidebar[open] {
  width: 324px;
}

.filters-sidebar .filters-summary {
  min-height: 72px;
  padding: 16px 14px;
  align-items: center;
  color: #eff6ff;
  border-bottom: 1px solid rgba(191, 219, 254, 0.08);
}

.filters-drawer-icon {
  width: 28px;
  min-width: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.filters-sidebar .filters-summary-main {
  gap: 10px;
  color: inherit;
}

.filters-sidebar .filters-summary-text,
.filters-sidebar .filters-helper-text {
  color: rgba(219, 234, 254, 0.72);
}

.filters-sidebar .filters-actions {
  min-width: auto;
}

.filters-sidebar .icon-ghost-button {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(191, 219, 254, 0.14);
  color: #dbeafe;
}

.filters-sidebar .filters-body {
  padding: 0 14px 18px;
  border-top: 0;
}

.filters-sidebar .filters-grid {
  gap: 12px;
}

.filters-sidebar select,
.filters-sidebar input {
  width: 100%;
  background: rgba(255, 255, 255, 0.92);
}

.filters-sidebar:not([open]) .filters-summary {
  justify-content: center;
}

.filters-sidebar:not([open]) .filters-summary-main strong,
.filters-sidebar:not([open]) .filters-summary-text,
.filters-sidebar:not([open]) .filters-actions,
.filters-sidebar:not([open]) .filters-body {
  display: none;
}

/* Absolute final stabilization override */
.app-shell,
.sidebar-collapsed.app-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
}

.sidebar-collapsed.app-shell {
  grid-template-columns: 92px minmax(0, 1fr);
}

.app-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
  border: 0;
  border-right: 1px solid #d8e3f3;
  border-radius: 0;
  background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
  box-shadow: none;
  overflow: hidden;
}

.sidebar-top {
  display: grid;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #dbe3f0;
}

.app-sidebar .app-menu {
  margin-top: 0;
  flex: 1 1 auto;
  padding: 0;
  display: grid;
  gap: 8px;
  position: static;
  top: auto;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.app-sidebar .menu-button {
  min-height: 52px;
  border-radius: 14px;
  color: #4f6480;
}

.app-sidebar .menu-button:hover {
  background: #edf3fe;
  color: var(--text);
}

.app-sidebar .menu-button.active {
  background: #ddeafe;
  color: #1f3f74;
  border-color: #b9d1fb;
}

.sidebar-toggle {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border-color: #d8e3f3;
  background: #edf3fe;
  color: #48617f;
}

.sidebar-brand-mark {
  border-radius: 12px;
  background: #edf3fe;
  color: var(--primary);
}

.sidebar-brand-copy {
  color: var(--text);
}

.sidebar-brand-copy small {
  color: var(--muted);
}

.sidebar-cache {
  position: static !important;
  margin-top: auto !important;
  width: 100%;
  min-width: 0;
  max-width: none;
  border-radius: 16px;
  overflow: hidden;
}

.sidebar-collapsed .sidebar-cache {
  display: none;
}

.app-content {
  min-width: 0;
  padding: 24px 92px 48px 20px;
}

.hero {
  position: static !important;
  top: auto;
  margin-top: 24px;
  padding: 24px 28px;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  box-shadow: none;
}

.filters-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 72px;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid #d8e3f3;
  border-radius: 0;
  background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
  box-shadow: none;
  overflow: hidden;
  z-index: 30;
  transition: width 160ms ease;
}

.filters-sidebar[open] {
  width: 324px;
}

.filters-sidebar summary {
  list-style: none;
  cursor: pointer;
}

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

.filters-sidebar .filters-summary {
  min-height: 72px;
  padding: 16px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
  border-bottom: 1px solid #dbe3f0;
  background: transparent;
}

.filters-sidebar .filters-summary-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.filters-sidebar .filters-summary-text,
.filters-sidebar .filters-helper-text {
  color: var(--muted);
}

.filters-sidebar .filters-body {
  display: grid;
  gap: 16px;
  padding: 16px 14px 18px;
  border-top: 0;
}

.filters-sidebar .filters-grid {
  gap: 12px;
}

.filters-sidebar select,
.filters-sidebar input {
  width: 100%;
  background: #ffffff;
  border-color: #d8e3f3;
}

.filters-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid #dbe3f0;
}

.filters-sidebar:not([open]) .filters-summary {
  justify-content: center;
}

.filters-sidebar:not([open]) .filters-summary-main strong,
.filters-sidebar:not([open]) .filters-summary-text,
.filters-sidebar:not([open]) .filters-body {
  display: none;
}

body:has(.filters-sidebar[open]) .app-content {
  padding-right: 344px;
}

@media (max-width: 980px) {

  .app-shell,
  .sidebar-collapsed.app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    position: static;
    min-height: 0;
  }

  .app-content,
  body:has(.filters-sidebar[open]) .app-content {
    padding: 20px 16px 40px;
  }

  .hero {
    margin-top: 20px;
  }

  .filters-sidebar,
  .filters-sidebar[open] {
    position: static;
    width: 100%;
    height: auto;
    min-height: 0;
  }
}

/* Layout stabilization after the latest sidebar refactor */
.app-shell,
.sidebar-collapsed.app-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
}

.sidebar-collapsed.app-shell {
  grid-template-columns: 92px minmax(0, 1fr);
}

.app-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
  border: 0;
  border-right: 1px solid #d8e3f3;
  border-radius: 0;
  background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
  box-shadow: none;
  overflow: hidden;
}

.sidebar-top {
  display: grid;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #dbe3f0;
}

.app-sidebar .app-menu {
  margin-top: 0;
  flex: 1 1 auto;
  padding: 0;
  display: grid;
  gap: 8px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.app-sidebar .menu-button {
  min-height: 52px;
  border-radius: 14px;
}

.sidebar-cache {
  position: static !important;
  margin-top: auto !important;
  width: 100%;
  min-width: 0;
  max-width: none;
  border-radius: 16px;
  overflow: hidden;
}

.sidebar-collapsed .sidebar-cache {
  display: none;
}

.app-content {
  min-width: 0;
  padding: 24px 92px 48px 20px;
}

body:has(.filters-sidebar[open]) .app-content {
  padding-right: 344px;
}

.hero {
  position: static !important;
  top: auto;
  margin-top: 24px;
  padding: 24px 28px;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  box-shadow: none;
}

.filters-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 72px;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid #d8e3f3;
  border-radius: 0;
  background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
  box-shadow: none;
  overflow: hidden;
  z-index: 30;
  transition: width 160ms ease;
}

.filters-sidebar[open] {
  width: 324px;
}

.filters-sidebar summary {
  list-style: none;
  cursor: pointer;
}

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

.filters-sidebar .filters-summary {
  min-height: 72px;
  padding: 16px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
  border-bottom: 1px solid #dbe3f0;
  background: transparent;
}

.filters-sidebar .filters-summary-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.filters-sidebar .filters-summary-text,
.filters-sidebar .filters-helper-text {
  color: var(--muted);
}

.filters-sidebar .filters-body {
  display: grid;
  gap: 16px;
  padding: 16px 14px 18px;
  border-top: 0;
}

.filters-sidebar .filters-grid {
  gap: 12px;
}

.filters-sidebar select,
.filters-sidebar input {
  width: 100%;
  background: #ffffff;
  border-color: #d8e3f3;
}

.filters-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid #dbe3f0;
}

.filters-sidebar:not([open]) .filters-summary {
  justify-content: center;
}

.filters-sidebar:not([open]) .filters-summary-main strong,
.filters-sidebar:not([open]) .filters-summary-text,
.filters-sidebar:not([open]) .filters-body {
  display: none;
}

@media (max-width: 980px) {

  .app-shell,
  .sidebar-collapsed.app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    position: static;
    min-height: 0;
  }

  .app-content,
  body:has(.filters-sidebar[open]) .app-content {
    padding: 20px 16px 40px;
  }

  .hero {
    margin-top: 20px;
  }

  .filters-sidebar,
  .filters-sidebar[open] {
    position: static;
    width: 100%;
    height: auto;
    min-height: 0;
  }
}

@media (max-width: 980px) {
  .app-content {
    padding-right: 16px;
  }

  .filters-sidebar,
  .filters-sidebar[open] {
    position: static;
    width: 100%;
    height: auto;
    min-height: 0;
    margin-top: 20px;
    border-left: 1px solid rgba(59, 130, 246, 0.14);
  }
}

/* Final visual theme for family accounting sidebars */
.app-sidebar {
  background: linear-gradient(180deg, #f5f8ff 0%, #eef4ff 100%);
  border-right: 1px solid #d8e3f3;
  color: var(--text);
}

.sidebar-top {
  border-bottom: 1px solid #dbe3f0;
}

.sidebar-toggle {
  border-color: #d8e3f3;
  background: #edf3fe;
  color: #48617f;
}

.sidebar-brand-mark {
  background: #edf3fe;
  color: var(--primary);
}

.sidebar-brand-copy {
  color: var(--text);
}

.sidebar-brand-copy small {
  color: var(--muted);
}

.app-sidebar .menu-button {
  color: #4f6480;
}

.app-sidebar .menu-button:hover {
  background: #edf3fe;
  color: var(--text);
}

.app-sidebar .menu-button.active {
  background: #ddeafe;
  color: #1f3f74;
  border-color: #b9d1fb;
}

.filters-sidebar {
  background: linear-gradient(180deg, #f7faff 0%, #eff4fd 100%);
  border-left: 1px solid #d8e3f3;
}

.filters-sidebar .filters-summary {
  color: var(--text);
  border-bottom: 1px solid #dbe3f0;
}

.filters-sidebar .filters-summary-text,
.filters-sidebar .filters-helper-text {
  color: var(--muted);
}

.filters-sidebar .icon-ghost-button {
  background: #edf3fe;
  border-color: #d8e3f3;
  color: #48617f;
}

.filters-sidebar select,
.filters-sidebar input {
  background: #ffffff;
  border-color: #d8e3f3;
}

body:has(.filters-sidebar[open]) .app-content {
  padding-right: 344px;
}

@media (max-width: 980px) {
  body:has(.filters-sidebar[open]) .app-content {
    padding-right: 16px;
  }
}

/* Final refinement: header fixed, cache in left sidebar, filter drawer footer buttons */
.app-sidebar {
  display: flex;
  flex-direction: column;
}

.hero {
  position: static;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.sidebar-cache {
  position: static;
  margin-top: auto;
  min-width: 0;
  max-width: none;
  border-radius: 12px;
}

.sidebar-collapsed .sidebar-cache {
  padding: 10px;
}

.sidebar-collapsed .sidebar-cache .compact-cache-body,
.sidebar-collapsed .sidebar-cache .compact-cache-tag span:last-child {
  display: none;
}

.sidebar-collapsed .sidebar-cache .compact-cache-head {
  justify-content: center;
}

.sidebar-toggle {
  width: 40px;
  height: 40px;
}

.filters-footer {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #dbe3f0;
}

.filters-sidebar .filters-body {
  padding: 0 14px 18px;
  border-top: 0;
}

.filters-sidebar:not([open]) .filters-body {
  display: none;
}

/* Absolute final stabilization override */
.app-shell,
.sidebar-collapsed.app-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
}

.sidebar-collapsed.app-shell {
  grid-template-columns: 92px minmax(0, 1fr);
}

.app-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
  border: 0;
  border-right: 1px solid #d8e3f3;
  border-radius: 0;
  background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
  box-shadow: none;
  overflow: hidden;
}

.sidebar-top {
  display: grid;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #dbe3f0;
}

.app-sidebar .app-menu {
  margin-top: 0;
  flex: 1 1 auto;
  padding: 0;
  display: grid;
  gap: 8px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.app-sidebar .menu-button {
  min-height: 52px;
  border-radius: 14px;
  color: #4f6480;
}

.app-sidebar .menu-button:hover {
  background: #edf3fe;
  color: var(--text);
}

.app-sidebar .menu-button.active {
  background: #ddeafe;
  color: #1f3f74;
  border-color: #b9d1fb;
}

.sidebar-toggle {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border-color: #d8e3f3;
  background: #edf3fe;
  color: #48617f;
}

.sidebar-brand-mark {
  border-radius: 12px;
  background: #edf3fe;
  color: var(--primary);
}

.sidebar-brand-copy {
  color: var(--text);
}

.sidebar-brand-copy small {
  color: var(--muted);
}

.sidebar-cache {
  position: static !important;
  margin-top: auto !important;
  width: 100%;
  min-width: 0;
  max-width: none;
  border-radius: 16px;
  overflow: hidden;
}

.sidebar-collapsed .sidebar-cache {
  display: none;
}

.app-content {
  min-width: 0;
  padding: 24px 92px 48px 20px;
}

.hero {
  position: static !important;
  top: auto;
  margin-top: 24px;
  padding: 24px 28px;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  box-shadow: none;
}

.filters-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 72px;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid #d8e3f3;
  border-radius: 0;
  background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
  box-shadow: none;
  overflow: hidden;
  z-index: 30;
  transition: width 160ms ease;
}

.filters-sidebar[open] {
  width: 324px;
}

.filters-sidebar summary {
  list-style: none;
  cursor: pointer;
}

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

.filters-sidebar .filters-summary {
  min-height: 72px;
  padding: 16px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
  border-bottom: 1px solid #dbe3f0;
  background: transparent;
}

.filters-sidebar .filters-summary-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.filters-sidebar .filters-summary-text,
.filters-sidebar .filters-helper-text {
  color: var(--muted);
}

.filters-sidebar .filters-body {
  display: grid;
  gap: 16px;
  padding: 16px 14px 18px;
  border-top: 0;
}

.filters-sidebar .filters-grid {
  gap: 12px;
}

.filters-sidebar select,
.filters-sidebar input {
  width: 100%;
  background: #ffffff;
  border-color: #d8e3f3;
}

.filters-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid #dbe3f0;
}

.filters-sidebar:not([open]) .filters-summary {
  justify-content: center;
}

.filters-sidebar:not([open]) .filters-summary-main strong,
.filters-sidebar:not([open]) .filters-summary-text,
.filters-sidebar:not([open]) .filters-body {
  display: none;
}

body:has(.filters-sidebar[open]) .app-content {
  padding-right: 344px;
}

@media (max-width: 980px) {

  .app-shell,
  .sidebar-collapsed.app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    position: static;
    min-height: 0;
  }

  .app-content,
  body:has(.filters-sidebar[open]) .app-content {
    padding: 20px 16px 40px;
  }

  .hero {
    margin-top: 20px;
  }

  .filters-sidebar,
  .filters-sidebar[open] {
    position: static;
    width: 100%;
    height: auto;
    min-height: 0;
  }
}

/* Last small fixes */
.app-sidebar .app-menu {
  position: static;
  top: auto;
}

.status-card.sidebar-cache {
  box-shadow: none;
}

/* Final sidebar and filter polish */
.app-sidebar {
  padding: 14px 12px;
}

.sidebar-top {
  gap: 12px;
  padding-bottom: 10px;
}

.sidebar-brand {
  gap: 10px;
}

.sidebar-brand-copy strong {
  font-size: 1rem;
}

.app-sidebar .menu-button {
  min-height: 44px;
  padding: 10px 12px;
  gap: 10px;
  font-weight: 600;
}

.menu-icon {
  width: 18px;
  min-width: 18px;
  font-size: 15px;
}

.hero {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--panel-border);
  box-shadow: none;
}

.filters-sidebar,
.filters-sidebar[open] {
  border-left-color: #d8e3f3;
}

.filters-sidebar {
  width: 56px;
}

.filters-sidebar[open] {
  width: 316px;
}

.app-content {
  padding-right: 76px;
}

body:has(.filters-sidebar[open]) .app-content {
  padding-right: 336px;
}

.filters-sidebar .filters-summary {
  min-height: 64px;
  padding: 14px 10px;
}

.filters-sidebar:not([open]) .filters-summary {
  padding-inline: 0;
}

.filters-sidebar .filters-grid {
  display: grid;
  gap: 12px;
}

.filters-sidebar label {
  display: block;
}

.filters-sidebar select,
.filters-sidebar input {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid #d8e3f3;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.filters-sidebar select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #64748b 50%),
    linear-gradient(135deg, #64748b 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.filters-sidebar select:focus,
.filters-sidebar input:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(147, 197, 253, 0.22);
}

#resetFiltersButton {
  background: #fdecec;
  border-color: #f5c7c7;
  color: #b42318;
}

#resetFiltersButton:hover {
  background: #fbdede;
}

.expense-radar-item.clickable {
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.expense-radar-item.clickable:hover,
.expense-radar-item.clickable:focus-visible {
  border-color: #93c5fd;
  background: #f8fbff;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.08);
}

@media (max-width: 980px) {

  .app-content,
  body:has(.filters-sidebar[open]) .app-content {
    padding-right: 16px;
  }

  .filters-sidebar,
  .filters-sidebar[open] {
    width: 100%;
  }
}

/* Sidebar size tuning */
.app-shell {
  grid-template-columns: 224px minmax(0, 1fr);
}

.sidebar-collapsed.app-shell {
  grid-template-columns: 60px minmax(0, 1fr);
}

.app-sidebar {
  padding: 10px 6px;
  gap: 12px;
}

.sidebar-top {
  gap: 10px;
  padding-bottom: 8px;
}

.sidebar-toggle {
  width: 32px;
  height: 32px;
  margin-inline: auto;
}

.sidebar-brand {
  gap: 8px;
  padding: 0 4px;
}

.sidebar-brand-mark {
  width: 32px;
  height: 32px;
  min-width: 32px;
  font-size: 16px;
}

.sidebar-brand-copy strong {
  font-size: 0.95rem;
}

.sidebar-brand-copy small {
  font-size: 0.8rem;
}

.app-sidebar .menu-button {
  min-height: 38px;
  padding: 8px 10px;
  gap: 8px;
  border-radius: 12px;
}

.menu-icon {
  width: 16px;
  min-width: 16px;
  font-size: 14px;
}

.menu-label {
  font-size: 0.92rem;
}

.sidebar-cache {
  padding: 10px;
  border-radius: 14px;
}

.sidebar-collapsed .app-sidebar {
  padding-inline: 4px;
}

.sidebar-collapsed .sidebar-toggle {
  margin-inline: auto;
}

.sidebar-collapsed .app-sidebar .menu-button {
  min-height: 36px;
  width: 100%;
  padding: 8px 0;
  justify-content: center;
}

.sidebar-collapsed .menu-icon {
  width: 14px;
  min-width: 14px;
  font-size: 13px;
}

/* Menu height + collapsed filters width tuning */
.app-shell {
  grid-template-columns: 260px minmax(0, 1fr);
}

.app-sidebar .menu-button {
  min-height: 32px;
  padding: 6px 10px;
  gap: 8px;
  align-items: center;
}

.app-sidebar .menu-button.active {
  min-height: 32px;
}

.menu-label {
  font-size: 0.9rem;
  line-height: 1.15;
}

.menu-icon {
  width: 15px;
  min-width: 15px;
  font-size: 13px;
}

.filters-sidebar {
  width: 44px;
}

.app-content {
  padding-right: 64px;
}

body:has(.filters-sidebar[open]) .app-content {
  padding-right: 336px;
}

.filters-sidebar:not([open]) .filters-summary {
  min-height: 56px;
}

.filters-drawer-icon {
  width: 22px;
  min-width: 22px;
  font-size: 14px;
}

/* Gmail-like left navigation refinement */
.app-sidebar {
  background: linear-gradient(180deg, #f7faff 0%, #eef4ff 100%);
  border-right: 1px solid #dbe3f0;
  padding: 12px 8px;
  gap: 14px;
}

.sidebar-top {
  gap: 12px;
  padding: 0 4px 10px;
}

.sidebar-toggle {
  width: 36px;
  height: 36px;
  margin: 0 0 2px 4px;
  border-radius: 18px;
  background: #edf3fe;
  border: 1px solid #d7e4fb;
  color: #506580;
}

.sidebar-brand {
  padding: 0 8px;
  gap: 10px;
}

.sidebar-brand-mark {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 50%;
  background: #e8f0fe;
  color: #1a73e8;
  font-size: 15px;
}

.sidebar-brand-copy strong {
  font-size: 0.98rem;
  font-weight: 700;
}

.sidebar-brand-copy small {
  font-size: 0.82rem;
}

.app-sidebar .app-menu {
  gap: 4px;
}

.app-sidebar .menu-button {
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 0 18px 18px 0;
  margin-right: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: #48617f;
  font-weight: 600;
  box-shadow: none;
}

.app-sidebar .menu-button:hover {
  background: #edf3fe;
  color: #16365f;
}

.app-sidebar .menu-button.active {
  background: #d3e3fd;
  color: #0b57d0;
  border-color: transparent;
  box-shadow: none;
}

.menu-icon {
  width: 18px;
  min-width: 18px;
  font-size: 14px;
}

.menu-label {
  font-size: 0.92rem;
  line-height: 1.1;
}

.sidebar-cache {
  margin: 8px 8px 0;
}

.sidebar-collapsed.app-shell {
  grid-template-columns: 72px minmax(0, 1fr);
}

.sidebar-collapsed .app-sidebar {
  padding-inline: 8px;
}

.sidebar-collapsed .sidebar-top {
  padding-inline: 0;
}

.sidebar-collapsed .sidebar-toggle {
  margin-inline: auto;
}

.sidebar-collapsed .sidebar-brand {
  padding: 0;
}

.sidebar-collapsed .app-sidebar .menu-button {
  min-height: 36px;
  margin-right: 0;
  padding: 8px 0;
  border-radius: 18px;
  justify-content: center;
}

.sidebar-collapsed .menu-icon {
  width: 16px;
  min-width: 16px;
}

/* Gmail-like nav sizing fix */
.app-sidebar {
  padding: 10px 8px;
}

.sidebar-top {
  gap: 10px;
  padding: 0 6px 8px;
}

.app-sidebar .app-menu {
  gap: 2px;
}

.app-sidebar .menu-button,
.app-sidebar .menu-button.active {
  min-height: 0;
  height: 32px;
  padding: 0 14px;
  margin-right: 10px;
  border: 0;
  border-radius: 0 16px 16px 0;
  font-weight: 600;
}

.app-sidebar .menu-button {
  background: transparent;
}

.app-sidebar .menu-button:hover {
  background: #eef3fd;
}

.app-sidebar .menu-button.active {
  background: #d3e3fd;
}

.menu-icon {
  width: 18px;
  min-width: 18px;
  font-size: 14px;
}

.menu-label {
  font-size: 0.96rem;
  line-height: 1;
}

.sidebar-collapsed.app-shell {
  grid-template-columns: 68px minmax(0, 1fr);
}

.sidebar-collapsed .app-sidebar .menu-button,
.sidebar-collapsed .app-sidebar .menu-button.active {
  height: 32px;
  width: 32px;
  min-height: 32px;
  padding: 0;
  margin: 0 auto;
  border-radius: 16px;
}

/* Sidebar spacing refinement */
.app-sidebar {
  padding: 12px 10px;
  gap: 10px;
}

.sidebar-top {
  gap: 8px;
  padding: 0 8px 8px;
}

.app-sidebar .app-menu {
  gap: 0;
}

.app-sidebar .menu-button,
.app-sidebar .menu-button.active {
  margin-right: 2px;
  margin-bottom: 2px;
}

.sidebar-cache {
  margin: 10px 2px 0;
  padding: 12px;
}

.sidebar-cache .compact-cache-head {
  gap: 10px;
}

.sidebar-cache .compact-cache-body {
  padding-inline: 2px;
}

/* Fix nav buttons stretching vertically on large screens */
.app-sidebar .app-menu {
  flex: 0 0 auto;
  align-content: start;
  align-items: start;
  grid-auto-rows: max-content;
}

/* Move sidebar toggle inline with brand */
.sidebar-brand {
  align-items: center;
}

.sidebar-toggle {
  margin-left: auto;
  margin-right: 0;
}

.sidebar-collapsed .sidebar-brand {
  justify-content: center;
}

.sidebar-collapsed .sidebar-toggle {
  margin: 0 auto;
}

/* Sidebar collapsed brand hiding + slightly larger nav buttons */
.app-sidebar .menu-button,
.app-sidebar .menu-button.active {
  height: 36px;
  min-height: 36px;
}

.sidebar-collapsed .sidebar-brand {
  display: none;
}

.sidebar-collapsed .app-sidebar .menu-button,
.sidebar-collapsed .app-sidebar .menu-button.active {
  width: 36px;
  height: 36px;
  min-height: 36px;
  border-radius: 18px;
}

/* Keep collapsed sidebar toggle visible at bottom-left */
.sidebar-collapsed .sidebar-brand {
  display: flex;
  margin-top: auto;
  padding: 0 0 8px;
  justify-content: flex-start;
}

.sidebar-collapsed .sidebar-brand-mark,
.sidebar-collapsed .sidebar-brand-copy {
  display: none;
}

.sidebar-collapsed .sidebar-toggle {
  margin: 0;
}

/* Collapsed toggle pinned to bottom-left */
.sidebar-collapsed .sidebar-top {
  padding: 0;
  border-bottom: 0;
}

.sidebar-collapsed .sidebar-brand {
  display: block;
  margin: 0;
  padding: 0;
}

.sidebar-collapsed .sidebar-toggle {
  position: absolute;
  left: 12px;
  bottom: 12px;
  margin: 0;
}

/* Google-like filter search drawer */
.filters-sidebar {
  width: 40px;
}

.app-content {
  padding-right: 60px;
}

body:has(.filters-sidebar[open]) .app-content {
  padding-right: 336px;
}

.filters-sidebar .filters-summary {
  min-height: 56px;
  padding: 8px;
}

.filters-search-shell {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-radius: 20px;
  background: #edf3fd;
  border: 1px solid #d8e3f3;
  color: #48617f;
}

.filters-search-icon {
  width: 18px;
  min-width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #5f6f86;
}

.filters-search-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.filters-search-copy strong {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.filters-search-copy .filters-summary-text {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.82rem;
}

.filters-drawer-icon {
  margin-left: auto;
  width: 18px;
  min-width: 18px;
  font-size: 14px;
  color: #5f6f86;
}

.filters-sidebar:not([open]) .filters-summary {
  justify-content: center;
  padding: 6px 4px;
}

.filters-sidebar:not([open]) .filters-search-shell {
  width: 32px;
  min-height: 32px;
  padding: 0;
  justify-content: center;
  border-radius: 16px;
}

.filters-sidebar:not([open]) .filters-search-copy,
.filters-sidebar:not([open]) .filters-drawer-icon {
  display: none;
}

.filters-sidebar .filters-body {
  gap: 14px;
  padding: 12px 14px 18px;
}

.filters-search-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 22px;
  background: #edf3fd;
  border: 1px solid #d8e3f3;
}

.filters-search-panel input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 42px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.filters-search-panel input:focus {
  box-shadow: none;
}

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

.filters-sidebar select {
  min-height: 42px;
  border-radius: 12px;
  background-color: #fff;
}

.filters-sidebar label {
  position: relative;
}

.filters-sidebar[open] .filters-summary {
  padding: 10px 12px;
}

@media (max-width: 980px) {

  .app-content,
  body:has(.filters-sidebar[open]) .app-content {
    padding-right: 16px;
  }

  .filters-sidebar,
  .filters-sidebar[open] {
    width: 100%;
  }

  .filters-sidebar:not([open]) .filters-search-copy,
  .filters-sidebar:not([open]) .filters-drawer-icon {
    display: block;
  }

  .filters-sidebar:not([open]) .filters-search-shell {
    width: 100%;
    justify-content: flex-start;
    padding: 0 12px;
    border-radius: 20px;
  }
}

/* Top search-bar filters layout */
.app-content {
  padding-right: 20px;
}

body:has(.filters-sidebar[open]) .app-content {
  padding-right: 20px;
}

.filters-sidebar {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  width: min(100%, 980px);
  margin: 20px 0 8px;
  border: 0;
  background: transparent;
  overflow: visible;
  z-index: 20;
}

.filters-sidebar[open] {
  width: min(100%, 980px);
}

.filters-sidebar .filters-summary {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.filters-search-shell {
  min-height: 52px;
  border-radius: 26px;
  background: #edf3fd;
  border: 1px solid #d8e3f3;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.filters-sidebar .filters-body {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: min(720px, calc(100vw - 360px));
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.14);
}

.filters-sidebar:not([open]) .filters-body {
  display: none;
}

.filters-search-panel {
  background: #f8fbff;
}

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

.filters-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 0;
}

#resetFiltersButton {
  min-width: 180px;
}

@media (max-width: 1100px) {

  .filters-sidebar,
  .filters-sidebar[open] {
    width: 100%;
  }

  .filters-sidebar .filters-body {
    width: min(720px, calc(100vw - 64px));
  }
}

@media (max-width: 760px) {
  .filters-sidebar .filters-body {
    position: static;
    width: 100%;
    margin-top: 10px;
  }

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

/* Canonical filters drawer override */
.filters-sidebar {
  position: relative;
  width: min(100%, 980px);
  margin: 20px 0 8px;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
  z-index: 30;
}

.filters-sidebar .filters-summary {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.filters-sidebar .filters-search-shell {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-radius: 26px;
  border: 1px solid #d8e3f3;
  background: #edf3fd;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.filters-sidebar .filters-search-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
  text-align: left;
}

.filters-sidebar .filters-summary-text,
.filters-sidebar .filters-helper-text {
  color: var(--muted);
}

.filters-sidebar .filters-drawer-icon {
  margin-left: auto;
  color: #5f6f86;
}

.filters-sidebar .filters-body {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: min(720px, 100%);
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.14);
}

.filters-sidebar:not([open]) .filters-body {
  display: none;
}

.filters-sidebar .filters-search-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 22px;
  border: 1px solid #d8e3f3;
  background: #f8fbff;
}

.filters-sidebar .filters-search-panel input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 42px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.filters-sidebar .filters-search-panel input:focus {
  box-shadow: none;
}

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

.filters-sidebar label {
  position: relative;
}

.filters-sidebar select {
  min-height: 42px;
  border-radius: 12px;
  background: #fff;
}

.filters-sidebar .filters-footer {
  display: flex;
  justify-content: flex-end;
}

body:has(.filters-sidebar[open]) .app-content {
  padding-right: 20px;
}

@media (max-width: 760px) {
  .filters-sidebar .filters-body {
    position: static;
    width: 100%;
    margin-top: 10px;
  }

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

/* Gmail-like finance search header */
#filtersPanel.filters-sidebar {
  position: relative;
  width: min(100%, 980px);
  margin: 20px 0 24px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  z-index: 40;
}

#filtersPanel.filters-sidebar>.filters-summary {
  list-style: none;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

#filtersPanel.filters-sidebar>.filters-summary::-webkit-details-marker {
  display: none;
}

#filtersPanel .filters-search-shell {
  width: 100%;
  min-height: 56px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  border: 1px solid #d8e3f3;
  border-radius: 28px;
  background: linear-gradient(180deg, #eef5ff 0%, #e8f0fe 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 8px 18px rgba(37, 99, 235, 0.06);
  transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

#filtersPanel:hover .filters-search-shell,
#filtersPanel[open] .filters-search-shell {
  border-color: #bfd4f6;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 16px 36px rgba(15, 23, 42, 0.08);
}

#filtersPanel[open] .filters-search-shell {
  background: linear-gradient(180deg, #eff5ff 0%, #edf4ff 100%);
}

#filtersPanel .filters-search-icon {
  width: 20px;
  min-width: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #56708f;
  font-size: 15px;
}

#filtersPanel .filters-search-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

#filtersPanel .filters-search-copy strong {
  color: #1f3352;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.1;
}

#filtersPanel .filters-summary-text {
  display: block;
  min-width: 0;
  color: #60758f;
  font-size: 0.84rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#filtersPanel .filters-summary-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid #cfe0f8;
  background: rgba(255, 255, 255, 0.72);
  color: #395575;
  font-size: 0.82rem;
  font-weight: 600;
}

#filtersPanel .filters-drawer-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid #cfe0f8;
  color: #395575;
  font-size: 14px;
  margin-left: 0;
}

#filtersPanel .filters-body {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: min(760px, 100%);
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid #d7e3f3;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.14);
}

#filtersPanel:not([open]) .filters-body {
  display: none;
}

#filtersPanel .filters-search-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 22px;
  border: 1px solid #dce7f7;
  background: #f7faff;
}

#filtersPanel .filters-search-panel input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #23395b;
  box-shadow: none;
}

#filtersPanel .filters-search-panel input::placeholder {
  color: #7b8da5;
}

#filtersPanel .filters-helper-text {
  margin: 0;
  color: #62748c;
  font-size: 0.9rem;
  line-height: 1.45;
}

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

#filtersPanel .filters-grid label {
  display: block;
}

#filtersPanel .filters-grid select {
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid #d7e3f3;
  background: #fff;
}

#filtersPanel .filters-footer {
  display: flex;
  justify-content: flex-end;
}

#filtersPanel #resetFiltersButton {
  min-width: 180px;
  border-radius: 14px;
}

@media (max-width: 760px) {
  #filtersPanel .filters-search-shell {
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 0 14px;
  }

  #filtersPanel .filters-summary-hint {
    display: none;
  }

  #filtersPanel .filters-body {
    position: static;
    width: 100%;
    margin-top: 10px;
  }

  #filtersPanel .filters-grid {
    grid-template-columns: 1fr;
  }
}

/* Monthly executive layout overrides */
.monthly-radar-grid,
.monthly-type-trend-panel,
.monthly-highlight-panel {
  margin-top: 20px;
}

.flow-summary-card.clickable {
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.flow-summary-card.clickable:hover,
.flow-summary-card.clickable:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(98, 154, 255, 0.42);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  outline: none;
}

.monthly-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  column-count: initial;
  column-gap: 0;
  gap: 20px;
  align-items: start;
}

.type-pocket-card {
  display: grid;
  width: 100%;
  margin: 0;
  break-inside: auto;
  -webkit-column-break-inside: auto;
  page-break-inside: auto;
}

.type-pocket-card.type-variant-fixed {
  background: linear-gradient(180deg, #ffffff 0%, var(--type-despesa-fixa-soft) 100%);
  border-color: rgba(132, 151, 173, 0.28);
}

.type-pocket-card.type-variant-fixed .type-pocket-icon {
  background: var(--type-despesa-fixa-soft);
  border-color: rgba(132, 151, 173, 0.32);
  color: var(--type-despesa-fixa-strong);
}

.type-pocket-card.type-variant-needed {
  background: linear-gradient(180deg, #ffffff 0%, var(--type-despesa-necesaria-soft) 100%);
  border-color: rgba(144, 133, 184, 0.28);
}

.type-pocket-card.type-variant-needed .type-pocket-icon {
  background: var(--type-despesa-necesaria-soft);
  border-color: rgba(144, 133, 184, 0.32);
  color: var(--type-despesa-necesaria-strong);
}

.type-pocket-card.type-variant-discretionary {
  background: linear-gradient(180deg, #ffffff 0%, var(--type-despesa-discrecional-soft) 100%);
  border-color: rgba(167, 153, 199, 0.32);
}

.type-pocket-card.type-variant-discretionary .type-pocket-icon {
  background: var(--type-despesa-discrecional-soft);
  border-color: rgba(167, 153, 199, 0.32);
  color: var(--type-despesa-discrecional-strong);
}

@media (max-width: 1100px) {
  .monthly-type-grid {
    grid-template-columns: 1fr;
  }
}

/* Monthly semantic color system */
.traffic-scale {
  background: linear-gradient(90deg, #cfe8ff 0%, #7db7e8 48%, #d83a52 100%);
}

.range-track-line.traffic-scale,
.expense-radar-track.traffic-scale {
  background: linear-gradient(90deg, rgba(173, 214, 247, 0.72) 0%, rgba(89, 148, 204, 0.48) 48%, rgba(216, 58, 82, 0.3) 100%);
}

.expense-radar-track.traffic-scale {
  background: linear-gradient(90deg, rgba(207, 232, 255, 0.96) 0%, rgba(125, 183, 232, 0.68) 55%, rgba(216, 58, 82, 0.26) 100%);
}

.range-average-marker {
  background: rgba(34, 52, 74, 0.6);
}

.range-current-marker.signal-low,
.expense-radar-fill.signal-low,
.expense-radar-marker.signal-low {
  background: #8fd3ff;
}

.expense-radar-fill.signal-low,
.expense-radar-marker.signal-low {
  background: #8fd3ff;
}

.range-current-marker.signal-mid,
.expense-radar-fill.signal-mid,
.expense-radar-marker.signal-mid {
  background: #2f6fae;
}

.range-current-marker.signal-high,
.expense-radar-fill.signal-high,
.expense-radar-marker.signal-high {
  background: #d83a52;
}

.expense-radar-fill.signal-low {
  background: linear-gradient(90deg, #d7efff, #8fd3ff);
}

.expense-radar-fill.signal-mid {
  background: linear-gradient(90deg, #4d86c1, #2f6fae);
}

.expense-radar-fill.signal-high {
  background: linear-gradient(90deg, #f06b81, #d83a52);
}

.status-pill.signal-low {
  background: #eaf6ff;
  color: #2d6b9e;
}

.expense-radar-item .status-pill.signal-low {
  background: #eaf6ff;
  color: #2d6b9e;
}

.status-pill.signal-mid {
  background: #e7f0fa;
  color: #24507d;
}

.status-pill.signal-high {
  background: #fdecef;
  color: #b4233a;
}

.expense-radar-item.signal-low {
  border-color: rgba(143, 211, 255, 0.42);
  background: #f7fbff;
}

.expense-radar-item.signal-mid {
  border-color: rgba(47, 111, 174, 0.28);
  background: #f5f9fd;
}

.expense-radar-item.signal-high {
  border-color: rgba(216, 58, 82, 0.34);
  background: #fff7f9;
}

.type-pocket-card {
  --type-accent: #64748b;
  --type-accent-strong: #42556c;
  --type-accent-soft: #f4f7fb;
  --type-border-strong: #cfd8e3;
  --type-category-bg: rgba(247, 249, 252, 0.98);
  --type-item-bg: #ffffff;
  --type-item-border: rgba(148, 163, 184, 0.26);
  background: linear-gradient(180deg, #ffffff 0%, var(--type-accent-soft) 100%);
  border-color: var(--type-border-strong);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
  position: relative;
  overflow: hidden;
}

.type-pocket-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--type-accent);
  border-radius: 20px 0 0 20px;
}

.type-pocket-card.danger,
.type-pocket-card.success,
.type-pocket-card.saving,
.type-pocket-card.teal {
  background: linear-gradient(180deg, #ffffff 0%, var(--type-accent-soft) 100%);
}

.type-pocket-card.saving,
.type-pocket-card.teal {
  --type-accent: var(--saving);
  --type-accent-strong: var(--saving-strong);
  --type-accent-soft: var(--saving-soft);
  --type-border-strong: #dde7dd;
  --type-category-bg: #fafcf9;
  --type-item-bg: #ffffff;
  --type-item-border: rgba(118, 146, 123, 0.18);
}

.type-pocket-card .type-pocket-icon {
  background: color-mix(in srgb, var(--type-accent) 16%, white);
  border-color: color-mix(in srgb, var(--type-accent) 34%, white);
  color: var(--type-accent-strong);
}

.type-pocket-card .type-category-card {
  background: var(--type-category-bg);
  border-color: color-mix(in srgb, var(--type-accent) 26%, white);
}

.type-pocket-card .type-category-card[open] {
  border-color: color-mix(in srgb, var(--type-accent) 42%, white);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--type-accent) 10%, transparent);
}

.type-pocket-card .type-category-body {
  border-top-color: color-mix(in srgb, var(--type-accent) 20%, white);
}

.type-pocket-card .type-pocket-item {
  background: var(--type-item-bg);
  border: 1px solid var(--type-item-border);
}

.type-pocket-card .type-pocket-item-clickable:hover,
.type-pocket-card .type-pocket-item-clickable:focus-visible {
  border-color: color-mix(in srgb, var(--type-accent) 48%, white);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--type-accent) 12%, transparent);
}

.type-pocket-card .type-range-card,
.type-pocket-card .category-range-card,
.type-pocket-card .subcategory-range-card {
  border-top-color: color-mix(in srgb, var(--type-accent) 20%, white);
}

.type-pocket-card .type-pocket-title h3,
.type-pocket-card .type-category-summary strong {
  color: var(--text);
}

.type-pocket-card .type-pocket-toggle,
.type-pocket-card .type-pocket-title p,
.type-pocket-card .activity-inline-copy,
.type-pocket-card .activity-collapsed-copy,
.type-pocket-card .range-caption {
  color: var(--muted);
}

.type-pocket-card.type-variant-fixed {
  --type-accent: var(--type-despesa-fixa);
  --type-accent-strong: var(--type-despesa-fixa-strong);
  --type-accent-soft: var(--type-despesa-fixa-soft);
  --type-border-strong: rgba(132, 151, 173, 0.32);
  --type-category-bg: rgba(236, 239, 244, 0.6);
  --type-item-bg: #ffffff;
  --type-item-border: rgba(132, 151, 173, 0.22);
}

.type-pocket-card.type-variant-needed {
  --type-accent: var(--type-despesa-necesaria);
  --type-accent-strong: var(--type-despesa-necesaria-strong);
  --type-accent-soft: var(--type-despesa-necesaria-soft);
  --type-border-strong: rgba(144, 133, 184, 0.32);
  --type-category-bg: rgba(238, 235, 244, 0.6);
  --type-item-bg: #ffffff;
  --type-item-border: rgba(144, 133, 184, 0.22);
}

.type-pocket-card.type-variant-discretionary {
  --type-accent: var(--type-despesa-discrecional);
  --type-accent-strong: var(--type-despesa-discrecional-strong);
  --type-accent-soft: var(--type-despesa-discrecional-soft);
  --type-border-strong: rgba(167, 153, 199, 0.36);
  --type-category-bg: rgba(241, 237, 246, 0.6);
  --type-item-bg: #ffffff;
  --type-item-border: rgba(167, 153, 199, 0.24);
}

.type-pocket-card .range-current-marker.signal-low {
  background: #8fd3ff;
}

.type-pocket-card .range-current-marker.signal-mid {
  background: #2f6fae;
}

.type-pocket-card .range-current-marker.signal-high {
  background: #d83a52;
}

.range-current-marker.signal-low,
.range-current-marker.signal-mid,
.range-current-marker.signal-high {
  width: 16px;
  height: 16px;
  margin-left: -8px;
  border: 2px solid rgba(255, 255, 255, 0.96);
}

.range-current-marker.signal-low {
  box-shadow: 0 0 0 3px rgba(143, 211, 255, 0.2), 0 4px 10px rgba(49, 111, 168, 0.22);
}

.range-current-marker.signal-mid {
  box-shadow: 0 0 0 3px rgba(47, 111, 174, 0.16), 0 4px 10px rgba(47, 111, 174, 0.26);
}

.range-current-marker.signal-high {
  box-shadow: 0 0 0 3px rgba(216, 58, 82, 0.18), 0 4px 10px rgba(178, 24, 43, 0.28);
}

.flow-summary-card.saving,
.flow-summary-card.teal {
  background: linear-gradient(180deg, #ffffff 0%, var(--saving-soft) 100%);
  border-color: #cde9d4;
}

.flow-summary-card.danger {
  background: linear-gradient(180deg, #ffffff 0%, #f8f3f5 100%);
  border-color: #e2d4da;
}

.member-flow-stat.saving,
.member-flow-stat.teal {
  background: var(--saving-soft);
}

.member-flow-stat.danger {
  background: #f8eef2;
}

.import-panel-header {
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.import-panel {
  padding: 12px 14px;
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.05), transparent 20%),
    linear-gradient(180deg, rgba(219, 234, 254, 0.18) 0%, rgba(255, 255, 255, 0) 22%),
    var(--panel);
}

.import-panel-header h2 {
  margin-bottom: 0.2rem;
  font-size: clamp(1.15rem, 1.7vw, 1.45rem);
  line-height: 1.15;
}

.import-panel-header p {
  margin-bottom: 0;
  font-size: 0.96rem;
  line-height: 1.4;
  max-width: 58rem;
}

.import-message-card.warning,
.import-connector-notice {
  border-color: rgba(217, 119, 6, 0.28);
  background: linear-gradient(180deg, rgba(255, 251, 235, 0.95), rgba(254, 243, 199, 0.86));
}

.import-message-card.error {
  border-color: rgba(220, 38, 38, 0.28);
  background: linear-gradient(180deg, rgba(254, 242, 242, 0.95), rgba(254, 226, 226, 0.86));
}

.import-connector-notice {
  margin-top: 0.7rem;
  padding: 0.75rem 0.9rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(217, 119, 6, 0.28);
  color: #92400e;
  font-size: 0.92rem;
  font-weight: 600;
}

.view-panel[data-view-panel="importar"]>section+section {
  margin-top: 14px;
}

.import-message-card {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
}

.import-message-summary-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem 0.85rem;
  margin-bottom: 0.55rem;
}

.import-message-summary-copy {
  min-width: 0;
}

.import-message-card h2 {
  margin-bottom: 0.12rem;
  font-size: 0.95rem;
  line-height: 1.2;
}

.import-message-card p {
  margin-bottom: 0;
  font-size: 0.86rem;
  line-height: 1.3;
}

.import-drafts-summary {
  margin: 0;
  white-space: nowrap;
  font-size: 0.8rem;
  color: var(--muted);
}

.import-summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 0.45rem;
}

.import-summary-grid .kpi-card {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(191, 219, 254, 0.34);
  background: rgba(255, 255, 255, 0.68);
  box-shadow: none;
}

.import-summary-grid .kpi-card.clickable {
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.import-summary-grid .kpi-card.clickable:hover,
.import-summary-grid .kpi-card.clickable:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.08);
}

.import-summary-grid .kpi-card.is-active {
  border-color: rgba(37, 99, 235, 0.52);
  background: linear-gradient(180deg, rgba(239, 246, 255, 0.95), rgba(255, 255, 255, 0.98));
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.12);
}

.import-summary-grid .kpi-label {
  font-size: 0.78rem;
  line-height: 1.2;
}

.import-summary-grid .kpi-value {
  margin: 3px 0 1px;
  font-size: 1.28rem;
  line-height: 1.05;
}

.import-summary-grid .kpi-meta {
  font-size: 0.78rem;
  line-height: 1.2;
}

.import-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.65rem;
  margin-top: 0.7rem;
}

.import-field {
  display: grid;
  gap: 0.35rem;
  padding: 0.75rem 0.85rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.84));
  box-shadow: none;
  min-width: 0;
}

.import-field-file {
  grid-column: 1 / -1;
}

.import-field span {
  font-weight: 600;
  font-size: 0.9rem;
}

.import-field input:not(.import-file-input),
.import-field select {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: 0.8rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(255, 255, 255, 0.88);
  color: inherit;
}

.import-selected-value {
  display: flex;
  align-items: center;
  min-height: 2.55rem;
  padding: 0.65rem 0.8rem;
  border-radius: 0.8rem;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  font-weight: 600;
}

.import-field input:not(.import-file-input):hover,
.import-field select:hover {
  border-color: rgba(37, 99, 235, 0.2);
}

.import-file-picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-height: 3.25rem;
  padding: 0.7rem 0.8rem;
  border-radius: 0.95rem;
  border: 1px dashed rgba(37, 99, 235, 0.24);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.9), rgba(239, 246, 255, 0.75));
}

.import-file-picker:hover {
  border-color: rgba(37, 99, 235, 0.34);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(219, 234, 254, 0.76));
}

.import-file-input:focus-visible~.import-file-picker-button,
.import-file-input:focus-visible~.import-file-picker-name {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.import-file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.import-file-picker-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.64rem 0.9rem;
  border-radius: 0.78rem;
  border: 1px solid rgba(37, 99, 235, 0.16);
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  color: #1d4ed8;
  font-weight: 700;
  box-shadow: none;
  white-space: nowrap;
}

.import-file-picker-name {
  min-width: 0;
  flex: 1 1 18rem;
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-file-picker-name.is-placeholder {
  color: var(--muted);
  font-weight: 500;
}

.import-field small {
  color: var(--muted-text, #64748b);
  font-size: 0.84rem;
}

.import-quick-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.import-quick-pick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.95rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(248, 250, 252, 0.92);
  color: #334155;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.import-quick-pick:hover {
  border-color: rgba(37, 99, 235, 0.26);
  background: rgba(239, 246, 255, 0.95);
  color: #1d4ed8;
}

.import-quick-pick.is-active {
  border-color: rgba(37, 99, 235, 0.3);
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  color: #1d4ed8;
}

.import-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
  margin-top: 0.7rem;
}

.import-actions .button {
  width: 100%;
}

.import-actions .button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.import-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.8rem;
  padding: 0.72rem 0.95rem;
  line-height: 1.15;
  box-shadow: none;
}

.import-action-button-analyze {
  color: #1e40af;
  border-color: rgba(37, 99, 235, 0.18);
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
}

.import-action-button-apply {
  color: #1e5e47;
  border-color: rgba(45, 125, 98, 0.22);
  background: linear-gradient(180deg, #e8f4f0 0%, #d1ede7 100%);
}

.import-action-button-discard {
  color: #475569;
  border-color: rgba(148, 163, 184, 0.24);
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.import-action-button-danger {
  color: #b91c1c;
  border-color: rgba(248, 113, 113, 0.22);
  background: linear-gradient(180deg, #fff1f2 0%, #ffe4e6 100%);
}

.import-action-button-danger:hover {
  border-color: rgba(248, 113, 113, 0.34);
  background: linear-gradient(180deg, #ffe4e6 0%, #fecdd3 100%);
}

.import-action-button-analyze:hover {
  border-color: rgba(37, 99, 235, 0.26);
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
}

.import-action-button-apply:hover {
  border-color: rgba(45, 125, 98, 0.3);
  background: linear-gradient(180deg, #d1ede7 0%, #bde3d8 100%);
}

.import-action-button-discard:hover {
  border-color: rgba(148, 163, 184, 0.34);
  background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
}

.import-control-row {
  display: grid;
  grid-template-columns: minmax(13rem, 1.3fr) minmax(8rem, 0.8fr) minmax(10rem, 1.1fr) minmax(20rem, 1.6fr);
  gap: 0.5rem;
  align-items: stretch;
}

.import-control-row .import-field {
  padding: 0.4rem 0.6rem;
  gap: 0.2rem;
}

.import-control-row .import-field>span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}

.import-control-row .import-file-picker {
  min-height: 2.2rem;
  padding: 0.3rem 0.45rem;
  gap: 0.5rem;
  border-radius: 0.65rem;
}

.import-control-row .import-file-picker-button {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  border-radius: 0.55rem;
}

.import-control-row .import-file-picker-name {
  font-size: 0.82rem;
}

.import-control-row .import-quick-pick {
  min-height: 1.6rem;
  padding: 0.18rem 0.5rem;
  font-size: 0.72rem;
}

.import-actions-inline {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.3fr) minmax(0, 0.85fr) minmax(0, 0.85fr);
  gap: 0.35rem;
  align-self: stretch;
}

.import-actions-inline .import-action-button {
  min-height: 2.2rem;
  padding: 0.4rem 0.55rem;
  font-size: 0.82rem;
  border-radius: 0.65rem;
}

.import-message-card {
  margin-top: 0.65rem;
}

@media (max-width: 1100px) {
  .import-control-row {
    grid-template-columns: 1fr 1fr;
  }
  .import-actions-inline {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .import-control-row {
    grid-template-columns: 1fr;
  }
  .import-actions-inline {
    grid-template-columns: 1fr 1fr;
  }
}

.import-form-grid-compact {
  grid-template-columns: minmax(16rem, 1.4fr) minmax(10rem, 1fr) minmax(12rem, 1.2fr);
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.import-form-grid-compact .import-field {
  padding: 0.5rem 0.65rem;
  gap: 0.25rem;
}

.import-form-grid-compact .import-field>span {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}

.import-form-grid-compact .import-field-file {
  grid-column: auto;
}

.import-form-grid-compact .import-file-picker {
  min-height: 2.4rem;
  padding: 0.35rem 0.5rem;
  gap: 0.55rem;
  border-radius: 0.7rem;
}

.import-form-grid-compact .import-file-picker-button {
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
  border-radius: 0.6rem;
}

.import-form-grid-compact .import-file-picker-name {
  font-size: 0.85rem;
}

.import-form-grid-compact .import-quick-pick {
  min-height: 1.7rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.74rem;
}

.import-actions-compact {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 0.9fr) minmax(0, 0.9fr);
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.import-actions-compact .import-action-button {
  min-height: 2.3rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.88rem;
}

@media (max-width: 720px) {
  .import-form-grid-compact {
    grid-template-columns: 1fr;
  }
  .import-actions-compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.import-summary-grid .kpi-card.tone-importable {
  border-color: rgba(37, 99, 235, 0.22);
  background: linear-gradient(180deg, rgba(239, 246, 255, 0.95), rgba(219, 234, 254, 0.5));
}
.import-summary-grid .kpi-card.tone-importable .kpi-value { color: #1d4ed8; }
.import-summary-grid .kpi-card.tone-importable.is-active {
  border-color: rgba(37, 99, 235, 0.6);
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.18);
}

.import-summary-grid .kpi-card.tone-fresh {
  border-color: rgba(45, 125, 98, 0.22);
  background: linear-gradient(180deg, rgba(232, 244, 240, 0.9), rgba(209, 237, 231, 0.5));
}
.import-summary-grid .kpi-card.tone-fresh .kpi-value { color: #1e5e47; }
.import-summary-grid .kpi-card.tone-fresh.is-active {
  border-color: rgba(45, 125, 98, 0.5);
  background: linear-gradient(180deg, #d1ede7 0%, #bde3d8 100%);
  box-shadow: 0 12px 28px rgba(45, 125, 98, 0.16);
}

.import-summary-grid .kpi-card.tone-review {
  border-color: rgba(217, 119, 6, 0.24);
  background: linear-gradient(180deg, rgba(255, 251, 235, 0.92), rgba(254, 243, 199, 0.5));
}
.import-summary-grid .kpi-card.tone-review .kpi-value { color: #b45309; }
.import-summary-grid .kpi-card.tone-review.is-active {
  border-color: rgba(217, 119, 6, 0.5);
  background: linear-gradient(180deg, #fef3c7 0%, #fde68a 100%);
  box-shadow: 0 12px 28px rgba(217, 119, 6, 0.16);
}

.import-summary-grid .kpi-card.tone-similar {
  border-color: rgba(124, 58, 237, 0.22);
  background: linear-gradient(180deg, rgba(245, 243, 255, 0.92), rgba(233, 220, 252, 0.45));
}
.import-summary-grid .kpi-card.tone-similar .kpi-value { color: #6d28d9; }
.import-summary-grid .kpi-card.tone-similar.is-active {
  border-color: rgba(124, 58, 237, 0.48);
  background: linear-gradient(180deg, #ede9fe 0%, #ddd6fe 100%);
  box-shadow: 0 12px 28px rgba(124, 58, 237, 0.16);
}

.import-summary-grid .kpi-card.tone-duplicate {
  border-color: rgba(220, 38, 38, 0.22);
  background: linear-gradient(180deg, rgba(255, 241, 242, 0.92), rgba(254, 226, 226, 0.45));
}
.import-summary-grid .kpi-card.tone-duplicate .kpi-value { color: #b91c1c; }
.import-summary-grid .kpi-card.tone-duplicate.is-active {
  border-color: rgba(220, 38, 38, 0.5);
  background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%);
  box-shadow: 0 12px 28px rgba(220, 38, 38, 0.16);
}

.import-summary-grid .kpi-card.tone-all {
  border-color: rgba(148, 163, 184, 0.28);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(241, 245, 249, 0.6));
}
.import-summary-grid .kpi-card.tone-all .kpi-value { color: #334155; }
.import-summary-grid .kpi-card.tone-all.is-active {
  border-color: rgba(100, 116, 139, 0.5);
  background: linear-gradient(180deg, #e2e8f0 0%, #cbd5e1 100%);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.1);
}

.import-summary-grid .kpi-card.clickable::after {
  content: '';
  position: absolute;
  inset: auto 10px 8px auto;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0;
  transition: opacity 140ms ease;
}

.import-summary-grid .kpi-card.is-active.clickable::after {
  opacity: 0.85;
}

.import-summary-grid .kpi-card {
  position: relative;
}

.import-confirm-panel {
  width: min(520px, calc(100vw - 32px));
  min-height: 0;
  max-height: min(80dvh, 720px);
}

.import-confirm-breakdown {
  margin: 0;
}

.import-confirm-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.import-confirm-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.7rem;
  border: 1px solid var(--panel-border);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.import-confirm-product {
  font-weight: 600;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-confirm-count {
  font-weight: 700;
  color: #1d4ed8;
  background: rgba(37, 99, 235, 0.08);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

.import-confirm-warning {
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-radius: 0.7rem;
  background: rgba(217, 119, 6, 0.08);
  color: #92400e;
  font-size: 0.86rem;
  font-weight: 500;
}

.import-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.import-confirm-actions .button {
  min-height: 2.4rem;
  padding: 0.55rem 1rem;
}

.import-progress-card {
  margin-bottom: 0.65rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(191, 219, 254, 0.28);
  background: rgba(255, 255, 255, 0.58);
}

.import-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.35rem;
}

.import-progress-head strong,
.import-progress-head span {
  font-size: 0.8rem;
}

.import-progress-bar {
  height: 0.35rem;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(191, 219, 254, 0.3);
}

.import-progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #93c5fd, #3b82f6);
  transition: width 0.14s ease;
}

.import-checklist {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.55rem;
}

.import-preview-panel {
  padding: 12px 14px;
}

.import-preview-panel-header {
  margin-bottom: 0.6rem;
}

.import-preview-panel-header h2 {
  margin-bottom: 0.15rem;
  font-size: 1.05rem;
}

.import-preview-panel-header p {
  margin-bottom: 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.import-preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.55rem 0.9rem;
  margin-bottom: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.94), rgba(255, 255, 255, 0.96));
}

.import-preview-toolbar .import-preview-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.import-preview-toolbar .import-inline-field {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 2.25rem;
}

.import-preview-toolbar .import-inline-field>span {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.import-preview-toolbar .import-inline-field select {
  height: 2.25rem;
  padding: 0 0.65rem;
  border-radius: 0.55rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: #fff;
  font-size: 0.85rem;
  line-height: 1;
  box-sizing: border-box;
}

.import-preview-toolbar .button {
  height: 2.25rem;
  padding: 0 0.85rem;
  border-radius: 0.55rem;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  box-sizing: border-box;
}

.import-review-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem 0.6rem;
  margin-top: 0.7rem;
  margin-bottom: 0.15rem;
}

.import-review-group {
  display: grid;
  gap: 0.22rem;
  align-content: start;
  min-width: 0;
}

.import-review-group-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}

.import-review-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}

.import-review-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 1.7rem;
  max-width: 100%;
  padding: 0.22rem 0.48rem;
  border-radius: 999px;
  border: 1px solid rgba(203, 213, 225, 0.92);
  background: rgba(255, 255, 255, 0.96);
  color: #334155;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.15;
  cursor: pointer;
}

.import-review-chip span {
  color: #64748b;
  font-size: 0.68rem;
}

.import-review-chip.is-active {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: rgba(96, 165, 250, 0.55);
}

.import-review-empty {
  color: #94a3b8;
  font-size: 0.72rem;
  padding: 0.18rem 0;
}

.import-visible-summary {
  margin: 0;
  color: var(--muted-text, #64748b);
  font-size: 0.94rem;
  font-weight: 600;
}

.import-preview-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.import-inline-field {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.import-inline-field.stacked {
  display: grid;
  gap: 0.35rem;
}

.import-inline-field span {
  font-weight: 600;
  color: #64748b;
  font-size: 0.84rem;
}

.import-inline-field select,
.import-inline-field input[type='text'] {
  min-width: 0;
}

.import-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  padding: 0.55rem 0.7rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.88);
}

.import-toggle input {
  width: 1rem;
  height: 1rem;
  accent-color: #2563eb;
}

.import-preview-list {
  display: grid;
  gap: 0.75rem;
}

.import-preview-card {
  position: relative;
  display: grid;
  gap: 0.8rem;
  padding: 0;
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.94));
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.035);
  overflow-x: clip;
  overflow-y: visible;
}

.import-preview-card-new {
  border-color: rgba(34, 197, 94, 0.18);
}

.import-preview-card-similar {
  border-color: rgba(245, 158, 11, 0.2);
  background: linear-gradient(180deg, rgba(255, 251, 235, 0.98), rgba(255, 255, 255, 0.96));
}

.import-preview-card-duplicate {
  border-color: rgba(148, 163, 184, 0.2);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(241, 245, 249, 0.92));
}

.import-row-similar {
  background: linear-gradient(180deg, rgba(255, 251, 235, 0.98), rgba(255, 255, 255, 0.97));
}

.import-row-duplicate {
  background: linear-gradient(180deg, rgba(254, 242, 242, 0.98), rgba(255, 255, 255, 0.96));
}

.import-preview-card-tone-success {
  border-color: rgba(34, 197, 94, 0.22);
  box-shadow: 0 12px 28px rgba(22, 163, 74, 0.06);
}

.import-preview-card-tone-warning {
  border-color: rgba(245, 158, 11, 0.22);
  box-shadow: 0 12px 28px rgba(245, 158, 11, 0.06);
}

.import-preview-card-tone-danger {
  border-color: rgba(239, 68, 68, 0.2);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.95));
}

.import-preview-card-tone-success::before,
.import-preview-card-tone-warning::before,
.import-preview-card-tone-danger::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: 1rem 0 0 1rem;
  pointer-events: none;
}

.import-preview-card-tone-success::before {
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.7), rgba(16, 185, 129, 0.28));
}

.import-preview-card-tone-warning::before {
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.72), rgba(251, 191, 36, 0.24));
}

.import-preview-card-tone-danger::before {
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.68), rgba(248, 113, 113, 0.22));
}

.import-preview-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem 0.75rem;
  align-items: center;
  padding: 0.55rem 0.8rem 0.55rem 0.85rem;
  cursor: pointer;
  list-style: none;
}

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

.import-preview-card[open] .import-preview-summary {
  border-bottom: 1px solid rgba(226, 232, 240, 0.84);
  background: rgba(248, 250, 252, 0.72);
}

.import-preview-summary-main {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
}

.import-preview-summary-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  min-width: 0;
}

.import-preview-summary-side {
  display: grid;
  justify-items: end;
  align-content: center;
  gap: 0.28rem;
  flex-shrink: 0;
}

.import-preview-card-kpi {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.import-preview-card-kpi strong {
  font-size: 0.92rem;
  line-height: 1.1;
}

.import-preview-card-amount {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.48rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
  color: #334155;
  font-weight: 700;
}

.import-preview-summary-concept {
  font-size: 0.92rem;
  line-height: 1.2;
  font-weight: 700;
  color: #1e293b;
}

.import-preview-summary-meta,
.import-preview-summary-note {
  color: #64748b;
  font-size: 0.78rem;
  line-height: 1.22;
}

.import-preview-card-flags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-left: 0.1rem;
}

.import-preview-summary-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-top: 0.1rem;
}

.import-classification-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  background: rgba(148, 163, 184, 0.12);
  color: #475569;
}

.import-classification-pill > span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.import-classification-pill > span:first-child {
  font-weight: 700;
}

.import-classification-pill em {
  font-style: normal;
  opacity: 0.55;
  font-weight: 400;
  flex-shrink: 0;
}

.import-classification-pill::before {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: currentColor;
  flex-shrink: 0;
  opacity: 0.7;
}

.import-classification-pill.type-ingres {
  background: var(--type-ingres-soft);
  border-color: rgba(123, 189, 164, 0.45);
  color: var(--type-ingres-strong);
}

.import-classification-pill.type-estalvi {
  background: var(--type-estalvi-soft);
  border-color: rgba(118, 146, 123, 0.45);
  color: var(--type-estalvi-strong);
}

.import-classification-pill.type-despesa-fixa {
  background: var(--type-despesa-fixa-soft);
  border-color: rgba(132, 151, 173, 0.45);
  color: var(--type-despesa-fixa-strong);
}

.import-classification-pill.type-despesa-necesaria {
  background: var(--type-despesa-necesaria-soft);
  border-color: rgba(144, 133, 184, 0.45);
  color: var(--type-despesa-necesaria-strong);
}

.import-classification-pill.type-despesa-discrecional {
  background: var(--type-despesa-discrecional-soft);
  border-color: rgba(167, 153, 199, 0.5);
  color: var(--type-despesa-discrecional-strong);
}

.import-classification-pill.type-especial {
  background: var(--type-especial-soft);
  border-color: rgba(125, 166, 193, 0.45);
  color: var(--type-especial-strong);
}

.import-classification-pill.type-unknown {
  background: var(--type-unknown-soft);
  border-color: rgba(163, 182, 198, 0.5);
  color: var(--type-unknown-strong);
}

.import-classification-pill.type-pending {
  background: rgba(217, 119, 6, 0.12);
  border-color: rgba(217, 119, 6, 0.32);
  color: #b45309;
  font-weight: 600;
}

.import-classification-pill.type-pending::before {
  background: #d97706;
}

.import-select-toggle {
  appearance: none;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 0.6rem;
  min-width: 10.8rem;
  padding: 0.42rem 0.6rem 0.42rem 0.72rem;
  border-radius: 1rem;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(255, 255, 255, 0.95);
  color: #334155;
  cursor: pointer;
  text-align: left;
}

.import-select-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.96;
}

.import-row-excluded {
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(243, 246, 250, 0.94));
}

.import-row-excluded .import-preview-summary,
.import-row-excluded .import-preview-card-body,
.import-row-excluded .import-preview-block {
  background: transparent;
}

.import-row-excluded .import-preview-summary-main,
.import-row-excluded .import-preview-summary-side,
.import-row-excluded .import-preview-card-body {
  opacity: 0.78;
}

.import-row-excluded .import-select-toggle {
  opacity: 1;
  background: rgba(241, 245, 249, 0.92);
  border-color: rgba(148, 163, 184, 0.28);
}

.import-row-excluded .import-select-toggle-copy strong,
.import-row-excluded .import-preview-summary-concept,
.import-row-excluded .import-preview-card-kpi strong,
.import-row-excluded .import-preview-card-amount {
  color: #64748b;
}

.import-row-excluded .import-select-toggle-copy small,
.import-row-excluded .import-preview-summary-meta,
.import-row-excluded .import-preview-summary-note,
.import-row-excluded .import-preview-disclosure {
  color: #94a3b8;
}

.import-row-excluded .import-preview-card-amount {
  background: rgba(148, 163, 184, 0.1);
}

.import-select-toggle-copy {
  display: grid;
  gap: 0.08rem;
  min-width: 0;
}

.import-select-toggle-copy strong {
  font-size: 0.84rem;
  line-height: 1.1;
  color: #0f172a;
}

.import-select-toggle-copy small {
  font-size: 0.7rem;
  line-height: 1.2;
  color: #64748b;
}

.import-select-toggle-success {
  background: rgba(220, 252, 231, 0.9);
  border-color: rgba(34, 197, 94, 0.18);
}

.import-select-toggle-warning {
  background: rgba(255, 247, 237, 0.92);
  border-color: rgba(245, 158, 11, 0.2);
}

.import-select-toggle-danger {
  background: rgba(254, 242, 242, 0.92);
  border-color: rgba(239, 68, 68, 0.18);
}

.import-switch {
  position: relative;
  width: 2.35rem;
  height: 1.45rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.12);
  transition: background 0.18s ease;
}

.import-switch::after {
  content: '';
  position: absolute;
  top: 0.14rem;
  left: 0.14rem;
  width: 1.17rem;
  height: 1.17rem;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
  transition: transform 0.18s ease;
}

.import-switch.is-on {
  background: rgba(34, 197, 94, 0.9);
}

.import-switch.is-on::after {
  transform: translateX(0.9rem);
}

.import-select-toggle:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.42);
  outline-offset: 2px;
}

.import-preview-disclosure {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: #64748b;
  font-size: 0.76rem;
  font-weight: 700;
}

.import-preview-disclosure::after {
  content: '▾';
  font-size: 0.85rem;
  transition: transform 0.18s ease;
}

.import-preview-card[open] .import-preview-disclosure::after {
  transform: rotate(180deg);
}

.import-preview-card-body {
  display: grid;
  gap: 0.55rem;
  padding: 0.5rem 0.65rem 0.65rem;
}

.import-preview-detail-grid {
  display: grid;
  grid-template-columns: minmax(14rem, 0.85fr) minmax(20rem, 1.3fr) minmax(13rem, 0.85fr);
  gap: 0.4rem;
  align-items: start;
}

.import-preview-block {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
  padding: 0.45rem 0.55rem;
  border-radius: 0.7rem;
  border: 1px solid rgba(226, 232, 240, 0.9);
  background: rgba(255, 255, 255, 0.88);
}

.import-preview-block-title {
  font-size: 0.72rem;
  color: #475569;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.import-preview-block-primary,
.import-preview-block-compact {
  gap: 0.45rem;
}

.import-preview-block-destination {
  background: linear-gradient(180deg, rgba(239, 246, 255, 0.86), rgba(255, 255, 255, 0.96));
  border-color: rgba(191, 219, 254, 0.95);
  box-shadow: inset 0 0 0 1px rgba(219, 234, 254, 0.45);
}

.import-preview-block-destination .import-preview-block-title {
  color: #1d4ed8;
}

.import-destination-owner {
  font-size: 0.8rem;
  font-weight: 700;
  color: #1e293b;
}

.import-preview-block-wide {
  grid-column: 1 / -1;
}

/* Shared row primitive: the three preview columns (origen, destí, suggeriments)
   all use this same label+value grid so they read as one component. */
.import-field-rows {
  display: grid;
  gap: 0.3rem;
  align-content: start;
}

.import-field-row {
  display: grid;
  grid-template-columns: 5.4rem minmax(0, 1fr);
  gap: 0.5rem;
  align-items: center;
  min-height: 1.5rem;
}

.import-field-row-label {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.2;
}

.import-field-row-value {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  min-width: 0;
}

.import-field-row-text {
  font-size: 0.8rem;
  line-height: 1.25;
  color: var(--text);
  min-width: 0;
  overflow-wrap: anywhere;
}

.import-field-row-chips {
  flex-wrap: wrap;
  justify-content: flex-start;
}

/* The classification result sits under the combobox, so it keeps the
   label column empty to stay aligned with the fields above it. */
.import-field-row-wide {
  grid-template-columns: 5.4rem minmax(0, 1fr);
  margin-top: -0.1rem;
}

.import-field-row-wide .import-field-row-value {
  grid-column: 2;
  justify-content: flex-start;
}

.import-field-rows .import-inline-action {
  flex-shrink: 0;
  min-height: 1.2rem;
  padding: 0.08rem 0.36rem;
  font-size: 0.64rem;
  border-color: transparent;
  background: transparent;
  opacity: 0.7;
}

.import-field-rows .import-inline-action:hover {
  background: #dbeafe;
  opacity: 1;
}

.import-primary-fields {
  display: grid;
  gap: 0.4rem;
}

.import-destination-section {
  display: grid;
  gap: 0.45rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(191, 219, 254, 0.85);
}

.import-destination-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: #1d4ed8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.import-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
}






.import-preview-grid-classification {
  grid-template-columns: minmax(0, 1fr);
  gap: 0.38rem;
}

.import-preview-warning,
.import-preview-reason {
  font-size: 0.88rem;
  line-height: 1.4;
}

.import-field-row .import-preview-warning {
  font-size: 0.72rem;
  line-height: 1.3;
  font-weight: 500;
}

.import-preview-reason {
  font-size: 0.82rem;
  color: #475569;
}

.import-preview-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: flex-start;
}

.import-preview-warning {
  color: #b91c1c;
  font-weight: 600;
}

.import-preview-card input[type='text'],
.import-preview-card textarea,
.import-preview-card select {
  width: 100%;
  min-width: 0;
  padding: 0.46rem 0.58rem;
  border-radius: 0.72rem;
  border: 1px solid rgba(203, 213, 225, 0.9);
  background: rgba(255, 255, 255, 0.96);
  box-sizing: border-box;
}

.import-field-row input[type='text'] {
  padding: 0.2rem 0.45rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  line-height: 1.25;
}

.import-preview-card textarea {
  resize: vertical;
  min-height: 2.4rem;
  line-height: 1.28;
}

.import-concept-meta {
  display: grid;
  gap: 0.5rem;
}

.import-concept-suggestions-title {
  font-size: 0.66rem;
  color: var(--muted);
  font-weight: 700;
}

.import-suggestion-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  padding: 0.32rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(191, 219, 254, 0.85);
  background: rgba(239, 246, 255, 0.85);
  color: #1d4ed8;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.import-suggestion-chip:hover {
  background: #dbeafe;
  border-color: rgba(37, 99, 235, 0.45);
}

.import-field-row .import-suggestion-chip {
  padding: 0.16rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: 0.5rem;
  max-width: 100%;
  min-width: 0;
}

.import-suggestion-chip-classification {
  display: grid;
  gap: 0.1rem;
  white-space: normal;
  border-radius: 0.7rem;
  padding: 0.4rem 0.6rem;
  text-align: left;
}

.import-suggestion-chip-classification strong {
  font-size: 0.84rem;
}

.import-suggestion-chip-classification span {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 500;
}

.import-suggestion-empty {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.2rem 0;
}



.import-inline-field select option[disabled] {
  color: var(--danger);
}

.import-combobox {
  position: relative;
  min-width: 0;
  flex: 1;
}

.import-preview-card .import-combobox-input {
  font-weight: 600;
  padding: 0.42rem 0.55rem;
  border-radius: 0.6rem;
  font-size: 0.85rem;
}

.import-preview-card .import-combobox-input.is-pending {
  border-color: rgba(217, 119, 6, 0.55);
  background: rgba(217, 119, 6, 0.06);
}

.import-preview-card .import-combobox-input.is-pending::placeholder {
  color: #b45309;
  opacity: 0.85;
  font-weight: 500;
}

.import-combobox-list {
  position: absolute;
  z-index: 30;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  max-height: 15rem;
  overflow-y: auto;
  padding: 0.3rem;
  border-radius: 0.8rem;
  border: 1px solid rgba(203, 213, 225, 0.95);
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
  overscroll-behavior: contain;
}

.import-combobox-list[hidden] {
  display: none;
}

.import-combobox-group {
  padding: 0.35rem 0.5rem 0.2rem;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.import-combobox-option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.42rem 0.55rem;
  border-radius: 0.6rem;
  cursor: pointer;
}

.import-combobox-option strong {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  min-width: 0;
}

.import-combobox-option span {
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.import-combobox-option:hover,
.import-combobox-option.is-active {
  background: var(--primary-soft);
}

.import-combobox-option.is-current {
  background: rgba(37, 99, 235, 0.08);
}

.import-combobox-option.is-current strong::after {
  content: ' ✓';
  color: var(--primary);
}

.import-combobox-empty {
  padding: 0.55rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.import-inline-action,
.import-suggestion-triplet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: fit-content;
  min-height: 1.6rem;
  padding: 0.24rem 0.48rem;
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  background: #eff6ff;
  color: #1d4ed8;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.import-inline-action:hover,
.import-suggestion-triplet:hover {
  background: #dbeafe;
}

.import-suggestion-triplet {
  max-width: 100%;
  justify-self: start;
  text-align: left;
  white-space: normal;
  border-radius: 0.9rem;
  padding: 0.36rem 0.6rem;
  line-height: 1.18;
}

.import-concept-suggestions {
  display: grid;
  gap: 0.26rem;
}

.import-concept-suggestion-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.import-concept-suggestion {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.24rem 0.42rem;
  border-radius: 999px;
  border: 1px solid rgba(203, 213, 225, 0.95);
  background: #f8fafc;
  color: #334155;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}

.import-concept-suggestion strong {
  font-size: 0.62rem;
  color: #1d4ed8;
}

.import-concept-suggestion.is-recommended {
  border-color: rgba(37, 99, 235, 0.22);
  background: #eff6ff;
  color: #1e40af;
}

.import-source-details {
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 0.8rem;
  background: rgba(248, 250, 252, 0.95);
  overflow: hidden;
}

.import-source-details summary {
  list-style: none;
  cursor: pointer;
  padding: 0.6rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
}

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

.import-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.38rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.import-status-pill.success {
  color: #1e5e47;
  background: rgba(45, 125, 98, 0.1);
  border-color: rgba(45, 125, 98, 0.2);
}

.import-status-pill.warning {
  color: #92400e;
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.22);
}

.import-status-pill.error {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.2);
}

.import-status-pill.neutral {
  color: #475569;
  background: rgba(148, 163, 184, 0.14);
  border-color: rgba(148, 163, 184, 0.2);
}

.import-status-pill.semaphore-success {
  color: #1e5e47;
  background: rgba(45, 125, 98, 0.1);
  border-color: rgba(45, 125, 98, 0.22);
}

.import-status-pill.semaphore-warning {
  color: #9a3412;
  background: rgba(249, 115, 22, 0.14);
  border-color: rgba(249, 115, 22, 0.22);
}

.import-status-pill.semaphore-danger {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.2);
}

.import-row-disabled {
  opacity: 0.72;
}

.import-history-match-list {
  display: grid;
  gap: 0.35rem;
}

.import-history-match-card {
  display: grid;
  gap: 0.18rem;
  padding: 0.38rem 0.45rem;
  border-radius: 0.7rem;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(248, 250, 252, 0.95);
}

.import-history-match-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.import-history-match-text {
  font-size: 0.8rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-history-match-subtext,
.import-history-match-meta,
.import-history-match-metrics {
  font-size: 0.7rem;
  color: #475569;
  line-height: 1.15;
}

.import-history-match-subtext {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-history-match-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.45rem;
}

.import-history-match-amount {
  font-size: 0.72rem;
  font-weight: 700;
  color: #334155;
}

.import-history-match-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.45rem;
}

@media (min-width: 1180px) {
  .import-form-grid {
    grid-template-columns: minmax(24rem, 2.2fr) repeat(2, minmax(12rem, 1fr));
    align-items: start;
  }

  .import-field-file {
    grid-column: auto;
  }

  .import-actions {
    grid-template-columns: minmax(11rem, 0.95fr) minmax(15rem, 1.2fr) minmax(11rem, 0.95fr) minmax(11rem, 0.95fr);
  }
}

@media (max-width: 1220px) {
  .import-preview-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .import-preview-block-destination {
    grid-column: auto;
  }
}

@media (max-width: 900px) {

  .import-panel-header,
  .import-preview-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .import-preview-controls,
  .import-select-toggle,
  .import-preview-grid,
  .import-actions {
    width: 100%;
  }

  .import-preview-summary {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .import-preview-summary-side {
    grid-template-columns: 1fr auto;
    align-items: center;
    justify-items: stretch;
  }

  .import-select-toggle {
    justify-content: space-between;
  }

  .import-field-row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
    align-items: start;
  }

  .import-preview-detail-grid {
    grid-template-columns: 1fr;
  }

  .import-preview-block-destination {
    grid-column: auto;
  }

  .import-review-filters {
    grid-template-columns: 1fr;
  }

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

  .import-file-picker-name {
    flex-basis: 100%;
  }
}

@media (max-width: 620px) {
  .import-panel {
    padding: 14px;
  }

  .view-panel[data-view-panel="importar"]>section+section {
    margin-top: 12px;
  }

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

  .import-field {
    padding: 0.7rem 0.75rem;
  }

  .import-message-card {
    padding: 10px 11px;
  }

  .import-message-summary-head {
    flex-direction: column;
    margin-bottom: 0.55rem;
  }

  .import-drafts-summary {
    white-space: normal;
  }
}


.cashflow-matrix-toggle {
  margin: 0;
  align-self: flex-start;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.7rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 250, 252, 0.95) 100%);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.035);
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease, transform 160ms ease;
}

.cashflow-matrix-toggle:hover {
  border-color: rgba(37, 99, 235, 0.22);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.cashflow-matrix-toggle:has(input:checked) {
  border-color: rgba(37, 99, 235, 0.24);
  background: linear-gradient(180deg, rgba(239, 246, 255, 0.98) 0%, rgba(247, 250, 255, 0.96) 100%);
}

.cashflow-matrix-toggle input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.cashflow-matrix-toggle-switch {
  position: relative;
  flex: 0 0 auto;
  width: 2.1rem;
  height: 1.2rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.34);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
  transition: background 160ms ease;
}

.cashflow-matrix-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
  transition: transform 160ms ease;
}

.cashflow-matrix-toggle-title {
  color: #24324b;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.cashflow-matrix-toggle input:checked+.cashflow-matrix-toggle-switch {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
}

.cashflow-matrix-toggle input:checked+.cashflow-matrix-toggle-switch .cashflow-matrix-toggle-thumb {
  transform: translateX(0.9rem);
}

.cashflow-matrix-toggle input:focus-visible+.cashflow-matrix-toggle-switch {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.cashflow-matrix-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 0.85rem;
}

.cashflow-matrix-picker-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(248, 250, 252, 0.92);
  color: #334155;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.cashflow-matrix-picker-button:hover {
  border-color: rgba(37, 99, 235, 0.26);
  background: rgba(239, 246, 255, 0.95);
  color: #1d4ed8;
}

.cashflow-matrix-picker-button.is-active {
  border-color: rgba(37, 99, 235, 0.3);
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  color: #1d4ed8;
}

.cashflow-matrix-window-controls {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  flex-wrap: wrap;
  align-self: flex-start;
  padding: 0.3rem;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.96) 0%, rgba(255, 255, 255, 0.98) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.cashflow-matrix-window-button {
  min-height: 2.5rem;
  padding-inline: 0.95rem;
  border-radius: 999px;
  font-size: 0.95rem;
  white-space: nowrap;
}

.cashflow-matrix-window-label {
  min-width: 132px;
  text-align: center;
  color: #51657f;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.cashflow-year-matrix {
  width: 100%;
  table-layout: fixed;
  transition: opacity 180ms ease, transform 220ms ease;
  transform-origin: center center;
}

.cashflow-year-matrix.is-shifting-left {
  opacity: 0.78;
  transform: translateX(-10px) scale(0.992);
}

.cashflow-year-matrix.is-shifting-right {
  opacity: 0.78;
  transform: translateX(10px) scale(0.992);
}

.cashflow-year-matrix th {
  vertical-align: top;
}

.cashflow-year-matrix thead th:first-child,
.cashflow-year-matrix tbody th.cashflow-year-axis {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #f8fbff;
}

.cashflow-year-matrix-heading {
  font-weight: 800;
}

.cashflow-year-matrix-subheading,
.cashflow-year-axis-meta,
.cashflow-year-matrix-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.cashflow-year-axis {
  width: 160px;
}

.cashflow-year-axis-label {
  font-weight: 800;
}

.cashflow-year-matrix-cell {
  background: #fafcff;
}

.cashflow-year-matrix-cell.positive {
  background: #f7fcf8;
}

.cashflow-year-matrix-cell.warning {
  background: #fffaf0;
}

.cashflow-year-matrix-cell.negative {
  background: #fff5f5;
}

.cashflow-year-matrix-cell.is-empty {
  color: var(--muted);
  text-align: center;
  background: #fbfdff;
}

.cashflow-year-matrix-cell.is-total {
  border-top: 2px solid #dce7f5;
  background: #f8fbff;
}

.cashflow-year-matrix-value {
  font-weight: 800;
}

/* Resum de diners reals: targetes per titular amb jerarquia forta
   (número > etiqueta) i sense divisors interns que fragmentin la lectura. */
.cashflow-member-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.cashflow-member-card {
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px;
  background: var(--panel);
  display: grid;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
  transition: box-shadow 160ms ease, border-color 160ms ease;
}

.cashflow-member-card:hover {
  border-color: rgba(37, 99, 235, 0.18);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.cashflow-member-card.is-negative {
  border-color: rgba(220, 38, 38, 0.2);
  background: linear-gradient(180deg, #fffafa 0%, var(--panel) 100%);
}

.cashflow-member-head {
  display: grid;
  gap: 2px;
}

.cashflow-member-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.cashflow-member-total {
  font-size: 1.4rem;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

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

.cashflow-holding-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.cashflow-holding-product {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cashflow-holding-balance {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}


.cashflow-year-matrix-chart {
  min-height: 0;
}

.cashflow-line-chart-shell {
  display: grid;
  gap: 14px;
}


.cashflow-matrix-chart-shell {
  display: grid;
  gap: 16px;
}

.cashflow-matrix-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.cashflow-matrix-chart-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.cashflow-matrix-chart-swatch.is-positive {
  background: #2d7d62;
}

.cashflow-matrix-chart-swatch.is-warning {
  background: #f59e0b;
}

.cashflow-matrix-chart-swatch.is-negative {
  background: #b05252;
}

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

.cashflow-matrix-chart-row {
  display: grid;
  grid-template-columns: minmax(180px, 220px) repeat(var(--cashflow-chart-columns, 1), minmax(140px, 1fr));
  gap: 10px;
  align-items: stretch;
}

.cashflow-matrix-chart-axis,
.cashflow-matrix-chart-cell {
  border-radius: 16px;
  padding: 14px;
}

.cashflow-matrix-chart-axis {
  background: #f8fbff;
  border: 1px solid #dce7f5;
}

.cashflow-matrix-chart-axis-corner,
.cashflow-matrix-chart-axis-year {
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #24364d;
}

.cashflow-matrix-chart-axis-product {
  display: grid;
  gap: 4px;
}

.cashflow-matrix-chart-axis-product strong {
  font-size: 0.95rem;
}

.cashflow-matrix-chart-axis-product small {
  color: var(--muted);
  font-size: 12px;
}

.cashflow-matrix-chart-cell {
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(248, 250, 252, 0.9);
  display: grid;
  gap: 4px;
  align-content: start;
}

.cashflow-matrix-chart-cell strong {
  font-size: 0.95rem;
  line-height: 1.25;
}

.cashflow-matrix-chart-cell small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.cashflow-matrix-chart-cell.is-positive {
  background: linear-gradient(180deg, rgba(22, 163, 74, calc(0.08 + var(--cashflow-cell-intensity, 0.2) * 0.2)) 0%, #ffffff 100%);
  border-color: rgba(22, 163, 74, 0.22);
}

.cashflow-matrix-chart-cell.is-warning {
  background: linear-gradient(180deg, rgba(245, 158, 11, calc(0.08 + var(--cashflow-cell-intensity, 0.2) * 0.22)) 0%, #ffffff 100%);
  border-color: rgba(245, 158, 11, 0.24);
}

.cashflow-matrix-chart-cell.is-negative {
  background: linear-gradient(180deg, rgba(220, 38, 38, calc(0.08 + var(--cashflow-cell-intensity, 0.2) * 0.2)) 0%, #ffffff 100%);
  border-color: rgba(220, 38, 38, 0.22);
}

.cashflow-matrix-chart-cell.is-total {
  border-width: 2px;
}

.cashflow-matrix-chart-cell.is-empty {
  place-items: center;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 960px) {
  .cashflow-matrix-chart-shell {
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .cashflow-matrix-chart-grid {
    min-width: 920px;
  }
}


.cashflow-table .cashflow-opening-row {
  background: #f8fbff;
}

.cashflow-table .cashflow-row.warning,
.cashflow-table .cashflow-row.warning:hover {
  background: #fffaf0;
}

.cashflow-table .cashflow-row.negative,
.cashflow-table .cashflow-row.negative:hover {
  background: #fff5f5;
}

.cashflow-row-label {
  color: var(--muted);
  font-weight: 700;
}

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

.view-panel[data-view-panel="configuracio"] .settings-panel {
  width: 100%;
  max-width: none;
}

.settings-overview {
  display: grid;
  gap: 8px;
}

.settings-overview-footer {
  margin-top: 4px;
}

.settings-cache-card {
  width: 100%;
  min-width: 0;
  max-width: none;
  padding: 18px 20px;
}

.settings-cache-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.settings-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.6);
}

.settings-toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.settings-toolbar-compact {
  grid-template-columns: minmax(220px, 360px) minmax(180px, 1fr);
  align-items: end;
}

.settings-profile-select-field {
  max-width: 360px;
}

.settings-inline-meta {
  display: grid;
  gap: 4px;
  align-content: end;
  min-height: 48px;
  padding: 0 2px 6px;
}

.settings-inline-meta-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.settings-inline-meta-value {
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.2;
  word-break: break-word;
}

.settings-form-compact {
  gap: 12px;
}

.settings-summary-card {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.52);
}

.settings-summary-list,
.settings-technical-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 14px;
  margin: 0;
}

.settings-summary-item,
.settings-technical-item {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.settings-summary-item dt,
.settings-technical-item dt {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.settings-summary-item dd,
.settings-technical-item dd {
  margin: 0;
  color: var(--ink);
  line-height: 1.35;
  word-break: break-word;
}

.settings-summary-value {
  font-size: 0.95rem;
  font-weight: 700;
}

.settings-technical-details {
  display: grid;
  gap: 0;
  padding-top: 4px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.settings-technical-details summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}

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

.settings-technical-details summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 6px;
  color: var(--muted);
  transition: transform 160ms ease;
}

.settings-technical-details[open] summary::before {
  transform: rotate(90deg);
}

.settings-technical-body {
  padding-top: 10px;
}

.settings-technical-item .settings-value-code {
  font-size: 0.82rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.settings-grid-compact {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.settings-readonly-note {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.settings-groups {
  display: grid;
  gap: 8px;
}

.settings-group {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(255, 255, 255, 0.55);
}

.settings-group-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--ink);
}

.settings-field {
  display: grid;
  gap: 3px;
}

.settings-field span {
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--ink);
}

.settings-field input,
.settings-field select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font: inherit;
}

.settings-display-field {
  align-content: start;
}

.settings-value {
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font: inherit;
  line-height: 1.35;
  font-size: 0.88rem;
  word-break: break-word;
}

.settings-value-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, monospace;
  font-size: 0.86rem;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.settings-actions .button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.92rem;
}

.settings-action-load {
  background: #eef7f3;
  border-color: #a8d4c4;
  color: #2d7d62;
}

.settings-action-load:hover {
  background: #e2f1ec;
  border-color: #88bfae;
}

.compact-clear,
.settings-action-danger {
  background: #fdf3f3;
  border-color: #e8c0c0;
  color: #b05252;
  box-shadow: none;
}

.compact-clear:hover,
.settings-action-danger:hover {
  background: #ffe4e6;
  border-color: #fda4af;
}

.settings-actions-secondary {
  padding-top: 4px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

@media (max-width: 700px) {
  .settings-actions .button {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 700px) {
  .settings-toolbar-compact {
    grid-template-columns: 1fr;
  }

  .settings-inline-meta {
    min-height: auto;
    padding-bottom: 0;
  }

  .settings-summary-list,
  .settings-technical-list {
    grid-template-columns: 1fr;
  }
}

.settings-message-card {
  margin-top: 2px;
}

.settings-unified-card {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
}

.settings-message-body {
  padding-bottom: 4px;
  border-bottom: 0;
}

.settings-unified-card .settings-overview {
  gap: 8px;
}

.settings-unified-subcard {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.settings-unified-subcard.status-card.success,
.settings-unified-subcard.status-card.warning,
.settings-unified-subcard.status-card.error {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.settings-unified-subcard .compact-cache-head {
  padding-top: 2px;
  align-items: flex-start;
}

.settings-unified-subcard .compact-cache-body {
  padding-bottom: 0;
}

.settings-unified-flow {
  padding-top: 2px;
}

.settings-unified-flow .settings-unified-subcard {
  display: grid;
  gap: 6px;
}

.settings-unified-flow .settings-unified-subcard+.settings-unified-subcard {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.settings-message-body strong {
  font-size: 13px;
}

/* Configuració en una sola columna: formulari a dalt, estat/càrrega al peu */
.view-panel[data-view-panel="configuracio"] .settings-panel {
  grid-template-columns: 1fr;
}

.settings-unified-flow {
  grid-template-columns: 1fr;
}

.settings-message-body p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.35;
}

.settings-unified-subcard .compact-cache-body strong {
  font-size: 13px;
}

.settings-unified-subcard .compact-cache-body p {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
}

.settings-unified-subcard .compact-cache-tag {
  background: rgba(255, 255, 255, 0.92);
}

@media (max-width: 480px) {

  html,
  body {
    overflow-x: hidden;
  }

  body {
    background: #f3f6fb;
  }

  .app-shell,
  .sidebar-collapsed.app-shell {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0 0 calc(16px + env(safe-area-inset-bottom));
  }

  .app-sidebar,
  .sidebar-collapsed .app-sidebar {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: auto;
    padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
    border: 0;
    border-bottom: 1px solid #d8e3f3;
    border-radius: 0;
    gap: 10px;
    background: rgba(248, 251, 255, 0.96);
    backdrop-filter: blur(14px);
  }

  .sidebar-top {
    padding: 0;
    gap: 8px;
    border-bottom: 0;
  }

  .sidebar-brand {
    gap: 10px;
  }

  .sidebar-brand-copy strong {
    font-size: 0.95rem;
  }

  .sidebar-brand-copy small {
    font-size: 0.75rem;
  }

  .sidebar-toggle {
    display: none;
  }

  .app-sidebar .app-menu {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(84px, max-content);
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 0 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .app-sidebar .app-menu::-webkit-scrollbar {
    display: none;
  }

  .app-sidebar .menu-button,
  .app-sidebar .menu-button.active,
  .sidebar-collapsed .app-sidebar .menu-button,
  .sidebar-collapsed .app-sidebar .menu-button.active {
    width: auto;
    min-width: 84px;
    min-height: 44px;
    height: auto;
    margin: 0;
    padding: 10px 12px;
    border-radius: 14px;
    justify-content: center;
  }

  .app-sidebar .menu-button .menu-label {
    font-size: 12px;
    line-height: 1.15;
    white-space: nowrap;
  }

  .sidebar-cache {
    margin: 0;
    padding: 10px 12px;
    border-radius: 14px;
  }

  .compact-cache {
    min-width: 0;
    max-width: none;
  }

  .compact-cache-head {
    align-items: flex-start;
  }

  .compact-cache-tag>span:last-child {
    white-space: normal;
  }

  .app-content {
    padding: 12px;
  }

  .filters-sidebar,
  .filters-sidebar[open] {
    position: static !important;
    top: auto;
    right: auto;
    bottom: auto;
    width: 100%;
    height: auto;
    margin: 0 0 12px;
    border: 1px solid #d8e3f3;
    border-radius: 18px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    overflow: hidden;
  }

  .filters-sidebar .filters-summary {
    min-height: auto;
    padding: 12px;
  }

  .filters-sidebar .filters-summary-main {
    align-items: flex-start;
  }

  .filters-sidebar .filters-body {
    padding: 12px 12px 14px;
  }

  .hero {
    margin-top: 0;
    padding: 16px;
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    display: grid;
    gap: 14px;
  }

  .hero-copy {
    max-width: none;
  }

  .hero-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 10px;
  }

  .panel,
  .status-card,
  .kpi-card {
    border-radius: 18px;
  }

  .panel {
    padding: 16px;
  }

  .status-card,
  .view-panel,
  .kpi-grid,
  .grid,
  .app-menu,
  .filters-panel {
    margin-top: 12px;
  }

  .panel-header,
  .monthly-summary-members-head,
  .cashflow-member-head,
  .compact-cache-head {
    display: grid;
    gap: 10px;
    justify-content: stretch;
    align-items: start;
  }

  .cashflow-matrix-toggle {
    justify-self: start;
  }

  .date-navigation-row,
  .panel-date-navigation,
  .panel-range-toggle {
    margin-left: 0;
    justify-content: flex-start;
    width: 100%;
  }

  .date-shift-button,
  .date-current-button,
  .panel-range-button {
    min-height: 42px;
  }

  .kpi-grid,
  .member-flow-grid,
  .two-columns,
  .income-top-grid,
  .expenses-content-grid,
  .full-width-snapshot-list,
  .cashflow-member-grid {
    grid-template-columns: 1fr;
  }

  .member-flow-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .expense-member-type-list {
    grid-template-columns: 1fr;
  }

  .chart-block,
  .expense-chart-block,
  .type-share-trend-host,
  .cashflow-line-chart-shell {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .chart-block>.monthly-chart,
  .chart-block>.income-annual-chart,
  .chart-block>.income-area-chart,
  .expense-chart-block>.monthly-chart,
  .type-share-trend-host>.monthly-chart,
  .cashflow-line-chart-shell {
    min-width: 640px;
  }

  .detail-modal-panel {
    width: calc(100vw - 12px);
    min-height: min(240px, calc(100dvh - 12px));
    max-height: min(calc(100dvh - 12px), 900px);
    margin: 6px;
    padding: 14px;
    border-radius: 18px;
  }
}

.forecast-members-grid {
  display: grid;
  gap: 1.25rem;
}

.forecast-member-panel {
  display: grid;
  gap: 1rem;
}

.forecast-member-header {
  align-items: flex-start;
  gap: 1rem;
}

.forecast-member-availability {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
}

.forecast-balance-pill {
  min-width: 10rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 1rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(241, 245, 249, 0.92));
  display: grid;
  gap: 0.2rem;
}

.forecast-balance-pill span,
.forecast-balance-pill small {
  color: var(--muted-text);
}

.forecast-balance-pill strong {
  font-size: 1.05rem;
}

.forecast-member-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.forecast-member-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.forecast-member-section {
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 1.1rem;
  padding: 1rem;
  background: rgba(248, 250, 252, 0.7);
}

.forecast-section-head {
  margin-bottom: 0.85rem;
}

.forecast-section-head h3 {
  margin: 0;
  font-size: 1rem;
}

.forecast-section-head p {
  margin: 0.2rem 0 0;
  color: var(--muted-text);
  font-size: 0.92rem;
}

.forecast-item-list {
  display: grid;
  gap: 0.75rem;
}

.forecast-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: start;
  padding: 0.85rem 0.95rem;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.9);
}

.forecast-item-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin-bottom: 0.2rem;
}

.forecast-kind-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.forecast-kind-income {
  background: var(--type-ingres-soft);
  color: var(--type-ingres-strong);
}

.forecast-kind-expense {
  background: rgba(176, 82, 82, 0.1);
  color: #b05252;
}

.forecast-kind-saving {
  background: var(--type-estalvi-soft);
  color: var(--type-estalvi-strong);
}

.forecast-kind-other {
  background: var(--type-unknown-soft);
  color: var(--type-unknown-strong);
}

.forecast-progress-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.45rem;
  color: var(--muted-text);
  font-size: 0.82rem;
}

.forecast-progress-track {
  position: relative;
  margin-top: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(148, 163, 184, 0.18);
}

.forecast-progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.forecast-progress-fill.forecast-kind-income {
  background: linear-gradient(90deg, #22a559, var(--type-ingres));
}

.forecast-progress-fill.forecast-kind-expense {
  background: linear-gradient(90deg, #c97878, #b05252);
}

.forecast-progress-fill.forecast-kind-saving {
  background: linear-gradient(90deg, #9ab19e, var(--type-estalvi));
}

.forecast-progress-fill.forecast-kind-other {
  background: linear-gradient(90deg, #cbd5e1, var(--type-unknown));
}

.forecast-item-side {
  display: grid;
  gap: 0.2rem;
  min-width: 8.5rem;
  justify-items: end;
  text-align: right;
}

.forecast-item-side strong {
  font-size: 0.98rem;
}

.forecast-item-side small.warning {
  color: #b45309;
}

.forecast-item-side small.positive {
  color: #2d7d62;
}

.forecast-item-side small.negative {
  color: #b91c1c;
}

@media (max-width: 960px) {
  .forecast-member-kpis,
  .forecast-member-columns {
    grid-template-columns: 1fr;
  }

  .forecast-member-availability {
    justify-content: stretch;
  }

  .forecast-balance-pill {
    min-width: 0;
    flex: 1 1 12rem;
  }
}

@media (max-width: 640px) {
  .forecast-item-row {
    grid-template-columns: 1fr;
  }

  .forecast-item-side {
    justify-items: start;
    text-align: left;
    min-width: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE DRAWER — slide-in sidebar (Twitter/X style)
   MUST be at the very end of the file so it wins over all earlier rules.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Desktop: hide mobile-only elements */
.mobile-nav-overlay {
  display: none;
}

.mobile-menu-fab {
  display: none;
}

.mobile-drawer-close {
  display: none;
}

@media (max-width: 980px) {

  /* ── Collapse the grid so sidebar takes no space ────────────────────────── */
  .app-shell,
  .sidebar-collapsed.app-shell,
  .app-shell:not(.sidebar-collapsed),
  body .app-shell {
    display: block;
    width: 100%;
    padding: 0 !important;
    margin: 0;
  }

  /* ── Sidebar as off-canvas drawer ───────────────────────────────────────── */
  .app-sidebar,
  .sidebar-collapsed .app-sidebar,
  .app-shell .app-sidebar,
  .sidebar-collapsed.app-shell .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100dvh;
    height: 100dvh;
    min-height: 100dvh;
    min-height: 100dvh;
    border-radius: 0;
    border-right: 1px solid rgba(59, 130, 246, 0.18);
    border-left: 0;
    padding: 24px 16px;
    z-index: 200;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-100%);
    transition: transform 300ms cubic-bezier(0.25, 0.8, 0.25, 1),
      box-shadow 300ms cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: none;
    /* Theme — match the light sidebar look */
    background: linear-gradient(180deg, #f5f8ff 0%, #eef4ff 100%);
  }

  body.mobile-drawer-open .app-sidebar,
  body.mobile-drawer-open .sidebar-collapsed .app-sidebar,
  body.mobile-drawer-open .app-shell .app-sidebar {
    transform: translateX(0);
    box-shadow: 6px 0 32px rgba(0, 0, 0, 0.22);
  }

  /* Prevent background scroll when drawer is open */
  body.mobile-drawer-open {
    overflow: hidden;
  }

  /* ── Scrim overlay (app-style, subtle) ─────────────────────────────────── */
  .mobile-nav-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms cubic-bezier(0.25, 0.8, 0.25, 1);
  }

  body.mobile-drawer-open .mobile-nav-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  /* ── Floating menu button (hamburger FAB) ───────────────────────────────── */
  .mobile-menu-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 20px;
    right: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom));
    right: calc(20px + env(safe-area-inset-right));
    z-index: 198;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    border: none;
    background: #1e3a5f;
    color: #dbeafe;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.25);
    transition: background 150ms ease,
      transform 150ms ease,
      opacity 300ms ease;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-menu-fab:active {
    transform: scale(0.92);
    background: #152b49;
  }

  body.mobile-drawer-open .mobile-menu-fab {
    opacity: 0;
    pointer-events: none;
  }

  /* ── Close button inside drawer ─────────────────────────────────────────── */
  .mobile-drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid #d8e3f3;
    background: #edf3fe;
    color: #48617f;
    font-size: 16px;
    cursor: pointer;
    margin-left: auto;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: background 150ms ease;
  }

  .mobile-drawer-close:active {
    background: #ddeafe;
  }

  /* ── Content adjustments ────────────────────────────────────────────────── */
  .app-content,
  body .app-content,
  body:has(.filters-sidebar) .app-content,
  body:has(.filters-sidebar[open]) .app-content {
    padding: 16px 16px 80px 16px !important;
    max-width: 100vw;
    box-sizing: border-box;
  }

  /* ── Filters sidebar: inline on mobile, not fixed right strip ───────────── */
  .filters-sidebar,
  .filters-sidebar[open] {
    position: static !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  /* ── Hide desktop sidebar toggle ────────────────────────────────────────── */
  .sidebar-toggle {
    display: none;
  }

  .sidebar-brand-copy,
  .menu-label {
    display: block;
  }

  /* ── Menu layout inside drawer ──────────────────────────────────────────── */
  .app-sidebar .app-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .app-sidebar .menu-button {
    justify-content: flex-start;
    padding: 13px 14px;
    border-radius: 12px;
    font-size: 15px;
  }

  .app-sidebar .menu-button .menu-icon {
    width: 24px;
    min-width: 24px;
    font-size: 17px;
  }

  /* ── Sidebar brand row styling ──────────────────────────────────────────── */
  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .sidebar-top {
    padding-bottom: 14px;
    margin-bottom: 6px;
    border-bottom: 1px solid #dbe3f0;
  }

  /* ── Status card at bottom ──────────────────────────────────────────────── */
  .sidebar-cache {
    margin-top: auto;
  }
}

/* CSS audit hardening */
html,
body {
  max-width: 100%;
  overflow-x: clip;
}

.app-shell,
.app-content,
main,
.view-panel,
.panel,
.hero,
.filters-panel,
.filters-sidebar,
.filters-summary,
.filters-summary-main,
.filters-search-shell,
.filters-search-copy,
.detail-row-body,
.detail-modal-head > *,
.member-flow-head h3 {
  min-width: 0;
}

.chart-block,
.expense-chart-block,
.type-share-trend-host,
.cashflow-line-chart-shell,
.cashflow-matrix-wrapper {
  max-width: 100%;
  scrollbar-gutter: stable both-edges;
  overscroll-behavior-inline: contain;
}

@media (max-width: 1024px) {
  .app-shell,
  .sidebar-collapsed.app-shell {
    grid-template-columns: 224px minmax(0, 1fr);
  }
}

@media (max-width: 980px) {
  .app-content,
  body .app-content,
  body:has(.filters-sidebar) .app-content,
  body:has(.filters-sidebar[open]) .app-content {
    padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(80px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)) !important;
    overflow-x: clip;
  }

  .app-sidebar,
  .sidebar-collapsed .app-sidebar,
  .app-shell .app-sidebar,
  .sidebar-collapsed.app-shell .app-sidebar {
    left: env(safe-area-inset-left);
    width: min(280px, calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right)));
    height: 100dvh;
    min-height: 100dvh;
    padding: calc(24px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  }
}

@media (max-width: 768px) {
  .member-flow-stats,
  .monthly-type-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1440px) {
  .app-shell,
  .sidebar-collapsed.app-shell {
    max-width: 1440px;
    margin: 0 auto;
  }
}

@media (max-width: 430px) {
  .mobile-menu-fab {
    top: calc(12px + env(safe-area-inset-top));
    left: calc(12px + env(safe-area-inset-left));
    right: auto;
    bottom: auto;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    z-index: 230;
  }

  #filtersPanel.filters-sidebar,
  #filtersPanel.filters-sidebar[open] {
    position: fixed !important;
    top: calc(12px + env(safe-area-inset-top)) !important;
    left: calc(60px + env(safe-area-inset-left)) !important;
    right: calc(12px + env(safe-area-inset-right)) !important;
    width: auto !important;
    margin: 0 !important;
    z-index: 220;
  }

  #filtersPanel.filters-sidebar > .filters-summary,
  #filtersPanel.filters-sidebar[open] > .filters-summary {
    width: 100%;
  }

  #filtersPanel .filters-search-shell {
    grid-template-columns: auto minmax(0, 1fr) auto !important;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 18px;
  }

  #filtersPanel .filters-drawer-button {
    justify-self: end;
    width: 40px;
    height: 40px;
    border-radius: 14px;
  }

  #filtersPanel .filters-body {
    position: fixed !important;
    top: calc(64px + env(safe-area-inset-top));
    left: calc(12px + env(safe-area-inset-left));
    right: calc(12px + env(safe-area-inset-right));
    width: auto;
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 76px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .app-content,
  body .app-content,
  body:has(.filters-sidebar) .app-content,
  body:has(.filters-sidebar[open]) .app-content {
    padding-top: calc(72px + env(safe-area-inset-top)) !important;
  }

  #monthlyExpenseTypeMix.compact-donut-block .donut-layout {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 10px;
  }

  #monthlyExpenseTypeMix.compact-donut-block .donut-svg {
    width: min(100%, 220px);
    max-width: 220px;
  }

  #monthlyExpenseTypeMix.compact-donut-block .donut-legend {
    width: 100%;
    max-width: 100%;
    justify-self: stretch;
  }

  #monthlyTypeShareCompare,
  #monthlyTypeShareTrend {
    overflow-x: hidden;
  }

  #monthlyTypeShareCompare > .type-share-chart {
    width: 100%;
    min-width: 0;
    gap: 10px;
  }

  #monthlyTypeShareCompare .type-share-chart-plot {
    min-height: 240px;
    padding-top: 6px;
  }

  #monthlyTypeShareCompare .type-share-chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  #monthlyTypeShareCompare .type-share-chart-group {
    gap: 8px;
    padding: 0;
  }

  #monthlyTypeShareCompare .type-share-chart-bars {
    min-height: 210px;
  }

  #monthlyTypeShareCompare .type-share-chart-delta small {
    font-size: 12px;
  }

  #monthlyCategoryShareTrend,
  #monthlySubcategoryShareTrend,
  #monthlyTypeShareTrend {
    overflow-x: hidden;
  }

  #monthlyCategoryShareTrend > .monthly-chart,
  #monthlySubcategoryShareTrend > .monthly-chart,
  #monthlyTypeShareTrend > .monthly-chart {
    min-width: 0;
    width: 100%;
    min-height: 0;
    padding: 12px 10px 10px;
    gap: 8px;
  }

  #monthlyCategoryShareTrend .monthly-svg,
  #monthlySubcategoryShareTrend .monthly-svg,
  #monthlyTypeShareTrend .monthly-svg {
    min-width: 0;
    height: auto;
  }

  #monthlyCategoryShareTrend .monthly-legend,
  #monthlySubcategoryShareTrend .monthly-legend,
  #monthlyTypeShareTrend .monthly-legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    justify-content: stretch;
    align-items: stretch;
  }

  #monthlyCategoryShareTrend .type-share-trend-legend-chip,
  #monthlySubcategoryShareTrend .type-share-trend-legend-chip,
  #monthlyTypeShareTrend .type-share-trend-legend-chip {
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
    padding: 7px 10px;
    font-size: 12px;
  }

  .detail-modal {
    place-items: center;
    padding: calc(20px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  }

  .detail-modal-panel {
    width: min(100%, calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    min-height: 0;
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 40px);
    margin: 0;
    padding: 12px;
    gap: 12px;
    border-radius: 20px;
  }

  .detail-modal-head {
    gap: 12px;
  }

  .detail-modal-list {
    gap: 10px;
    padding-right: 0;
    padding-bottom: 0;
  }

  .detail-row {
    gap: 4px 8px;
    padding: 8px 10px;
  }

  .donut-layout,
  .pie-layout {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    justify-items: center;
    gap: 10px;
  }

  .pie-layout {
    width: 100%;
    padding-inline: 12px;
  }

  .donut-svg,
  .pie-svg {
    width: min(100%, 220px);
    max-width: 220px;
  }

  .donut-legend,
  .pie-legend {
    width: 100%;
    max-width: 100%;
    justify-self: stretch;
    gap: 6px;
  }

  .donut-legend-row,
  .pie-legend-row {
    gap: 8px;
    padding: 7px 9px;
    border-radius: 12px;
  }

  .donut-legend-row {
    font-size: 13px;
  }

  .pie-legend-row {
    font-size: 12px;
  }

  .pie-svg {
    width: min(100%, 200px);
    max-width: 200px;
  }

  .pie-slice-percent {
    font-size: 10px;
    stroke-width: 2.4px;
  }

  .pie-slice-label-line {
    stroke-width: 1px;
  }
}

/* ── Expenses view redesign ─────────────────────────────────────── */

.panel-header-year {
  font-weight: 400;
  color: var(--muted);
  font-size: 1.1rem;
  margin-left: 6px;
}

.expenses-kpi-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: stretch;
}

.expenses-kpi-main {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  color: #fff;
  border-radius: 18px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  min-width: 220px;
  cursor: pointer;
}

.expenses-kpi-main-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.expenses-kpi-main-label {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.expenses-kpi-date {
  font-size: 12px;
  opacity: 0.65;
}

.expenses-kpi-main-value {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
  color: #fff;
}

.expenses-kpi-secondary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.expenses-kpi-pill {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 14px 16px;
  background: #fbfdff;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: box-shadow 0.15s ease, background 0.15s ease;
}

.expenses-kpi-pill:hover {
  background: #f5f8ff;
  box-shadow: var(--shadow);
}

.expenses-kpi-pill-label {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.expenses-kpi-pill-value {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.1;
}

.expenses-kpi-pill-meta {
  font-size: 11px;
  color: var(--muted);
}

.kpi-signal {
  font-size: 11px;
  font-weight: 800;
  border-radius: 4px;
  padding: 1px 4px;
}

.kpi-signal--ok {
  background: #e8f4f0;
  color: #2d7d62;
}

.kpi-signal--warn {
  background: #f7edee;
  color: #b05252;
}

/* ── Members compact strip ──────────────────────────────────────── */

.expenses-members-compact {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(219, 227, 240, 0.7);
  display: grid;
  gap: 12px;
}

.expenses-member-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  align-items: center;
}

.expenses-member-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.expenses-member-name strong {
  font-size: 14px;
}

.expenses-member-name .muted {
  font-size: 12px;
}

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

.expenses-member-type-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.expenses-member-type-header {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  flex-wrap: wrap;
}

.expenses-member-type-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.expenses-member-type-name {
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expenses-member-type-pct {
  font-weight: 700;
  color: var(--text);
}

.expenses-member-type-val {
  font-size: 11px;
  margin-left: auto;
}

.expenses-member-bar {
  height: 5px;
  border-radius: 99px;
}

/* ── Expense type accordions ────────────────────────────────────── */

.expense-type-annual-sections {
  display: grid;
  gap: 10px;
}

@media (max-width: 900px) {
  .expenses-kpi-row {
    grid-template-columns: 1fr;
  }

  .expenses-kpi-secondary {
    grid-template-columns: 1fr;
  }

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

  .expenses-member-types {
    grid-template-columns: 1fr;
  }
}

.income-kpi-main {
  background: linear-gradient(135deg, #1a4d3a 0%, #2d7d62 100%);
}

/* ── Income member stacked bar ──────────────────────────────────── */

.income-member-distribution {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.income-member-stack {
  display: flex;
  height: 10px;
  border-radius: 99px;
  overflow: hidden;
  gap: 2px;
}

.income-member-stack-segment {
  border-radius: 99px;
  transition: opacity 0.15s;
}

.income-member-stack-segment:hover {
  opacity: 0.75;
}

.income-member-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.income-member-legend-row {
  display: grid;
  grid-template-columns: 10px 1fr auto auto auto;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.income-member-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.income-member-legend-name {
  font-weight: 600;
}

.income-member-legend-amount {
  font-weight: 700;
  font-size: 13px;
}

.income-member-legend-pct {
  font-size: 12px;
  min-width: 42px;
  text-align: right;
}

.income-member-legend-avg {
  font-size: 12px;
  min-width: 90px;
  text-align: right;
}

@media (max-width: 600px) {
  .income-member-legend-avg {
    display: none;
  }

  .income-member-legend-row {
    grid-template-columns: 10px 1fr auto auto;
  }
}


/* ===========================================================================
   Matriu anual de despesa (taulell)
   Cada fila hereta el color del seu Tipus via --type-<slug>; el mes actiu del
   navegador de dates queda ressaltat en columna sencera per situar la lectura.
   =========================================================================== */
.expense-matrix-panel {
  overflow: hidden;
}

.expense-matrix-legend {
  flex-wrap: wrap;
  gap: 6px;
}

.expense-matrix-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--type-soft, #f4f6fa);
  font-size: 12px;
  font-weight: 700;
  color: var(--type-strong, var(--text));
  white-space: nowrap;
}

.expense-matrix-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--type-base, var(--muted));
}

.expense-matrix-legend-value {
  color: var(--muted);
  font-weight: 600;
}

/* Mateixa mida i forma que els xips de la llegenda del costat. */
.expense-matrix-capture-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: #f4f6fa;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
}

.expense-matrix-capture-button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.expense-matrix-capture-button:disabled {
  cursor: default;
  opacity: 0.75;
}

/* `overflow-x: auto` amb `overflow-y: visible` no és una combinació vàlida (el
   navegador la converteix en `auto`/`auto` i reintrodueix el scroll vertical
   intern). `scroll clip` sí permet scroll horitzontal sense caixa vertical.
   `scrollbar-gutter: stable both-edges` ve heretat de `.table-wrapper` i reserva
   espai per una scrollbar vertical que aquí no existeix mai: deixa una franja
   blanca morta a la dreta en finestres amples. La desactivem. */
.expense-matrix-wrapper {
  overflow-x: scroll;
  overflow-y: clip;
  scrollbar-gutter: auto;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
}

/* La taula surt del padding del .panel per guanyar amplada real als mesos:
   el títol/llegenda es queden dins la caixa normal, però la matriu s'estén
   fins al cantell del panell (bleed horitzontal, sense tocar dalt/baix). */
.expense-matrix-panel {
  padding-left: 0;
  padding-right: 0;
  overflow: hidden;
}

.expense-matrix-panel .panel-header {
  padding-left: 22px;
  padding-right: 22px;
}

.expense-matrix-panel .expense-matrix-wrapper {
  border-left: none;
  border-right: none;
  border-radius: 0;
}

.expense-matrix {
  width: max-content;
  min-width: 100%;
  table-layout: auto;
  font-variant-numeric: tabular-nums;
}

.expense-matrix th,
.expense-matrix td {
  padding: 7px 8px;
  font-size: 12.5px;
  border-bottom: 1px solid #eef2f8;
}

.expense-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f5f8fd;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #51657f;
  text-align: right;
  border-bottom: 2px solid #dce7f5;
}

.expense-matrix thead th.expense-matrix-axis {
  text-align: left;
}

.expense-matrix-month-short {
  display: none;
}

/* Les tres columnes d'eix queden fixades a l'esquerra amb el color del Tipus
   perquè l'scroll horitzontal dels mesos no faci perdre la referència. */
.expense-matrix .expense-matrix-axis {
  position: sticky;
  z-index: 2;
  background: #fbfdff;
  text-align: left;
  font-weight: 700;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expense-matrix thead .expense-matrix-axis {
  z-index: 4;
  background: #f5f8fd;
}

/* Els offsets `left` dels eixos sticky han de coincidir amb amplades exactes:
   amb només min-width la taula els eixampla i les columnes es solapen en scroll. */
.expense-matrix .expense-matrix-axis:first-child {
  left: 0;
  width: 108px;
  min-width: 108px;
  max-width: 108px;
}

.expense-matrix .expense-matrix-axis-sub {
  left: 108px;
  width: 132px;
  min-width: 132px;
  max-width: 132px;
  font-weight: 800;
  color: var(--text);
}

.expense-matrix .expense-matrix-axis-type {
  left: 240px;
  width: 120px;
  min-width: 120px;
  max-width: 120px;
  box-shadow: 1px 0 0 #dce7f5;
}

.expense-matrix-type-pill {
  display: block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--type-soft, #f0f3f8);
  color: var(--type-strong, var(--muted));
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expense-matrix-type-short {
  display: none;
}

.expense-matrix-budget {
  text-align: right;
  color: var(--muted);
  background: #f9fbfe;
}

.expense-matrix-cell {
  text-align: right;
  min-width: 62px;
}

/* Direcció del diner: sortida en vermell, entrada en verd. */
.expense-matrix td.is-outflow {
  color: var(--danger);
}

.expense-matrix td.is-inflow {
  color: var(--success);
}

/* Els estats de cel·la (buida, futura, mes destacat) han de continuar manant el color
   per sobre del signe, així que es reforcen amb la mateixa especificitat o més. */
.expense-matrix td.expense-matrix-cell.is-empty {
  color: #b6c2d2;
}

.expense-matrix-cell.is-empty {
  color: #b6c2d2;
}

.expense-matrix .is-clickable {
  cursor: pointer;
}

.expense-matrix .is-clickable:hover {
  outline: 2px solid rgba(37, 99, 235, 0.45);
  outline-offset: -2px;
  color: var(--primary);
}

.expense-matrix .is-clickable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.expense-matrix td.expense-matrix-cell.is-future,
.expense-matrix-cell.is-future {
  color: #c2ccd9;
  background: repeating-linear-gradient(
    135deg,
    #fbfcfe,
    #fbfcfe 4px,
    #f5f7fb 4px,
    #f5f7fb 8px
  );
}

/* Mes en curs del panel-date-navigation: columna destacada de dalt a baix. */
.expense-matrix .expense-matrix-cell.is-active-month {
  background: var(--primary-soft);
  box-shadow: inset 1px 0 0 rgba(37, 99, 235, 0.28), inset -1px 0 0 rgba(37, 99, 235, 0.28);
  font-weight: 800;
  color: #1d3f8a;
}

.expense-matrix thead th.expense-matrix-cell.is-active-month {
  background: #cadffb;
  color: #1b3a80;
  box-shadow: inset 1px 0 0 rgba(37, 99, 235, 0.4), inset -1px 0 0 rgba(37, 99, 235, 0.4);
}

.expense-matrix-total {
  text-align: right;
  font-weight: 800;
  background: #f6f9fe;
  box-shadow: inset 1px 0 0 #dce7f5;
}

.expense-matrix-share {
  text-align: right;
  font-weight: 700;
  color: var(--muted);
  background: #f6f9fe;
  padding-right: 14px;
  min-width: 58px;
}

.expense-matrix-share.is-over { color: var(--danger); }
.expense-matrix-share.is-warn { color: var(--warning); }
.expense-matrix-share.is-under { color: var(--success); }

/* Bandes per Tipus: el to de fons ve del token del Tipus, així "estalvi",
   "fixa", "necessària" i "discrecional" es distingeixen d'un cop d'ull. */
.expense-matrix-row.type-ingres { --type-base: var(--type-ingres); --type-soft: var(--type-ingres-soft); --type-strong: var(--type-ingres-strong); }
.expense-matrix-row.type-estalvi { --type-base: var(--type-estalvi); --type-soft: var(--type-estalvi-soft); --type-strong: var(--type-estalvi-strong); }
.expense-matrix-row.type-despesa-fixa { --type-base: var(--type-despesa-fixa); --type-soft: var(--type-despesa-fixa-soft); --type-strong: var(--type-despesa-fixa-strong); }
.expense-matrix-row.type-despesa-necesaria { --type-base: var(--type-despesa-necesaria); --type-soft: var(--type-despesa-necesaria-soft); --type-strong: var(--type-despesa-necesaria-strong); }
.expense-matrix-row.type-despesa-discrecional { --type-base: var(--type-despesa-discrecional); --type-soft: var(--type-despesa-discrecional-soft); --type-strong: var(--type-despesa-discrecional-strong); }
.expense-matrix-row.type-especial { --type-base: var(--type-especial); --type-soft: var(--type-especial-soft); --type-strong: var(--type-especial-strong); }
.expense-matrix-row.type-unknown { --type-base: var(--type-unknown); --type-soft: var(--type-unknown-soft); --type-strong: var(--type-unknown-strong); }

.expense-matrix-legend-item.type-ingres { --type-base: var(--type-ingres); --type-soft: var(--type-ingres-soft); --type-strong: var(--type-ingres-strong); }
.expense-matrix-legend-item.type-estalvi { --type-base: var(--type-estalvi); --type-soft: var(--type-estalvi-soft); --type-strong: var(--type-estalvi-strong); }
.expense-matrix-legend-item.type-despesa-fixa { --type-base: var(--type-despesa-fixa); --type-soft: var(--type-despesa-fixa-soft); --type-strong: var(--type-despesa-fixa-strong); }
.expense-matrix-legend-item.type-despesa-necesaria { --type-base: var(--type-despesa-necesaria); --type-soft: var(--type-despesa-necesaria-soft); --type-strong: var(--type-despesa-necesaria-strong); }
.expense-matrix-legend-item.type-despesa-discrecional { --type-base: var(--type-despesa-discrecional); --type-soft: var(--type-despesa-discrecional-soft); --type-strong: var(--type-despesa-discrecional-strong); }
.expense-matrix-legend-item.type-especial { --type-base: var(--type-especial); --type-soft: var(--type-especial-soft); --type-strong: var(--type-especial-strong); }
.expense-matrix-legend-item.type-unknown { --type-base: var(--type-unknown); --type-soft: var(--type-unknown-soft); --type-strong: var(--type-unknown-strong); }

.expense-matrix-row .expense-matrix-axis {
  background: var(--type-soft, #fbfdff);
}

.expense-matrix-row .expense-matrix-axis:first-child {
  box-shadow: inset 3px 0 0 var(--type-base, transparent);
}

.expense-matrix-row.starts-type-group th,
.expense-matrix-row.starts-type-group td {
  border-top: 2px solid var(--type-base, #dce7f5);
}

.expense-matrix tbody tr:hover .expense-matrix-cell {
  background: #eef4fd;
}

.expense-matrix tbody tr:hover .expense-matrix-cell.is-active-month {
  background: #c6dcfa;
}

.expense-matrix-total-row th,
.expense-matrix-total-row td {
  background: #eef3fb;
  border-top: 2px solid #cddbee;
  border-bottom: none;
  font-weight: 800;
  color: var(--text);
}

.expense-matrix-total-row .expense-matrix-axis {
  z-index: 4;
  background: #eef3fb;
}

.expense-matrix-total-row .expense-matrix-cell.is-active-month {
  background: #c6dcfa;
}

/* Tablet: amaguem la columna Categoria i escurcem els noms de mes. */
@media (max-width: 1100px) {
  .expense-matrix-month-long {
    display: none;
  }

  .expense-matrix-month-short {
    display: inline;
  }

  .expense-matrix th,
  .expense-matrix td {
    padding: 6px 7px;
    font-size: 12px;
  }

  .expense-matrix .expense-matrix-axis:first-child {
    display: none;
  }

  .expense-matrix .expense-matrix-axis-sub {
    left: 0;
    width: 122px;
    min-width: 122px;
    max-width: 122px;
    box-shadow: inset 3px 0 0 var(--type-base, transparent);
  }

  .expense-matrix .expense-matrix-axis-type {
    left: 122px;
    width: 106px;
    min-width: 106px;
    max-width: 106px;
  }

  .expense-matrix-type-long {
    display: none;
  }

  .expense-matrix-type-short {
    display: inline;
  }
}

/* Mòbil: només l'eix de subcategoria queda fix; el Tipus es redueix a una
   barra de color a l'esquerra i les columnes de referència desapareixen. */
@media (max-width: 700px) {
  .expense-matrix-panel .panel-header {
    padding-left: 16px;
    padding-right: 16px;
  }

  .expense-matrix-wrapper {
    border-radius: 12px;
  }

  .expense-matrix th,
  .expense-matrix td {
    padding: 6px 6px;
    font-size: 11.5px;
  }

  .expense-matrix .expense-matrix-axis-type,
  .expense-matrix-budget {
    display: none;
  }

  .expense-matrix .expense-matrix-axis-sub {
    left: 0;
    width: 110px;
    min-width: 110px;
    max-width: 110px;
    box-shadow: inset 3px 0 0 var(--type-base, transparent), 1px 0 0 #dce7f5;
  }

  .expense-matrix-cell {
    min-width: 52px;
  }

  .expense-matrix-legend-item {
    padding: 3px 8px;
    font-size: 11px;
  }

  .expense-matrix-legend-value {
    display: none;
  }
}

@media (max-width: 430px) {
  .expense-matrix .expense-matrix-axis-sub {
    width: 96px;
    min-width: 96px;
    max-width: 96px;
  }

  .expense-matrix-share {
    display: none;
  }
}

/* ══ Supabase auth gate (only shown in mode=supabase) ══ */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, rgba(237, 243, 255, 0.98), rgba(245, 248, 253, 0.98));
}

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

.auth-gate-card {
  width: min(100%, 360px);
  display: grid;
  gap: 14px;
  padding: 28px 24px;
  border: 1px solid var(--chrome-border, #c7d5e4);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.14);
  text-align: center;
}

.auth-gate-brand { font-size: 20px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.auth-gate-text { margin: 0; color: #475569; line-height: 1.5; }
.auth-gate-button { width: 100%; }
.auth-gate-error { margin: 0; color: #b91c1c; font-size: 13px; }
.auth-gate-error[hidden] { display: none; }

/* Auth gate: no scroll while gated */
body.auth-gate-open { overflow: hidden; }
