:root {
  --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --brand: #0B1F3A;
  --brand-dark: #071628;
  --brand-deep: #050E1C;
  --brand-soft: #3D5A80;
  --navy: #0B1F3A;
  --navy-2: #16325C;
  --gold: #0B1F3A;
  --gold-2: #D6E4F2;
  --cream: #F3F6FA;
  --paper: #FFFFFF;
  --ink: #0E1A2B;
  --muted: #5A6B80;
  --line: #D4DEEA;
  --milestone: #E6EEF6;
  --danger: #0B1F3A;
  --shadow: rgba(11, 31, 58, 0.12);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
}

html, body, button, input, select, textarea, table, th, td,
h1, h2, h3, h4, p, a, span, label, li, div, strong, em, small, b {
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 28px;
}

.utility-bar {
  background: var(--brand-deep);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.utility-bar .shell {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.utility-bar a {
  color: #fff;
  text-decoration: none;
}

.utility-bar a:hover { text-decoration: underline; }

.site-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}

.brand img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 56px;
  box-shadow: 0 0 0 2px var(--brand);
}

.brand strong {
  display: block;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--brand);
}

.brand em {
  display: block;
  font-style: normal;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.site-nav a {
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 8px;
}

.site-nav a:hover { background: var(--cream); color: var(--brand); }

.nav-cta {
  background: var(--brand) !important;
  color: #fff !important;
  margin-left: 6px;
}

.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  flex-direction: column;
  justify-content: space-between;
}

.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--brand);
  border-radius: 2px;
}

.page-hero {
  background: linear-gradient(135deg, var(--brand-deep) 0%, var(--brand) 58%, #16325C 100%);
  color: #fff;
  padding: 36px 0 32px;
  border-bottom: 0;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 700;
  color: #C5D4E8;
}

h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.sub {
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 15px;
  max-width: 720px;
  line-height: 1.5;
  font-weight: 500;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button, .ghost {
  border: 0;
  cursor: pointer;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 700;
  font-size: 13px;
  touch-action: manipulation;
  min-height: 40px;
}

.btn-gold { background: var(--brand); color: #fff; }
.btn-light { background: #fff; color: var(--brand); }
.btn-outline { background: transparent; color: #fff; border: 1px solid #C5D4E8; }

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 20px 48px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 24px var(--shadow);
  max-width: 100%;
}

.inputs {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 14px;
}

.inputs > * { min-width: 0; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="color"]),
select {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  width: 100%;
  max-width: 100%;
}

.derived {
  grid-column: span 6;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  padding-top: 4px;
  color: var(--navy);
  font-size: 13px;
}

.derived b { color: var(--brand); }

.error {
  margin: 12px 20px 0;
  padding: 10px 12px;
  background: #fdecee;
  color: var(--danger);
  border-radius: 8px;
  font-size: 13px;
}

.kpis {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

.kpis > * { min-width: 0; }

.kpi {
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.kpi-label {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.kpi-value {
  margin: 8px 0 4px;
  font-size: 20px;
  color: var(--navy);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.kpi-sub {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.year-cards {
  display: none;
}

.table-hint {
  display: none;
}

.table-wrap {
  margin-top: 16px;
  overflow: auto;
  max-height: calc(100vh - 120px);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.table-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  padding: 14px 16px 0;
}

.table-head h2 {
  margin: 0;
  font-size: 16px;
  color: var(--navy);
}

.table-head p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 1480px;
}

th, td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  z-index: 2;
}

th:nth-child(-n+2), td:nth-child(-n+2) {
  text-align: center;
}

th:nth-child(1), td:nth-child(1) {
  position: sticky;
  left: 0;
  min-width: 72px;
  z-index: 3;
  background: var(--paper);
  box-shadow: 4px 0 8px var(--shadow);
}

th:nth-child(2), td:nth-child(2) {
  position: sticky;
  left: 72px;
  min-width: 72px;
  z-index: 3;
  background: var(--paper);
  box-shadow: 4px 0 8px var(--shadow);
}

th:nth-child(1), th:nth-child(2) {
  z-index: 4;
  background: var(--navy);
  color: #fff;
  box-shadow: 4px 0 8px rgba(5, 14, 28, 0.22);
}

tbody tr:nth-child(even) td:nth-child(-n+2) {
  background: #F3F6FA;
}

tr.milestone td:nth-child(-n+2) {
  background: var(--milestone);
}

th.fv-active, td.fv-active {
  background: #C5D4E8;
  color: var(--brand-dark);
  font-weight: 700;
}

tbody tr:nth-child(even) { background: #F3F6FA; }

tr.milestone td {
  background: var(--milestone);
  font-weight: 700;
  color: var(--navy);
}

tr.milestone td:nth-last-child(-n+5) {
  color: var(--brand);
}

.formulas {
  margin-top: 16px;
  padding: 16px 18px 8px;
}

.formulas h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.formulas ol {
  margin: 0 0 12px;
  padding-left: 18px;
  color: #334;
  font-size: 13px;
  line-height: 1.55;
}

.note {
  font-size: 12px;
  color: var(--muted);
  padding: 0 4px 12px;
}

.charts-panel {
  margin-top: 16px;
  padding: 16px 18px 20px;
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 20px;
  align-items: start;
}

.chart-block {
  position: relative;
}

.chart-block h2 {
  margin: 0 0 4px;
  font-size: 16px;
  color: var(--navy);
}

.chart-block p {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
}

.chart-block canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: crosshair;
  touch-action: none;
}

.chart-tooltip {
  position: absolute;
  z-index: 8;
  pointer-events: none;
  background: var(--brand-deep);
  color: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.35;
  border: 1px solid var(--brand-soft);
  box-shadow: 0 10px 24px var(--shadow);
  white-space: nowrap;
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 4px;
  color: #C5D4E8;
  font-size: 12px;
}

.chart-tooltip .tip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.chart-tooltip .tip-row i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.chart-tooltip .tip-row b {
  margin-left: auto;
  padding-left: 12px;
}

.pie-legend li.active {
  font-weight: 700;
}

.pie-legend {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}

.pie-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--navy);
  padding: 4px 0;
}

.pie-legend .swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: 0 0 12px;
}

.pie-legend b {
  margin-left: auto;
  font-size: 12px;
}

.pie-legend em {
  color: var(--muted);
  font-style: normal;
  min-width: 42px;
  text-align: right;
}

.export-panel {
  margin-top: 16px;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 1.4fr 1.6fr auto;
  gap: 16px;
  align-items: center;
}

.export-copy h2 {
  margin: 0 0 6px;
  font-size: 16px;
  color: var(--navy);
}

.export-copy p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

.export-rates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rate-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.rate-check input {
  width: 15px;
  height: 15px;
  margin: 0;
}

.rate-check small {
  color: var(--muted);
  font-weight: 600;
}

.rate-check.locked {
  background: #C5D4E8;
  cursor: default;
}

.export-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button.solid {
  border: 1px solid var(--navy);
}

.site-footer {
  background: var(--brand-deep);
  color: #fff;
  margin-top: 8px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 1fr;
  gap: 28px;
  padding: 36px 0 28px;
}

.footer-brand {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-start;
}

.footer-brand img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 3px #fff;
}

.site-footer h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 800;
}

.site-footer h3 {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #C5D4E8;
}

.site-footer p {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.55;
  color: rgba(255,255,255,0.86);
  font-weight: 500;
}

.site-footer a {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

.site-footer a:hover { text-decoration: underline; }

.footer-base {
  border-top: 1px solid rgba(255,255,255,0.12);
  padding: 12px 0;
  font-size: 12px;
  color: rgba(255,255,255,0.7);
}

@media (max-width: 1100px) {
  .export-panel { grid-template-columns: 1fr; }
  .charts-panel { grid-template-columns: 1fr; }
  .inputs, .kpis { grid-template-columns: repeat(2, 1fr); }
  .derived { grid-column: span 2; }
}

@media (max-width: 900px) {
  .shell {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .site-header-inner { min-height: 68px; }

  .brand img { width: 46px; height: 46px; flex-basis: 46px; }

  .brand strong { font-size: 14px; }

  .nav-toggle { display: flex; }

  .site-nav {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: #fff;
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    align-items: stretch;
    padding: 8px 16px 14px;
    box-shadow: 0 12px 24px var(--shadow);
  }

  body.nav-open .site-nav { display: flex; }

  .site-nav a { padding: 12px 10px; }

  .nav-cta { margin: 4px 0 0; text-align: center; }

  .page-hero { padding: 24px 0 20px; }

  h1 { font-size: 24px; line-height: 1.25; }

  .sub { font-size: 13px; }

  .footer-grid {
    grid-template-columns: 1fr;
    padding: 24px 0 20px;
  }

  main {
    padding: 12px 12px 32px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(32px, env(safe-area-inset-bottom));
  }

  .inputs {
    padding: 14px;
    gap: 12px;
  }

  .inputs label:nth-child(5),
  .inputs label:nth-child(6) {
    grid-column: span 2;
  }

  .derived {
    flex-direction: column;
    gap: 6px;
  }

  .error { margin: 10px 0 0; }

  .kpis {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .kpi {
    padding: 12px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 12px;
  }

  .kpi-sub { font-size: 11px; }

  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="color"]),
  select {
    height: 44px;
    font-size: 16px;
  }

  .kpi-value { font-size: 16px; }

  .table-head {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 14px 0;
  }

  .year-cards {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 12px 14px 4px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }

  .year-card {
    flex: 0 0 min(220px, 78vw);
    scroll-snap-align: start;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
  }

  .year-card.milestone {
    background: var(--milestone);
    border-color: #9BB0C9;
  }

  .year-card h3 {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--navy);
  }

  .year-card dl {
    margin: 0;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 10px;
    font-size: 12px;
  }

  .year-card dt { color: var(--muted); }
  .year-card dd { margin: 0; font-weight: 700; color: var(--navy); text-align: right; }

  .table-hint {
    display: block;
    margin: 8px 14px 0;
    font-size: 12px;
    color: var(--muted);
  }

  .table-wrap {
    margin-top: 8px;
    max-height: min(52vh, 440px);
  }

  table { font-size: 11px; min-width: 1080px; }

  th, td { padding: 7px 8px; }

  th:nth-child(1), td:nth-child(1) {
    min-width: 48px;
    width: 48px;
  }

  th:nth-child(2), td:nth-child(2) {
    left: 48px;
    min-width: 48px;
    width: 48px;
  }

  .charts-panel,
  .export-panel,
  .formulas {
    padding: 14px;
  }

  .chart-tooltip {
    white-space: normal;
    max-width: min(260px, calc(100% - 16px));
    font-size: 11px;
  }

  .pie-legend li {
    gap: 6px;
  }

  .pie-legend b,
  .pie-legend em {
    font-size: 12px;
  }

  .export-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .export-actions button {
    width: 100%;
    min-height: 44px;
  }

  .rate-check {
    min-height: 40px;
  }

  .formulas ol { padding-left: 18px; font-size: 13px; }
}

@media (max-width: 480px) {
  h1 { font-size: 20px; }

  .eyebrow { letter-spacing: 0.1em; }

  .year-card { flex-basis: min(200px, 84vw); }

  .kpi-label { font-size: 10px; }
}

@media print {
  .utility-bar, .site-header, .site-nav, .nav-toggle, #exportPanel, .year-cards, .table-hint, .site-footer, .admin-bar { display: none !important; }
  body { background: #fff; }
  .table-wrap { max-height: none; overflow: visible; }
  tr.milestone td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { size: A4 landscape; margin: 8mm; }
}

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 12px;
}

.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 8px 24px var(--shadow);
}

.auth-card img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
}

.auth-card h1 {
  margin: 12px 0 6px;
  font-size: 22px;
  color: var(--brand);
}

.auth-card p { color: var(--muted); font-size: 14px; }

.auth-card form {
  display: grid;
  gap: 12px;
  text-align: left;
  margin-top: 16px;
}

.auth-card button { width: 100%; }

.auth-back { margin: 16px 0 0; }

.auth-back a { color: var(--brand); font-weight: 700; text-decoration: none; }

.auth-password-wrap {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.auth-password-wrap input {
  flex: 1;
}

.auth-password-toggle {
  width: auto !important;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f4f7fb;
  color: var(--brand);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.auth-remember input {
  width: 15px;
  height: 15px;
}

.auth-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.auth-lockout {
  background: #fff6e5;
  border: 1px solid #f0d9a0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 8px;
}

.admin-bar {
  background: var(--brand-deep);
  color: #fff;
}

.admin-bar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 56px;
  gap: 12px;
}

.admin-bar a {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  margin-left: 14px;
}

.admin-main { padding: 24px 0 48px; }

.admin-lead { color: var(--muted); max-width: 640px; }

.admin-ok {
  background: #e8f6ee;
  color: #1a6b5c;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 700;
}

.admin-form {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.admin-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 16px;
  color: var(--ink);
  min-height: 88px;
}

.admin-form h2 {
  margin: 8px 0 0;
  font-size: 16px;
  color: var(--brand);
}

@media (max-width: 720px) {
  .admin-grid { grid-template-columns: 1fr; }
}
