/* base.css — resets, typography, app shell layout */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  background: var(--surface-canvas);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: var(--fs-14);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body {
  min-height: 100vh;
  font-feature-settings: "tnum" 1, "cv11" 1;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img, svg { display: block; max-width: 100%; }
.num, .mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- App shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "topbar topbar"
    "rail   content";
  min-height: 100vh;
}
[data-rail="collapsed"] .app-shell { grid-template-columns: var(--rail-w-collapsed) 1fr; }

/* ---------- Top bar ---------- */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-4);
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-1);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar__brand {
  display: flex; align-items: center; gap: var(--s-2);
  font-weight: 600; font-size: var(--fs-14); letter-spacing: -.01em;
}
.topbar__brand-mark {
  width: 24px; height: 24px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent) 0%, #6E8BFF 100%);
}
.topbar__icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-2);
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; color: var(--text-2);
}
.topbar__icon-btn:hover { background: var(--surface-rail); color: var(--text-1); }

.topbar__scope {
  display: flex; align-items: center; gap: var(--s-2);
  height: 36px; padding: 0 var(--s-3);
  border: 1px solid var(--border-1); border-radius: var(--r-2);
  background: var(--surface-card); color: var(--text-1);
  font-size: var(--fs-13);
}
.topbar__scope:hover { background: var(--surface-rail); }
.topbar__scope .crumb { color: var(--text-3); }
.topbar__scope .crumb.is-leaf { color: var(--text-1); font-weight: 500; }
.topbar__scope .sep { color: var(--text-3); margin: 0 2px; }

.topbar__search {
  flex: 1; max-width: 560px;
  display: flex; align-items: center; gap: var(--s-2);
  height: 36px; padding: 0 var(--s-3);
  border: 1px solid var(--border-1); border-radius: var(--r-2);
  background: var(--surface-rail); color: var(--text-3);
  cursor: text;
}
.topbar__search:hover { background: var(--surface-sunk); }
.topbar__search .kbd {
  margin-left: auto;
  font-family: var(--font-mono); font-size: 11px;
  padding: 2px 6px; border: 1px solid var(--border-2); border-radius: 4px;
  color: var(--text-3); background: var(--surface-card);
}
.topbar__spacer { flex: 1; }
.topbar__right { display: flex; align-items: center; gap: var(--s-1); }

.avatar {
  width: 30px; height: 30px; border-radius: 999px;
  background: var(--accent-weak); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
}

/* ---------- Nav rail ---------- */
.rail {
  grid-area: rail;
  background: var(--surface-rail);
  border-right: 1px solid var(--border-1);
  overflow-y: auto;
  padding: var(--s-3) var(--s-2);
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
}
.rail__group { margin-bottom: var(--s-3); }
.rail__group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-3); padding: var(--s-2) var(--s-3) var(--s-1);
  font-weight: 600;
}
[data-rail="collapsed"] .rail__group-label { display: none; }
.rail__item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 8px 10px; border-radius: var(--r-2);
  color: var(--text-2); font-size: var(--fs-13); font-weight: 500;
  position: relative;
}
.rail__item:hover { background: var(--surface-card); color: var(--text-1); }
.rail__item.is-active {
  background: var(--accent-weak); color: var(--accent);
}
.rail__item.is-active::before {
  content: ""; position: absolute; left: -2px; top: 6px; bottom: 6px; width: 3px;
  background: var(--accent); border-radius: 3px;
}
.rail__item .icon { width: 18px; height: 18px; flex: none; }
.rail__item .label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-rail="collapsed"] .rail__item .label,
[data-rail="collapsed"] .rail__item .badge { display: none; }
[data-rail="collapsed"] .rail__item { justify-content: center; padding: 10px; }
.badge {
  font-size: 11px; padding: 1px 6px; border-radius: 999px;
  background: var(--neutral-weak); color: var(--text-2); font-weight: 600;
}
.badge.is-accent { background: var(--accent-weak); color: var(--accent); }
.badge.is-warn { background: var(--warn-weak); color: var(--warn); }
.badge.is-danger { background: var(--danger-weak); color: var(--danger); }

/* ---------- Content ---------- */
.content {
  grid-area: content;
  padding: var(--s-5) var(--s-6) var(--s-12);
  min-width: 0;
}
.crumbs {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-12); color: var(--text-3); margin-bottom: 6px;
}
.crumbs a:hover { color: var(--text-1); }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--s-5); gap: var(--s-4);
}
.page-header h1 {
  margin: 0; font-size: var(--fs-28); font-weight: 600; letter-spacing: -.02em;
}
.page-header .meta { color: var(--text-3); font-size: var(--fs-13); margin-top: 2px; }
.page-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ---------- Layout Utilities ---------- */
.hstack { display: flex; align-items: center; }
.vstack { display: flex; flex-direction: column; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 var(--s-3);
  border-radius: var(--r-2); border: 1px solid var(--border-1);
  background: var(--surface-card); color: var(--text-1);
  font-size: var(--fs-13); font-weight: 500; cursor: pointer;
  text-decoration: none; transition: all 0.15s;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn--primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn--primary:hover { background: #1a4ce0; }
.btn--ghost { background: transparent; border-color: var(--border-1); color: var(--text-1); }
.btn--ghost:hover { background: var(--surface-rail); border-color: var(--border-2); }
.btn--danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn--danger:hover { background: #c92a2a; }

/* ---------- Form Inputs ---------- */
.input, .select, .textarea {
  height: 32px; padding: 0 10px; border-radius: var(--r-2);
  border: 1px solid var(--border-1); background: var(--surface-card);
  font-size: var(--fs-13); color: var(--text-1);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(30, 94, 255, 0.1);
}
.textarea { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-1);
}
.card__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-4) var(--s-5) var(--s-3);
  border-bottom: 1px solid var(--border-1);
}
.card__title { font-weight: 600; font-size: var(--fs-14); letter-spacing: -.005em; }
.card__sub { font-size: var(--fs-12); color: var(--text-3); margin-top: 2px; }
.card__body { padding: var(--s-4) var(--s-5); }
.card__foot { padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border-1); color: var(--text-3); font-size: var(--fs-12); }
.card__actions { display: flex; gap: var(--s-1); align-items: center; }

/* ---------- Pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--neutral-weak); color: var(--text-2);
  text-transform: capitalize;
}
.pill--success { background: var(--success-weak); color: var(--success); }
.pill--warn    { background: var(--warn-weak);    color: var(--warn); }
.pill--danger  { background: var(--danger-weak);  color: var(--danger); }
.pill--info    { background: var(--info-weak);    color: var(--info); }
.pill__dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }

/* ---------- Form bits ---------- */
.input, .select {
  height: 34px; padding: 0 var(--s-3);
  border: 1px solid var(--border-1); border-radius: var(--r-2);
  background: var(--surface-card); color: var(--text-1); font: inherit;
}
.input:focus, .select:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }

/* ---------- Modal / dialog overlay ---------- */
.overlay {
  position: fixed; inset: 0; background: var(--surface-overlay);
  display: none; align-items: flex-start; justify-content: center;
  padding-top: 10vh; z-index: 60;
}
.overlay.is-open { display: flex; }
.dialog {
  background: var(--surface-card); border: 1px solid var(--border-1);
  border-radius: var(--r-4); box-shadow: var(--shadow-pop);
  width: min(680px, 92vw); max-height: 80vh; display: flex; flex-direction: column;
}
.dialog__head {
  padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border-1);
  display: flex; align-items: center; gap: var(--s-2);
}
.dialog__body { padding: 0; overflow: auto; }
.dialog__foot {
  padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border-1);
  display: flex; justify-content: flex-end; gap: var(--s-2);
  font-size: var(--fs-12); color: var(--text-3);
}

/* ---------- Utilities ---------- */
.hstack { display: flex; align-items: center; gap: var(--s-2); }
.vstack { display: flex; flex-direction: column; gap: var(--s-2); }
.muted { color: var(--text-3); }
.fz-12 { font-size: var(--fs-12); }
.fz-13 { font-size: var(--fs-13); }
.fz-20 { font-size: var(--fs-20); }
.fz-28 { font-size: var(--fs-28); }
.fw-600 { font-weight: 600; }
.fw-500 { font-weight: 500; }
.delta-up { color: var(--success); }
.delta-down { color: var(--danger); }
.delta-flat { color: var(--text-3); }
.divider { height: 1px; background: var(--border-1); margin: var(--s-3) 0; }
.scroll-y { overflow-y: auto; }
.icon { width: 16px; height: 16px; flex: none; }
.icon--lg { width: 20px; height: 20px; }
.icon--xl { width: 28px; height: 28px; }

/* responsive */
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: var(--rail-w-collapsed) 1fr; }
  .rail__group-label, .rail__item .label, .rail__item .badge { display: none; }
  .rail__item { justify-content: center; padding: 10px; }
}
@media (max-width: 720px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "topbar" "content";
  }
  .rail { display: none; }
  .topbar__search { display: none; }
  .content { padding: var(--s-4); }
}

/* Flash messages */
.flash-stack { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-4); }
.flash {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 10px 14px;
  border-radius: var(--r-2);
  font-size: var(--fs-13);
  font-weight: 500;
  border: 1px solid transparent;
}
.flash .icon { width: 16px; height: 16px; flex-shrink: 0; }
.flash--success { background: #d1fae5; color: #047857; border-color: #a7f3d0; }
.flash--error { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.flash--info { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.flash--warning { background: #fef3c7; color: #b45309; border-color: #fde68a; }

/* =====================================================================
   IAM Module Utilities — shared across all IAM templates
   ===================================================================== */

/* --- Page header row --- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-6);
  flex-wrap: wrap;
}
.page-title {
  font-size: var(--fs-22, 22px);
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text-1);
  margin: 0 0 4px;
  line-height: 1.2;
}
.page-subtitle {
  font-size: var(--fs-13);
  color: var(--text-2);
  margin: 0;
  line-height: 1.5;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-shrink: 0;
}

/* --- Form utilities --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--s-4);
}
.form-group:last-child { margin-bottom: 0; }

.label {
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: .005em;
}
.input-hint {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.4;
  margin-top: 2px;
}

/* --- Card sub-components (mirrors card__head/title using BEM-lite) --- */
.card-header {
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--border-1);
  margin: calc(-1 * var(--s-4)) calc(-1 * var(--s-5)) var(--s-4);
}
.card-title {
  font-size: var(--fs-14);
  font-weight: 700;
  color: var(--text-1);
  margin: 0;
  letter-spacing: -.01em;
}

/* --- Key-Value list (profile sidebars) --- */
.kv-list { display: flex; flex-direction: column; gap: 0; }
.kv-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  border-bottom: 1px solid var(--border-1);
  font-size: var(--fs-13);
}
.kv-row:last-child { border-bottom: none; }
.kv-key {
  color: var(--text-3);
  font-weight: 500;
  flex-shrink: 0;
  min-width: 110px;
}

/* --- Section label (above groups of cards) --- */
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* --- Empty state --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--s-10) var(--s-4);
}
.empty-state-icon { font-size: 48px; margin-bottom: var(--s-3); opacity: .7; }
.empty-state-title { font-size: var(--fs-16, 16px); font-weight: 700; margin-bottom: 6px; }
.empty-state-body { font-size: var(--fs-13); color: var(--text-2); max-width: 320px; line-height: 1.5; }

/* --- Extra pill variants --- */
.pill--error   { background: #fee2e2; color: #b91c1c; }
.pill--warning { background: #fef3c7; color: #b45309; }
.pill--info    { background: #dbeafe; color: #1d4ed8; }
.pill--primary { background: var(--accent)18; color: var(--accent); }

/* --- Data table --- */
.data-table { border-collapse: collapse; width: 100%; }
.data-table th {
  padding: var(--s-3) var(--s-4);
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .07em;
  background: var(--surface-canvas);
  border-bottom: 1px solid var(--border-1);
  white-space: nowrap;
}
.data-table td {
  padding: var(--s-3) var(--s-4);
  font-size: var(--fs-13);
  border-bottom: 1px solid var(--border-1);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-canvas); }

/* --- User avatar initials --- */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  letter-spacing: -.02em;
}
.avatar--lg { width: 52px; height: 52px; font-size: 18px; }

/* --- Breadcrumb --- */
.crumbs {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  font-size: var(--fs-12);
  color: var(--text-3);
  margin-bottom: var(--s-5);
}
.crumbs a { color: var(--text-2); }
.crumbs a:hover { color: var(--text-1); }
.crumbs > *:last-child { color: var(--text-1); font-weight: 500; }

/* --- Divider --- */
.divider { border: none; border-top: 1px solid var(--border-1); }

/* --- Warning / info alert banners (for SYS-01 etc) --- */
.alert-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-4);
  border-radius: var(--r-3);
  font-size: var(--fs-13);
  line-height: 1.5;
  border: 1px solid transparent;
}
.alert-banner--warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.alert-banner--info    { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.alert-banner--error   { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-banner--success { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }

/* --- Link utility --- */
.p-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.p-link:hover { opacity: .8; }


/* ==========================================================================
   ADMIT CARD MODULE — Component Styles
   ========================================================================== */

/* ── Status chips (ac-status-chip) ── */
.ac-status-chip {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}

.ac-status--pending            { background: #f3f4f6; color: #6b7280; }
.ac-status--eligible           { background: #d1fae5; color: #065f46; }
.ac-status--blocked_fees       { background: #fee2e2; color: #991b1b; }
.ac-status--blocked_attendance { background: #fef3c7; color: #92400e; }
.ac-status--manual_hold        { background: #ede9fe; color: #5b21b6; }
.ac-status--generated          { background: #dbeafe; color: #1e40af; }
.ac-status--downloaded         { background: #ede9fe; color: #6d28d9; }
.ac-status--scanned            { background: #d1fae5; color: #064e3b; border: 1px solid #10b981; }

/* ── Criteria chips (ac-chip) ── */
.ac-chip {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.ac-chip--fees      { background: #fee2e2; color: #991b1b; }
.ac-chip--att       { background: #fef3c7; color: #92400e; }
.ac-chip--muted     { background: #f3f4f6; color: #6b7280; }
.ac-chip--published { background: #d1fae5; color: #065f46; }
.ac-chip--draft     { background: #f3f4f6; color: #6b7280; border: 1px dashed #d1d5db; }
.ac-chip--override  { background: #ede9fe; color: #5b21b6; font-size: .68rem; }

/* ── Filter chips (clickable) ── */
.ac-filter-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .35rem .8rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 500;
  background: var(--surface, #fff);
  border: 1.5px solid var(--border, #e5e7eb);
  color: var(--text-muted, #6b7280);
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.ac-filter-chip:hover { background: #f3f4f6; border-color: #9ca3af; }
.ac-filter-chip--active {
  background: var(--brand, #1a56db);
  border-color: var(--brand, #1a56db);
  color: #fff !important;
}

/* ── Shared data table ── */
.data-table th {
  padding: .65rem 1rem;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted, #6b7280);
  background: var(--surface-2, #f9fafb);
  border-bottom: 1px solid var(--border, #e5e7eb);
  text-align: left;
  white-space: nowrap;
}
.data-table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
  font-size: .875rem;
  vertical-align: middle;
}
.data-table tr:hover td { background: rgba(59,130,246,.03); }
.data-table tr:last-child td { border-bottom: none; }

/* ── KPI grid ── */
.kpi-grid {
  display: grid;
  gap: 1rem;
}
.kpi-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: .75rem;
  padding: 1rem 1.25rem;
  border-top: 3px solid var(--border, #e5e7eb);
}
.kpi-label {
  font-size: .75rem;
  color: var(--text-muted, #6b7280);
  font-weight: 500;
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text, #111827);
  line-height: 1;
}

/* ── Badge ── */
.badge-muted {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  background: #f3f4f6;
  color: #6b7280;
}

/* ── Alert banners (Transport / compliance) ── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .75rem 1rem;
  border-radius: .5rem;
  font-size: var(--fs-13, .8125rem);
  line-height: 1.4;
}
.alert--warn  { background: #fefce8; color: #854d0e; border: 1px solid #fde68a; }
.alert--danger{ background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert--info  { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert--success{background:#f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ── Extra pill variants ── */
.pill--danger {
  background: #fef2f2;
  color: #dc2626;
}
.pill--warn {
  background: #fefce8;
  color: #ca8a04;
}

/* ── Font mono utility ── */
.font-mono { font-family: var(--font-mono, 'JetBrains Mono', monospace); }

/* ── Danger ghost button ── */
.btn--danger-ghost {
  background: transparent;
  border: 1px solid var(--border-1);
  color: var(--danger, #dc2626);
}
.btn--danger-ghost:hover {
  background: #fef2f2;
  border-color: #fecaca;
}

/* ── is-danger badge ── */
.badge.is-danger { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

/* ── Form hint text ── */
.hint {
  display: block;
  margin-top: .25rem;
  font-size: var(--fs-12, .75rem);
  color: var(--text-3, #9ca3af);
}
