:root {
  --bg:#f6f7fb;
  --paper:#f6f7fb;
  --ink:#172238;
  --muted:#495874;
  --line:#dbe3f1;
  --primary:#4558dc;
  --phase-blue:#4558dc;
  --phase-pale:#ebf1ff;
  --phase-border:#dbe3f1;
  --phase-white:#fff;
  --phase-ink:#172238;
  --phase-muted:#495874;
}
[hidden] {display:none !important}
body {background:var(--paper);color:var(--phase-ink);}
header {background:#fff;color:var(--phase-ink);border-bottom:1px solid var(--phase-border);padding-block:10px}
header span {color:var(--phase-muted)}
header button {color:var(--phase-blue);background:#fff}
header #go-home {min-height:44px}
main {padding-top:12px}
main > .muted:has(#current-date) {margin:0 0 8px;}
h1 {color:var(--phase-ink);margin:0 0 8px}
button, select, input {scroll-margin-block:16px 88px}
button, select {border-color:var(--phase-border);color:var(--phase-ink);border-radius:12px}
button.primary, .primary:hover {background:var(--phase-blue);color:#fff;border-color:var(--phase-blue)}
button:focus-visible, a:focus-visible, summary:focus-visible, select:focus-visible, input:focus-visible {
  outline:3px solid #174bcc;outline-offset:2px;
}

/* Mobile reference screens 19 and 20 use the same cards and typography as the main home. */
#phase-home .phase-expense-card {position:relative;background:var(--phase-pale);border-radius:20px}
#phase-home .phase-expense-card::after {content:'›';position:absolute;top:10px;right:15px;color:var(--phase-muted);}
#phase-home .phase-expense-card > small {align-self:baseline}
#phase-home[data-state=beginning] .phase-expense-card > small:last-child,
.phase-start-metrics {grid-column:1/-1}
.phase-start-metrics {display:flex;justify-content:space-around;gap:5px;background:#fff;border-radius:12px;text-align:center;padding:6px;margin:5px 0}
.phase-start-metrics > div {min-width:0}
.phase-start-metrics :is(small,b) {display:block;overflow-wrap:anywhere}
[data-metric=income] b,#phase-annual-metrics [data-metric=income] strong {color:#197248}
[data-metric=saving] b,#phase-annual-metrics [data-metric=saving] strong {color:#713ad3}
[data-metric=bank] b {color:#245cbd}
.phase-metric[data-metric=income] svg {color:#187749;background:#e3f5e9}
.phase-metric[data-metric=bank] svg {color:#4558dc;background:#ebf1ff}
.phase-metric:is([data-metric=goal],[data-metric=saving]) svg {color:#703bce;background:#f1e9fe}
.phase-metric progress {grid-column:1/-1;width:100%;height:7px;accent-color:#7c3aed}
.phase-metric progress::-webkit-progress-value {background:#7c3aed}
.phase-metric-missing {border-color:#d0a346}
.phase-metric-missing strong,.phase-metric-incomplete strong {color:#86490c}
.phase-metric .phase-metric-action {color:#1d4ab5;}
.phase-metric .phase-chip {grid-column:1/-1}
#phase-home-start {padding:11px 13px;margin:8px 0}
#phase-home-start h2 {margin:0 0 3px}
.phase-start-steps {list-style:none;counter-reset:phase-start;padding:0;margin:0}
.phase-start-steps li {counter-increment:phase-start;border-bottom:1px solid #edf0f6}
.phase-start-steps li:last-child {border:0}
.phase-start-steps button {display:grid;grid-template-columns:30px minmax(0,1fr);column-gap:9px;width:100%;min-height:48px;text-align:left;background:#fff;border:0;padding:5px 0}
.phase-start-steps button::before {content:counter(phase-start);grid-row:1/3;display:grid;place-items:center;align-self:center;width:28px;height:28px;border:1px solid #4558dc;border-radius:50%;color:#4558dc;}
.phase-start-steps small {grid-column:2;}
#phase-start-goal .phase-metric {width:100%;margin:0 0 8px}
#phase-home[data-state=beginning] #phase-home-actions {margin-top:8px}
#phase-home[data-state=beginning] #phase-home-start {order:0}
#phase-category {max-width:560px;margin:0 auto}
#phase-category .phase-heading {display:grid;grid-template-columns:44px 1fr 44px;text-align:center}
#phase-category .phase-heading h1 {grid-column:2;margin:0}
#phase-category-close {background:transparent;border:0;}
#phase-category-period {text-align:center}
#phase-category-amounts,.phase-category-history {background:#fff;border:1px solid var(--phase-border);border-radius:14px;padding:12px;margin:9px 0}
#phase-category-amounts progress {height:8px;accent-color:#eb820e}
#phase-category-amounts progress::-webkit-progress-value {background:#eb820e}
.phase-category-history h2 {margin:0 0 6px;}
.phase-category-history p {margin:0;color:var(--phase-muted);}
#phase-category-edit {width:100%;min-height:44px}
.phase-category-actions {display:flex;gap:7px}
.phase-category-actions button {flex:1;min-height:44px}
.phase-category-actions small {display:block}
.phase-chart-ledger li {display:grid;grid-template-columns:10px minmax(0,1fr) auto auto;gap:6px;align-items:center}
.phase-chart-ledger .chart-swatch {margin:0}
.phase-chart-ledger strong {text-align:right}
#phase-actions [data-phase-pending] {
  display:flex;align-items:center;gap:10px;background:#fff;width:100%;min-height:48px;
  text-align:left;padding:8px 10px;border:0;border-radius:8px;margin-bottom:6px;color:#495874;opacity:.75;
}
#phase-actions [data-phase-pending] small {display:block;}
.phase-over {background:#fbe9e8;color:#8e3127}
.phase-remainder {background:#edf1f8;color:#34537d}
#phase-annual-metrics {grid-template-columns:repeat(3,minmax(0,1fr))}
#phase-annual-metrics .phase-compact-metric {padding:8px}
#phase-annual-metrics .phase-chip {overflow-wrap:anywhere}
.phase-trend-bars .planned,.phase-trend-legend .planned::before {background:#d0d6e4}
.phase-trend-bars .confirmed,.phase-trend-legend .confirmed::before {background:#4558dc}
.phase-trend-bars .partial,.phase-trend-legend .partial::before {background:#9ec5ff}
#phase-entry-options {margin:8px 0}
.phase-exception-entry {display:flex;align-items:center;justify-content:space-between;gap:10px;background:#fff;padding:7px 9px;border-radius:9px}
.phase-exception-entry input {min-height:44px;flex:none}
#manual-rows td:first-child .phase-icon {width:23px;height:23px;margin-right:4px;vertical-align:middle}
@media (max-width:767px) {
  #month[data-phase-mode=entry] #manual-form .monthly-amounts label:last-child {grid-column:auto}
  #month[data-phase-mode=entry] #manual-form .stacked-table tbody tr:not(.category-group) {
    grid-template-columns:minmax(0,1.2fr) minmax(0,.75fr) minmax(82px,1fr);
  }
}
.panel, .budget-card {border-color:var(--phase-border);border-radius:16px}
.help, small, .muted {color:var(--phase-muted)}
.setup-method-options button {background:#fff;border:1px solid var(--phase-border);color:var(--phase-ink)}
.setup-method-options button:hover {background:var(--phase-pale)}
#phase-home, #phase-plus {max-width:760px;margin-inline:auto}
#phase-home-title,#phase-plus-title,#month > h1,#year > h1 {text-align:center}
#phase-home-period,#phase-year-caption {text-align:center;margin:0 0 12px}
body:has(#phase-home:not([hidden])) #closing-reminder {display:none}
body:has(#phase-home:not([hidden])) main > .muted:has(#current-date) {display:none}
.phase-alert {
  display:block;background:#fff3db;color:#783f0c;border:1px solid #ead4a7;
  border-radius:12px;margin-bottom:10px;padding:4px 10px;
}
.phase-alert:empty {display:none}
.phase-alert p {margin:6px 0}
.phase-alert button {background:transparent;border:0;color:inherit;text-align:left;padding:6px 0}
.phase-alert-danger {background:#fff0ec;border-color:#efc7bd;color:#8b2f22}
.phase-expense-card {
  display:grid;gap:4px;text-align:left;background:var(--phase-pale);
  color:var(--phase-ink);border:1px solid #cfddfc;padding:14px 16px;width:100%;margin-bottom:10px;
}
.phase-expense-card progress {width:100%;height:8px;accent-color:var(--phase-blue)}
.phase-expense-card progress::-webkit-progress-value {background:var(--phase-blue)}
.phase-card-grid {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.phase-metric {
  min-width:0;text-align:left;background:#fff;color:var(--phase-ink);
  display:grid;gap:3px;align-content:start;padding:10px 12px;border:1px solid var(--phase-border);border-radius:13px;
  overflow-wrap:anywhere;
}
.phase-metric {grid-template-columns:27px minmax(0,1fr);align-items:center}
.phase-metric strong,.phase-metric small {grid-column:1/-1}
.phase-metric svg, #navigation svg {width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.65;stroke-linecap:round;stroke-linejoin:round}
.phase-metric svg {width:27px;height:27px;background:var(--phase-pale);color:var(--phase-blue);padding:4px;border-radius:8px}
.phase-metric:nth-child(even) svg {color:#693db7;background:#f0e9ff}
.phase-home-actions {display:grid;gap:8px;margin:10px 0}
.phase-home-actions button {min-height:44px}
#phase-home-invite {background:#f2ebff;margin-top:10px}
#phase-home-invite h2 {margin:0 0 8px}
.phase-list {display:grid;gap:7px}
.phase-list button {display:flex;justify-content:space-between;align-items:center;text-align:left;min-height:48px;padding-inline:14px}
.phase-list button::after {content:'›';color:var(--phase-blue);margin-left:10px}
#setup:is([data-phase-settings=files],[data-phase-settings=restore]) > :not(#backup-settings),
#setup[data-phase-settings=reminders] > :not(#setup-title,#reminder-settings) {display:none}
#setup[data-phase-settings=reminders] #setup-title {display:none}
.phase-segments {display:grid;grid-auto-flow:column;grid-auto-columns:1fr;background:#fff;gap:4px;border-radius:13px;padding:4px;margin:8px auto;max-width:640px}
.phase-segments button {border-color:transparent;min-height:44px;padding-inline:4px}
.phase-segments [aria-pressed=true] {background:var(--phase-blue);border-color:var(--phase-blue);color:#fff}
.phase-budget-panel {background:#fff;border:1px solid var(--phase-border);border-radius:15px;padding:12px;margin-bottom:10px}
#phase-budget-coverage {margin:0 0 8px}
.phase-table {width:100%;min-width:0;table-layout:fixed;border-collapse:collapse}
.phase-table th,.phase-table td {padding:8px;vertical-align:top;text-align:right;overflow-wrap:anywhere}
.phase-table th:first-child {text-align:left}
.phase-table td small {display:block;}
.phase-table .phase-total {background:#edf2ff}
#phase-budget-plan-actions {margin-top:10px}
#phase-existing-month-tabs {display:none}
#month[data-budget-period=year][data-phase-mode=budget] > .period-nav {display:none}
#month[data-budget-period=year][data-phase-mode=budget] :is(#month-actions,#month-entry-block,#month-dashboard,#month-bank-summary) {display:none}
#month[data-phase-mode=budget] #month-featured,
#month[data-phase-mode=budget] #manual-summary,
#month[data-phase-mode=budget] #manual-title,
#month[data-phase-mode=budget] #month-dashboard > details,
#month[data-phase-mode=budget] .month-planning,
#month:not([data-phase-mode=review]) #phase-month-chart {display:none}
#month[data-phase-mode=budget] #manual-panel:has(#monthly-review[hidden]):not(:has(#month-entry-block:not([hidden]))) {
  padding:0;background:transparent;border:0;
}
#month-actions {margin:8px 0;flex-wrap:wrap}
#month-actions button {min-height:44px}
#month[data-phase-mode=entry] .month-planning {display:none}
#year:not([data-phase-analysis=annual]) #annual-report,
#year:not([data-phase-analysis=annual]) #phase-annual-trend,
#year:not([data-phase-analysis=annual]):not([data-phase-analysis=charts]) #phase-charts-panel,
#year:not([data-phase-analysis=projection]) #rolling-bank,
#year:not([data-phase-analysis=projection]) #balance-details,
#year:not([data-phase-analysis=savings]) #saving-goal,
#year:not([data-phase-analysis=annual]):not([data-phase-analysis=months]) #phase-month-status {display:none}
#year:is([data-phase-analysis=savings],[data-phase-analysis=projection]) > .period-nav,
#year:is([data-phase-analysis=savings],[data-phase-analysis=months]) #phase-analysis-tabs {display:none}
#phase-saving-months {border-bottom:1px solid var(--phase-border);padding-bottom:12px;margin-bottom:12px}
#phase-saving-months h2 {margin:0}
#saving-goal .goal-progress {accent-color:#693db7}
.phase-trend {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,135px),1fr));gap:8px}
.phase-trend-month {background:#f5f7fd;border-radius:10px;padding:8px;min-width:0}
.phase-trend-amount {margin-top:4px;overflow-wrap:anywhere}
.phase-trend-amount progress {display:block;width:100%;height:8px;accent-color:#56749f}
.phase-trend-amount.confirmed progress {accent-color:#2458d8}
.phase-trend-amount.partial progress {accent-color:#6489da}
:is(#month-featured,#manual-summary,#year-cumulative) .report-hero {
  background:#e8efff;color:var(--phase-ink);border:1px solid #cfddfc;padding:14px;min-height:0;
}
:is(#month-featured,#manual-summary,#year-cumulative) .report-hero small {color:var(--phase-muted)}
:is(#month-featured,#manual-summary,#year-cumulative) .report-hero .bad {color:#982d20}
:is(#month-featured,#manual-summary,#year-cumulative) .report-hero .good {color:#175e45}
#navigation {
  display:grid;grid-template-columns:1fr 1fr auto 1fr 1fr;align-items:center;
  gap:5px;background:#fff;border:1px solid var(--phase-border);border-radius:15px;
  padding:5px;margin-bottom:16px;
}
#navigation button {
  min-width:0;min-height:46px;border:0;background:#fff;color:var(--phase-muted);
  display:grid;place-items:center;align-content:center;gap:2px;padding:3px;
}
#navigation button[aria-current=page] {color:#1645b7;background:var(--phase-pale)}
#navigation #phase-add {color:#fff;background:var(--phase-blue);width:46px;height:46px;border-radius:50%;box-shadow:0 4px 12px #2458d844}
#phase-actions {
  color:var(--phase-ink);background:#f7f9fe;border:1px solid var(--phase-border);border-radius:18px;
  padding:14px;width:min(440px,calc(100% - 24px));max-height:calc(100dvh - 24px);
}
#phase-actions::backdrop {background:#14233d99}
.phase-heading {display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px}
.phase-heading h2 {margin:0}
#phase-actions-close,#phase-category-close {min-width:44px;min-height:44px}
.phase-category-link {border:0;background:transparent;padding:4px 0;text-align:left;min-height:44px;color:#1645b7;text-decoration:underline;text-underline-offset:3px}
#phase-actions [data-phase-action] {width:100%;text-align:left;margin-bottom:6px;min-height:48px}
#phase-actions-note {margin:4px 0 0}
#daily-operation {
  color:var(--phase-ink);background:#f7f9fe;border:1px solid var(--phase-border);border-radius:18px;
  padding:14px;width:min(440px,calc(100% - 24px));max-height:calc(var(--daily-viewport-height,100dvh) - 16px);
  overflow:auto;overscroll-behavior:contain;box-sizing:border-box;
}
#daily-operation::backdrop {background:#14233d99}
#daily-operation h2 {margin:0 0 8px;}
#daily-operation form {display:grid;gap:8px;min-width:0}
#daily-operation label {min-width:0}
#daily-operation :is(input:not([type=checkbox]),select) {width:100%;min-width:0;}
#daily-operation input[type=date] {display:block;max-width:100%;min-height:42px}
#daily-operation .actions button {min-height:44px}
#daily-operation-preview p,#daily-operation-status {margin:3px 0}
#daily-operation-status:empty {display:none}
#daily-operation-approval:not([hidden]) {display:block;padding:6px 0}
.phase-income-detail {
  background:transparent;border:0;padding:0;text-align:left;min-height:28px;color:inherit;text-decoration:underline;text-underline-offset:3px;
}
.daily-history {list-style:none;padding:0;margin:4px 0}
.daily-history li {
  display:flex;justify-content:space-between;align-items:baseline;gap:8px;
  border-top:1px solid var(--phase-border);padding:7px 0;overflow-wrap:anywhere;
}
.daily-history li > div {min-width:0}
.daily-history li small {display:block;color:var(--phase-muted)}
.daily-history li > b {white-space:nowrap}
.daily-history-actions {display:flex;flex-wrap:wrap;gap:4px;margin-top:4px}
.daily-history-actions button,#phase-category-resume {min-height:44px}
#linked-operation-missing label {display:block;margin:7px 0}
#linked-operation-missing input {width:100%;}
#linked-operation-review:not([hidden]) {margin:8px 0}
#close-month-dialog.linked-operation-dialog {
  max-height:calc(var(--daily-viewport-height,100dvh) - 16px);overflow:auto;overscroll-behavior:contain;box-sizing:border-box;
}
#phase-category-status:not(:empty) {margin-top:8px}
@media (max-width:767px) {
  #daily-operation,#close-month-dialog.linked-operation-dialog {inset:var(--daily-viewport-top,0px) 0 auto;margin:8px auto}
}
#close-month-missing-list li {display:flex;flex-wrap:wrap;gap:6px;align-items:center}
#close-month-missing-list button {min-height:44px}
@media (max-width:767px) {
  body.with-budget-nav {padding-bottom:calc(66px + env(safe-area-inset-bottom,0px))}
  #navigation {
    position:fixed;z-index:10;inset:auto 0 0;max-width:none;margin:0;
    border-radius:0;padding:4px max(4px,env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom,0px)) max(4px,env(safe-area-inset-left));
    box-shadow:0 -4px 20px #182b521a;
  }
  .mobile-keyboard #navigation {display:none}
  #phase-actions {margin:auto auto 0;border-radius:18px 18px 0 0;padding-bottom:calc(14px + env(safe-area-inset-bottom,0px))}
  #month-guided .month-question input[type=number] {width:100%;max-width:100%;min-height:44px}
  .phase-table th,.phase-table td {padding:7px 4px;}
  #phase-budget-panel {padding:8px}
}
@media (max-width:365px) {
  .phase-table:has(th:nth-child(4)) thead {
    position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);
  }
  .phase-table:has(th:nth-child(4)) tr {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));border-bottom:1px solid var(--phase-border);padding:6px 0}
  .phase-table:has(th:nth-child(4)) th[scope=row] {grid-column:1/-1}
  .phase-table:has(th:nth-child(4)) td {text-align:left;border:0}
  .phase-table:has(th:nth-child(4)) td::before {content:attr(data-label);display:block;color:var(--phase-muted);}
}

/* Layouts aligned with the reference screens. Existing forms and controls stay in place. */
.phase-visually-hidden {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.phase-caption {text-align:center;color:var(--phase-muted);margin:0 0 12px}
.phase-icon {width:30px;height:30px;display:inline-grid;place-items:center;border-radius:9px;flex:none}
.phase-icon svg,.phase-review-state svg {width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.65;stroke-linecap:round;stroke-linejoin:round}
.phase-tone-blue {background:#e8efff;color:#2458d8}
.phase-tone-purple {background:#f1eaff;color:#6838bd}
.phase-tone-orange {background:#fff0df;color:#9b4c15}
.phase-tone-teal {background:#e2f6f3;color:#176b63}
.phase-tone-pink {background:#fdebf2;color:#973454}
#phase-home {max-width:620px}
#phase-home-period {margin-bottom:14px}
.phase-expense-card {gap:6px;padding:13px 15px;margin-bottom:8px;grid-template-columns:auto 1fr;align-items:baseline}
.phase-expense-card > span,.phase-expense-card progress {grid-column:1/-1}
.phase-expense-card progress {margin:2px 0 1px}
.phase-alert {margin:0 0 9px}
#phase-home-alert:not(.phase-alert-danger):has(p) {width:max-content;max-width:100%;margin-inline:0;border:0}
#phase-home-cards {gap:7px}
.phase-metric {padding:10px;grid-template-columns:25px minmax(0,1fr)}
.phase-metric svg {height:25px;width:25px}
#phase-home-invite .actions {display:grid;grid-template-columns:1fr 1fr}
#phase-home-invite button {min-height:44px}
#phase-home-invite [data-phase-action=saving-plan] {background:#6739bd;color:#fff}
#phase-home-last {background:#eaf0ff;color:#173f9b}
.phase-home-actions {gap:6px}
#month > .period-nav,#year > .period-nav {max-width:540px;margin:8px auto 12px;display:grid;grid-template-columns:44px 1fr 44px}
.period-nav label {min-width:0;margin:0}
.period-nav :is(button,select) {min-height:44px;background:transparent;border-color:transparent}
.period-nav select {width:100%;text-align:center;}
.phase-budget-panel {border:0;background:transparent;padding:0;margin:0 0 10px}
.phase-table {background:#fff;border-radius:13px;overflow:hidden}
.phase-table caption {background:#fff;text-align:left;padding:8px 10px;border-radius:13px 13px 0 0;color:var(--phase-muted)}
.phase-table caption strong {float:right;color:var(--phase-ink)}
.phase-table th,.phase-table td {padding:8px 10px;border-color:#ecf0f7}
#month:not([data-budget-kind=compare]) .phase-table th[scope=row] {width:68%;text-align:left}
#month:not([data-budget-kind=compare]) .phase-table thead {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
#month:not([data-budget-kind=compare]) .phase-table th[scope=row] .phase-icon {vertical-align:middle;margin-inline-end:8px}
.phase-table .phase-icon {width:27px;height:27px}
.phase-category-link {text-decoration:none;color:var(--phase-ink);min-height:28px}
.phase-table tr:has(.phase-category-link) th {position:relative}
.phase-category-link::after {content:'';position:absolute;inset:0}
#month:not([data-budget-kind=compare]) .phase-table tr:has(.phase-category-link) td::after {content:' ›';margin-left:5px;color:#5872a0}
.phase-table td {vertical-align:middle}
.phase-missing {color:#86490c;background:#fff4df}
.phase-match {color:#165e3b;background:#eaf8ee}
.phase-budget-totals {display:grid;grid-auto-flow:column;grid-auto-columns:1fr;gap:6px;margin:9px 0}
.phase-budget-totals div {background:#fff;border-radius:9px;padding:7px 6px;text-align:center;min-width:0}
.phase-budget-totals :is(small,strong) {display:block;overflow-wrap:anywhere}
.phase-budget-totals strong {color:#1d4ab5}
#month[data-phase-mode=budget] #manual-status {display:none}
#month[data-phase-mode=budget] #phase-budget-panel + #manual-draft-status {margin-top:8px}
#month[data-phase-mode=budget][data-budget-kind=planned] #month-actions:has(#update-manual:not([hidden])) {display:none}
#month[data-phase-mode=budget]:not([data-budget-kind=planned]) #month-actions {margin:10px 0 0}
#month[data-phase-mode=budget] #manual-panel {display:flex;flex-direction:column}
#month[data-phase-mode=budget] #phase-budget-panel {order:-1}
#month[data-phase-mode=budget] #phase-budget-coverage:empty {display:none}
#month[data-phase-mode=budget] #phase-budget-plan-actions button {min-height:44px}
#phase-budget-rows + #phase-budget-coverage {margin:8px 0 0}
#month[data-phase-mode=review] #manual-panel {background:none;border:0;padding:0}
#month[data-phase-mode=review] #manual-title,#month[data-phase-mode=review] #manual-status {display:none}
.phase-review-state {display:grid;grid-template-columns:24px 1fr;gap:3px 7px;align-items:center;background:#fff2db;color:#783f0c;border-radius:12px;padding:9px 11px;margin:0 0 9px}
.phase-review-state.done {background:#e3f5e9;color:#185839}
.phase-review-state small {grid-column:2;color:inherit;}
.phase-compact-metric {min-width:0;display:grid;gap:3px;background:#fff;border-radius:12px;padding:10px;border:1px solid var(--phase-border)}
.phase-compact-metric span {color:var(--phase-muted);}
.phase-compact-metric strong {overflow-wrap:anywhere}
.phase-chip {background:#edf1f8;border-radius:7px;width:max-content;max-width:100%;padding:2px 6px;}
.phase-chip.good {background:#e3f5e9}
.phase-chip.bad {background:#ffebe9}
.phase-chip.phase-missing {background:#fff4df}
#monthly-review {background:#fff;border:1px solid var(--phase-border);border-radius:13px;padding:11px;margin:9px 0}
#monthly-review h3 {margin:0 0 5px}
#review-advice {padding-left:20px;margin:6px 0;}
#month[data-phase-mode=review] #phase-month-chart {background:#fff;width:100%;text-align:left;min-height:44px}
#month:not([data-phase-mode=review]) #phase-month-chart-open,
#month[data-phase-mode=review]:has(#monthly-review:not([hidden])) #phase-month-chart-open {display:none}
#phase-month-chart-open {min-height:44px}
#month[data-phase-mode=review] #close-month {margin:8px 0 0;width:100%;min-height:44px}
#phase-entry-detail {display:block;margin:8px 0;}
#month[data-phase-mode=entry] #manual-panel {background:transparent;border:0;padding:0}
#month[data-phase-mode=entry] #manual-status {display:none}
#month[data-phase-mode=entry] #manual-entry {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
#month[data-phase-mode=entry] #close-month {width:100%;margin-top:8px;min-height:44px}
#month[data-phase-mode=entry] .entry-navigation {margin:4px 0;justify-content:space-between}
#month[data-phase-mode=entry] .entry-navigation button {min-height:44px;border:0;background:transparent;color:#1746b7;padding-inline:4px}
#month[data-phase-mode=entry] #manual-draft-status {margin:4px 0}
#month[data-phase-mode=entry] :is(#manual-status,#manual-coverage) {margin:5px 0}
#month[data-phase-mode=entry] #month-actions button {min-height:44px}
#month[data-phase-mode=entry] #manual-form {display:flex;flex-direction:column;align-items:stretch}
#month[data-phase-mode=entry] #manual-form > fieldset {order:-1;background:#fff;border:0;margin-bottom:9px}
#month[data-phase-mode=entry] #manual-form > .actions {margin-top:10px}
#month[data-phase-mode=entry] #save-manual {min-height:44px}
#month[data-phase-mode=entry] #manual-form > .actions {justify-content:stretch;width:100%}
#month[data-phase-mode=entry] #save-manual {flex:1 1 auto}
#year[data-phase-analysis=annual] #annual-report {background:transparent;padding:0;border:0}
#year[data-phase-analysis=annual] #annual-report > h2 {display:none}
#phase-annual-metrics {grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
#phase-annual-metrics > p {grid-column:1/-1}
#annual-report #year-coverage {text-align:center;margin:8px 0}
#phase-annual-trend {padding:12px}
#phase-annual-trend h2 {margin:0 0 10px}
.phase-trend {display:grid;grid-auto-flow:column;grid-auto-columns:minmax(26px,1fr);overflow-x:auto;gap:4px}
.phase-trend-month {background:transparent;padding:0;text-align:center}
.phase-trend-bars {height:130px;display:flex;justify-content:center;align-items:flex-end;gap:3px;border-bottom:1px solid var(--phase-border)}
.phase-trend-bars span {width:min(35%,20px);border-radius:4px 4px 0 0}
.phase-trend-legend {display:flex;flex-wrap:wrap;gap:7px 12px;margin-top:8px;}
.phase-trend-legend span::before {content:'';display:inline-block;width:9px;height:9px;margin-right:4px;border-radius:2px}
#phase-month-chart-summary h2,#phase-month-chart-summary > p {text-align:center}
#phase-month-chart-summary .chart-legend li {padding:7px 5px;margin:0;border-bottom:1px solid #e9eef7}
#phase-month-chart-summary .chart-legend {margin-top:10px}
.phase-month-donut .chart-pie {position:relative;display:grid;place-items:center}
.phase-month-donut .chart-pie span {display:grid;place-items:center;width:70%;height:70%;border-radius:50%;background:#fff;}
#year[data-phase-analysis=charts] #phase-analysis-tabs {display:none}
#year[data-phase-analysis=charts] > .period-nav {display:none}
#phase-chart-month-label {display:block;text-align:center;margin:0 auto 12px}
#phase-chart-month {min-height:44px;border:0;background:transparent;}
#rolling-bank {background:#fff}
#rolling-bank > h2 {display:none}
#rolling-bank > p.help {margin:4px 0}
#balance-status {padding:9px 10px;margin:0 0 9px;border:0;background:#e9f4ed;color:#245b3a;}
#balance-status.bad {background:#fceae6;color:#8b2f22}
#balance-overview {margin:10px 0}
#balance-chart {color:var(--phase-blue)}
#phase-bank-moments {margin:9px 0}
.phase-bank-row,.phase-month-list-row {display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:8px;padding:7px;border-bottom:1px solid var(--phase-border);}
.phase-bank-row small {display:block;}
#saving-goal {border:0;background:transparent;padding:0}
#phase-saving-months,#saving-goal-summary,#saving-goal-form,#saving-goal-update {background:#fff;border:1px solid var(--phase-border);border-radius:13px;padding:12px}
#phase-saving-months p,#saving-goal-summary p {margin:5px 0}
.phase-saving-ledger {display:flex;justify-content:space-around;gap:8px;text-align:center;margin-top:8px}
.phase-saving-ledger :is(small,strong) {display:block}
.phase-saving-ledger strong {background:#eef4ff;color:#1742a0;border-radius:6px;padding:2px 4px;}
#saving-goal-summary h3 {margin:0}
#phase-goal-ring {float:left;display:grid;place-items:center;width:64px;height:64px;margin:1px 10px 4px 0;border-radius:50%;background:conic-gradient(#6739bd var(--phase-goal-progress),#e9dfff 0)}
#phase-goal-ring span {display:grid;place-items:center;width:50px;height:50px;border-radius:50%;background:#fff;color:#6739bd;}
#saving-goal-summary::after {content:'';display:block;clear:both}
#saving-goal button {min-height:44px;margin-top:8px}
#saving-goal:not([data-show-total=true]) #saving-goal-update {display:none}
#saving-goal[data-show-total=true] #phase-saving-edit-total {display:none}
#phase-saving-edit-total,#saving-goal-edit {width:100%}
.phase-list {gap:1px;background:#fff;border-radius:14px;overflow:hidden}
.phase-list button,#phase-actions [data-phase-action],#backup-settings .file-actions > * {
  display:flex;align-items:center;justify-content:flex-start;gap:10px;
  text-align:left;width:100%;border:0;border-bottom:1px solid #edf1f8;border-radius:0;min-height:48px;
}
.phase-list button small,#phase-actions button small,#backup-settings button small {display:block;}
.phase-list button::after {margin-left:auto}
#phase-plus .phase-list button:nth-child(5),#phase-plus .phase-list button:nth-child(8) {border-top:5px solid #f2f5fb}
#backup-settings .file-actions {display:grid;gap:0;margin:8px 0}
#backup-settings .file-actions label {padding:8px 13px;position:relative;cursor:pointer}
#backup-settings .file-actions label small {display:block;}
#backup-settings .file-actions label input {position:absolute;inset:0;opacity:0;width:100%;height:100%;cursor:pointer}
#backup-settings .file-actions label:focus-within {outline:3px solid #174bcc;outline-offset:-3px}
#backup-settings details {background:#ebf1ff;border-radius:10px;padding:8px}
#phase-month-status > h2 {display:none}
#phase-month-status > #phase-month-list {display:none}
#year[data-phase-analysis=months] #phase-month-status > #phase-month-list {display:block}
#year[data-phase-analysis=months] #phase-month-status > details {margin-bottom:6px}
.phase-month-list-row {grid-template-columns:minmax(75px,1fr) minmax(70px,1fr) auto}
.phase-month-list-row button {color:#1746b7;border:0;background:transparent;min-height:44px;padding-inline:5px}
#phase-month-list > button {width:100%;min-height:44px}
#phase-actions .phase-heading {padding-bottom:6px}
#phase-actions [data-phase-action] {background:#fff;border-radius:8px}
#phase-category {border-radius:17px}
#phase-category-amounts {background:#fff;border-radius:12px;padding:8px 11px;margin-bottom:8px}
#phase-category-amounts p {margin:4px 0}
#setup:has(#setup-progress:not([hidden])) #setup-form-panel {border:1px solid var(--phase-border);background:#fff;border-radius:16px;box-shadow:0 5px 18px #213d7410}
#setup:has(#setup-progress:not([hidden])) .settings-group {border-color:#e5ebf6}
#setup-guided-question {background:#eef3ff;border-color:#dae4fa;border-radius:13px}
#setup-progress:not([hidden]) {background:#e8efff;color:#173f9b;width:max-content;padding:3px 9px;border-radius:8px}
@media (min-width:768px) {
  #month > .phase-budget-panel,#month[data-phase-mode=budget] #manual-panel,#phase-month-chart-summary {max-width:820px;margin-inline:auto}
  #month[data-phase-mode=budget] #manual-panel {min-height:0}
  #phase-plus .phase-list {max-width:600px;margin-inline:auto}
  #saving-goal,#phase-month-status {max-width:760px;margin-inline:auto}
  #year[data-phase-analysis=annual] #phase-month-status {max-width:none}
}
@media (max-width:767px) {
  body:has(#navigation:not([hidden])) > header {display:none}
  body:has(#navigation:not([hidden])) main > .muted:has(#current-date) {display:none}
  body:has(#navigation:not([hidden])):not(:has(#phase-plus:not([hidden]))) footer {display:none}
  main {padding-top:16px}
  #month[data-budget-kind=compare] .phase-table :is(th,td) {padding:7px 4px}
  #month[data-budget-kind=compare] .phase-table td:not(.phase-missing,.phase-match) {overflow-wrap:normal}
  #month[data-phase-mode=entry] #manual-form .monthly-amounts {grid-template-columns:minmax(0,1fr);gap:4px}
  #month[data-phase-mode=entry] #manual-form .monthly-amounts label {display:grid;grid-template-columns:minmax(0,1fr) minmax(88px,.55fr);align-items:center;gap:6px}
  #month[data-phase-mode=entry] #manual-form .stacked-table tbody tr:not(.category-group) {
    grid-template-columns:minmax(0,1fr) minmax(88px,.55fr);
    align-items:center;gap:4px;padding:6px 8px;margin:0 0 3px;background:#fff;
  }
  #month[data-phase-mode=entry] #manual-rows td:first-child {grid-column:1;grid-row:1}
  #month[data-phase-mode=entry] #manual-rows td:nth-child(2) {grid-column:1;grid-row:2;color:var(--phase-muted);}
  #month[data-phase-mode=entry] #manual-rows td:nth-child(2) .mobile-cell-label {display:inline;margin-right:4px}
  #month[data-phase-mode=entry] #manual-rows td:nth-child(3) {grid-column:2;grid-row:1/3}
  #month[data-phase-mode=entry]:not(:has(#phase-entry-detail-toggle:checked)) #manual-rows td:nth-child(n+4) {display:none}
  #month[data-phase-mode=entry] #manual-rows td:nth-child(n+4) {grid-column:1/-1;grid-row:auto}
  #month[data-phase-mode=entry] #manual-rows tr.category-group {padding:5px 0;margin:0}
  #month[data-phase-mode=entry] #manual-rows .report-bar {display:none}
  #month[data-phase-mode=entry] #manual-rows td:nth-child(3) .mobile-cell-label {display:none}
  #month[data-phase-mode=entry] #manual-form > .actions {
    position:sticky;bottom:calc(62px + env(safe-area-inset-bottom,0px));z-index:2;
    background:#f2f5fb;padding:5px 0;margin:5px 0;
  }
  .mobile-keyboard #month[data-phase-mode=entry] #manual-form > .actions {position:static}
  #month[data-phase-mode=entry] input {scroll-margin-bottom:128px}
  #setup:has(#setup-progress:not([hidden])) #setup-form-panel {padding:12px}
}

/* Keep category cues consistent from creation to analysis. */
.setup-category-icon { display:inline-grid; place-items:center; flex:none; vertical-align:middle; margin-inline-end:.4rem; }
.setup-category-icon svg { width:1em; height:1em; }
.guided-expense-options label { min-width:0; }

/* File operations are shown only on the Mes données screen. */
#setup:not([data-phase-settings=files],[data-phase-settings=restore]) > #backup-settings,
#setup[data-phase-settings=restore] #backup-settings > :not(.phase-heading,.file-actions,#backup-message,#download-restore-recovery),
#setup[data-phase-settings=restore] .file-actions > :not(#phase-restore-label) {display:none}
.data-download {display:grid;justify-items:start;gap:8px;margin:12px 0;overflow-wrap:anywhere}
.data-download p {margin:0}
.data-download a {max-width:100%}

#perso-account {width:min(430px,calc(100% - 24px));max-height:calc(100dvh - 24px);overflow:auto}
#perso-account label {display:grid;gap:4px}
#perso-account input {width:100%;min-width:0}
#account-status:empty {display:none}

.account-password-field { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .4rem; align-items: center; }
.account-password-field button { display: grid; place-items: center; min-width: 44px; min-height: 44px; }
.account-password-slash { display: none; }
.account-password-field .is-visible .account-password-slash { display: inline; }
#budget-sync-panel p { margin-block: .25rem .65rem; overflow-wrap: anywhere; }
#budget-sync-copies button { margin: .25rem; }

.field-required-mark { color: inherit; font-size: .8em; margin-inline-start: .25em; }
.field-input-error { display: block; margin-block-start: .25em; color: #a12634; font-size: .875rem; font-weight: 500; line-height: 1.35; }
