/* Combined SME Ninja Stylesheet (with non-conflicting additions) */

:root {
  /* Base theme (SS1) */
  --sb-body-bg: #f5f7fb;
  --sb-sidebar-bg: #111827;
  --sb-primary: #3b82f6;
  --sb-primary-soft: rgba(59, 130, 246, 0.12);
  --sb-success: #10b981;
  --sb-danger: #ef4444;
  --sb-warning: #f59e0b;
  --sb-info: #0ea5e9;
  --sb-card-bg: #ffffff;
  --sb-card-border: rgba(15, 23, 42, 0.06);
  --sb-muted: #6b7280;
  --sb-heading: #111827;
  --sb-radius-lg: 0.9rem;
  --sb-radius-md: 0.6rem;
  --sb-shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.08);
  --sb-shadow-subtle: 0 4px 14px rgba(15, 23, 42, 0.06);

  /* Extra color from stylesheet 3 (Nova) */
  --nova-primary: #4c6fff;
  --nova-primary-dark: #3045b0;

  /* Common fallbacks from stylesheet 2 (extended) */
  --bs-body-bg: #f5f6fa;
  --bs-card-bg: #ffffff;
  --bs-primary: #0d6efd;
  --bs-primary-soft: rgba(13,110,253,0.08);
  --bs-border-color: #dee2e6;
  --bs-text-muted: #6c757d;
  --bs-success: #198754;
  --bs-warning: #ffc107;
  --bs-danger: #dc3545;
}

/* Box-sizing reset */
* {
  box-sizing: border-box;
}

/* Global body / layout */
body {
  margin: 0;
  background: radial-gradient(circle at top left, #f9fafb, #e5ebff);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
}

.container {
  max-width: 1320px;
}

/* Typography */
h3,
h5,
h6 {
  color: var(--sb-heading);
  letter-spacing: 0.01em;
}

/* Make generic text dark inside cards/tables */
.card-body,
.card-body p,
.card-body span,
.card-body .small,
.card-body .form-label,
.table,
.table td,
.table th {
  color: #111827;
}

/* Ensure small muted text is actually visible */
.small,
.small.text-muted,
.form-text {
  color: var(--sb-muted) !important;
  font-size: 0.76rem;
}

/* Keep white text only on colored headers/badges/buttons */
.card-header.bg-primary,
.card-header.bg-dark,
.card-header.bg-secondary,
.card-header.bg-success,
.card-header.bg-danger,
.card-header.bg-warning {
  color: #ffffff !important;
}

/* Override text-white inside card bodies */
.card-body .text-white {
  color: #eeeeee !important;
}

/* Labels */
.form-label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sb-muted);
  margin-bottom: 0.15rem;
}

.form-control,
.form-select {
  border-radius: 0.55rem;
  border-color: rgba(148, 163, 184, 0.5);
  font-size: 0.9rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--sb-primary);
  box-shadow: 0 0 0 1px var(--sb-primary-soft);
}

/* Top bar buttons (no-print) */
.no-print .btn {
  border-radius: 999px;
  font-size: 0.8rem;
  padding-inline: 0.9rem;
}

/* Generic cards */
.card {
  border-radius: var(--sb-radius-lg);
  border: 1px solid var(--sb-card-border);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08); /* stronger base shadow */
  overflow: hidden;
  background-color: var(--sb-card-bg);
  transition:
    box-shadow 0.25s ease,
    transform 0.25s ease,
    border-color 0.25s ease;
}

/* Highlight on hover / focus */
.card:hover,
.card:focus-within {
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.35);
}

/* Card header */
.card-header {
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
}

.card-header.bg-primary,
.card-header.bg-dark {
  background: linear-gradient(135deg, var(--sb-primary), #2563eb) !important;
}

.card-header.bg-secondary {
  background: linear-gradient(135deg, #4b5563, #1f2937) !important;
}

.card-header.bg-success {
  background: linear-gradient(135deg, var(--sb-success), #059669) !important;
}

.card-header.bg-danger {
  background: linear-gradient(135deg, var(--sb-danger), #b91c1c) !important;
}

.card-header.bg-warning {
  background: linear-gradient(135deg, var(--sb-warning), #d97706) !important;
}

.card-header.bg-light {
  background: #f9fafb !important;
  color: var(--sb-heading) !important;
}

/* Card Header Redefined */

    .card-redefined {
      background-color: var(--bs-card-bg);
      border-radius: 0.5rem;
      border: 1px solid var(--bs-border-color);
      box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
      margin-bottom: 1.25rem;
    }
    .card-redefined-header {
      padding: 0.75rem 1rem;
      border-bottom: 1px solid var(--bs-border-color);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.5rem;
    }
    .card-redefined-title {
      font-size: 0.95rem;
      font-weight: 600;
      margin: 0;
    }
    .card-redefined-subtitle {
      font-size: 0.8rem;
      color: var(--bs-text-muted);
      margin: 0.25rem 0 0;
    }
    .card-redefined-header-main {
      display: flex;
      flex-direction: column;
    }
    .card-redefined-header-actions {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      flex-wrap: wrap;
      justify-content: flex-end;
    }
    .card-redefined-body {
      padding: 0.95rem 1rem 1.1rem;
    }


/* Section spacing */
.card + .card {
  margin-top: 1rem;
}

/* Result metric cards */
.result-box {
  opacity: 0;
  transform: translateY(8px) scale(0.99);
  transition:
    opacity 0.3s ease,
    transform 0.3s ease,
    box-shadow 0.3s ease;
  border-radius: var(--sb-radius-md);
}

.result-box.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  box-shadow: 0 18px 40px rgba(37, 99, 235, 0.16);
}

.result-highlight {
  animation: sb-pulse 0.9s ease;
}

@keyframes sb-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.45);
  }
  100% {
    box-shadow: 0 0 0 30px rgba(59, 130, 246, 0);
  }
}

/* Period cards */
.cashflow-row {
  border-radius: var(--sb-radius-md);
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
  background: #ffffff;
}

.cashflow-row .card-body {
  padding: 0.75rem 0.9rem 0.9rem;
}

.cashflow-row input {
  min-width: 90px;
  font-size: 0.8rem;
}

.card-period {
  border-left: 4px solid rgba(59, 130, 246, 0.7);
}

.cashflow-row .badge.bg-secondary {
  background: rgba(15, 23, 42, 0.9) !important;
  font-size: 0.7rem;
  padding-inline: 0.65rem;
  border-radius: 999px;
}

/* Make sure badge text stays readable */
.cashflow-row .badge {
  color: #ffffff !important;
}

.cashflow-row .btn.btn-outline-secondary {
  border-radius: 999px;
  padding-inline: 0.75rem;
  font-size: 0.75rem;
}

/* Scenario analysis card */
.card-header .small {
  color: var(--sb-muted);
}

.table-sm th,
.table-sm td {
  font-size: 0.8rem;
  vertical-align: middle;
}

.table thead th {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--sb-muted);
  border-bottom-width: 1px;
}

.table tbody td {
  border-color: rgba(226, 232, 240, 0.9);
}

.table-bordered {
  border-radius: var(--sb-radius-md);
  overflow: hidden;
}

/* Charts card */
#cashflowChart,
#npvProfileChart {
  max-height: 260px;
}

/* Monte Carlo summary */
#monteCarloSummary {
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Dashboard header row */
.dashboard-header {
  margin-bottom: 1.75rem;
}

.dashboard-header h3 {
  font-weight: 600;
}

.dashboard-header .text-muted {
  font-size: 0.85rem;
}

/* Buttons general (base from #1) */
.btn-primary {
  background: linear-gradient(135deg, var(--sb-primary), #2563eb);
  border: none;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.4);
  color: #ffffff;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.45);
}

/* Keep outline buttons readable on white */
.btn-outline-primary,
.btn-outline-warning {
  border-radius: 999px;
  color: #111827;
}

/* --- Additions from stylesheet #2 that don't contradict #1 --- */

/* Button base (adds generic btn styling without changing .btn-primary colours) */
.btn {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  border-radius: 0.35rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

/* Use Bootstrap border on outline secondary, but keep #1 outline-primary */
.btn-outline-secondary {
  background-color: transparent;
  border-color: var(--bs-border-color);
  color: #495057;
}

.btn-outline-secondary:hover {
  background-color: #f1f3f5;
}

/* Badge (only soft variant from #2, mapped to sb tokens) */
.badge-soft {
  font-size: 0.7rem;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  background-color: var(--sb-primary-soft);
  color: var(--sb-primary);
}

/* Alerts from #2 (no conflicts in #1) */
.alert {
  border-radius: 0.35rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  margin-top: 0.85rem;
}

.alert-success {
  background-color: #d1e7dd;
  border: 1px solid #badbcc;
  color: #0f5132;
}

.alert-info {
  background-color: #cff4fc;
  border: 1px solid #b6effb;
  color: #055160;
}

/* Navbar + layout from #2, adjusted to not override #1’s card/body palette */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1.5rem;
  background-color: #ffffff;
  border-bottom: 1px solid var(--bs-border-color);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.navbar-brand {
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.navbar-brand-badge {
  width: 24px;
  height: 24px;
  border-radius: 0.35rem;
  background: linear-gradient(135deg, #0d6efd, #6610f2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.navbar-subtitle {
  font-size: 0.8rem;
  color: var(--bs-text-muted);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Layout shell */
.layout {
  display: flex;
  min-height: calc(100vh - 48px);
  flex-direction: row-reverse;
}

.sidebar {
  position: sticky;
  width: 180px;
  background-color: #ffffff;
  border-right: 1px solid var(--bs-border-color);
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-2 {
/*  margin-top: 60px; */
  position: sticky;
  width: 100%;
  display: flex;
}

.sidebar-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--bs-text-muted);
  font-weight: 600;
  padding: 0 0.75rem 0.5rem;
}

/* Sidebar nav pills */
.nav-pills {
  display: flex;
  flex-wrap: wrap;          /* optional: allow wrapping on smaller screens */
  gap: 0.35rem;             /* space between items */
  list-style: none;
  padding: 0;
  margin: 0;
}
.nav-pills li {
  margin: 0;                /* reset vertical spacing */
  margin-bottom: 0.25rem;
}

/* multiple sticky menus */
.menu-primary {
  position: sticky;
  top: 0;
  z-index: 20;
}

.menu-secondary {
  position: sticky;
  top: 48px;   /* height of .menu-primary */
  z-index: 10;
}

.nav-pills button {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.9rem;
  color: #495057;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background-color 0.15s, color 0.15s;
  gap: 0.35rem;
}

.nav-pills button span.label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-pills button span.badge {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background-color: #e9ecef;
  color: #495057;
}

.nav-pills button.active {
  background-color: var(--bs-primary-soft);
  color: var(--bs-primary);
  font-weight: 500;
}

/* Main content wrapper */
.content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 1.25rem;
}

.page-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.page-subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--bs-text-muted);
}

/* Card utilities from #2 (do not change core card box model of #1) */
.card-header-main {
  display: flex;
  flex-direction: column;
}

.card-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--bs-text-muted);
  margin: 0.25rem 0 0;
}

/* Form layout helpers from #2 (keep #1’s tokens) */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem 1rem;
}

.form-group {
  margin-bottom: 0.75rem;
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
}

/* Do not change #1’s form-control border-radius/colour, only extra options */
.form-control-inline {
  width: 100%;
  padding: 0.35rem 0.5rem;
}

.input-inline {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.input-inline span.unit {
  font-size: 0.75rem;
  color: var(--bs-text-muted);
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  background-color: #f8f9fa;
  border: 1px solid var(--bs-border-color);
}

/* Chip / small pill from #2 */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  font-size: 0.75rem;
  border-radius: 999px;
  background-color: #f1f3f5;
  color: #495057;
}

/* KPI grid + cards (new layout blocks only) */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.kpi-card {
  background-color: var(--bs-card-bg);
  border-radius: 0.5rem;
  border: 1px solid var(--bs-border-color);
  padding: 0.7rem 0.8rem;
}

.kpi-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bs-text-muted);
  margin-bottom: 0.15rem;
}

.kpi-main {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.kpi-value {
  font-size: 1.35rem;
  font-weight: 600;
}

.kpi-status {
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
  border: 1px solid transparent;
}

.kpi-status.ok {
  border-color: #c7eed8;
  background-color: #d1e7dd;
  color: #0f5132;
}

.kpi-status.warn {
  border-color: #ffeeba;
  background-color: #fff3cd;
  color: #664d03;
}

.kpi-status.bad {
  border-color: #f5c2c7;
  background-color: #f8d7da;
  color: #842029;
}

.kpi-subtext {
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: var(--bs-text-muted);
  display: flex;
  justify-content: space-between;
}

/* Ratio layout & detail components (entirely additive) */
.ratio-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 0.75rem;
}

@media (max-width: 900px) {
  .ratio-layout {
    grid-template-columns: 1fr;
  }
}

.ratio-list {
  max-height: 320px;
  overflow-y: auto;
  border-radius: 0.5rem;
  border: 1px solid var(--bs-border-color);
  background-color: #ffffff;
}

.ratio-item {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 0.35rem;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--bs-border-color);
  font-size: 0.8rem;
  cursor: pointer;
}

.ratio-item:last-child {
  border-bottom: none;
}

.ratio-item:hover {
  background-color: #f8f9fa;
}

.ratio-item.active {
  background-color: var(--bs-primary-soft);
}

.ratio-item-title {
  font-weight: 500;
}

.ratio-item-meta {
  color: var(--bs-text-muted);
  font-size: 0.75rem;
}

.ratio-item-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  align-items: flex-end;
}

.ratio-badge {
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  background-color: #f1f3f5;
  color: #212529;
}

.ratio-detail {
  background-color: #ffffff;
  border-radius: 0.5rem;
  border: 1px solid var(--bs-border-color);
  padding: 0.75rem 0.9rem;
  font-size: 0.8rem;
}

.ratio-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.ratio-detail-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.ratio-detail-chip {
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  background-color: #f1f3f5;
  color: #495057;
}

.ratio-bands {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.ratio-band {
  font-size: 0.7rem;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--bs-border-color);
}

.ratio-band.ok {
  border-color: #c7eed8;
  color: #0f5132;
  background-color: #d1e7dd;
}

.ratio-band.warn {
  border-color: #ffeeba;
  color: #664d03;
  background-color: #fff3cd;
}

.ratio-band.bad {
  border-color: #f5c2c7;
  color: #842029;
  background-color: #f8d7da;
}

.ratio-detail-body {
  margin-top: 0.3rem;
  color: var(--bs-text-muted);
}

.ratio-formula {
  margin-top: 0.4rem;
  padding: 0.35rem 0.45rem;
  background-color: #f8f9fa;
  border-radius: 0.35rem;
  border: 1px solid var(--bs-border-color);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.75rem;
}

.ratio-detail-footer {
  margin-top: 0.4rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.35rem;
  color: var(--bs-text-muted);
}

/* Responsive tweaks from #2 (only for layout/sidebar) */
@media (max-width: 768px) {
  .layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--bs-border-color);
    flex-direction: row;
    overflow-x: auto;
  }
  .sidebar-title {
    display: none;
  }
  .nav-pills {
    display: flex;
    gap: 0.25rem;
  }
  /* addition */
      .sub-navbar {
      position: sticky;
      top: 0;
      z-index: 100;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0.55rem 1.5rem;
      background-color: #ffffff;
      border-bottom: 1px solid var(--bs-border-color);
      box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    }
    .sub-navbar-brand {
      font-weight: 600;
      font-size: 1rem;
      display: flex;
      align-items: center;
      gap: 0.4rem;
    }
    .sub-navbar-brand-badge {
      width: 24px;
      height: 24px;
      border-radius: 0.35rem;
      background: linear-gradient(135deg, #0d6efd, #6610f2);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      color: #fff;
      font-size: 0.75rem;
      font-weight: 700;
    }
    .sub-navbar-subtitle {
      font-size: 0.8rem;
      color: var(--bs-text-muted);
    }

    .sub-navbar-actions {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      flex-wrap: wrap;
      justify-content: flex-end;
    }

    .badge-soft {
      font-size: 0.7rem;
      border-radius: 999px;
      padding: 0.1rem 0.45rem;
      background-color: var(--bs-primary-soft);
      color: var(--bs-primary);
    }

    .layout {
      display: flex;
      min-height: calc(100vh - 48px);
      flex-direction: row-reverse;
    }

    .right-sidebar {
      width: 180px;
      background-color: #ffffff;
      border-right: 1px solid var(--bs-border-color);
      padding: 1rem 0.75rem;
      display: flex;
      flex-direction: column;
      gap: 0.25rem;
    }

    .right-sidebar-title {
      font-size: 0.8rem;
      text-transform: uppercase;
      color: var(--bs-text-muted);
      font-weight: 600;
      padding: 0 0.75rem 0.5rem;
    }
}
