/* Mason Cashflow ships light-only. Same anti-flash rationale as the
   prior dark-only theme: pinning the palette in :root (and pairing
   with ``<meta name="color-scheme" content="light">`` in base.html)
   means every browser repaints identically, regardless of OS-level
   prefers-color-scheme. Every value below is tuned for ≥ 7:1 contrast
   on white per Brian's 'high contrast' brief — text colours sit at
   slate-900 / slate-600 / slate-500, borders at slate-300, accents
   at indigo-700. Hardcoded reds / ambers in the templates also got
   re-keyed to darker shades suitable for white. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #d1d5db;
  --text: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --primary: #4338ca;
  --primary-hover: #3730a3;
  --positive: #15803d;
  --positive-soft: rgba(21, 128, 61, 0.10);
  --neutral-soft: rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.10);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --nav-h: 64px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica,
    Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ---------- Navbar ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.navbar__inner {
  height: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.brand__name {
  font-size: 16px;
}

.nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
  justify-content: center;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  color: var(--text);
  background: var(--neutral-soft);
}

.nav-link.is-active {
  color: var(--text);
  background: var(--neutral-soft);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease,
    transform 0.15s ease;
}

.icon-btn:hover {
  color: var(--text);
  background: var(--neutral-soft);
  border-color: var(--border);
}

.icon-btn:active {
  transform: translateY(1px);
}

.icon-btn.is-active {
  color: var(--text);
  background: var(--neutral-soft);
  border-color: var(--border);
}

/* ---------- Page ---------- */
.page {
  flex: 1;
  width: 100%;
  max-width: 1340px;
  margin: 0 auto;
  padding: 56px 24px 80px;
}

.eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: 12px;
}

.hero {
  margin-bottom: 40px;
}

.hero__title {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0 0 10px;
  background: linear-gradient(135deg, var(--text) 30%, var(--primary) 110%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero__subtitle {
  font-size: 16px;
  color: var(--text-muted);
  max-width: 60ch;
  margin: 0;
}

/* ---------- Cards ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 22px 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease,
    border-color 0.18s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card__label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.card__value {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.card__hint {
  font-size: 13px;
  color: var(--text-subtle);
  margin: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.pill--positive {
  color: var(--positive);
  background: var(--positive-soft);
}

.pill--neutral {
  color: var(--text-muted);
  background: var(--neutral-soft);
}

/* ---------- Panel ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.panel__title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panel__hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-subtle);
}

/* ---------- Page header (hero + actions) ---------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 40px;
}

.page-header .hero__title { margin-bottom: 10px; }
.page-header .hero__subtitle { margin-bottom: 0; }

.page-header__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  padding-top: 22px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease,
    transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn--primary {
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover {
  filter: brightness(1.05);
  box-shadow: var(--shadow-md);
}

/* ---------- Error panel ---------- */
.error-panel {
  margin-top: 28px;
  padding: 18px 20px;
  border: 1px solid color-mix(in srgb, #ef4444 35%, var(--border));
  background: color-mix(in srgb, #ef4444 8%, var(--surface));
  border-radius: var(--radius-lg);
  color: var(--text);
}

.error-panel__head {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #b91c1c;
}

.error-panel__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.error-panel__hint {
  margin: 6px 0 10px;
  color: var(--text-muted);
  font-size: 13px;
}

.error-panel__list {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.6;
}

.error-panel__list li { margin: 0; }

/* ---------- Projects section ---------- */
.projects-section {
  margin-top: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px 22px 6px;
}

.projects-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.projects-section__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.projects-section__meta {
  font-size: 13px;
  color: var(--text-subtle);
}

.table-scroll {
  overflow-x: auto;
  margin: 0 -22px;
  padding: 0 22px 18px;
}

.projects-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 14px;
}

.projects-table th,
.projects-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.projects-table thead th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.projects-table thead tr:first-child th { border-bottom: 1px solid var(--border); }

.projects-table tbody tr:last-child td { border-bottom: none; }

.th--right, .td--right { text-align: right; }
.th--center, .td--center { text-align: center; }
.th--super { color: var(--primary); }
.th--sub { font-weight: 500; text-transform: none; letter-spacing: 0; }

.th--sticky, .td--sticky {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
}
.projects-table thead .th--sticky { background: var(--surface-2); }

.td--num {
  font-variant-numeric: tabular-nums;
}

.td--muted {
  color: var(--text-subtle);
}

.months-input {
  width: 80px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.months-input:hover { border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }
.months-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}

/* Hide number-input spinner arrows for a cleaner look */
.months-input::-webkit-outer-spin-button,
.months-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.months-input { -moz-appearance: textfield; }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  .navbar__inner {
    grid-template-columns: auto auto;
    gap: 12px;
  }
  .nav-links {
    display: none;
  }
  .page {
    padding: 36px 18px 64px;
  }
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }
  .page-header__actions {
    padding-top: 0;
  }
}

/* ---------- Dashboard chrome (LHS nav + RHS panel) ---------- */
/* Mirrors the Set Up layout grid so both top-level inner pages feel
   parallel: pick a thing on the left, edit it on the right. */
.dash-layout {
  display: grid;
  grid-template-columns: minmax(220px, 22%) 1fr;
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}
@media (max-width: 820px) {
  .dash-layout { grid-template-columns: 1fr; }
}

.dash-nav {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 8px 6px;
  position: sticky;
  top: calc(var(--nav-h) + 12px);
}
.dash-nav__title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  padding: 6px 10px 8px;
  margin: 0;
}
.dash-nav__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dash-nav__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
}
.dash-nav__link:hover {
  background: var(--neutral-soft);
  color: var(--text);
}
.dash-nav__link.is-active {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--text);
  font-weight: 600;
}
.dash-nav__count {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-subtle);
  background: var(--neutral-soft);
  padding: 0 7px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}
.dash-nav__link.is-active .dash-nav__count {
  background: color-mix(in srgb, var(--primary) 22%, transparent);
  color: var(--text);
}

/* ---------- Dashboard (legacy single-column layout, kept for now) ---------- */
.dashboard-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1120px;
}

.dash-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px 24px;
}

.dash-panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.dash-panel__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dash-panel__badge {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--surface-2);
}

.dash-panel__lede {
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dash-group-total {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.dash-panel__meta {
  font-size: 14px;
  color: var(--text-muted);
}

.dash-panel__hint {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.dash-table th,
.dash-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.dash-table thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--surface-2);
}

.dash-table tbody tr:last-child td {
  border-bottom: none;
}

.td--strong {
  font-weight: 600;
}

.dash-flag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
}

.dash-flag--critical {
  color: #991b1b;
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.35);
}

.dash-flag--warning {
  color: #854d0e;
  background: rgba(217, 119, 6, 0.12);
  border: 1px solid rgba(217, 119, 6, 0.35);
}

.dash-flag--ok {
  color: var(--text-subtle);
  background: var(--neutral-soft);
}

.dash-empty {
  margin: 0;
  padding: 12px 0 4px;
  color: var(--text-muted);
  font-size: 14px;
}

.td--variance-neg {
  color: #b91c1c;
}

/* ---------- Login ---------- */
.login-layout {
  max-width: 440px;
  margin: 0 auto;
  padding: 48px 20px 80px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 28px 26px 30px;
}

.login-card__title {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-card__hint {
  margin: 0 0 22px;
  font-size: 14px;
  color: var(--text-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-form__errors {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.35);
  color: #991b1b;
  font-size: 14px;
}

.login-form__errors p {
  margin: 0;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.login-form input[type='text'],
.login-form input[type='password'] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.login-form input:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}

.login-field__error {
  margin: 0;
  font-size: 13px;
  color: #b91c1c;
}

.login-submit {
  margin-top: 6px;
  width: 100%;
  justify-content: center;
}

.nav-links__dropdown {
  position: relative;
}

.nav-details {
  position: relative;
}

.nav-summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}

.nav-summary::-webkit-details-marker {
  display: none;
}

.nav-summary.is-active {
  color: var(--text);
  background: var(--neutral-soft);
}

.nav-details__menu {
  list-style: none;
  margin: 6px 0 0;
  padding: 8px 0;
  min-width: 180px;
  position: absolute;
  left: 0;
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.nav-details__menu a {
  display: block;
  padding: 8px 14px;
  font-size: 14px;
  color: var(--text-muted);
}

.nav-details__menu a:hover {
  color: var(--text);
  background: var(--surface-2);
}

/* ---------- Forecast 12M ---------- */

.forecast-12m__scroll {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}

.forecast-12m__table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.forecast-12m__th,
.forecast-12m__cell {
  padding: 8px 10px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.forecast-12m__th--sticky,
.forecast-12m__row-label {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
  min-width: 220px;
  max-width: 320px;
  background: var(--surface);
  box-shadow: 4px 0 8px -4px rgba(15, 23, 42, 0.12);
}

.forecast-12m__th--corner {
  z-index: 4;
  vertical-align: bottom;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-muted);
}

.forecast-12m__row-label {
  font-weight: 500;
  color: var(--text);
}

.forecast-12m__month-group {
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
  border-left: 1px solid var(--border);
}

.forecast-12m__month-group--locked {
  background: color-mix(in srgb, var(--surface-2) 88%, var(--primary) 12%);
}

.forecast-12m__month-group--forecast {
  background: var(--surface-2);
}

.forecast-12m__subth {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  border-left: 1px solid var(--border);
}

.forecast-12m__subth--actual {
  background: color-mix(in srgb, var(--surface) 92%, var(--primary) 8%);
}

.forecast-12m__subth--forecast {
  background: var(--surface);
}

.forecast-12m__subth--var {
  background: color-mix(in srgb, var(--surface) 94%, var(--text-subtle) 6%);
}

.forecast-12m__cell--actual {
  background: color-mix(in srgb, var(--surface) 96%, var(--primary) 4%);
}

.forecast-12m__cell--forecast {
  background: var(--surface);
}

.forecast-12m__cell--variance {
  background: var(--surface-2);
}

.forecast-12m__cell--muted {
  color: var(--text-subtle);
  background: var(--surface-2);
}

.forecast-12m__var--bad {
  color: #991b1b;
  font-weight: 600;
  background: color-mix(in srgb, rgba(220, 38, 38, 0.18) 50%, var(--surface-2) 50%);
}

.forecast-12m__section-row th {
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.forecast-12m__subheader-row th {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  color: var(--text);
  background: color-mix(in srgb, var(--surface-2) 85%, var(--surface) 15%);
  border-bottom: 1px solid var(--border);
}

.forecast-12m__data-row--total .forecast-12m__row-label,
.forecast-12m__data-row--grand .forecast-12m__row-label,
.forecast-12m__data-row--balance .forecast-12m__row-label {
  font-weight: 700;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-2);
}

.forecast-12m__data-row--total .forecast-12m__cell,
.forecast-12m__data-row--grand .forecast-12m__cell {
  font-weight: 700;
  border-top: 1px solid var(--border);
}
