/* Finanzas claras: shared visual system for the two primary workspaces. */
:root {
  --page: #f3f7f5;
  --surface: #ffffff;
  --surface-soft: #edf4f0;
  --text: #183129;
  --muted: #5d7168;
  --line: #d8e5dd;
  --green: #147653;
  --green-soft: #e2f3e8;
  --amber: #8e5d0a;
  --amber-soft: #fff2d8;
  --red: #b33f39;
  --red-soft: #fff0ed;
  --shadow: 0 5px 18px #153e2a0a;
  --money-font: "Roboto Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

body { background: var(--page); color: var(--text); }
.finance-shell { grid-template-columns: 208px minmax(0, 1fr); }
.finance-shell .sidebar {
  padding: 16px 12px;
  background: linear-gradient(180deg, #fff 0%, #fbfdfc 100%);
  border-right-color: #d9e5de;
}
.finance-shell .brand { color: #20372f; }
.finance-shell .brand-mark { background: #147653; }
.finance-shell .nav-item { min-height: 42px; border-radius: 9px; color: #50665c; }
.finance-shell .nav-item.is-active { background: #e2f3e8; color: #116a49; }
.finance-shell .nav-item.is-active::before { background: #147653; }
.finance-shell .topbar { border-color: #dce7e1; background: #ffffffed; }
.finance-shell .page-content { width: min(1540px, 100%); padding: 22px clamp(18px, 2.4vw, 38px) 42px; }
.finance-shell .page-content.is-calendar-view { width: 100%; max-width: none; padding: 18px clamp(18px, 2.1vw, 34px) 42px; }
.button-primary { background: #147653; }
.button-primary:hover { background: #0f6244; }
.button-secondary, .month-control, .icon-button { border-color: #d6e3db; }

/* Home is a month-close workspace: decision first, chart and card table next. */
.month-close-view { display: grid; align-content: start; gap: 14px; }
.month-close-view.is-hidden { display: none !important; }
.month-close-heading { align-items: center; margin: 0; }
.month-close-heading .eyebrow { color: #147653; }
.month-close-heading h1 { color: #17342a; font-size: clamp(27px, 2.3vw, 34px); letter-spacing: -.05em; }
.month-close-heading .page-subtitle { max-width: 700px; }
.month-close-view .projection-view-switch { width: max-content; margin: 0; border-color: #d6e3db; background: #eaf2ed; }
.month-close-view .projection-reading { margin: 0; border-radius: 11px; }
.month-close-view .balance-projection,
.month-close-view .projected-card-summaries {
  min-width: 0;
  margin: 0;
  border-color: #d7e4dc;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.month-close-view .balance-projection { padding: 18px; }
.month-close-view .balance-projection-heading h2 { color: #19372c; font-size: 21px; letter-spacing: -.035em; }
.month-close-view .projection-card-flow { border-color: #cfe2d6; border-radius: 11px; background: #f2f8f4; }
.month-close-view .projection-card-flow-steps { grid-template-columns: minmax(0,1fr) minmax(0,1.1fr) minmax(0,1fr) auto; }
.month-close-view .balance-chart-layout { grid-template-columns: minmax(0,1fr) 278px; gap: 18px; margin-top: 14px; }
.month-close-view .balance-chart-main { min-width: 0; }
.month-close-view .balance-chart-wrap { min-height: 260px; }
.month-close-view .balance-chart { width: 100%; min-height: 250px; }
.month-close-view .balance-chart-summary-panel {
  min-width: 0;
  padding: 14px;
  border-color: #dce7e1;
  border-radius: 12px;
  background: #f8fbf9;
}
.month-close-view .balance-chart-summary-panel h3 { color: #244338; }
.month-close-view .balance-chart-summary-row { min-height: 37px; }
.month-close-view .projected-card-summaries { padding: 17px; }
.month-close-view .projected-card-summaries-heading { margin-bottom: 13px; }
.month-close-view .projected-card-summaries-heading h2 { color: #19372c; font-size: 19px; }
.month-close-view .projected-card-table-scroll { border-radius: 11px; }
.month-close-view .projected-card-table-header { background: #edf4f0; }
.month-close-view .projected-card-table-row { min-height: 66px; }
.home-context-disclosure { border-color: #d8e5dd; border-radius: 12px; box-shadow: none; }
.month-close-view .projection-reading { padding: 9px 12px; border-radius: 9px; }
.month-close-view .projection-reading p { line-height: 1.35; }
.workspace-loading { display: flex; min-height: 112px; align-items: center; gap: 12px; padding: 20px; color: #355348; }
.workspace-loading > span:last-child { display: grid; gap: 4px; }
.workspace-loading strong { font-size: 14px; }
.workspace-loading small { color: var(--muted); font-size: 13px; }
.workspace-loading-dots { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 4px; }
.workspace-loading-dots i { width: 7px; height: 7px; border-radius: 50%; background: #25815c; animation: workspace-pulse 1s ease-in-out infinite alternate; }
.workspace-loading-dots i:nth-child(2) { animation-delay: .18s; }
.workspace-loading-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes workspace-pulse { to { opacity: .28; transform: translateY(-3px); } }

/* Calendar is a distinct, full-width monthly canvas with lanes and ledger. */
body[data-active-view="calendar"] { --page: #f1f6f3; }
body[data-active-view="calendar"] #breadcrumb > span { display: none; }
.calendar-view:not(.is-hidden) { display: grid; align-content: start; gap: 14px; }
.calendar-view .calendar-page-top {
  min-height: 74px;
  align-items: center;
  margin: 0;
  padding: 0 0 12px;
  border-bottom: 1px solid #d7e4dc;
}
.calendar-view .calendar-page-title .eyebrow { color: #147653; }
.calendar-view .calendar-page-title h1 { color: #17342a; font-size: clamp(27px, 2.2vw, 32px); letter-spacing: -.05em; }
.calendar-view .calendar-page-title .page-subtitle { max-width: 680px; }
.calendar-view .calendar-page-actions { gap: 8px; }
.calendar-view .calendar-page-actions .month-control,
.calendar-view .calendar-page-actions .calendar-today-button,
.calendar-view .calendar-balance-card { border-color: #d6e3db; border-radius: 10px; background: #fff; }
.calendar-view .dashboard-focus-controls {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid #d7e4dc;
  border-radius: 11px;
  background: #fff;
}
.calendar-view .dashboard-focus-toolbar { width: 100%; }
.calendar-view .card-lane-toggle { min-height: 36px; border-radius: 9px; }
.calendar-view .card-lane-toggle.is-selected { background: #edf7f1; }
.calendar-view .financial-calendar-section {
  min-width: 0;
  margin: 0;
  padding: 17px;
  overflow: hidden;
  border: 1px solid #d4e2d9;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}
.calendar-view .calendar-risk-alert { margin-bottom: 12px; }
.calendar-view .calendar-risk-alert { padding: 9px 11px; border-radius: 9px; }
.calendar-view .financial-calendar-scroll { border: 1px solid #e0e9e4; border-radius: 10px; }
.calendar-view .calendar-lanes-grid { --calendar-row-separator: #e2ebe5; min-width: 1000px; }
.calendar-view .calendar-month-head { min-height: 47px; background: #f7faf8; }
.calendar-view .calendar-lane-name { background: #f9fbfa; }
.calendar-view .calendar-fortnight-parts > strong { min-height: 34px; background: #e4f2e9; color: #116b49; }
.calendar-view .calendar-lane-row { min-height: 86px; border-bottom-color: var(--calendar-row-separator); }
.calendar-view .calendar-lane-track { min-height: 85px; }
.calendar-view .calendar-lane-track::before { top: 42px; height: 2px; }
.calendar-view .calendar-lane-track::after { top: 41px; }
.calendar-view .calendar-lane-event-label { top: 4px; max-width: 180px; border: 1px solid #e4ece7; box-shadow: 0 1px 2px #193d2b0b; }
.calendar-view .calendar-lane-event.is-lower .calendar-lane-event-label { top: 54px; }
.calendar-view .calendar-lane-event-label strong,
.calendar-view .calendar-lane-event-label small { font-size: 13px; }
.calendar-view .journey-details-grid { grid-template-columns: minmax(0,1.55fr) minmax(300px,.85fr); gap: 14px; margin: 0; align-items: start; }
.calendar-view .journey-details-grid > .timeline-panel,
.calendar-view .journey-details-grid > .side-stack > .panel { min-width: 0; border-color: #d7e4dc; border-radius: 14px; box-shadow: var(--shadow); }
.calendar-view .journey-details-grid .timeline-heading h2 { color: #19372c; font-size: 18px; }
.calendar-view .calendar-ledger-scroll { border-color: #dce7e1; border-radius: 10px; }
.calendar-view .calendar-ledger-head { background: #edf4f0; }
.calendar-view .calendar-ledger-row { min-height: 54px; }
.calendar-view .upcoming-card-list { gap: 9px; margin-top: 12px; }
.calendar-view .upcoming-card-row,
.calendar-view .upcoming-shared-group { padding: 11px; border-radius: 10px; }
.calendar-view .upcoming-card-row { border-left-width: 4px; }
.calendar-view .upcoming-card-simple-summary { border-radius: 8px; }
.calendar-view .side-alert { margin-top: 10px; border-radius: 9px; }
.calendar-view #credit-panel .upcoming-card-member { border-radius: 10px; }

@media (max-width: 980px) {
  .month-close-view .balance-chart-layout { grid-template-columns: minmax(0,1fr) 250px; gap: 13px; }
  .calendar-view .journey-details-grid { grid-template-columns: minmax(0,1.25fr) minmax(260px,.85fr); }
}
@media (max-width: 720px) {
  .finance-shell { display: block; min-height: 100vh; }
  .finance-shell .sidebar {
    position: fixed; z-index: 30; inset: auto 0 0; display: block; width: 100%;
    height: calc(66px + env(safe-area-inset-bottom)); padding: 3px 6px calc(3px + env(safe-area-inset-bottom));
    border: 0; border-top: 1px solid #d7e3dc; background: #ffffffed;
    box-shadow: 0 -8px 24px #193c2b0d; backdrop-filter: blur(12px);
  }
  .finance-shell .sidebar .brand, .finance-shell .sidebar .sidebar-bottom { display: none; }
  .finance-shell .nav-list { display: grid; height: 100%; grid-template-columns: repeat(6,minmax(0,1fr)); align-items: stretch; gap: 2px; }
  .finance-shell .nav-item { min-width: 0; min-height: 56px; flex-direction: column; justify-content: center; gap: 3px; padding: 3px 1px; border-radius: 8px; font-size: 12px; line-height: 1.05; text-align: center; white-space: normal; overflow-wrap: anywhere; }
  .finance-shell .nav-item .material-symbols-outlined { font-size: 19px; }
  .finance-shell .nav-item.is-active::before { display: none; }
.finance-shell .page-content, .finance-shell .page-content.is-calendar-view { padding: 14px 12px calc(84px + env(safe-area-inset-bottom)); }
  .month-close-view { gap: 10px; }
  .month-close-heading { align-items: flex-start; }
  .month-close-heading h1 { font-size: 26px; }
  .month-close-view .balance-projection { padding: 13px 11px; }
  .month-close-view .balance-chart-layout { grid-template-columns: minmax(0,1fr); gap: 10px; }
  .month-close-view .balance-chart-wrap { overflow-x: auto; }
  .month-close-view .balance-chart { min-width: 500px; }
  .month-close-view .balance-chart-summary-panel { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 12px; }
  .month-close-view .balance-chart-summary-panel h3,
  .month-close-view .balance-chart-summary-panel > p { grid-column: 1 / -1; }
  .month-close-view .projection-card-flow-steps { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .month-close-view .projected-card-summaries { padding: 12px; }
  .calendar-view { gap: 10px; }
  .calendar-view .calendar-page-top { align-items: flex-start; flex-direction: column; gap: 10px; }
  .calendar-view .calendar-page-actions { display: grid; width: 100%; grid-template-columns: minmax(0,1fr) auto; justify-content: start; }
  .calendar-view .calendar-page-actions .month-control { grid-column: 1 / -1; justify-self: start; }
  .calendar-view .calendar-page-actions .calendar-balance-card { min-width: 0; }
  .calendar-view .dashboard-focus-controls { padding: 8px; }
  .calendar-view .dashboard-focus-toolbar { align-items: flex-start; flex-direction: column; gap: 8px; }
  .calendar-view .financial-calendar-section { padding: 10px; }
  .calendar-view .calendar-lanes-grid { min-width: 1000px; }
  .calendar-view .journey-details-grid { grid-template-columns: 1fr; }
  .calendar-view .journey-details-grid .timeline-panel { padding: 11px; }
  .calendar-view .side-stack { position: static; }
}

/* The calendar is a first-class workspace, not a section embedded in Home.
   Its month header owns the context controls, so hide the global breadcrumb bar
   and give this dense calendar more horizontal room like the reference view. */
@media (min-width: 721px) {
  body[data-active-view="calendar"] .finance-shell { grid-template-columns: 148px minmax(0, 1fr); }
  body[data-active-view="calendar"] .finance-shell .sidebar { padding: 16px 8px; }
  body[data-active-view="calendar"] .finance-shell .topbar { display: none; }
  body[data-active-view="calendar"] .finance-shell .page-content.is-calendar-view { padding: 16px 14px 36px; }
  body[data-active-view="calendar"] .calendar-page-top { min-height: 54px; padding-bottom: 10px; }
  body[data-active-view="calendar"] .calendar-page-title .eyebrow { display: none; }
  body[data-active-view="calendar"] .calendar-page-title h1 { font-size: 24px; letter-spacing: -.035em; }
  body[data-active-view="calendar"] .calendar-page-title .page-subtitle { display: none; }
}
@media (max-width: 380px) {
  .finance-shell .nav-item { font-size: 12px; }
  .finance-shell .nav-item .material-symbols-outlined { font-size: 18px; }
  .calendar-view .calendar-page-actions .calendar-balance-card { font-size: 12px; }
}

/* Reference-led finishing pass: two complete workspaces, one quiet visual language. */
:root {
  --page: #f4f7fa;
  --surface: #fff;
  --surface-soft: #eef3f6;
  --text: #1d2b39;
  --muted: #5d6d79;
  --line: #dce5eb;
  --green: #11815d;
  --green-soft: #e3f3e9;
  --amber: #95620a;
  --amber-soft: #fff2d8;
  --red: #bd4844;
  --red-soft: #fff0ef;
  --shadow: 0 6px 20px #263f520a;
}
body { background: var(--page); color: var(--text); }
.finance-shell .sidebar {
  background: linear-gradient(180deg, #f8fafc 0%, #f4f7fb 100%);
  border-right-color: #e0e7ed;
}
.finance-shell .brand { color: #1d3441; }
.finance-shell .brand-mark { background: #e6f4ec; }
.finance-shell .nav-item { color: #4c6170; }
.finance-shell .nav-item.is-active { color: #116b4d; background: #e1f2e9; }
.finance-shell .topbar { background: #fff; border-color: #e1e8ed; }
.finance-shell .page-content { gap: 16px; }
.month-close-view { gap: 15px; }
.month-close-view .projection-reading[data-tone="warning"] { background: #fff8e9; }
.month-close-view .balance-projection,
.month-close-view .projected-card-summaries,
.calendar-view .financial-calendar-section,
.calendar-view .journey-details-grid > .timeline-panel,
.calendar-view .journey-details-grid > .side-stack > .panel {
  border-color: #dbe5eb;
  border-radius: 13px;
  box-shadow: 0 4px 16px #263f5208;
}
.month-close-view .projection-card-flow {
  border-color: #d6e8dc;
  background: linear-gradient(105deg, #f1f8f4 0%, #f8fbf9 100%);
}
.month-close-view .balance-chart-summary-panel { background: #f8fafb; }
.month-close-view .projected-card-table-header,
.calendar-view .calendar-ledger-head { background: #edf3f6; }
.month-close-view .projected-card-table-row + .projected-card-table-row,
.calendar-view .calendar-ledger-row + .calendar-ledger-row { border-top-color: #e4ebf0; }

/* The Calendar menu opens a full page: month controls, day scale, fortnight bands,
   colored financial lanes, then the movement ledger and card-cycle summary. */
.calendar-view:not(.is-hidden) { gap: 13px; }
.finance-shell .page-content.is-calendar-view { padding: 16px clamp(20px, 2.2vw, 36px) 40px; }
.calendar-view .calendar-page-top {
  min-height: 66px;
  padding: 0 0 11px;
  border-bottom-color: #dbe5eb;
}
.calendar-view .calendar-page-title h1 { font-size: clamp(24px, 2vw, 30px); }
.calendar-view .calendar-page-actions .month-control,
.calendar-view .calendar-page-actions .calendar-today-button,
.calendar-view .calendar-balance-card { border-color: #d8e2e9; }
.calendar-view .dashboard-focus-controls { border-color: #dce5eb; box-shadow: none; }
.calendar-view .card-lane-controls { gap: 6px; }
.calendar-view .card-lane-toggle {
  min-height: 38px;
  border: 1px solid #e1e8ed;
  border-radius: 9px;
  background: #fff;
}
.calendar-view .card-lane-toggle.is-selected {
  border-color: #c9dfd2;
  background: #edf7f1;
}
.calendar-view .financial-calendar-section { padding: 14px; }
.calendar-view .financial-calendar-scroll { border-color: #e1e8ed; }
.calendar-view .calendar-lanes-grid {
  min-width: 1120px;
  --calendar-row-separator: #e2e9ee;
}
.calendar-view .calendar-month-head { background: #f7f9fb; }
.calendar-view .calendar-date-cell.is-today { background: #e7f3ed; }
.calendar-view .calendar-fortnight-parts > strong {
  min-height: 36px;
  border-radius: 0;
  background: #e8f2ed;
  color: #146b4d;
}
.calendar-view .calendar-fortnight-parts .calendar-fortnight-second { border-left: 1px solid #93b5a2; }
.calendar-view .calendar-lane-row { min-height: 84px; }
.calendar-view .calendar-lane-name { background: #f8fafb; }
.calendar-view .calendar-lane-track { min-height: 83px; }
.calendar-view .calendar-lane-track::before { opacity: .88; }
.calendar-view .calendar-lane-event-label { max-width: 170px; border-color: #e1e8ed; }
.calendar-view .journey-details-grid { grid-template-columns: minmax(0, 1.6fr) minmax(310px, .9fr); gap: 14px; }
.calendar-view .calendar-ledger-scroll { border-color: #e0e7ed; }
.calendar-view .calendar-ledger-head { position: sticky; top: 0; z-index: 2; }
.calendar-view .calendar-ledger-row { min-height: 56px; }
.calendar-view .side-stack { position: sticky; top: 68px; }

@media (max-width: 980px) {
  .calendar-view .journey-details-grid { grid-template-columns: minmax(0, 1.2fr) minmax(270px, .9fr); }
}
@media (max-width: 720px) {
  .finance-shell .page-content.is-calendar-view { padding: 13px 12px calc(82px + env(safe-area-inset-bottom)); }
  .month-close-view { gap: 11px; }
  .calendar-view .calendar-page-top { padding-bottom: 9px; }
  .calendar-view .dashboard-focus-controls { padding: 8px; }
  .calendar-view .card-lane-controls { width: 100%; flex-wrap: wrap; }
  .calendar-view .calendar-lanes-grid { min-width: 1120px; }
  .calendar-view .journey-details-grid { grid-template-columns: 1fr; }
  .calendar-view .side-stack { position: static; }
}
