/* styles.css — Yoma Impacts Dashboard
   Iframe-safe: no position:fixed, no 100vh assumptions, no third-party fonts at runtime.
   Fonts loaded in index.html head to avoid CSP issues. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Yoma brand palette (sourced from app.yoma.world design system) ── */
  --bg:           #F9F6FB;
  --bg-card:      #FFFFFF;
  --bg-muted:     #F4EDF7;
  --border:       #EAE0F0;
  --border-str:   #D8C8E8;

  /* Primary — Yoma deep purple */
  --purple:       #41204b;
  --purple-mid:   #6B3578;
  --purple-light: #E8D8F2;
  --purple-pale:  #F4EDF7;

  /* Coral — Yoma accent (logo arc + error) */
  --coral:        #fe4d57;
  --coral-light:  #FFEBEC;
  --orange:       #fe4d57;   /* alias for existing coral usages */

  /* Green — Yoma secondary */
  --green:        #387f6a;
  --green-light:  #DDF2EC;

  /* Info blue — Yoma info */
  --teal:         #4cade9;
  --teal-light:   #DFF1FC;

  /* Semantic */
  --amber:        #F9AB3E;
  --amber-light:  #FEF3C7;
  --red:          #fe4d57;
  --red-light:    #FFEBEC;

  /* Text */
  --text-pri:     #1A0B22;
  --text-sec:     #6B5877;
  --text-mut:     #9B8FAA;

  --shadow-sm:    0 2px 15px -3px rgba(65,32,75,0.08);
  --shadow-md:    0 4px 24px -4px rgba(65,32,75,0.12);
  --radius-md:    10px;
  --radius-lg:    14px;
}

html { font-size: 14px; }
body {
  background: var(--bg);
  color: var(--text-pri);
  font-family: 'Montserrat', system-ui, sans-serif;
  min-height: 100%;
  padding: 0;
}

/* ── Portal context banner ── */
.portal-banner {
  background: var(--purple-light);
  border-bottom: 1px solid #DDD6FE;
  padding: 6px 16px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--purple);
  font-weight: 600;
}
.portal-banner-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--purple);
  flex-shrink: 0;
}
.portal-banner-did { font-family: 'Montserrat', monospace; font-size: 10px; color: #6D28D9; }

/* ── Dashboard shell ── */
.dashboard { display: flex; flex-direction: column; min-height: 100%; }

.dash-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 18px 20px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.dash-wordmark { display: flex; align-items: center; gap: 10px; }
.dash-logo {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.dash-title  { font-size: 16px; font-weight: 800; color: var(--text-pri); letter-spacing: -0.3px; }
.dash-sub    { font-size: 11px; color: var(--text-sec); margin-top: 1px; }
.dash-meta   { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.context-chip {
  font-size: 10px; font-weight: 600;
  padding: 3px 10px; border-radius: 12px;
  background: var(--bg-muted); color: var(--text-sec);
  border: 1px solid var(--border);
}

/* ── Navigation ── */
.view-nav {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 12px 20px 0;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.vnav-btn {
  padding: 8px 16px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg-muted);
  color: var(--text-sec); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: 0.15s; font-family: inherit;
  margin-bottom: -1px;
}
.vnav-btn:hover { border-color: var(--purple); color: var(--purple); }
.vnav-btn.active { background: var(--purple); color: #fff; border-color: var(--purple); box-shadow: 0 2px 8px rgba(65,32,75,0.30); }

.sub-nav {
  display: flex; gap: 0;
  border-bottom: 2px solid var(--border);
  padding: 0 20px;
  background: var(--bg-card);
}
.stab {
  padding: 10px 18px; font-size: 12px; font-weight: 500;
  background: none; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; color: var(--text-sec); font-family: inherit;
  margin-bottom: -2px; transition: 0.15s;
}
.stab.active { color: var(--purple); border-bottom-color: var(--purple); font-weight: 700; }
.stab:hover  { color: var(--purple-mid); }

/* ── Main body ── */
.dash-body { padding: 16px 20px 32px; display: flex; flex-direction: column; gap: 0; }

/* ── Section heading ── */
.sec-head {
  display: flex; align-items: center; gap: 10px;
  margin: 22px 0 12px;
}
.sec-head span {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--purple); white-space: nowrap;
}
.sec-head::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── KPI grid ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 10px;
  margin-bottom: 4px;
}
.kpi {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--shadow-sm);
}
.kpi-label  { font-size: 10px; color: var(--text-sec); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-value  { font-size: 22px; font-weight: 800; font-family: 'Montserrat', monospace; letter-spacing: -0.5px; display: flex; align-items: baseline; gap: 5px; }
.kpi-target { font-size: 11px; color: var(--text-mut); font-weight: 400; }
.kpi-meta   { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-mut); }
.kpi-bar    { height: 4px; background: var(--bg-muted); border-radius: 2px; overflow: hidden; }
.kpi-fill   { height: 100%; border-radius: 2px; transition: width 0.8s cubic-bezier(0.4,0,0.2,1); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700; padding: 3px 9px;
  border-radius: 20px; white-space: nowrap;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-on-track  { color: #166534;  background: var(--green-light); border: 1px solid #BBF7D0; }
.badge-at-risk   { color: #92400E;  background: var(--amber-light); border: 1px solid #FDE68A; }
.badge-delayed   { color: #991B1B;  background: var(--red-light);   border: 1px solid #FECACA; }
.badge-complete  { color: #1E40AF;  background: #DBEAFE;            border: 1px solid #BFDBFE; }

/* ── Alert / callout ── */
.alert {
  display: flex; align-items: flex-start; gap: 12px;
  border-radius: var(--radius-lg); padding: 13px 16px; margin-bottom: 4px;
}
.alert.amber { background: var(--amber-light); border: 1px solid #FDE68A; font-size: 13px; color: #92400E; }
.alert-icon  { font-size: 15px; color: var(--amber); flex-shrink: 0; margin-top: 1px; }
.alert strong { color: var(--amber); }

.info-box {
  background: var(--purple-pale); border: 1px solid #DDD6FE;
  border-radius: var(--radius-lg); padding: 13px 16px; margin-bottom: 16px;
  font-size: 13px; color: #4C1D95; line-height: 1.6;
}
.info-box strong { color: var(--purple); }

.gap-callout {
  background: #FFF7ED; border: 1px solid #FED7AA;
  border-radius: var(--radius-lg); padding: 14px 16px; margin-top: 16px;
  font-size: 13px; color: #92400E; line-height: 1.6;
}
.gap-title { font-size: 13px; font-weight: 700; color: var(--orange); margin-bottom: 5px; }

/* ── Data tables ── */
.data-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.data-table th {
  padding: 9px 13px; text-align: left;
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--text-sec); text-transform: uppercase;
  background: var(--bg-muted); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td { padding: 10px 13px; color: var(--text-sec); border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--purple-pale); }
.data-table td.bold  { color: var(--text-pri); font-weight: 600; }
.data-table td.muted { color: var(--text-mut); font-size: 11px; }

/* ── Mini bar (trajectory) ── */
.mini-bar-wrap { display: flex; align-items: center; gap: 7px; }
.mini-bar      { width: 56px; height: 5px; background: var(--bg-muted); border-radius: 3px; overflow: hidden; flex-shrink: 0; }
.mini-fill     { height: 100%; border-radius: 3px; }

/* ── Funder views ── */
.funder-header {
  background: var(--funder-light, #F9FAFB);
  border: 1px solid var(--funder-border, #E5E7EB);
  border-left: 4px solid var(--funder-color, #7C3AED);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 4px;
}
.funder-header-top {
  display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap;
}
.funder-logo-chip {
  width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 900; color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.funder-title-block { flex: 1; min-width: 140px; }
.funder-name        { font-size: 15px; font-weight: 800; color: var(--text-pri); }
.funder-mandate     { font-size: 11px; color: var(--text-sec); margin-top: 3px; }
.funder-contrib-box {
  margin-left: auto; text-align: right; flex-shrink: 0;
  border: 1px solid; border-radius: var(--radius-md);
  padding: 9px 14px; min-width: 140px;
}
.funder-contrib-label  { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-sec); }
.funder-contrib-value  { font-size: 19px; font-weight: 800; font-family: 'Montserrat', monospace; letter-spacing: -0.5px; margin: 3px 0 2px; }
.funder-contrib-period { font-size: 10px; color: var(--text-sec); }
.funder-focus-tags     { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 13px; }
.focus-tag {
  font-size: 11px; font-weight: 600; padding: 3px 10px;
  border-radius: 12px; border: 1px solid; white-space: nowrap;
}

.funder-narrative {
  font-size: 13px; line-height: 1.7; color: var(--text-sec);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
  margin-bottom: 4px;
}

/* Allocation breakdown */
.alloc-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 18px;
  display: flex; flex-direction: column; gap: 13px;
  box-shadow: var(--shadow-sm);
}
.alloc-row   { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.alloc-label { font-size: 12px; color: var(--text-pri); font-weight: 500; min-width: 200px; flex: 1; }
.alloc-right { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.alloc-bar-wrap { flex: 1; height: 6px; background: var(--bg-muted); border-radius: 3px; overflow: hidden; min-width: 60px; }
.alloc-bar-fill { height: 100%; border-radius: 3px; transition: width 0.8s cubic-bezier(0.4,0,0.2,1); }
.alloc-pct    { font-size: 11px; font-weight: 700; white-space: nowrap; min-width: 30px; text-align: right; }
.alloc-amount { font-size: 11px; color: var(--text-sec); font-family: 'Montserrat', monospace; white-space: nowrap; }

/* Milestone tracker */
.ms-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 18px;
  display: flex; flex-direction: column; gap: 0;
  box-shadow: var(--shadow-sm);
}
.ms-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.ms-row:last-child { border-bottom: none; }
.ms-dot    { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.ms-label  { font-size: 12px; color: var(--text-pri); font-weight: 500; flex: 1; min-width: 160px; }
.ms-due    { font-size: 11px; color: var(--text-sec); font-family: 'Montserrat', monospace; white-space: nowrap; }

/* ── Platform analytics ── */
.growth-up { color: #16A34A; font-size: 11px; font-weight: 700; }

.analytics-period {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 14px; border-radius: var(--radius-md);
  background: var(--bg-muted); border: 1px solid var(--border);
  margin-bottom: 4px;
}
.analytics-period-label {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-sec);
}
.analytics-period-value {
  font-size: 12px; font-weight: 700; color: var(--text-pri);
  font-family: 'Montserrat', monospace;
}
.analytics-period-vs {
  font-size: 11px; color: var(--text-sec);
}

.geo-map-container {
  width: 100%; height: 300px;
  border-radius: var(--radius-lg);
  background: #0c1322;
  overflow: hidden;
  border: 1px solid #1e293b;
  box-shadow: var(--shadow-sm);
  margin-bottom: 4px;
}

/* ── Digital marketplace funnel ── */
.funnel-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 18px;
  display: flex; flex-direction: column; gap: 0;
  box-shadow: var(--shadow-sm);
}
.funnel-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.funnel-row:last-child { border-bottom: none; }
.funnel-step {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: #fff;
}
.funnel-label {
  font-size: 12px; color: var(--text-pri); font-weight: 500;
  min-width: 190px; flex-shrink: 0;
}
.funnel-bar-wrap {
  flex: 1; height: 8px; background: var(--bg-muted);
  border-radius: 4px; overflow: hidden; min-width: 40px;
  transition: max-width 0.3s ease;
}
.funnel-bar-fill {
  height: 100%; border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}
.funnel-nums {
  display: flex; align-items: baseline; gap: 5px;
  white-space: nowrap; min-width: 120px; justify-content: flex-end;
}
.funnel-value  { font-size: 13px; font-weight: 800; font-family: 'Montserrat', monospace; }
.funnel-target { font-size: 11px; color: var(--text-mut); }
.funnel-pct    { font-size: 11px; font-weight: 700; min-width: 30px; text-align: right; }

/* ── Geography badge ── */
.geo-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; white-space: nowrap;
  background: var(--teal-light); color: #0369a1;
  border: 1px solid #BAE6FD;
}
.geo-badge::before {
  content: '📍'; font-size: 9px;
}

/* ── Outcomes & certificates tracker ── */
.outcome-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  margin-bottom: 4px;
}
.outcome-card {
  background: var(--bg-card);
  border: 1px solid var(--oc-border, var(--border));
  border-top: 3px solid var(--oc-color, var(--purple));
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-sm);
}
.outcome-card-header {
  display: flex; align-items: flex-start; gap: 12px;
}
.outcome-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; border: 1px solid;
}
.outcome-card-title-block { flex: 1; }
.outcome-type { font-size: 14px; font-weight: 700; color: var(--text-pri); }
.outcome-sdgs { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px; }
.sdg-tag {
  font-size: 9px; font-weight: 700; padding: 2px 7px;
  border-radius: 10px; border: 1px solid; letter-spacing: 0.04em;
}
.outcome-card-count { text-align: right; flex-shrink: 0; }
.outcome-issued { font-size: 24px; font-weight: 800; font-family: 'Montserrat', monospace; letter-spacing: -0.5px; }
.outcome-unit { font-size: 9px; color: var(--text-sec); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }

.outcome-bar {
  height: 5px; background: var(--bg-muted);
  border-radius: 3px; overflow: hidden;
}
.outcome-bar-fill { height: 100%; border-radius: 3px; transition: width 0.8s cubic-bezier(0.4,0,0.2,1); }

.outcome-desc {
  font-size: 12px; line-height: 1.6; color: var(--text-sec);
  border-left: 2px solid var(--oc-border, var(--border));
  padding-left: 10px;
}
.outcome-breakdown {
  background: var(--oc-light, var(--bg-muted));
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 7px;
}
.outcome-breakdown-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.outcome-breakdown-label { font-size: 11px; color: var(--text-sec); }
.outcome-breakdown-value { font-size: 12px; font-weight: 700; font-family: 'Montserrat', monospace; white-space: nowrap; }

.outcome-card-footer {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: flex; flex-direction: column; gap: 5px;
}
.outcome-meta-row { display: flex; gap: 8px; align-items: baseline; }
.outcome-meta-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-mut); min-width: 52px; }
.outcome-meta-value { font-size: 11px; color: var(--text-sec); }

/* ── Responsive ── */
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-header { flex-direction: column; }
  .funder-contrib-box { margin-left: 0; width: 100%; text-align: left; }
  .alloc-right { min-width: 0; flex-wrap: wrap; }
}

/* ── Methodology library ── */
.meth-card {
  transition: box-shadow 0.15s;
}
.meth-card:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.meth-tag {
  display: inline-block;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 3px;
  margin: 2px 2px 2px 0;
  font-family: 'Montserrat', monospace;
  line-height: 1.4;
}
.meth-tag-reg {
  font-weight: 700;
  margin-right: 3px;
}
.meth-live-strip {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: center;
}
