:root {
  --navy: #102d39;
  --navy-2: #21414d;
  --teal: #008878;
  --ink: #18333f;
  --muted: #75848a;
  --line: #e4eaea;
  --bg: #f5f7f8;
  --mint: #e6f2ed;
  --bs-primary: #008878;
  --bs-primary-rgb: 0, 136, 120;
  --bs-body-bg: #f5f7f8;
  --bs-modal-bg: #fff;
  --bs-modal-color: #18333f;
  --bs-body-color: #18333f;
  --bs-body-font-family: "DM Sans", "Segoe UI", sans-serif;
  --bs-secondary-color: #75848a;
  --bs-border-color: #e4eaea;
  --bs-link-color: #008878;
  --bs-link-hover-color: #007468;
  --bs-focus-ring-color: rgba(0, 136, 120, 0.28);
  --sidebar: 248px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "DM Sans", "Segoe UI", sans-serif;
  font-size: 14px;
}

h1, h2, h3, .stat-value, .brand-name, .snapshot {
  font-family: Manrope, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
a { color: inherit; }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 2000;
  background: white;
  color: var(--navy);
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
}
.skip-link:focus { top: 1rem; }

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  background: var(--navy);
  color: #a8bcc4;
  padding: 1.8rem 1.05rem 1.3rem;
  flex-direction: column;
  z-index: 1030;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  padding: 0 0.45rem;
}
.brand-name {
  color: #fff;
  font-weight: 800;
  font-size: 1.55rem;
  letter-spacing: 0.16em;
  line-height: 1;
}
.brand-name small {
  display: block;
  margin-top: 0.4rem;
  font-family: "DM Sans", "Segoe UI", sans-serif;
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #9db8c0;
}
.brandmark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #b8e4cc;
  color: var(--navy);
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.workspace-label {
  margin: 2.4rem 0.7rem 1rem;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow: auto;
}
.side-link {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.72rem 0.85rem;
  border-radius: 8px;
  text-decoration: none;
  color: #c5d5db;
  font-size: 0.92rem;
}
.side-link i { width: 1.15rem; text-align: center; font-size: 1.02rem; }
.side-link:hover { background: var(--navy-2); color: white; }
.side-link.active { background: #275451; color: white; }
.side-link .counter {
  margin-left: auto;
  background: #43645f;
  color: white;
  border-radius: 4px;
  font-size: 0.68rem;
  padding: 0.15rem 0.4rem;
}

.sidebar-user {
  margin-top: auto;
  display: flex;
  gap: 0.7rem;
  align-items: center;
  border-top: 1px solid #2b4650;
  padding-top: 1.15rem;
  color: #e0eaed;
  font-size: 0.78rem;
}
.sidebar-user small { display: block; color: #91aab4; margin-top: 0.25rem; }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #45616c;
  color: white;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  flex-shrink: 0;
}

.workspace {
  margin-left: var(--sidebar);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 74px;
  background: white;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 2rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}
.btn-topbar {
  background: var(--navy);
  color: white;
  border: 0;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
}
.btn-topbar:hover { background: #21485a; color: white; }
.crumb { font-size: 0.8rem; color: var(--muted); }
.crumb strong { font-weight: 600; color: var(--ink); }
.crumb .sep { margin: 0 0.7rem; color: #b7c2c6; }
.demo-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  font-size: 0.68rem;
  color: #627a7a;
  white-space: nowrap;
  background: white;
}
.demo-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4e9b85;
  display: inline-block;
}

main {
  flex: 1;
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 2rem 2rem 2.8rem;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.95rem 2rem 1.15rem;
  border-top: 1px solid var(--line);
  color: #8b999e;
  font-size: 0.7rem;
}

.eyebrow {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
  font-weight: 700;
  margin-bottom: 0.45rem;
}
.page-title {
  font-weight: 800;
  letter-spacing: -0.035em;
  font-size: clamp(1.45rem, 2vw, 1.85rem);
  margin: 0 0 0.35rem;
  color: var(--ink);
}
.page-sub { color: #718187; font-size: 0.84rem; margin: 0; line-height: 1.5; }

.btn {
  --bs-btn-font-size: 0.78rem;
  --bs-btn-font-weight: 600;
  --bs-btn-padding-y: 0.55rem;
  --bs-btn-padding-x: 0.85rem;
  --bs-btn-border-radius: 0.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.btn-primary {
  --bs-btn-bg: var(--teal);
  --bs-btn-border-color: var(--teal);
  --bs-btn-hover-bg: #007468;
  --bs-btn-hover-border-color: #007468;
  --bs-btn-active-bg: #00685d;
  --bs-btn-active-border-color: #00685d;
  --bs-btn-disabled-bg: var(--teal);
  --bs-btn-disabled-border-color: var(--teal);
}
.btn-outline-secondary {
  --bs-btn-color: var(--ink);
  --bs-btn-border-color: #d6e0e1;
  --bs-btn-bg: #fff;
  --bs-btn-hover-bg: #edf3f2;
  --bs-btn-hover-color: var(--ink);
  --bs-btn-hover-border-color: #d6e0e1;
  --bs-btn-active-bg: #e4eeec;
  --bs-btn-active-color: var(--ink);
  --bs-btn-active-border-color: #d6e0e1;
}
.btn:focus-visible, .side-link:focus-visible, .link-action:focus-visible, .step:focus-visible {
  outline: 3px solid #75beab;
  outline-offset: 2px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: none;
  background: white;
}
.panel-head {
  background: white;
  border-bottom: 1px solid var(--line);
  padding: 1.05rem 1.25rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
}
.panel-title { font-size: 1rem; font-weight: 700; margin: 0; }
.panel-sub { margin: 0.3rem 0 0; color: #718187; font-size: 0.75rem; }
.section-title { font-size: 1.05rem; font-weight: 700; margin: 0.4rem 0 1rem; }

.stat-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.1rem 0.95rem;
  height: 100%;
}
.stat-card.accent { background: var(--mint); border-color: #d3e7df; }
.stat-label {
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  text-transform: uppercase;
}
.stat-value {
  font-weight: 700;
  font-size: 1.45rem;
  line-height: 1.2;
  margin: 0.7rem 0 0.3rem;
  color: var(--ink);
}
.stat-card.accent .stat-value { color: #176855; }
.stat-value .stat-of { font-size: 0.95rem; color: var(--muted); font-weight: 600; }
.stat-pending { font-size: 1.05rem; }
.stat-money { font-size: 1.2rem; }
.stat-note { font-size: 0.7rem; color: #819096; }
.stat-value .data-error { font-family: "DM Sans", "Segoe UI", sans-serif; font-size: 0.95rem; font-weight: 600; }

.stepper-card .card-body { padding: 1.1rem 0.6rem; }
.stepper-scroll { overflow-x: auto; }
.stepper {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  min-width: 680px;
}
.step {
  position: relative;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0 0.75rem;
  color: #829096;
}
.step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 16px;
  left: 52px;
  right: 6px;
  height: 2px;
  background: #e5ebeb;
}
.step .circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #dbe3e5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  position: relative;
  z-index: 1;
  margin-bottom: 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
}
.step strong { display: block; font-size: 0.72rem; font-weight: 600; }
.step small { display: block; margin-top: 0.25rem; font-size: 0.62rem; color: #8f9c9f; }
.step.active { color: var(--teal); }
.step.done .circle { background: #e7f4ed; border-color: #e7f4ed; color: #16785e; }
.step.active .circle {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
  box-shadow: 0 0 0 4px #dcedea;
}

.table {
  --bs-table-bg: transparent;
  --bs-table-hover-bg: #f7fbfa;
  font-size: 0.78rem;
  margin-bottom: 0;
  color: var(--ink);
}
.table > :not(caption) > * > * {
  padding: 0.85rem 1.15rem;
  border-bottom-color: #f0f3f3;
  vertical-align: middle;
}
.table thead th {
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #8b969c;
  font-weight: 600;
  background: #fbfcfc;
  border-bottom: 0;
  white-space: nowrap;
}
.table-scroll { max-height: 640px; overflow: auto; }
.table-scroll thead th { position: sticky; top: 0; z-index: 1; }
td strong { font-weight: 600; }
td .meta, .meta {
  display: block;
  color: #879499;
  font-size: 0.68rem;
  margin-top: 0.2rem;
  font-weight: 400;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.28rem 0.5rem;
  white-space: nowrap;
}
.status-badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.status-ok { background: #e9f5ee; color: #267e5d; }
.status-warn { background: #fff4df; color: #a47128; }
.status-info { background: #ecf3fb; color: #4b75a2; }

.phase-pill {
  font-size: 0.68rem;
  padding: 0.3rem 0.5rem;
  background: #edf3f1;
  border-radius: 4px;
  color: #528478;
  white-space: nowrap;
  font-weight: 600;
}

.link-action {
  border: 0;
  background: transparent;
  color: var(--teal);
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0;
  white-space: nowrap;
}
.link-action:hover { color: #007468; text-decoration: underline; }

.progress.thin { height: 5px; background: #e9efed; border-radius: 99px; }
.progress.thin .progress-bar { background: var(--teal); }
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #75838a;
}
.hint { font-size: 0.78rem; color: #718187; line-height: 1.6; margin: 0.7rem 0; }

.notice {
  background: #f5f9f7;
  border: 1px solid #dfece5;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  color: #57736b;
  font-size: 0.75rem;
  line-height: 1.6;
  margin-top: 1rem;
}
.notice-amber { background: #fffbf2; border-color: #f3e7cf; color: #8b713b; }
.card-body .notice { margin-top: 1rem; }
.card-body .notice:first-child { margin-top: 0; }

.review-step {
  display: flex;
  gap: 0.75rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid #edf1f1;
}
.review-step:last-of-type { border-bottom: 0; }
.review-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #edf4f2;
  color: var(--teal);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.review-step strong { font-size: 0.78rem; }
.review-step p { margin: 0.25rem 0 0; font-size: 0.75rem; color: #718187; }
.role-label { font-size: 0.85rem; font-weight: 700; margin-bottom: 0.35rem; }
.role-copy { color: #718187; font-size: 0.82rem; }

.activity {
  font-size: 0.78rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #eef2f2;
  line-height: 1.55;
}
.activity:last-child { border-bottom: 0; padding-bottom: 0; }
.activity small { display: block; color: #96a1a5; margin-top: 0.2rem; }
.risk-score { font-weight: 700; color: #a47128; }

.gate-tabs {
  border-bottom: 1px solid #dfe7e7;
  gap: 0.35rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  margin-bottom: 1.25rem;
}
.gate-tabs .nav-link {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: #74878c;
  background: transparent;
  font-size: 0.82rem;
  padding: 0.55rem 0.35rem 0.8rem;
  white-space: nowrap;
}
.gate-tabs .nav-link:hover { color: var(--teal); border-color: transparent; }
.gate-tabs .nav-link.active {
  color: var(--teal);
  font-weight: 700;
  background: transparent;
  border-bottom-color: var(--teal);
}

.form-control, .form-select {
  font-size: 0.82rem;
  border-color: #d9e3e3;
  border-radius: 6px;
  color: var(--ink);
}
.form-control:focus, .form-select:focus {
  border-color: #8dcec0;
  box-shadow: 0 0 0 0.2rem rgba(0, 136, 120, 0.15);
}

.budget-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 160px 160px;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.budget-row:last-child { border-bottom: 0; }
.budget-head {
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #839599;
  font-weight: 600;
}

.empty-state { padding: 2.2rem 1rem; text-align: center; color: var(--muted); }
.data-error { color: #a47128; font-weight: 600; }
.source-value { cursor: help; }
.cell-source { display: block; margin-top: 0.3rem; color: #93a09e; font-size: 0.66rem; }
.kv-label { display: block; font-size: 0.68rem; color: #7a8b89; margin-bottom: 0.3rem; }
.kv-value { display: block; font-size: 0.95rem; font-weight: 700; line-height: 1.45; color: var(--ink); }

.portfolio-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.2rem;
  background: var(--mint);
  border: 1px solid #d4e7dd;
  border-radius: 12px;
  padding: 1.45rem 1.6rem;
}
.snapshot {
  text-align: right;
  font-weight: 800;
  font-size: 2.6rem;
  line-height: 1;
  color: #157961;
}
.snapshot span {
  display: block;
  margin-top: 0.4rem;
  font-family: "DM Sans", "Segoe UI", sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  color: #618277;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  height: 190px;
  gap: 0.4rem;
}
.bar-column {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
}
.bar-column > span { font-size: 0.62rem; color: #56766b; white-space: nowrap; }
.bar-column > small { font-size: 0.58rem; margin-top: 0.4rem; color: #81978f; }
.bar-track {
  height: 140px;
  width: 100%;
  display: flex;
  align-items: flex-end;
  border-bottom: 1px solid #dce8e2;
  margin-top: 0.3rem;
}
.bar-track div {
  width: 100%;
  background: #5ba991;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}

.source-name { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.4rem; }

.modal-content { border: 0; border-radius: 14px; color: var(--ink); background: #fff; }
.modal-header, .modal-footer { background: #fff; }
.modal-header { align-items: flex-start; border-bottom: 1px solid var(--line); padding: 1.2rem 1.3rem; }
.modal-body { padding: 1.2rem 1.3rem 1.4rem; }
.modal-footer { border-top: 1px solid var(--line); }
.toast-container { z-index: 1090; }
#appToast { border-radius: 8px; font-size: 0.82rem; }

#mobileNav.offcanvas {
  background: var(--navy);
  color: #d5e4ea;
  width: min(300px, 88vw);
}
#mobileNav .offcanvas-header { padding: 1.2rem 1.1rem 0.4rem; }
#mobileNav .brand-name { font-size: 1.35rem; }
#mobileNav .offcanvas-body { padding: 0.6rem 0.8rem 1.2rem; }

@media (max-width: 1199.98px) {
  .step small { display: none; }
}
@media (max-width: 991.98px) {
  .workspace { margin-left: 0; }
  main, .topbar, .app-footer { padding-left: 1rem; padding-right: 1rem; }
  .portfolio-hero { align-items: flex-start; }
  .snapshot { font-size: 2rem; }
}
@media (max-width: 575.98px) {
  .page-title { font-size: 1.4rem; }
  .stat-value { font-size: 1.15rem; }
  .budget-row { grid-template-columns: 1fr 1fr; gap: 0.55rem; padding: 0.85rem 0.8rem; }
  .budget-row strong, .budget-head span:first-child { grid-column: 1 / -1; }
  .portfolio-hero { flex-direction: column; }
  .snapshot { text-align: left; }
  .demo-pill { display: none; }
  .table > :not(caption) > * > * { padding: 0.7rem 0.75rem; }
}
