/* =============================================================================
   AJNIFM Incentive Management Portal -- Design System
   ----------------------------------------------------------------------------
   Visual identity: deep navy + restrained gold, continuing the language of
   the Institute's Merit-Based Incentive Policy briefing -- navy for
   institutional trust, gold reserved specifically for credit/rupee value
   (the gauge, cap callouts, key totals) so it always signals "this number is
   money," never used decoratively. Source Serif for headings (an official,
   typeset feel), Public Sans for body/data (the US government's own
   USWDS typeface -- a genuinely apt choice for a public financial
   institution's back-office system, and legible at small sizes in dense
   tables). Bootstrap 5 remains the grid/utility backbone; everything visual
   is re-themed through the tokens below.
============================================================================= */

:root {
  /* Ink & surfaces */
  --navy-deep:  #0B1526;
  --navy:       #16294D;
  --navy-mid:   #223764;
  --navy-line:  rgba(255,255,255,.10);
  --ink:        #16203A;
  --ink-soft:   #5B6478;
  --ink-faint:  #8891A3;
  --paper:      #F6F7FA;
  --panel:      #FFFFFF;
  --line:       #E3E7EF;
  --line-soft:  #EEF1F6;

  /* Gold -- reserved for credit/rupee value signalling */
  --gold:       #B8892B;
  --gold-deep:  #8C6A1F;
  --gold-soft:  #F3E8CB;
  --gold-line:  #E4CE9B;

  /* Semantic */
  --success:    #2F7A4D;
  --success-bg: #E4F3EA;
  --warning:    #9C6B10;
  --warning-bg: #FBF0D9;
  --danger:     #B23B3B;
  --danger-bg:  #FBEAEA;
  --info:       #2C5C8F;
  --info-bg:    #E7EFF7;

  /* Type */
  --font-display: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --font-body: "Public Sans", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;

  --radius-sm: .55rem;
  --radius-md: .9rem;
  --radius-lg: 1.15rem;
  --shadow-sm: 0 1px 2px rgba(11,21,38,.06);
  --shadow-md: 0 10px 26px -18px rgba(11,21,38,.45);
  --shadow-lg: 0 22px 48px -22px rgba(11,21,38,.42);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  overflow-x: hidden;
  font-size: .96rem;
  line-height: 1.5;
}

h1, h2, h3, h4, .font-display {
  font-family: var(--font-display);
  letter-spacing: -.01em;
  color: var(--ink);
}

.text-mono, .mono, code, .claim-ref { font-family: var(--font-mono); }

a { color: var(--info); }
a:hover { color: var(--navy); }

::selection { background: var(--gold-soft); color: var(--navy-deep); }

/* Focus visibility -- always keep a visible ring, never suppress outline */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, .nav-link:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* -----------------------------------------------------------------------
   Header
----------------------------------------------------------------------- */
.portal-header {
  min-height: 72px;
  background: linear-gradient(100deg, var(--navy-deep), var(--navy) 65%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1040;
  box-shadow: 0 12px 28px -22px rgba(11,21,38,.85);
}

.portal-logo { display: flex; align-items: center; gap: .75rem; color: #fff; text-decoration: none; }
.portal-logo:hover { color: #fff; }
.portal-logo-mark {
  width: 42px; height: 42px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: .8rem;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(184,137,43,.55);
  color: var(--gold);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
}
.portal-logo strong { display: block; font-family: var(--font-display); font-size: 1.12rem; line-height: 1.15; font-weight: 600; }
.portal-logo small { display: block; color: rgba(255,255,255,.68); font-size: .71rem; margin-top: .1rem; letter-spacing: .01em; }

.portal-header-user { display: flex; align-items: center; gap: .85rem; text-align: right; }
.portal-header-user small { display: block; color: rgba(255,255,255,.68); font-size: .74rem; }
.portal-header-user .fw-semibold { font-size: .92rem; }

.user-avatar {
  width: 40px; height: 40px; border-radius: .8rem;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .85rem; flex-shrink: 0;
  background: linear-gradient(150deg, var(--navy-mid), var(--navy));
}
.portal-header .user-avatar { background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.18); }

.header-icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: .8rem;
  display: inline-flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.85); background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12); text-decoration: none; font-size: 1.05rem;
}
.header-icon-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.header-icon-btn .badge-dot {
  position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--gold); border: 2px solid var(--navy-deep);
}

/* -----------------------------------------------------------------------
   Sidebar
----------------------------------------------------------------------- */
.dashboard-wrapper { display: flex; min-height: calc(100vh - 72px); }

.sidebar {
  width: 264px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #dbe1ee;
  flex-shrink: 0;
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,.04);
}

.sidebar-header { padding: 1.4rem 1.35rem 1.1rem; }
.sidebar-header .eyebrow {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .11em; font-weight: 600;
  color: var(--gold); margin-bottom: .3rem;
}
.sidebar-header .logo { display: block; color: #fff; text-decoration: none; font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; line-height: 1.3; }

.sidebar-nav { padding: .4rem .85rem 1.25rem; }
.sidebar .nav-item { margin-bottom: .15rem; list-style: none; }
.sidebar .nav-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .62rem .8rem; margin-left: 2px;
  color: #b7c0d6; text-decoration: none; border-radius: .65rem;
  font-size: .87rem; font-weight: 600; letter-spacing: .003em;
  border-left: 2px solid transparent;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.sidebar .nav-link i { width: 20px; text-align: center; font-size: 1.02rem; opacity: .85; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.055); color: #fff; }
.sidebar .nav-link.active {
  background: rgba(184,137,43,.14);
  color: #fff;
  border-left-color: var(--gold);
}
.sidebar .nav-link.active i { opacity: 1; color: var(--gold); }
.sidebar .logout-link { color: #e8b4b4; }
.sidebar .logout-link:hover { background: rgba(178,59,59,.16); color: #ffd7d7; }
.nav-divider { height: 1px; margin: .85rem 1rem; background: rgba(255,255,255,.08); }

/* -----------------------------------------------------------------------
   Main content / top bar
----------------------------------------------------------------------- */
.main-content { min-width: 0; flex: 1; display: flex; flex-direction: column; }

.top-bar {
  background: var(--panel);
  padding: 1.1rem 2rem;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  flex-wrap: wrap;
}
.page-title h1 { font-size: 1.5rem; font-weight: 600; margin: 0; }
.breadcrumb-text {
  display: flex; align-items: center; gap: .4rem;
  color: var(--ink-faint); font-size: .78rem; margin-top: .2rem;
  text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
}
.breadcrumb-text i { font-size: .7rem; }

.user-dropdown { display: flex; align-items: center; gap: .6rem; }

.content-area { flex: 1; padding: 1.85rem 2rem 2.5rem; max-width: 1520px; width: 100%; margin: 0 auto; }

/* -----------------------------------------------------------------------
   Cards / panels
----------------------------------------------------------------------- */
.metric, .stat-card, .panel, .panel-modern, .modern-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.metric { padding: 1.2rem 1.3rem; height: 100%; }
.metric .value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 600; line-height: 1; color: var(--ink); }
.metric .value.value-gold { color: var(--gold-deep); }
.metric-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--ink-faint); }

.panel { padding: 1.3rem; overflow: hidden; }
.panel-modern { overflow: hidden; }
.panel-header {
  padding: 1.05rem 1.35rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfbfd, #fff);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.panel-header h2, .panel h2, .modern-card h2 {
  font-size: 1rem; font-weight: 600; margin: 0; font-family: var(--font-display);
  display: flex; align-items: center; gap: .5rem;
}
.panel-body { padding: 1.35rem; }
.panel-accent-top { border-top: 3px solid var(--gold); }

/* -----------------------------------------------------------------------
   Tables
----------------------------------------------------------------------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; font-size: .89rem; }
.table thead th, .table-custom th {
  background: #fafbfd; color: var(--ink-soft);
  font-size: .71rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700;
  padding: .85rem .95rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td, .table-custom td { padding: .85rem .95rem; vertical-align: middle; border-bottom: 1px solid var(--line-soft); }
.table-hover tbody tr:hover td, .table-custom tbody tr:hover td { background: #fafbfd; }
.table .num, .table td.num { font-variant-numeric: tabular-nums; text-align: right; }
.table-responsive { border-radius: var(--radius-md); }

/* -----------------------------------------------------------------------
   Forms
----------------------------------------------------------------------- */
.form-label { font-weight: 700; color: var(--ink-soft); font-size: .84rem; margin-bottom: .3rem; }
.required::after { content: " *"; color: var(--danger); }
.form-control, .form-select {
  border-radius: .65rem; border: 1px solid var(--line); padding: .6rem .85rem;
  font-size: .92rem; color: var(--ink); background: #fff;
}
.form-control:focus, .form-select:focus {
  border-color: var(--gold); box-shadow: 0 0 0 .18rem rgba(184,137,43,.18);
}
.form-text { color: var(--ink-faint); font-size: .78rem; }
fieldset legend, .field-group-title {
  font-family: var(--font-display); font-size: 1.02rem; font-weight: 600; color: var(--navy);
  padding-bottom: .4rem; margin-bottom: .9rem; border-bottom: 1px solid var(--line);
}

/* -----------------------------------------------------------------------
   Buttons
----------------------------------------------------------------------- */
.btn { border-radius: .65rem; font-weight: 700; font-size: .87rem; padding: .55rem 1.05rem; }
.btn-sm { padding: .38rem .75rem; font-size: .81rem; }
.btn-primary, .btn-primary-modern {
  background: var(--navy); border: 1px solid var(--navy);
}
.btn-primary:hover, .btn-primary-modern:hover { background: var(--navy-deep); border-color: var(--navy-deep); }
.btn-gold { background: var(--gold); border: 1px solid var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-deep); border-color: var(--gold-deep); color: #fff; }
.btn-outline-primary { color: var(--navy); border-color: var(--navy); }
.btn-outline-primary:hover { background: var(--navy); border-color: var(--navy); }
.btn-outline-secondary { color: var(--ink-soft); border-color: var(--line); }
.btn-dark { background: var(--ink); border-color: var(--ink); }

/* -----------------------------------------------------------------------
   Badges / status pills
----------------------------------------------------------------------- */
.badge { border-radius: 999px; padding: .38rem .7rem; font-weight: 700; font-size: .72rem; letter-spacing: .01em; }
.badge.text-bg-primary { background: var(--info-bg) !important; color: var(--info) !important; }
.badge.text-bg-info { background: var(--info-bg) !important; color: var(--info) !important; }
.badge.text-bg-success { background: var(--success-bg) !important; color: var(--success) !important; }
.badge.text-bg-warning { background: var(--warning-bg) !important; color: var(--warning) !important; }
.badge.text-bg-danger { background: var(--danger-bg) !important; color: var(--danger) !important; }
.badge.text-bg-dark { background: var(--navy) !important; color: #fff !important; }
.badge.text-bg-secondary { background: var(--line-soft) !important; color: var(--ink-soft) !important; }
.badge.text-bg-gold { background: var(--gold-soft) !important; color: var(--gold-deep) !important; }

.pill-institution-determined {
  display: inline-flex; align-items: center; gap: .3rem;
  background: var(--gold-soft); color: var(--gold-deep);
  border: 1px solid var(--gold-line); border-radius: 999px;
  padding: .18rem .6rem; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}

/* -----------------------------------------------------------------------
   Alerts
----------------------------------------------------------------------- */
.alert { border-radius: var(--radius-md); border: 1px solid transparent; font-size: .88rem; }
.alert-danger { background: var(--danger-bg); color: #7a2727; border-color: #f0d2d2; }
.alert-success { background: var(--success-bg); color: #1e5535; border-color: #cfe8d8; }
.alert-warning { background: var(--warning-bg); color: #6b4a0a; border-color: #ecd9a8; }
.alert-info { background: var(--info-bg); color: #1c3e60; border-color: #cddcec; }

/* -----------------------------------------------------------------------
   Annual cap gauge -- the portal's signature element. Renders a radial
   progress ring (SVG) showing credits/rupees used against the policy's
   annual ceiling. See helpers.php: render_cap_gauge().
----------------------------------------------------------------------- */
.cap-gauge-wrap { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.cap-gauge svg { display: block; }
.cap-gauge-figure { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; fill: var(--ink); }
.cap-gauge-sub { font-size: .68rem; fill: var(--ink-faint); }
.cap-gauge-legend { display: flex; flex-direction: column; gap: .55rem; min-width: 200px; }
.cap-gauge-legend-row { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; font-size: .86rem; }
.cap-gauge-legend-row .label { color: var(--ink-soft); }
.cap-gauge-legend-row .amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.cap-gauge-legend-row .amount.gold { color: var(--gold-deep); }

/* -----------------------------------------------------------------------
   Workflow stepper -- a genuine sequence (submitted -> verified ->
   reconciled -> eligible -> paid), used on claim detail pages.
----------------------------------------------------------------------- */
.workflow-stepper { display: flex; align-items: flex-start; gap: 0; overflow-x: auto; padding: .5rem 0 .25rem; }
.wf-step { display: flex; flex-direction: column; align-items: center; flex: 1; min-width: 92px; position: relative; }
.wf-step:not(:last-child)::after {
  content: ""; position: absolute; top: 15px; left: 55%; width: 100%; height: 2px;
  background: var(--line);
}
.wf-step.is-done:not(:last-child)::after { background: var(--gold); }
.wf-dot {
  width: 32px; height: 32px; border-radius: 50%; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel); border: 2px solid var(--line); color: var(--ink-faint);
  font-size: .85rem; font-weight: 700;
}
.wf-step.is-done .wf-dot { background: var(--navy); border-color: var(--navy); color: #fff; }
.wf-step.is-current .wf-dot { background: var(--gold); border-color: var(--gold); color: #fff; }
.wf-step.is-rejected .wf-dot { background: var(--danger); border-color: var(--danger); color: #fff; }
.wf-label { margin-top: .5rem; font-size: .74rem; font-weight: 700; color: var(--ink-soft); text-align: center; }
.wf-step.is-done .wf-label, .wf-step.is-current .wf-label { color: var(--ink); }

/* -----------------------------------------------------------------------
   Footer
----------------------------------------------------------------------- */
.portal-footer {
  display: flex; justify-content: space-between; align-items: center; gap: 1.25rem;
  padding: 1.15rem 2rem;
  background: linear-gradient(100deg, var(--navy-deep), var(--navy) 65%);
  color: #cdd6e6; border-top: 1px solid rgba(255,255,255,.06);
  flex-wrap: wrap;
}
.footer-brand { display: flex; align-items: center; gap: .8rem; }
.footer-mark {
  width: 38px; height: 38px; border-radius: .75rem;
  background: rgba(255,255,255,.08); border: 1px solid rgba(184,137,43,.5);
  display: flex; align-items: center; justify-content: center; color: var(--gold);
  font-family: var(--font-display); font-weight: 600;
}
.footer-title { color: #fff; font-weight: 600; font-family: var(--font-display); line-height: 1.2; }
.footer-subtitle { font-size: .78rem; color: rgba(205,214,230,.8); }
.footer-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem .9rem; font-size: .82rem; }
.footer-meta span { display: inline-flex; align-items: center; gap: .3rem; }

/* -----------------------------------------------------------------------
   Login page
----------------------------------------------------------------------- */
.login-page { min-height: 100vh; background: var(--paper); color: var(--ink); }
.login-wrapper { display: flex; flex: 1; min-height: 100vh; }
.login-content { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 3rem 4rem; background: var(--panel); }
.login-form-panel {
  width: 44%; background: linear-gradient(160deg, var(--navy-deep) 0%, var(--navy) 100%);
  display: flex; align-items: center; justify-content: center; padding: 2rem; position: relative; overflow: hidden;
}
.login-form-panel::before {
  content: ''; position: absolute; top: -40%; right: -35%; width: 160%; height: 160%;
  background: radial-gradient(circle, rgba(184,137,43,.10) 0%, transparent 65%);
  pointer-events: none;
}
.institution-badge {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--gold-soft); color: var(--gold-deep);
  padding: .4rem 1rem; border-radius: 40px; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; width: fit-content;
}
.login-title { font-family: var(--font-display); font-size: 2.7rem; font-weight: 600; line-height: 1.18; color: var(--ink); margin: 1.4rem 0 1rem; letter-spacing: -.01em; }
.lead-text { color: var(--ink-soft); font-size: 1.05rem; line-height: 1.55; margin-bottom: 1.75rem; }
.feature-card { background: var(--paper); border-radius: 1.1rem; padding: 1.15rem; border: 1px solid var(--line); transition: all .2s ease; }
.feature-card:hover { transform: translateY(-3px); background: #fff; box-shadow: var(--shadow-md); border-color: var(--line); }
.feature-icon { width: 42px; height: 42px; background: var(--gold-soft); border-radius: .9rem; display: flex; align-items: center; justify-content: center; margin-bottom: .9rem; color: var(--gold-deep); font-size: 1.15rem; }
.feature-title { font-weight: 700; color: var(--ink); margin-bottom: .2rem; font-size: .92rem; }
.login-card { width: 100%; max-width: 410px; background: #fff; border-radius: 1.5rem; padding: 2.1rem 1.9rem; box-shadow: 0 30px 60px -20px rgba(0,0,0,.45); }
.login-footer { background: var(--panel); border-top: 1px solid var(--line); padding: 1rem 2rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: .75rem; font-size: .78rem; color: var(--ink-soft); }

/* -----------------------------------------------------------------------
   Misc utility
----------------------------------------------------------------------- */
.text-gold { color: var(--gold-deep) !important; }
.bg-paper { background: var(--paper) !important; }
.rounded-chip { border-radius: 999px; }
.divider-line { border: none; border-top: 1px solid var(--line); margin: 1.25rem 0; }
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--ink-faint); }
.empty-state i { font-size: 2.2rem; margin-bottom: .75rem; display: block; color: var(--line); }
.institution-note {
  background: var(--gold-soft); border: 1px solid var(--gold-line); border-radius: var(--radius-md);
  padding: .9rem 1.1rem; font-size: .85rem; color: #5a4110;
}

/* -----------------------------------------------------------------------
   Responsive
----------------------------------------------------------------------- */
@media (max-width: 992px) {
  .portal-header { position: relative; align-items: flex-start; flex-direction: column; gap: .7rem; }
  .portal-header-user { width: 100%; justify-content: space-between; }
  .dashboard-wrapper { display: block; }
  .sidebar { position: relative; width: 100%; height: auto; top: auto; }
  .sidebar-nav { display: flex; overflow-x: auto; gap: .3rem; padding: .75rem 1rem; }
  .sidebar .nav-item { flex: 0 0 auto; }
  .sidebar .nav-link { white-space: nowrap; border-left: none; border-bottom: 2px solid transparent; }
  .sidebar .nav-link.active { border-left: none; border-bottom-color: var(--gold); }
  .nav-divider { display: none; }
  .login-wrapper { flex-direction: column; }
  .login-form-panel { width: 100%; min-height: auto; padding: 2rem; }
  .login-content { padding: 2rem; }
  .login-title { font-size: 2.1rem; }
}

@media (max-width: 768px) {
  .top-bar, .portal-footer { align-items: flex-start; flex-direction: column; }
  .content-area { padding: 1rem; }
  .footer-meta { justify-content: flex-start; }
  .user-dropdown { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .cap-gauge-wrap { gap: 1rem; }
}
