/* =========================================================================
   Foresight — Cancellation Prediction System
   Shared design system. Tailwind (CDN) handles layout/spacing utilities;
   this file adds brand tokens and components Tailwind doesn't ship.
   Brand color = Tailwind `indigo`. Risk semantics = red / amber / emerald.
   ========================================================================= */

:root {
  --brand: #4f46e5;        /* indigo-600 */
  --brand-dark: #4338ca;   /* indigo-700 */
  --brand-soft: #eef2ff;   /* indigo-50  */
  --ink: #0f172a;          /* slate-900  */
  --muted: #64748b;        /* slate-500  */
  --line: #e2e8f0;         /* slate-200  */
  --surface: #f8fafc;      /* slate-50   */
  --risk-high: #dc2626;    /* red-600    */
  --risk-med: #d97706;     /* amber-600  */
  --risk-low: #059669;     /* emerald-600*/
}

* { -webkit-font-smoothing: antialiased; }

body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--surface);
}

/* Tabular figures for data-dense tables and KPIs */
.tnum { font-variant-numeric: tabular-nums; }

/* ---- Scrollbars -------------------------------------------------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; border: 2px solid var(--surface); }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---- App shell --------------------------------------------------------- */
.sidebar-link {
  display: flex; align-items: center; gap: .625rem;
  padding: .55rem .75rem; border-radius: .625rem;
  color: #cbd5e1; font-size: .875rem; font-weight: 500;
  transition: background .15s, color .15s; position: relative;
}
.sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-link.active { background: rgba(99,102,241,.18); color: #fff; }
.sidebar-link.active::before {
  content: ''; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px; border-radius: 99px; background: #818cf8;
}
.sidebar-link svg { width: 18px; height: 18px; flex: none; }

/* ---- Cards ------------------------------------------------------------- */
.card {
  background: #fff; border: 1px solid var(--line);
  border-radius: 1rem; box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.card-pad { padding: 1.25rem 1.5rem; }

/* ---- Risk badges ------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .15rem .55rem; border-radius: 99px;
  font-size: .72rem; font-weight: 600; line-height: 1.4; white-space: nowrap;
}
.badge-high { background: #fee2e2; color: #b91c1c; }
.badge-med  { background: #fef3c7; color: #b45309; }
.badge-low  { background: #d1fae5; color: #047857; }
.badge-neutral { background: #f1f5f9; color: #475569; }
.badge-brand { background: var(--brand-soft); color: var(--brand-dark); }
.dot { width: 7px; height: 7px; border-radius: 99px; background: currentColor; }

/* Risk score text colors */
.risk-high { color: var(--risk-high); }
.risk-med  { color: var(--risk-med); }
.risk-low  { color: var(--risk-low); }

/* ---- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .55rem .9rem; border-radius: .625rem; font-size: .875rem; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
  border: 1px solid transparent; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface); }
.btn-danger { background: #fff; color: #b91c1c; border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: .35rem .65rem; font-size: .8rem; }

/* ---- Inputs ------------------------------------------------------------ */
.input, .select {
  width: 100%; padding: .55rem .75rem; border: 1px solid var(--line);
  border-radius: .625rem; font-size: .875rem; background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}
.label { font-size: .8rem; font-weight: 600; color: #334155; margin-bottom: .35rem; display: block; }

/* ---- Tables ------------------------------------------------------------ */
.tbl { width: 100%; border-collapse: collapse; font-size: .875rem; }
.tbl thead th {
  text-align: left; font-size: .72rem; font-weight: 600; letter-spacing: .03em;
  text-transform: uppercase; color: var(--muted); padding: .7rem 1rem;
  border-bottom: 1px solid var(--line); background: #fcfcfd; position: sticky; top: 0; z-index: 1;
}
.tbl tbody td { padding: .8rem 1rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: #fafaff; }
.row-clickable { cursor: pointer; }

/* ---- Feature-importance / contribution bars ---------------------------- */
.bar-track { background: #eef2f7; border-radius: 99px; height: 8px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--brand); transition: width .6s cubic-bezier(.2,.8,.2,1); }

/* ---- Circular risk gauge (SVG) ----------------------------------------- */
.gauge { transform: rotate(-90deg); }
.gauge .track { stroke: #eef2f7; }
.gauge .meter { stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.2,.8,.2,1); }

/* ---- Toast ------------------------------------------------------------- */
#toast-host { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 80; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  display: flex; align-items: center; gap: .6rem; background: var(--ink); color: #fff;
  padding: .7rem 1rem; border-radius: .7rem; font-size: .875rem; font-weight: 500;
  box-shadow: 0 10px 30px rgba(15,23,42,.25); animation: toast-in .25s ease both;
}
.toast svg { width: 18px; height: 18px; color: #6ee7b7; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- Modal ------------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; z-index: 70; padding: 1rem;
}
.modal-overlay.open { display: flex; animation: fade .2s ease both; }
.modal {
  background: #fff; border-radius: 1rem; width: 100%; max-width: 520px;
  box-shadow: 0 25px 50px rgba(15,23,42,.3); animation: pop .2s ease both; max-height: 90vh; overflow: auto;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Skeleton / loading state ------------------------------------------ */
.skeleton {
  background: linear-gradient(90deg, #eef2f7 25%, #e2e8f0 37%, #eef2f7 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: .5rem;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---- Misc -------------------------------------------------------------- */
.divider { height: 1px; background: var(--line); }
.kbd { font: 600 .7rem ui-monospace, monospace; background: #f1f5f9; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: .35rem; padding: .05rem .35rem; color: #475569; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; }
.fade-up { animation: fade-up .4s ease both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---- Mobile navigation ------------------------------------------------- */
@media (max-width: 1023px) {
  body.nav-open #sidebar { transform: translateX(0); }
  body.nav-open #scrim { display: block; }
}

/* ---- Tabs & segmented controls ---------------------------------------- */
.tab { padding: .5rem .9rem; border-radius: .6rem; font-size: .85rem; font-weight: 600; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.tab:hover { color: var(--ink); background: #f1f5f9; }
.tab-active { background: var(--brand-soft); color: var(--brand-dark); }
.seg { display: inline-flex; background: #f1f5f9; border-radius: .7rem; padding: 3px; gap: 2px; }
.seg button { padding: .35rem .75rem; border-radius: .55rem; font-size: .8rem; font-weight: 600; color: var(--muted); }
.seg button.on { background: #fff; color: var(--brand-dark); box-shadow: 0 1px 2px rgba(15,23,42,.1); }

/* ---- Confusion-matrix cells ------------------------------------------- */
.cm { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.cm-cell { border-radius: .75rem; padding: 1rem; text-align: center; }
