/* CRI India™ Component Library */
/* No @import of tokens.css here. Every page links it directly, and the
   bare URL in an @import is a second cache entry: it served a stale copy
   with the old gold long after the pinned link had the corrected one,
   and being imported it won the cascade. */

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

html { scroll-behavior:smooth; }

body {
  background: var(--n0);
  color: var(--tx);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Navigation ── */
.top-nav {
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bd2);
  padding: var(--sp-3) var(--sp-8);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.nav-brand {
  display: flex; align-items: center; gap: var(--sp-3);
  text-decoration: none; color: inherit;
}
.nav-logo {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  background: var(--blue-p); border: 1px solid var(--blue-b);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.nav-brand-text { font-family: var(--font-display); }
.nav-brand-name { font-size: .9rem; font-weight: 400; color: var(--tx); letter-spacing:-.01em; }
.nav-brand-sub  { font-size: .65rem; color: var(--tx-d); }
.nav-actions { display: flex; gap: var(--sp-2); align-items: center; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  border-radius: var(--r); font-size: var(--text-sm); font-weight: 700;
  padding: var(--sp-2) var(--sp-4); cursor: pointer; border: none;
  text-decoration: none; transition: all .15s; white-space: nowrap;
}
.btn-primary {
  background: var(--blue); color: #fff;
  box-shadow: var(--sh-blue);
}
.btn-primary:hover { opacity:.9; transform:translateY(-1px); }
.btn-gold {
  background: var(--gold); color: #0a1220;
  box-shadow: var(--sh-gold);
}
.btn-gold:hover { opacity:.9; transform:translateY(-1px); }
.btn-ghost {
  background: transparent; color: var(--tx-m);
  border: 1px solid var(--bd2);
}
.btn-ghost:hover { border-color: var(--blue); color: var(--blue-l); }
.btn-sm { padding: var(--sp-1) var(--sp-3); font-size: var(--text-xs); }
.btn-lg { padding: var(--sp-3) var(--sp-6); font-size: var(--text-base); }
.btn-icon { width:36px; height:36px; padding:0; justify-content:center; }
.btn:disabled { opacity:.4; cursor:not-allowed; pointer-events:none; }

/* ── Cards ── */
.card {
  background: var(--n1); border: 1px solid var(--bd2);
  border-radius: var(--r-lg); overflow: hidden;
}
.card-body { padding: var(--sp-5); }
.card-header { padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--bd); }
.card-footer { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--bd); }

/* ── Form Elements ── */
.form-group { margin-bottom: var(--sp-4); }
.form-label {
  display: block; font-size: var(--text-xs); font-weight: 800;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--tx-m); margin-bottom: var(--sp-2);
}
.form-req { color: var(--red); margin-left: 3px; }
.form-input, .form-select, .form-textarea {
  width: 100%; background: var(--n2); border: 1px solid var(--bd);
  border-radius: var(--r); padding: var(--sp-3) var(--sp-4);
  color: var(--tx); font-size: var(--text-sm); font-family: var(--font-body);
  transition: border-color .18s; appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(61,130,242,.12);
}
.form-input.filled, .form-select.filled { border-color: rgba(42,184,120,.35); }
.form-hint { font-size: var(--text-xs); color: var(--tx-d); margin-top: var(--sp-1); }
.form-error { font-size: var(--text-xs); color: var(--red); margin-top: var(--sp-1); }
.sel-wrap { position: relative; }
.sel-wrap::after {
  content:'▾'; position:absolute; right:14px; top:50%;
  transform:translateY(-50%); color:var(--tx-d); pointer-events:none;
}

/* ── Progress / Steps ── */
.step-bar {
  display: flex; align-items: center; gap: 0;
  padding: var(--sp-4) var(--sp-8);
  border-bottom: 1px solid var(--bd);
  background: var(--n1);
  overflow-x: auto;
}
.step-item { display: flex; align-items: center; flex-shrink: 0; }
.step-dot {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-xs); font-weight: 800; transition: all .2s;
}
.step-dot.done { background: var(--green); color: #fff; }
.step-dot.active { background: var(--n3); border: 2px solid var(--blue); color: var(--blue-l); }
.step-dot.idle { background: transparent; border: 1px solid var(--bd2); color: var(--tx-d); }
.step-label { font-size: var(--text-xs); color: var(--tx-d); margin-top: 4px; }
.step-block { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.step-line { width: 32px; height: 1px; background: var(--bd); margin: 0 var(--sp-2); flex-shrink:0; }
.step-line.done { background: var(--green); }

/* ── Progress Bar ── */
.progress-bar {
  height: 4px; background: var(--bd); border-radius: var(--r-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--blue); border-radius: var(--r-full);
  transition: width .3s ease;
}
.progress-fill.gold { background: var(--gold); }
.progress-fill.green { background: var(--green); }

/* ── Badges / Pills ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--text-xs); font-weight: 700; padding: 2px 8px;
  border-radius: var(--r-full); border: 1px solid;
}
.badge-blue  { background:var(--blue-p);   color:var(--blue-l);  border-color:rgba(61,130,242,.3); }
.badge-gold  { background:var(--gold-p);   color:var(--gold-l);  border-color:rgba(200,146,58,.3); }
.badge-green { background:var(--green-p);  color:var(--green);   border-color:rgba(42,184,120,.3); }
.badge-red   { background:var(--red-p);    color:var(--red);     border-color:rgba(229,90,90,.3); }
.badge-amber { background:var(--amber-p);  color:var(--amber);   border-color:rgba(245,166,35,.3); }

/* ── Score Ring ── */
.score-ring-wrap { position:relative; display:inline-block; }
.score-ring-label {
  position:absolute; inset:0; display:flex; flex-direction:column;
  align-items:center; justify-content:center; text-align:center;
}
.score-ring-n {
  font-family: var(--font-display); font-size: 1.8rem; font-weight:400;
  color: var(--tx); line-height:1;
}
.score-ring-sub { font-size: var(--text-xs); color: var(--tx-d); margin-top:3px; }

/* ── Stat tiles ── */
.stat-row { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.stat-tile {
  flex: 1; min-width: 100px;
  background: var(--n1); border: 1px solid var(--bd); border-radius: var(--r);
  padding: var(--sp-4); text-align: center;
}
.stat-n {
  font-family: var(--font-mono); font-size: 1.6rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat-l { font-size: var(--text-xs); color: var(--tx-d); text-transform: uppercase; letter-spacing:.08em; margin-top:3px; }

/* ── Eyebrow / section heading ── */
.eyebrow {
  font-size: var(--text-xs); font-weight: 800; text-transform: uppercase;
  letter-spacing: .14em; color: var(--blue); margin-bottom: var(--sp-3);
}
.eyebrow.gold { color: var(--gold-text); }
.eyebrow.green { color: var(--green); }
.section-title {
  font-family: var(--font-display); font-size: 1.7rem; font-weight: 400;
  color: var(--tx); margin-bottom: var(--sp-2); text-wrap: balance;
}
.section-sub { font-size: var(--text-sm); color: var(--tx-m); max-width: 600px; }

/* ── Dividers ── */
hr { border: none; border-top: 1px solid var(--bd); }
.div-accent { height: 2px; background: linear-gradient(90deg, var(--blue) 0%, transparent 100%); border:none; }
.div-accent.gold { background: linear-gradient(90deg, var(--gold) 0%, transparent 100%); }

/* ── Layout helpers ── */
.shell { max-width: 860px; margin: 0 auto; padding: var(--sp-8) var(--sp-8) var(--sp-16); }
.shell-sm { max-width: 620px; margin: 0 auto; padding: var(--sp-8) var(--sp-5) var(--sp-16); }
.shell-lg { max-width: 1100px; margin: 0 auto; padding: var(--sp-8) var(--sp-8) var(--sp-16); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--sp-3); }
.flex-between { display:flex; align-items:center; justify-content:space-between; gap:var(--sp-4); }
.flex-center { display:flex; align-items:center; justify-content:center; gap:var(--sp-3); }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  background: var(--n2); border: 1px solid var(--bd2); border-radius: var(--r);
  padding: var(--sp-3) var(--sp-4); font-size: var(--text-sm);
  display: flex; align-items: center; gap: var(--sp-2);
  box-shadow: var(--sh); opacity: 0; pointer-events: none;
  transform: translateY(8px); transition: all .22s;
}
.toast.show { opacity:1; pointer-events:auto; transform:translateY(0); }
.toast-ok { border-color: rgba(42,184,120,.4); }
.toast-err { border-color: rgba(229,90,90,.4); }

/* ── Empty state ── */
.empty { text-align:center; padding: var(--sp-16) var(--sp-8); color:var(--tx-d); }
.empty-icon { font-size:3rem; margin-bottom:var(--sp-4); }
.empty-title { font-size:1.1rem; font-weight:600; color:var(--tx-m); margin-bottom:var(--sp-2); }

/* ── Utilities ── */
.text-blue { color:var(--blue-l); }
.text-gold { color:var(--gold-l); }
.text-green { color:var(--green); }
.text-red { color:var(--red); }
.text-dim { color:var(--tx-d); }
.text-mid { color:var(--tx-m); }
.font-serif { font-family:var(--font-display); }
.font-mono { font-family:var(--font-mono); }
.fw-bold { font-weight:700; }
.text-center { text-align:center; }
.mt-4 { margin-top:var(--sp-4); }
.mt-5 { margin-top:var(--sp-5); }
.mt-6 { margin-top:var(--sp-6); }
.gap-2 { gap:var(--sp-2); }
.gap-3 { gap:var(--sp-3); }

/* ── Reveal animation (observe-based) ── */
.reveal { opacity:0; transform:translateY(18px); transition:opacity .42s ease, transform .42s ease; }
.reveal.revealed { opacity:1; transform:translateY(0); }

/* ── Button micro-interactions ── */
.btn { will-change: transform; }
.btn-primary:active { transform:translateY(1px) scale(.98); }
.btn-gold:active    { transform:translateY(1px) scale(.98); }

/* ── Card hover lift ── */
.card:hover {
  box-shadow: 0 8px 32px rgba(0,0,0,.38), 0 2px 8px rgba(0,0,0,.2);
  transform: translateY(-2px);
  transition: box-shadow .2s, transform .2s;
}

/* ── AI Panel ── */
.ai-insight-panel {
  background: linear-gradient(135deg, rgba(61,130,242,.06) 0%, rgba(139,92,246,.04) 100%);
  border: 1px solid rgba(61,130,242,.2);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  margin-top: var(--sp-5);
}
.ai-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-4); gap: var(--sp-2);
}
.ai-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(61,130,242,.12); border: 1px solid rgba(61,130,242,.25);
  border-radius: var(--r-full); padding: 3px 10px;
  font-size: var(--text-xs); font-weight: 800; color: var(--blue-l);
  letter-spacing: .05em;
}
.ai-narrative {
  font-size: var(--text-sm); color: var(--tx-m); line-height: 1.75;
  padding: var(--sp-3) var(--sp-4);
  background: rgba(255,255,255,.03); border-radius: var(--r);
  border-left: 2px solid var(--blue); margin-bottom: var(--sp-4);
}
.ai-insights-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.ai-insight-item {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  font-size: var(--text-sm); color: var(--tx-m); line-height: 1.55;
  padding: var(--sp-2) 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.ai-insight-item:last-child { border-bottom: none; }
.ai-insight-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; margin-top: 5px;
}

/* ── Priority ranking list ── */
.priority-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.priority-item {
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--n2); border: 1px solid var(--bd); border-radius: var(--r);
  padding: var(--sp-3) var(--sp-4); transition: border-color .15s;
}
.priority-item:hover { border-color: var(--blue-b); }
.priority-rank {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-xs); font-weight: 800;
  background: var(--blue-p); color: var(--blue-l); border: 1px solid var(--blue-b);
}
.priority-rank.high { background: var(--red-p); color: var(--red); border-color: rgba(229,90,90,.3); }
.priority-rank.med  { background: var(--amber-p); color: var(--amber); border-color: rgba(245,166,35,.3); }
.priority-body { flex: 1; min-width: 0; }
.priority-id   { font-size: var(--text-xs); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--tx-d); }
.priority-name { font-size: var(--text-sm); color: var(--tx); font-weight: 600; }
.priority-score { font-family: var(--font-mono); font-weight: 700; font-size: .9rem; flex-shrink: 0; }

/* ── Churn risk gauge ── */
.churn-gauge {
  text-align: center; padding: var(--sp-5);
  background: var(--n2); border-radius: var(--r-lg); border: 1px solid var(--bd);
}
.churn-pct {
  font-family: var(--font-display); font-size: 3rem; font-weight: 400; line-height: 1;
}
.churn-label { font-size: var(--text-xs); color: var(--tx-d); text-transform: uppercase; letter-spacing: .1em; margin-top: 4px; }
.churn-driver {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  font-size: var(--text-xs); color: var(--tx-m); padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--bd);
}
.churn-driver:last-child { border: none; }
.churn-driver-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--amber); flex-shrink: 0; margin-top: 4px; }

/* ── Score pulse animation ── */
@keyframes scorePulse {
  0%   { box-shadow: 0 0 0 0 rgba(61,130,242,.4); }
  70%  { box-shadow: 0 0 0 14px rgba(61,130,242,0); }
  100% { box-shadow: 0 0 0 0 rgba(61,130,242,0); }
}
.score-pulse { animation: scorePulse 1.8s ease-out 0.5s 1; }

/* ── Animated number ── */
@keyframes fadeUp {
  from { opacity:0; transform:translateY(12px); }
  to   { opacity:1; transform:translateY(0); }
}
.fade-up { animation: fadeUp .45s ease both; }

/* ── Progress bar animate ── */
.progress-fill { transition: width 1s cubic-bezier(.16,1,.3,1); }

/* ── Anomaly flag ── */
.anomaly-flag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--text-xs); font-weight: 700;
  padding: 2px 8px; border-radius: var(--r-full);
}
.anomaly-strength { background: rgba(42,184,120,.12); color: var(--green); border: 1px solid rgba(42,184,120,.3); }
.anomaly-weakness { background: var(--red-p); color: var(--red); border: 1px solid rgba(229,90,90,.3); }

/* ── Percentile badge ── */
.percentile-badge {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  background: rgba(200,146,58,.08); border: 1px solid rgba(200,146,58,.25);
  border-radius: var(--r); padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-xs); font-weight: 700; color: var(--gold-l);
}

@media (max-width:700px) {
  .top-nav { padding:var(--sp-3) var(--sp-4); }
  .shell, .shell-sm, .shell-lg { padding:var(--sp-5) var(--sp-4) var(--sp-12); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns:1fr; }
  .step-bar { padding:var(--sp-3) var(--sp-4); }
}
