/* Amarillo: canarino, becco e nero. Font locali, nessuna richiesta a terzi. */
@font-face { font-family: 'Hanken Grotesk'; src: url('/fonts/hanken-grotesk.woff2') format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Bricolage Grotesque'; src: url('/fonts/bricolage-grotesque.woff2') format('woff2'); font-weight: 200 800; font-style: normal; font-display: swap; }
:root {
  --canary: #FAAF25; --beak: #F26128; --accent: var(--canary); --accent-bg: var(--canary);
  --primary-text: #000000; --radius-card: 12px; --radius-btn: 8px;
  --font: 'Hanken Grotesk', system-ui, sans-serif; --font-title: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-mono: ui-monospace, monospace; --weight-ui: 500;
}
:root[data-theme='light'] {
  color-scheme: light; --bg: #FFFFFF; --bg-panel: #FFF8E7; --bg-card: transparent; --bg-card-hover: #EAF2FC;
  --bg-elevated: #FFFFFF; --bg-input: #FFFFFF; --text: #000000; --text-secondary: #393326;
  --text-muted: #625A49; --text-faint: #625A49; --accent-ink: #8A5A00; --border-input: #8C8065; --border: #EFE3C4; --border-subtle: #EFE3C4;
  --green: #1F7A4D; --green-text: #1F7A4D; --blue: #2F65A8; --red: #B8400F; --red-soft: #FFF0E8;
}
:root[data-theme='dark'] {
  color-scheme: dark; --bg: #000000; --bg-panel: #15130F; --bg-card: transparent; --bg-card-hover: #152438;
  --bg-elevated: #15130F; --bg-input: #15130F; --text: #FAF5E9; --text-secondary: #E8DCC0;
  --text-muted: #C2B9A5; --text-faint: #C2B9A5; --accent-ink: #FAAF25; --border-input: #81765F; --border: #2B2720; --border-subtle: #2B2720;
  --green: #4CC38A; --green-text: #4CC38A; --blue: #7AAEE8; --red: #F26128; --red-soft: #2C160D;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-font-smoothing: antialiased; scroll-padding-bottom: 90px; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
button, input, select { min-height: 44px; }
button, summary { cursor: pointer; }
button:disabled { opacity: .6; cursor: wait; }
:where(button, a, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 3px; box-shadow: 0 0 0 2px var(--canary); }
input:focus, select:focus { border-color: var(--accent-ink); }
a { color: var(--accent-ink); }
.wrap { max-width: 1160px; margin: auto; padding: 32px 32px 64px; min-width: 0; }
.skip-link { position: absolute; left: 12px; top: -80px; z-index: 100; padding: 12px; color: #000; background: var(--canary); }
.skip-link:focus { top: 12px; }
header { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.logo { width: 36px; height: 36px; }
h1, h2, h3 { font-family: var(--font-title); letter-spacing: -.03em; line-height: 1.2; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 24px; margin: 0; }
h3 { font-size: 18px; }
.spacer { flex: 1; }
.user-menu { position: relative; z-index: 30; max-width: 55%; }
.user-menu > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 8px; min-height: 44px; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu summary svg { width: 16px; height: 16px; flex-shrink: 0; }
.user-chip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu[open] > summary { background: var(--bg-panel); }
.user-menu-panel { position: absolute; top: calc(100% + 8px); right: 0; display: grid; padding: 8px; min-width: 180px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 30px #0002; }
.theme-toggle { padding: 10px 12px; color: var(--text); background: transparent; border: 0; border-radius: 6px; text-align: left; }
.theme-toggle:hover { background: var(--bg-card-hover); }
.tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 36px; }
.tab { display: flex; align-items: center; gap: 8px; color: var(--text-muted); text-decoration: none; padding: 10px 16px; min-height: 44px; border-radius: 8px; font-size: 15px; }
.tab svg { width: 20px; height: 20px; display: none; flex-shrink: 0; }
.tab:hover { color: var(--text); background: var(--bg-panel); }
.tab.active { color: #000000; background: var(--canary); font-weight: 700; }
.card { margin: 0 0 40px; min-width: 0; }
.card-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 12px; padding: 0 0 20px; }
.card-head .meta, .meta { color: var(--text-muted); font-size: 13px; }
.card-body { padding: 0; min-width: 0; }
.form-row { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-secondary); }
input, select, textarea { color: var(--text); background: var(--bg-input); border: 1px solid var(--border-input); border-radius: var(--radius-btn); padding: 10px 12px; min-width: 0; }
input::placeholder { color: var(--text-muted); opacity: 1; }
.btn-primary { border: 0; padding: 10px 18px; border-radius: var(--radius-btn); background: var(--canary); color: #000; font-weight: 700; }
.btn-primary:hover { background: #FFD36B; }
.btn-small { padding: 8px 12px; border: 1px solid var(--border-input); border-radius: var(--radius-btn); color: var(--text); background: var(--bg-input); }
.btn-small:hover { border-color: var(--accent-ink); }
.login-card { max-width: 420px; margin: 8vh auto; }
.login-brand { width: 80px; height: 80px; margin-bottom: 24px; }
.login-card h2 { font-size: 32px; }
.login-card .card-head { display: block; }
.login-card .card-head p { margin: 12px 0 8px; color: var(--text-muted); }
.login-form { display: grid; gap: 20px; }
.login-form input { width: 100%; }
.login-error { color: var(--red); margin-top: 16px; }
.kpis { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 24px; margin-bottom: 32px; }
.kpi { min-width: 0; }
.kpi .label { color: var(--text-muted); font-size: 13px; }
.kpi .value { font-family: var(--font-title); font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi .hint { font-size: 13px; color: var(--text-muted); }
.kpi.neg .value { color: var(--red); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-size: 13px; font-weight: 600; color: var(--text-muted); padding: 12px; border-bottom: 1px solid var(--border); }
td { padding: 14px 12px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; overflow-wrap: break-word; }
tbody tr:hover td { background: var(--bg-card-hover); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: 13px; }
.t-income, .t-income .num { color: var(--green-text); }
.t-transfer, .t-transfer .num { color: var(--blue); }
tr.neg-balance td.saldo { color: var(--red); }
.badge { display: inline-block; padding: 3px 8px; font-size: 13px; border-radius: 6px; color: var(--text-secondary); white-space: nowrap; }
.badge.paid { color: var(--green-text); }
.badge.due { color: var(--text-muted); }
.badge.est { color: var(--accent-ink); }
.chart-box { position: relative; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; color: var(--text-muted); font-size: 13px; padding-top: 12px; }
.chart-legend .swatch { display: inline-block; width: 18px; height: 3px; vertical-align: middle; margin-right: 6px; }
svg .axis { stroke: none; fill: var(--text-muted); font-size: 12px; }
svg .zero { stroke: var(--red); stroke-dasharray: 4 3; }
#chart, .table-scroll { overflow-x: auto; max-width: 100%; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 16px; }
.chip { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: transparent; font-size: 13px; }
.chip.active { color: #000; background: var(--canary); border-color: var(--canary); }
.accounts-list { list-style: none; margin: 0; padding: 0; }
.account { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 20px; padding: 24px 0; border-bottom: 1px solid var(--border); }
.account-summary { display: flex; flex: 1; align-items: center; justify-content: space-between; gap: 24px; min-width: 0; }
.account-summary > div:first-child { min-width: 0; }
.account .name { font-size: 18px; font-weight: 600; }
.account .balance { font-size: 24px; font-family: var(--font-title); font-variant-numeric: tabular-nums; white-space: nowrap; }
.account .iban { font-size: 13px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-actions { display: flex; flex-wrap: wrap; align-items: start; justify-content: end; gap: 12px; }
summary { padding: 10px 12px; border-radius: 8px; min-height: 44px; }
.account-form { max-width: 420px; margin-top: 12px; }
.account-form label { flex: 1 1 140px; }
.balance-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.balance-form label { flex: 1 1 120px; min-width: 0; }
.balance-form input { width: 100%; }
.legend-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; }
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 640px) {
  .wrap { padding: 20px 16px calc(100px + env(safe-area-inset-bottom)); }
  header { margin-bottom: 28px; }
  h1 { font-size: 24px; }
  h2 { font-size: 24px; }
  input, select, textarea { font-size: 16px; }
  .tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 0; padding: 8px 4px calc(8px + env(safe-area-inset-bottom)); margin: 0; border: 0; border-top: 1px solid var(--border); background: var(--bg-elevated); }
  .tab { padding: 6px 2px; flex-direction: column; gap: 4px; font-size: 13px; min-height: 52px; }
  .tab svg { display: block; }
  .card { margin-bottom: 32px; }
  .card-head { gap: 8px; padding-bottom: 16px; }
  .kpis { gap: 20px; }
  .kpi .value { font-size: 24px; }
  .account-summary { flex-basis: 100%; gap: 12px; }
  .account-actions { width: 100%; justify-content: start; }
  .account-actions details { width: 100%; }
  .form-row > input, .form-row > select { flex: 1 1 100%; width: 100%; }
  .login-card { margin: 4vh auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

#due-table td:nth-child(1), #due-table td:nth-child(2), #due-table td:nth-child(5),
#pay-table td:nth-child(1), #pay-table td:nth-child(2), #pay-table td:nth-child(6),
#payee-table td:last-child, #cf-table td:first-child { white-space: nowrap; overflow-wrap: normal; }
:root[data-theme='light'] .tab.active { box-shadow: inset 0 -2px var(--accent-ink); }
@media (max-width: 640px) {
  header .logo { width: 28px; height: 28px; }
  header h1 { font-size: 18px; }
}

.nowrap { white-space: nowrap; }
.urgent { color: var(--red); }
.app-dialog { color: var(--text); background: var(--bg-elevated); border: 1px solid var(--border-input); border-radius: 16px; width: min(600px,calc(100% - 32px)); max-height: calc(100dvh - 40px); padding: 24px; }
.app-dialog::backdrop { background: #0009; }
.dialog-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; padding-bottom: 24px; }
.dialog-body { display: grid; gap: 16px; }
.dialog-body label { min-width: 0; }
.dialog-actions { display: flex; justify-content: end; gap: 12px; margin-top: 24px; }
.field-error { color: var(--red); font-size: 13px; margin: 4px 0; }
[aria-invalid='true'] { border-color: var(--red); }
#toast-region { position: fixed; bottom: 24px; right: 24px; max-width: min(480px,calc(100% - 32px)); z-index: 100; display: grid; gap: 12px; }
.toast { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: var(--text); background: var(--bg-elevated); border: 1px solid var(--border-input); border-radius: 12px; box-shadow: 0 8px 32px #0003; }
.toast span { flex: 1; }
.toast-error { border-color: var(--red); }
.sort-header { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; color: inherit; background: none; font-size: inherit; text-align: inherit; }
.mobile-sort, .mobile-rows { display: none; }
.chart-tooltip { position: fixed; z-index: 110; max-width: min(320px,calc(100vw - 16px)); white-space: pre-line; overflow-wrap: anywhere; padding: 12px; color: var(--text); background: var(--bg-elevated); border: 1px solid var(--border-input); border-radius: 10px; pointer-events: none; font-size: 13px; }
@media (max-width: 640px) {
  .app-dialog { margin: auto 0 0; max-height: calc(100dvh - 24px); width: 100%; max-width: 100%; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .desktop-table { display: none; }
  .mobile-sort { display: block; margin-bottom: 12px; }
  .mobile-sort label { max-width: 100%; }
  .mobile-rows { display: block; list-style: none; padding: 0; margin: 0; }
  .mobile-rows li { padding: 16px 0; border-bottom: 1px solid var(--border); }
  .mobile-primary { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
  .mobile-primary > :first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-primary > :last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
  .mobile-secondary { color: var(--text-muted); font-size: 13px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #toast-region { bottom: calc(88px + env(safe-area-inset-bottom)); right: 12px; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.payment-warning { background: var(--canary); color: #000; --red: #7A2B08; --accent-ink: #603900; --border-input: #8A5A00; --bg-input: #FFF8E7; --text: #000; padding: 28px; border-radius: 16px; margin-bottom: 32px; }
.payment-warning-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.payment-warning-head h2 { font-size: 32px; margin: 0; min-width: 0; }
.payment-warning > p { margin: 12px 0 24px; }
.due-group h3 { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 0 12px; }
.due-group ul, .secondary-due ul { list-style: none; padding: 0; margin: 0; }
.due-item { display: grid; grid-template-columns: minmax(0,1fr) auto 36px; align-items: center; gap: 16px; padding: 16px 0; border-top: 1px solid #0003; }
.due-description { display: grid; gap: 4px; min-width: 0; }
.due-description > strong, .due-cause { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due-cause { font-size: 13px; }
.due-actions { display: flex; align-items: center; gap: 12px; }
.due-amount { font-variant-numeric: tabular-nums; font-size: 18px; }
.due-actions a { font-size: 13px; }
.secondary-due { margin: 0 0 36px; }
.secondary-due summary { display: flex; align-items: center; gap: 10px; padding-left: 0; font-weight: 600; }
.secondary-due summary::before { content: ''; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); flex-shrink: 0; }
.secondary-due[open] summary::before { transform: rotate(45deg); }
.secondary-due summary > span { flex: 1; min-width: 0; }
.secondary-due li { display: grid; grid-template-columns: minmax(0,1fr) auto 36px; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.secondary-due li > span { min-width: 0; overflow-wrap: anywhere; }
.secondary-due li > strong { white-space: nowrap; }
@media (max-width: 640px) {
  .payment-warning { padding: 20px 16px; }
  .payment-warning-head h2 { font-size: 24px; }
  .due-item { grid-template-columns: minmax(0,1fr) 36px; gap: 12px; align-items: start; }
  .due-description { grid-column: 1; grid-row: 1; }
  .due-item > .assistant-anchor { grid-column: 2; grid-row: 1; }
  .due-actions { grid-column: 1/-1; grid-row: 2; flex-wrap: wrap; gap: 8px 12px; }
  .mark-paid { padding: 8px; }
}
.liquidity-interactive { display: grid; grid-template-columns: minmax(260px,360px) minmax(0,1fr); gap: 40px; align-items: center; }
.donut-box { position: relative; width: 100%; min-height: 220px; }
.liquidity-donut { display: block; width: 100%; height: auto; overflow: visible; }
.donut-center { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 56%; display: grid; text-align: center; gap: 4px; pointer-events: none; }
.donut-center > strong { font-family: var(--font-title); font-size: 24px; font-variant-numeric: tabular-nums; }
.donut-account-name { font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.donut-center:has(.donut-account-name) > strong { font-size: 18px; }
.liquidity-slice { cursor: pointer; transform-origin: 128px 128px; }
.liquidity-slice:focus-visible { outline: none; stroke: var(--accent-ink); stroke-width: 4; }
.donut-legend { list-style: none; padding: 0; margin: 0; min-width: 0; }
.donut-legend li { display: grid; grid-template-columns: minmax(0,1fr) 36px; align-items: center; gap: 8px; }
.donut-legend a { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--text); text-decoration: none; min-height: 44px; padding: 10px; border-radius: 8px; }
.donut-legend .is-active a { background: var(--bg-panel); box-shadow: inset 3px 0 var(--accent-ink); }
.legend-account-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend strong { white-space: nowrap; font-variant-numeric: tabular-nums; }
.liquidity-exceptions { list-style: none; padding: 0; margin-top: 24px; }
.liquidity-exceptions li { display: grid; grid-template-columns: minmax(0,1fr) auto 36px; align-items: center; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.liquidity-exceptions a { grid-column: 1; grid-row: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.liquidity-exceptions strong { grid-column: 2; grid-row: 1; white-space: nowrap; }
.liquidity-exceptions .muted { grid-column: 1/3; grid-row: 2; }
.liquidity-exceptions .assistant-anchor { grid-column: 3; grid-row: 1/3; }
.liquidity-note { font-size: 13px; }
@media (prefers-reduced-motion: no-preference) {
  .liquidity-slice { animation: donut-in .4s ease-out both; transition: transform .15s ease-out; }
  @keyframes donut-in { from { opacity: 0; } to { opacity: 1; } }
}
@media (max-width: 640px) {
  .liquidity-interactive { grid-template-columns: 1fr; gap: 16px; }
  .donut-box { max-width: 300px; margin: auto; }
  .donut-center > strong { font-size: 24px; }
}
:root[data-theme='light'] .liquidity-slice { stroke: var(--border-input); stroke-width: 1; }
#chart { overflow: visible; }
.cashflow-chart { touch-action: pan-y; }
.chart-readout { font-size: 13px; min-height: 40px; }
.chart-instructions { margin-bottom: 4px; }
#view-cashflow .kpis { display: flex; flex-wrap: wrap; gap: 20px 32px; padding: 0 0 24px; border-bottom: 1px solid var(--border); }
#view-cashflow .kpi { flex: 1 1 180px; }
#view-cashflow .kpi .value { font-size: 24px; }
.monthly-chart { display: block; width: 100%; height: auto; }
#view-cashflow { --monthly-red: #b93446; }
:root[data-theme='dark'] #view-cashflow { --monthly-red: #ff7284; }
.monthly-chart .axis { font-size: 11px; }
.monthly-grid { stroke: var(--border-subtle); }
.monthly-income { fill: var(--blue); background: var(--blue); }
.monthly-expense { fill: var(--monthly-red); background: var(--monthly-red); }
.monthly-zero { stroke: var(--text-muted); stroke-width: 1.5; }
.monthly-result-line { fill: none; stroke: #7e838b; stroke-width: 1.5; }
.monthly-result-point { stroke: var(--bg); stroke-width: 1; }
.monthly-result-point.non-negative { fill: var(--green); }
.monthly-result-point.negative { fill: var(--monthly-red); }
.monthly-guide { stroke: var(--text-faint); stroke-dasharray: 3 3; pointer-events: none; }
.monthly-legend { justify-content: center; padding-top: 6px; }
.monthly-legend .swatch { border-radius: 2px; }
.monthly-legend .monthly-net { background: #7e838b; height: 2px; vertical-align: .28em; }
#cf-table td, #cf-table th { padding: 3px 8px; }
#cf-table .sort-header { min-height: 30px; }
.month-mobile-heading { display: flex; align-items: baseline; gap: 10px; flex: 1; min-width: 0; }
.month-mobile-heading a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.month-mobile-heading > span { font-size: 13px; }
.monthly-mobile-values { display: flex; flex-wrap: wrap; gap: 2px 14px; }
.monthly-mobile-values > div { white-space: nowrap; }
.monthly-cashflow .mobile-secondary { overflow: visible; white-space: normal; margin-top: 2px; }
.monthly-cashflow .mobile-rows > li { padding: 5px 0; }
.chart-tooltip { max-height: calc(100dvh - 16px); overflow-y: auto; }
@media (max-width: 640px) {
  #view-cashflow .kpis { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px 12px; }
  #view-cashflow .kpi .value { font-size: 18px; }
}

.chart-tooltip.is-interactive { pointer-events: auto; max-height: min(60dvh,480px); }

.chart-readout.sr-only { min-height: 0; }
#view-conti .card-head > .btn-primary { margin-left: auto; }
.account-name { font-weight: 600; font-size: 18px; color: var(--text); border: 0; padding: 0; text-align: left; background: transparent; min-height: 44px; }
.account-value { text-align: right; }
.account-value .balance { font-size: 24px; }
.account-value .faint { font-size: 13px; }
.account-summary > div:first-child { flex: 1; overflow-wrap: anywhere; }
.stale-balance { text-decoration: underline dotted; text-underline-offset: 3px; }
.inactive-accounts { margin-top: 28px; }
.inactive-accounts > summary { color: var(--text-muted); padding-left: 0; }
.input-with-action { display: flex; gap: 8px; }
.input-with-action > input { flex: 1; width: 100%; min-width: 0; }
.switch-field { flex-direction: row; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; }
.switch-field input { appearance: none; position: relative; width: 44px; height: 26px; min-height: 26px; padding: 0; border-radius: 30px; background: var(--bg-panel); }
.switch-field input::before { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--text); }
.switch-field input:checked { background: var(--canary); border-color: var(--accent-ink); }
.switch-field input:checked::before { transform: translateX(18px); background: #000; }
.balance-history { list-style: none; padding: 0; }
.balance-history li { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--border); }
@media (max-width: 640px) {
  .account-value .balance { font-size: 18px; }
  .account .account-actions { justify-content: end; }
  .account .account-actions button { min-height: 44px; }
}

@media (max-width: 640px) { .account { padding: 16px 0; gap: 12px; } }
.movement-search { flex: 1; min-width: 180px; }
.movement-summary, .month-summary { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; }
.movement-summary { padding: 16px 0; }
.month-name { font-family: var(--font-title); font-size: 18px; display: block; margin-bottom: 4px; color: var(--text); }
.month-heading { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.month-heading .month-name { margin-bottom: 0; white-space: nowrap; }
.month-separator { background: var(--bg-panel); color: var(--text); }
.month-separator > th { position: sticky; top: 0; z-index: 2; background: var(--bg-panel); padding: 14px 12px; }
.movements-scroll { max-height: none; overflow: visible; }
#pay-table .desktop-table { table-layout: fixed; }
#pay-table .desktop-table th.assistant-selection-cell { width: 44px; }
#pay-table .desktop-table .assistant-selection-cell { padding: 4px; text-align: center; }
#pay-table .desktop-table th.movement-date { width: 105px; }
#pay-table .desktop-table th.movement-status { width: 56px; }
#pay-table .desktop-table th.movement-amount { width: 150px; }
.type-label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.type-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }
.status-label { font-size: 13px; }
.estimate-mark { font-size: 13px; color: var(--text-muted); }
@media (max-width: 640px) {
  .movements-scroll { max-height: none; overflow: visible; }
  #pay-table .mobile-rows > .month-separator { position: sticky; top: 0; z-index: 2; padding: 12px; margin: 0 -12px; }
  .mobile-rows > li.selectable-row { display: grid; grid-template-columns: 36px minmax(0,1fr); column-gap: 8px; }
  .selectable-row > .assistant-select { grid-column: 1; grid-row: 1 / 3; align-self: start; }
  .selectable-row > .mobile-primary, .selectable-row > .mobile-secondary { grid-column: 2; }
  .month-summary { gap: 2px 10px; font-size: 13px; }
  .month-summary > span:last-child { flex-basis: 100%; }
  #filters label { flex: 1 1 130px; min-width: 0; }
}

#pay-table .desktop-table .month-separator > th { width: auto; }

#pay-table .desktop-table { border-collapse: separate; border-spacing: 0; }
#pay-table .month-group { position: relative; }
#pay-table .desktop-table .month-separator { position: sticky; top: 0; z-index: 3; }
#pay-table .desktop-table .month-separator > th { position: static; background: var(--bg-panel); }
.movements-scroll { padding: 0; isolation: isolate; }
.mobile-month-group { position: relative; }
/* Chrome ancora riferisce lo sticky di TR alla tabella: i separatori precedenti
   restano sovrapposti. Lo sfondo pieno e la stessa struttura tengono visibile solo
   quello corrente; mantenere questa opacità se si cambia il layout del riepilogo. */
.payee-search { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 24px; margin-bottom: 16px; }
.payee-search input { min-width: min(280px,100%); }
.payee-name { color: var(--text); text-decoration-color: var(--accent-ink); text-underline-offset: 4px; }
.payee-ratio { display: flex; height: 5px; width: 100%; max-width: 240px; margin-top: 8px; background: var(--bg-panel); }
.payee-ratio > span { display: block; height: 100%; }
.payee-ratio .received { background: var(--green); }
.payee-ratio .sent { background: var(--text-secondary); }
@media (max-width: 640px) {
  .payee-search label, .payee-search input { width: 100%; min-width: 0; }
  .payee-search > p { margin: 0; }
  .payee-mobile-summary { position: relative; padding-bottom: 10px; }
  .payee-mobile-summary .payee-ratio { position: absolute; bottom: 0; max-width: none; height: 4px; margin: 0; }
}
.payee-over-scale { font-size: 13px; color: var(--text-muted); }
.payee-scale-note { flex-basis: 100%; margin: 0; }
#view-metodi .card-head > .btn-primary { margin-left: auto; }
.method-kind { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }
.method-kind svg { width: 18px; height: 18px; flex-shrink: 0; }
.unclassified { color: var(--accent-ink); font-weight: 600; }
.text-button { background: transparent; border: 0; color: var(--text); padding: 0; text-align: left; text-decoration: underline; text-decoration-color: var(--accent-ink); text-underline-offset: 4px; }
.method-distribution { display: flex; width: 100%; border-radius: 8px; overflow: hidden; margin: 12px 0; }
.method-distribution button { min-height: 44px; min-width: 3px; padding: 0; border: 1px solid var(--border-input); cursor: pointer; flex-shrink: 1; }
.method-distribution button:focus-visible { outline-offset: -4px; }
.inactive-methods { margin-top: 28px; }
.inactive-methods > summary { color: var(--text-muted); padding-left: 0; }
.method-history ul { list-style: none; padding: 0; max-height: 240px; overflow: auto; }
.method-history li { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.method-history strong { white-space: nowrap; }
#methods-table .mobile-secondary { white-space: normal; }
#methods-table .mobile-secondary .method-kind { display: inline-flex; }
#methods-table .text-button { max-width: 220px; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  #methods-table .text-button { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

.method-distribution-legend { display: flex; flex-wrap: wrap; gap: 4px 20px; list-style: none; padding: 0; }
.method-distribution-legend .text-button { font-size: 13px; text-decoration: none; min-height: 44px; }
.paid-offset { font-size: 13px; white-space: nowrap; }
.paid-method { margin-top: 4px; }
.paid-method a { color: var(--text-muted); text-decoration-color: var(--accent-ink); }
.movement-mobile-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.mobile-method { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) {
  #pay-table .mobile-secondary { white-space: normal; overflow: visible; }
}
#pay-table .desktop-table th:nth-child(2) { width: 220px; }
#pay-table .desktop-table { min-width: 1000px; }
#pay-table .status-label { white-space: nowrap; display: block; }
.paid-method { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { #pay-table .desktop-table { min-width: 0; } }

.inline-new-method { display: grid; gap: 16px; border-left: 3px solid var(--canary); padding-left: 16px; }
.account .balance { white-space: nowrap; }
.tabs { overflow-y: hidden; }

/* ---- assistente (chat) ---- */
.chat-log {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 420px; overflow-y: auto; padding: 4px 2px 14px;
}
.chat-msg {
  max-width: 78%; padding: 10px 14px; border-radius: 10px;
  font-size: 14px; line-height: 1.45;
}
.chat-msg.user {
  align-self: flex-end; background: var(--accent-bg); color: #fff;
  border-bottom-right-radius: 3px;
}
.chat-msg.bot {
  align-self: flex-start; background: var(--bg-elevated);
  border: 1px solid var(--border); border-bottom-left-radius: 3px;
}
.chat-actions { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.chat-action {
  font-family: var(--font-mono); font-size: 11.5px;
  padding: 2px 7px; border-radius: 4px;
  border: 1px solid var(--border); color: var(--text-muted);
}
.chat-action.ok { color: var(--green-text); border-color: var(--green); }
.chat-action.fail { color: var(--red); border-color: var(--red); }
.chat-form {
  display: flex; gap: 8px; border-top: 1px solid var(--border-subtle); padding-top: 12px;
}
.chat-form input { flex: 1; }
.chat-form .btn-primary { white-space: nowrap; }
/* Assistente contestuale: comandi visibili anche senza hover. */
.assistant-anchor { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; min-width: 36px; padding: 8px; box-sizing: border-box; flex-shrink: 0; vertical-align: middle; }
.assistant-anchor svg { width: 18px; height: 18px; flex-shrink: 0; }
.assistant-controls, .assistant-row-controls, .assistant-selection-tools, .assistant-history-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.assistant-layout { display: grid; grid-template-columns: minmax(205px, 25%) minmax(0, 1fr); min-height: 380px; height: calc(100dvh - 205px); border: 1px solid var(--border); border-radius: var(--radius-card); }
.assistant-sidebar, .assistant-thread { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.assistant-sidebar { gap: 7px; padding: 10px; background: var(--bg-panel); border-inline-end: 1px solid var(--border); border-radius: var(--radius-card) 0 0 var(--radius-card); }
.assistant-sidebar-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.assistant-sidebar-head h2 { font-size: 18px; }
.assistant-history-tools { justify-content: space-between; }
.category-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.category-actions .btn-small { min-height: 36px; font-size: 13px; padding: 4px 8px; }
.assistant-layout #assistant-search { width: 100%; min-height: 32px; padding: 4px 8px; font-size: 14px; }
.assistant-layout .btn-small, .assistant-reply .btn-primary { min-height: 30px; padding: 3px 8px; font-size: 13px; }
#assistant-chats { overflow: auto; min-height: 0; padding: 3px; }
#assistant-chats a { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 34px; padding: 5px 8px; color: var(--text); border-radius: 6px; text-decoration: none; font-size: 14px; }
#assistant-chats a:hover, #assistant-chats a[aria-current] { background: var(--bg-card-hover); }
#assistant-chats a[aria-current] { box-shadow: inset 3px 0 var(--accent-ink); font-weight: 700; }
#assistant-chats span, #assistant-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#assistant-chats time { flex-shrink: 0; color: var(--text-muted); font-size: 12px; }
#assistant-chats p { margin: 2px 5px; font-size: 13px; }
#assistant-more, #assistant-older { align-self: flex-start; }
#assistant-title { margin: 0; padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: 16px; }
.assistant-scroll { flex: 1; min-height: 0; overflow: auto; padding: 10px 14px; scrollbar-gutter: stable; }
#assistant-scroll:focus-visible { outline-offset: -3px; }
.assistant-empty { margin: 14px 0; }
.assistant-exchange { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 14px; overflow-wrap: anywhere; }
.assistant-question, .assistant-reply { padding: 7px 10px; border-radius: 10px; }
.assistant-question { align-self: flex-end; max-width: 85%; background: var(--bg-panel); border: 1px solid var(--border); border-end-end-radius: 3px; }
.assistant-reply { align-self: flex-start; max-width: 94%; background: var(--bg-card-hover); border-end-start-radius: 3px; }
.assistant-reply .meta, .assistant-reply .assistant-controls { font-size: 12px; }
.assistant-reply .assistant-controls { margin-top: 6px; }
.assistant-markdown > :first-child { margin-top: 0; }
.assistant-markdown > :last-child { margin-bottom: 0; }
.assistant-markdown p, .assistant-markdown ul, .assistant-markdown ol { margin: 6px 0; }
.assistant-markdown pre { max-width: 100%; overflow: auto; }
.assistant-markdown table { display: block; overflow: auto; }
.assistant-prompt-dialog { width: min(820px, calc(100% - 32px)); }
.assistant-prompt { max-height: min(58dvh, 560px); overflow: auto; }
.assistant-prompt summary { padding: 6px 0; }
.assistant-prompt pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }
.assistant-exchange details { margin: 6px 0; }
.assistant-feedback-note { margin: 6px 0 0; border-inline-start: 2px solid var(--border-input); padding-inline-start: 8px; }
.assistant-feedback-form { display: grid; grid-template-columns: auto 1fr; justify-items: start; gap: 5px; margin-top: 6px; }
.assistant-feedback-form label { grid-column: 1 / -1; width: 100%; }
.assistant-composer { padding: 8px 12px; border-top: 1px solid var(--border); }
.assistant-context-chip { margin-bottom: 6px; font-size: 13px; overflow-wrap: anywhere; }
.assistant-context-chip a { margin-inline-start: 5px; }
.assistant-context-chip .btn-small { margin-inline-start: 5px; }
.assistant-form { display: flex; align-items: end; gap: 6px; }
.assistant-form textarea, .assistant-feedback-form textarea { width: 100%; min-width: 0; resize: vertical; padding: 5px 8px; }
.assistant-form textarea { min-height: 40px; max-height: 26dvh; }
#assistant-send { min-height: 40px; padding: 5px 12px; }
#assistant-status { display: block; font-size: 13px; }
.assistant-select { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px; margin: 0; }
.assistant-select input { min-width: 24px; min-height: 24px; margin: 0; }
.assistant-selection-tools { padding: 8px 0; }
.assistant-analysis { border-inline-start: 2px solid var(--border-input); padding-inline-start: 8px; margin: 7px 0; }
.assistant-analysis p, .assistant-analysis ul { margin: 5px 0; }
.chart-assistant-anchor { min-height: 34px; }
@media (max-width: 700px) {
  .assistant-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: calc(100dvh - 155px); min-height: 440px; }
  .assistant-sidebar { border-inline-end: 0; border-bottom: 1px solid var(--border); border-radius: var(--radius-card) var(--radius-card) 0 0; padding: 7px; gap: 4px; }
  #assistant-chats { max-height: 82px; }
  .assistant-scroll { padding: 6px 9px; }
  .assistant-composer { padding: 6px 8px; }
  .assistant-reply { max-width: 96%; }
}
@media (max-width: 640px) {
  .account-actions { flex-wrap: wrap; }
}
.assistant-fields { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 12px; }
.assistant-fields > div { min-width: 0; }
.assistant-fields dt { color: var(--text-muted); font-size: 12px; }
.assistant-fields dd { margin: 0; overflow-wrap: anywhere; }
.cashflow-figure { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; white-space: nowrap; }
.cashflow-figure > .assistant-anchor { width: 30px; min-width: 30px; height: 30px; padding: 5px; }
.month-mobile-heading > .cashflow-figure { flex-shrink: 0; }
#view-cashflow .kpi .hint .cashflow-figure { font-size: inherit; }

/* Densità comune: restano invariati i bersagli tattili da 44px. */
.wrap { padding-top: 20px; }
header { margin-bottom: 18px; }
.tabs { gap: 4px; margin-bottom: 22px; padding-bottom: 8px; }
.tab { padding: 8px 12px; }
.card { margin-bottom: 24px; }
.card-head { padding-bottom: 12px; gap: 8px; }
th { padding: 8px; }
td { padding: 6px 8px; }
.account { padding: 12px 0; gap: 12px; }
.kpis { gap: 16px; margin-bottom: 20px; }
.payment-warning { padding: 18px; margin-bottom: 20px; }
.payment-warning > p { margin: 8px 0 12px; }
.due-item { padding: 8px 0; gap: 12px; }
.liquidity-interactive { gap: 20px; }
#pay-table [data-row-id]:focus { outline: 2px solid var(--blue); outline-offset: -2px; }
#pay-table [data-row-id]:focus > td, #pay-table li[data-row-id]:focus,
#pay-table tr:has(input:checked) > td, #pay-table li:has(input:checked) { background: var(--bg-card-hover); }
@media (max-width: 640px) {
  .wrap { padding-top: 16px; }
  .tabs { gap: 0; margin: 0; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .tab { padding: 6px 2px; }
  .mobile-rows > li { padding-top: 8px; padding-bottom: 8px; }
}

/* EL-318: una sola testata persistente, con navigazione principale e menu utente. */
html { scroll-padding-top: calc(var(--app-header-height, 100px) + 12px); scroll-padding-bottom: 16px; }
.wrap { padding-top: 0; padding-bottom: 32px; }
header { position: sticky; top: 0; z-index: 50; display: grid; grid-template-columns: auto auto minmax(0,1fr) auto; gap: 8px; padding: 6px 0; margin-bottom: 16px; background: var(--bg); border-bottom: 1px solid var(--border); }
header .logo { width: 28px; height: 28px; }
header h1 { font-size: 20px; }
header .brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
header .app-version { font-size: 13px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
header .tabs { position: static; z-index: auto; display: flex; justify-content: center; gap: 4px; padding: 0; margin: 0; border: 0; background: transparent; }
header .tab { padding: 8px 10px; gap: 4px; font-size: 14px; flex-direction: row; min-height: 44px; }
header .tab svg { display: none; }
.user-menu { grid-column: 4; justify-self: end; max-width: 180px; }
.user-menu > summary { padding: 6px 8px; }
.user-menu-panel { min-width: 220px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 72px); overflow-y: auto; }
.user-menu-panel a { display: flex; align-items: center; min-height: 44px; text-decoration: none; }
.user-menu-panel [aria-current='page'] { background: var(--canary); color: #000; font-weight: 700; }
.user-menu.active > summary { box-shadow: inset 0 -2px var(--accent-ink); }
#pay-table .desktop-table .month-separator, .month-separator > th,
#pay-table .mobile-rows > .month-separator { top: var(--app-header-height, 100px); }
@media (max-width: 800px) {
  header { grid-template-columns: auto minmax(0,1fr) auto; gap: 0 8px; }
  header h1 { font-size: 18px; }
  header .tabs { grid-column: 1/-1; grid-row: 2; display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); }
  header .tab { justify-content: center; padding: 6px 2px; font-size: 13px; }
  .user-menu { grid-column: 3; grid-row: 1; max-width: 42vw; }
  .wrap { padding-top: 0; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  #toast-region { bottom: 12px; }
}
.movement-id { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); white-space: nowrap; }
#pay-table .desktop-table th.movement-id { width: 66px; }
.history-table { table-layout: fixed; }
.history-table .history-id { width: 72px; }
.history-table .history-date { width: 155px; }
.history-table .history-actor { width: 125px; }
.history-table .history-actions { width: 146px; }
.history-table td { vertical-align: top; }
.history-table .history-actions > div { display: flex; gap: 4px; flex-wrap: wrap; }
.history-icon { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; padding: 8px; }
.history-icon svg { width: 20px; height: 20px; }
.history-description { display: block; font-weight: 600; }
.history-detail dl { margin: 0; }
.history-detail dl > div { margin: 4px 0; }
.history-detail dd { margin-left: 12px; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .history-table { font-size: 13px; }
  .history-table .history-id { width: 46px; }
  .history-table .history-date { width: 90px; }
  .history-table .history-actions { width: 52px; }
  .history-table .history-actor { display: none; }
  .history-table th, .history-table td { padding: 6px 4px; }
  .history-table .history-date time { overflow-wrap: anywhere; }
}

/* EL-319: foglio Movimenti. Un solo viewport per le righe, senza scroll della pagina. */
body.movements-page { height: 100dvh; overflow: hidden; }
.movements-page .wrap { display: flex; flex-direction: column; height: 100dvh; max-width: none; padding: 0 16px 12px; }
.movements-page header { flex: 0 0 auto; margin-bottom: 8px; }
.movements-page #main, .movements-page #view-movimenti, .movements-page #view-movimenti > .card { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.movements-page #view-movimenti > .card { margin: 0; }
.movements-page #view-movimenti .card-head { flex: 0 0 auto; padding-bottom: 4px; }
.movements-page .movements-scroll { display: flex; flex: 1; min-height: 0; overflow: visible; }
#pay-table { --sheet-header-height: 44px; display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
#pay-table .assistant-selection-tools { flex: 0 0 auto; gap: 4px 8px; padding: 4px 0; }
#pay-table .movement-sheet { flex: 1; min-height: 0; min-width: 0; overflow: auto; border: 1px solid var(--border-input); border-radius: 4px; overscroll-behavior: contain; scroll-padding-top: calc(var(--sheet-header-height) + 72px); scroll-padding-bottom: 8px; }
#pay-table .spreadsheet-table { display: table; width: max-content; min-width: 100%; table-layout: auto; border-collapse: separate; border-spacing: 0; font-size: 14px; }
#pay-table .spreadsheet-table th, #pay-table .spreadsheet-table td { white-space: nowrap; overflow-wrap: normal; padding: 0 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
#pay-table .spreadsheet-table td { height: 44px; }
#pay-table .spreadsheet-table th:is(.movement-id,.movement-date,.movement-status,.movement-amount,.movement-paid-date,.assistant-selection-cell,.assistant-action-cell) { width: 1%; }
#pay-table .spreadsheet-table td.movement-status { padding-right: 4px; padding-left: 4px; }
#pay-table .spreadsheet-table .movement-status { text-align: center; }
.movement-status-icon { display: inline-flex; vertical-align: middle; width: 20px; height: 20px; }
.movement-status-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.movement-status-icon.is-paid { color: var(--green); }
.movement-status-icon.is-pending { color: #000; }
.movement-status-icon.is-soon { color: #000; }
.movement-status-icon.is-soon rect { fill: var(--canary); }
[data-theme="dark"] .movement-status-icon.is-pending { background: #fff; border-radius: 3px; }
#pay-table .spreadsheet-table thead { position: sticky; top: 0; z-index: 6; }
#pay-table .spreadsheet-table thead th { height: var(--sheet-header-height); color: var(--text-secondary); background: var(--bg-elevated); }
#pay-table .spreadsheet-table .sort-header { width: 100%; min-height: calc(var(--sheet-header-height) - 2px); }
#pay-table .spreadsheet-table .month-separator { top: var(--sheet-header-height); z-index: 4; }
#pay-table .spreadsheet-table .month-separator > th { position: static; padding: 6px 8px; width: auto; }
#pay-table .spreadsheet-table .month-heading, #pay-table .spreadsheet-table .month-summary { max-width: calc(100vw - 60px); }
#pay-table .spreadsheet-table .month-name { font-size: 15px; }
#pay-table .spreadsheet-table .month-summary { white-space: normal; gap: 2px 10px; font-size: 12px; }
#pay-table .sheet-text { display: block; max-width: 32ch; min-height: 42px; padding: 0; border: 0; color: var(--text); background: transparent; text-align: left; font-size: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#pay-table .movement-payee .sheet-text { max-width: 24ch; }
#pay-table .sheet-text:hover { text-decoration: underline dotted; text-underline-offset: 3px; }
#pay-table .sheet-method { display: block; max-width: 20ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#pay-table .spreadsheet-table .assistant-selection-cell { position: sticky; left: 0; z-index: 3; padding: 0 4px; background: var(--bg); }
#pay-table .spreadsheet-table thead .assistant-selection-cell { z-index: 7; background: var(--bg-elevated); }
#pay-table .spreadsheet-table tr:hover > .assistant-selection-cell { background: var(--bg-card-hover); }
#pay-table .spreadsheet-table .assistant-select { min-height: 42px; }
#pay-table .spreadsheet-table .assistant-anchor { width: 36px; min-width: 36px; height: 42px; min-height: 42px; }
.movement-filters { display: flex; flex: 0 0 auto; align-items: start; gap: 8px; margin-bottom: 4px; min-width: 0; }
.movement-filter-panel { flex: 1; min-width: 0; }
.movement-filter-panel > summary { display: flex; align-items: center; gap: 8px; padding: 4px 8px; min-height: 44px; border: 1px solid var(--border); }
.movement-filter-panel > summary::before { content: '▸'; }
.movement-filter-panel[open] > summary::before { content: '▾'; }
.movement-filter-panel > summary::-webkit-details-marker { display: none; }
.movement-filter-summary { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--text-muted); }
#filters .movement-filter-fields { display: grid; grid-template-columns: repeat(auto-fit,minmax(130px,1fr)); gap: 6px 8px; padding: 8px 0; max-height: 36dvh; overflow-y: auto; }
#filters .movement-filter-fields label { gap: 2px; min-width: 0; }
#filters .movement-filter-fields input, #filters .movement-filter-fields select { width: 100%; padding: 4px 6px; }
#filters .movement-search { min-width: 0; }
#pay-summary { flex: 0 0 auto; padding: 4px 0; font-size: 12px; }
.movement-full-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
@media (pointer: fine) {
  #pay-table { --sheet-header-height: 32px; }
  #pay-table .spreadsheet-table td { height: 32px; }
  #pay-table .sheet-text, #pay-table .spreadsheet-table .assistant-select { min-height: 30px; }
  #pay-table .spreadsheet-table .assistant-anchor { width: 28px; min-width: 28px; height: 30px; min-height: 30px; padding: 4px; }
  #pay-table .spreadsheet-table .assistant-select input { min-width: 20px; min-height: 20px; }
  #filters .movement-filter-fields input, #filters .movement-filter-fields select { min-height: 32px; }
}
@media (max-width: 640px) {
  .movements-page .wrap { padding-right: 8px; padding-left: 8px; padding-bottom: env(safe-area-inset-bottom, 0px); }
  #filters .movement-filter-fields { grid-template-columns: repeat(2,minmax(0,1fr)); }
  #pay-table .spreadsheet-table .month-summary > span:last-child { flex-basis: auto; }
}

/* EL-322: dettagli dei pagamenti leggibili, con spaziatura compatta. */
.payment-warning { padding: 12px 16px; margin-bottom: 16px; }
.payment-warning-head h2 { font-size: 24px; }
.payment-warning > p { margin: 4px 0 8px; font-size: 13px; }
.due-group h3 { margin: 10px 0 4px; font-size: 15px; }
.due-item { padding: 6px 0; gap: 8px; }
.due-description { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.due-description > strong, .due-cause { white-space: normal; overflow: visible; overflow-wrap: anywhere; }
.due-cause { flex-basis: 100%; }
.due-date { font-size: 13px; }
.due-details { display: flex; flex-wrap: wrap; gap: 2px 12px; margin: 0; font-size: 13px; }
.due-details > div { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.due-details dt::after { content: ':'; }
.due-details dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.due-actions { gap: 8px; flex-wrap: wrap; justify-content: flex-end; max-width: 340px; }
.due-amount { white-space: nowrap; }
.secondary-due { margin-bottom: 16px; }
@media (max-width: 640px) {
  .payment-warning-head h2 { font-size: 20px; }
  .due-description, .due-details { gap: 2px 8px; }
  .due-actions { justify-content: flex-start; max-width: none; }
}

/* ================= Messaggi ricevuti (ingest) ================= */
.message-filter-fields .message-counts { display: flex; flex-wrap: wrap; gap: 2px 16px; margin: 0; }
#messages-table .desktop-table { table-layout: auto; min-width: 760px; }
#messages-table .desktop-table th, #messages-table .desktop-table td { vertical-align: top; }
#messages-table .desktop-table td.message-text { max-width: 340px; }
#messages-table .message-text { max-width: 100%; text-align: left; overflow-wrap: anywhere; }
#messages-table [data-row-id] { cursor: pointer; }
.message-detail-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 4px 16px; margin: 0 0 8px; }
.message-detail-fields dt { font-size: 12px; color: var(--text-muted); }
.message-detail-fields dd { margin: 0; overflow-wrap: anywhere; }
.message-payload pre {
  background: var(--bg-panel);
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0 0;
  max-height: 55vh;
  overflow: auto;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
@media (max-width: 640px) {
  .message-detail-fields { grid-template-columns: 1fr; }
}
