/* ==========================================================================
   iCREDIT -- credit.irad.app
   Sits in the iRad family: same deep navy ground and purple-blue gradient as
   iRad Report and iRad Trainer. iCREDIT's own accent is emerald (quality and
   improvement); each module then carries a colour of its own so a screenshot
   is identifiable at a glance.
   ========================================================================== */

:root {
  --bg-deep:        #00111f;
  --bg-raise:       #0a1d30;
  --bg-panel:       rgba(255, 255, 255, 0.035);
  --bg-panel-hover: rgba(255, 255, 255, 0.06);
  --bg-navbar:      rgba(8, 21, 36, 0.94);
  --border-soft:    rgba(255, 255, 255, 0.09);
  --border-strong:  rgba(255, 255, 255, 0.16);

  --accent-1:       #667eea;   /* shared iRad purple-blue */
  --accent-2:       #764ba2;
  --accent-credit:  #10b981;   /* iCREDIT: quality / improvement */
  --accent-cyan:    #22d3ee;   /* iRad circuit cyan */

  --mod-training:   #22d3ee;
  --mod-audit:      #10b981;
  --mod-dose:       #f59e0b;

  --ok:             #22c55e;
  --warn:           #f59e0b;
  --risk:           #ef4444;

  --text:           rgba(255, 255, 255, 0.92);
  --text-muted:     rgba(255, 255, 255, 0.60);
  --text-faint:     rgba(255, 255, 255, 0.40);

  --radius:         12px;
  --radius-sm:      8px;
}

/* --- Base ---------------------------------------------------------------- */
body {
  background:
    radial-gradient(900px 480px at 82% -12%, rgba(16, 185, 129, 0.10), transparent 62%),
    radial-gradient(760px 420px at 6% 0%, rgba(102, 126, 234, 0.12), transparent 60%),
    var(--bg-deep);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
}

main { flex: 1 0 auto; }

a { color: var(--accent-cyan); text-decoration: none; }
a:hover { color: #7dd3fc; }

h1, h2, h3, h4, h5 { font-weight: 600; letter-spacing: -0.01em; }

.text-muted-soft { color: var(--text-muted) !important; }
.text-faint { color: var(--text-faint) !important; }

.page-title {
  font-size: 1.6rem;
  margin-bottom: 0.15rem;
}
.page-sub {
  color: var(--text-muted);
  font-size: 0.93rem;
  margin-bottom: 1.5rem;
}

/* --- Navbar -------------------------------------------------------------- */
.navbar-credit {
  background: var(--bg-navbar);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
  box-shadow: 0 2px 18px rgba(0, 0, 0, 0.35);
}
.navbar-credit .navbar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: #fff;
  font-weight: 650;
  font-size: 1.28rem;
  letter-spacing: -0.02em;
}
.navbar-credit .navbar-brand svg { width: 38px; height: 38px; flex: none; }
.navbar-credit .brand-stack { display: flex; flex-direction: column; line-height: 1.04; }
.navbar-credit .brand-sub {
  font-size: 0.625rem;
  color: var(--accent-credit);
  letter-spacing: 1.4px;
  text-transform: uppercase;
  font-weight: 600;
}
.navbar-credit .nav-link {
  color: var(--text-muted) !important;
  font-size: 0.94rem;
  padding: 0.5rem 0.85rem !important;
  border-radius: var(--radius-sm);
  transition: color .15s ease, background .15s ease;
}
.navbar-credit .nav-link:hover { color: #fff !important; background: var(--bg-panel-hover); }
.navbar-credit .nav-link.active { color: #fff !important; background: rgba(16, 185, 129, 0.16); }
.navbar-credit .dropdown-menu {
  background: #0d2036;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}
.navbar-credit .dropdown-item { color: var(--text); font-size: 0.93rem; }
.navbar-credit .dropdown-item:hover { background: rgba(102, 126, 234, 0.18); color: #fff; }
.navbar-credit .dropdown-divider { border-color: var(--border-soft); }
.navbar-credit .navbar-toggler { border-color: var(--border-strong); padding: 4px 8px; }
.navbar-credit .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255,255,255,0.85%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.avatar-chip {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.74rem; font-weight: 700; color: #fff; letter-spacing: 0.4px;
}

/* --- Panels / cards ------------------------------------------------------ */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
}
.panel-tight { padding: 0.9rem 1rem; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 0.9rem;
}
.panel-head h2, .panel-head h3 {
  font-size: 1.02rem; margin: 0; font-weight: 600;
}
.panel-head .bi { color: var(--accent-credit); }

/* --- Stat tiles ---------------------------------------------------------- */
.stat-row { display: grid; gap: 0.85rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 0.95rem 1.05rem;
}
.stat .stat-label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.9px;
  color: var(--text-faint); font-weight: 600;
}
.stat .stat-value {
  font-size: 1.85rem; font-weight: 680; line-height: 1.15; margin-top: 0.15rem;
  font-variant-numeric: tabular-nums;
}
.stat .stat-note { font-size: 0.78rem; color: var(--text-muted); }
.stat.accent-ok .stat-value { color: var(--ok); }
.stat.accent-warn .stat-value { color: var(--warn); }
.stat.accent-risk .stat-value { color: var(--risk); }
.stat.accent-cyan .stat-value { color: var(--accent-cyan); }

/* --- Module cards -------------------------------------------------------- */
.module-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.module-card {
  position: relative;
  display: block;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.35rem 1.35rem 1.2rem;
  color: var(--text);
  overflow: hidden;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.module-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  background: var(--bg-panel-hover);
  color: var(--text);
}
.module-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--mod, var(--accent-credit));
}
.module-card .mod-icon {
  width: 42px; height: 42px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.25rem; margin-bottom: 0.7rem;
  background: color-mix(in srgb, var(--mod, var(--accent-credit)) 16%, transparent);
  color: var(--mod, var(--accent-credit));
}
.module-card h3 { font-size: 1.06rem; margin-bottom: 0.3rem; }
.module-card p { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 0.65rem; }
.module-card.is-training { --mod: var(--mod-training); }
.module-card.is-audit    { --mod: var(--mod-audit); }
.module-card.is-dose     { --mod: var(--mod-dose); }

.chip {
  display: inline-flex; align-items: center; gap: 0.32rem;
  font-size: 0.7rem; font-weight: 650; letter-spacing: 0.5px;
  text-transform: uppercase; padding: 0.2rem 0.55rem; border-radius: 999px;
  border: 1px solid var(--border-soft); color: var(--text-muted);
}
.chip-live { color: var(--ok); border-color: rgba(34, 197, 94, 0.35); background: rgba(34, 197, 94, 0.10); }
.chip-soon { color: var(--text-faint); }

/* --- Buttons ------------------------------------------------------------- */
.btn-credit {
  background: linear-gradient(135deg, var(--accent-1) 0%, var(--accent-2) 100%);
  color: #fff; border: none; font-weight: 550;
  padding: 0.55rem 1.15rem; border-radius: var(--radius-sm);
  transition: transform .14s ease, box-shadow .14s ease;
}
.btn-credit:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 8px 22px rgba(102, 126, 234, 0.35); }
.btn-quality {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #fff; border: none; font-weight: 550;
  padding: 0.55rem 1.15rem; border-radius: var(--radius-sm);
}
.btn-quality:hover { color: #fff; box-shadow: 0 8px 22px rgba(16, 185, 129, 0.32); }
.btn-ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 0.52rem 1.05rem; font-weight: 500;
}
.btn-ghost:hover { background: var(--bg-panel-hover); color: #fff; border-color: rgba(255,255,255,0.3); }

/* --- Forms --------------------------------------------------------------- */
.form-control, .form-select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-soft);
  color: var(--text);
  border-radius: var(--radius-sm);
}
.form-control:focus, .form-select:focus {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-credit);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.16);
  color: var(--text);
}
.form-control::placeholder { color: var(--text-faint); }
.form-select option { background: #0d2036; color: var(--text); }
.form-label { font-size: 0.83rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.3rem; }
.form-text { color: var(--text-faint); font-size: 0.78rem; }
.form-check-input { background-color: rgba(255,255,255,0.08); border-color: var(--border-strong); }
.form-check-input:checked { background-color: var(--accent-credit); border-color: var(--accent-credit); }
.input-group-text { background: rgba(255,255,255,0.05); border-color: var(--border-soft); color: var(--text-muted); }

/* --- Tables -------------------------------------------------------------- */
.table-credit {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border-soft);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.045);
  --bs-table-hover-color: var(--text);
  margin-bottom: 0;
}
.table-credit thead th {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-faint); font-weight: 650;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.table-credit td { vertical-align: middle; font-size: 0.9rem; }
.table-credit td .sub { font-size: 0.78rem; color: var(--text-faint); }

/* --- Progress ------------------------------------------------------------ */
.bar {
  height: 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--accent-credit); }
.bar.is-complete > span { background: var(--ok); }
.bar.is-on-track > span { background: var(--accent-cyan); }
.bar.is-behind   > span { background: var(--warn); }
.bar.is-at-risk  > span { background: var(--risk); }

.ring {
  --p: 0;
  width: 86px; height: 86px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background:
    conic-gradient(var(--accent-credit) calc(var(--p) * 1%), rgba(255,255,255,0.09) 0);
  position: relative;
}
.ring::after {
  content: ""; position: absolute; inset: 8px; border-radius: 50%;
  background: var(--bg-deep);
}
.ring b { position: relative; z-index: 1; font-size: 1.15rem; font-variant-numeric: tabular-nums; }

/* --- Domain progress tiles ----------------------------------------------- */
.domain-grid { display: grid; gap: 0.8rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.domain-tile {
  background: var(--bg-panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 0.95rem 1.05rem;
}
.domain-tile .d-name { font-weight: 600; font-size: 0.96rem; }
.domain-tile .d-count { font-size: 0.78rem; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.domain-tile .gap-list { font-size: 0.78rem; color: var(--warn); margin-top: 0.45rem; }

/* --- Status badges ------------------------------------------------------- */
.badge-soft {
  font-size: 0.72rem; font-weight: 600; padding: 0.26rem 0.6rem;
  border-radius: 999px; border: 1px solid transparent;
}
.badge-ok   { background: rgba(34,197,94,0.14);  color: #4ade80; border-color: rgba(34,197,94,0.3); }
.badge-warn { background: rgba(245,158,11,0.14); color: #fbbf24; border-color: rgba(245,158,11,0.3); }
.badge-risk { background: rgba(239,68,68,0.14);  color: #f87171; border-color: rgba(239,68,68,0.3); }
.badge-info { background: rgba(34,211,238,0.12); color: #67e8f9; border-color: rgba(34,211,238,0.28); }
.badge-mute { background: rgba(255,255,255,0.06); color: var(--text-muted); border-color: var(--border-soft); }

/* --- Case library -------------------------------------------------------- */
.case-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); }
.case-card {
  background: var(--bg-panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 1rem 1.1rem; color: var(--text);
  display: flex; flex-direction: column; gap: 0.45rem;
  transition: transform .15s ease, border-color .15s ease;
}
.case-card:hover { transform: translateY(-2px); border-color: var(--border-strong); color: var(--text); }
.case-card .c-title { font-weight: 600; font-size: 0.98rem; line-height: 1.3; }
.case-card .c-meta { font-size: 0.78rem; color: var(--text-faint); }

/* --- Compare view (resident report vs consultant report) ----------------- */
.compare { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.compare .col-pane {
  background: var(--bg-panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 1rem 1.1rem;
}
.compare .col-pane.mine { border-left: 3px solid var(--accent-1); }
.compare .col-pane.final { border-left: 3px solid var(--accent-credit); }
.compare h4 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.9px; color: var(--text-faint); }
.report-text { white-space: pre-wrap; font-size: 0.9rem; line-height: 1.6; }

/* --- Alerts / messages --------------------------------------------------- */
.alert { border-radius: var(--radius); border: 1px solid var(--border-soft); font-size: 0.9rem; }
.alert-success { background: rgba(34,197,94,0.12); color: #86efac; border-color: rgba(34,197,94,0.3); }
.alert-danger  { background: rgba(239,68,68,0.12); color: #fca5a5; border-color: rgba(239,68,68,0.3); }
.alert-warning { background: rgba(245,158,11,0.12); color: #fcd34d; border-color: rgba(245,158,11,0.3); }
.alert-info    { background: rgba(34,211,238,0.10); color: #a5f3fc; border-color: rgba(34,211,238,0.28); }

/* --- Empty state --------------------------------------------------------- */
.empty {
  text-align: center; padding: 2.6rem 1rem; color: var(--text-muted);
  border: 1px dashed var(--border-soft); border-radius: var(--radius);
}
.empty .bi { font-size: 2rem; color: var(--text-faint); display: block; margin-bottom: 0.6rem; }

/* --- Governance note ----------------------------------------------------- */
.gov-note {
  font-size: 0.79rem; color: var(--text-faint);
  border-left: 2px solid rgba(16,185,129,0.4); padding-left: 0.7rem;
}

/* --- Footer -------------------------------------------------------------- */
.footer-credit {
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.35));
  border-top: 1px solid var(--border-soft);
  color: var(--text-faint); font-size: 0.82rem;
  padding: 1.4rem 0; margin-top: 3rem;
}
.footer-credit a { color: var(--text-muted); }
.footer-credit a:hover { color: #fff; }

/* --- Auth page ----------------------------------------------------------- */
.auth-wrap { min-height: calc(100vh - 120px); display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card {
  width: 100%; max-width: 420px;
  background: rgba(255,255,255,0.045);
  border: 1px solid var(--border-soft);
  border-radius: 16px; padding: 2rem 1.9rem;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
}
.auth-card .brand-lockup { display: flex; flex-direction: column; align-items: center; gap: 0.55rem; margin-bottom: 1.4rem; }
.auth-card .brand-lockup svg { width: 62px; height: 62px; }
.auth-card .brand-lockup .name { font-size: 1.5rem; font-weight: 680; letter-spacing: -0.02em; }
.auth-card .brand-lockup .tag { font-size: 0.74rem; color: var(--text-faint); text-align: center; line-height: 1.4; }

/* --- Print / PDF portfolio ----------------------------------------------- */
@media print {
  body { background: #fff !important; color: #111 !important; }
  .navbar-credit, .footer-credit, .no-print { display: none !important; }
  .panel, .stat, .domain-tile { border: 1px solid #ccc !important; background: #fff !important; }
  .table-credit { --bs-table-color: #111; --bs-table-border-color: #ccc; }
  .table-credit thead th { color: #444 !important; }
  a { color: #111 !important; }
}

/* --- Responsive ---------------------------------------------------------- */
@media (max-width: 575.98px) {
  .page-title { font-size: 1.3rem; }
  .stat .stat-value { font-size: 1.5rem; }
  .panel { padding: 1rem; }
}
