/* ====================================================================
   DFIA Welfare — Premium UI v2
   Airport / railway-status inspired. Smooth, animated, professional.
   ==================================================================== */

:root {
  /* Brand */
  --brand-1: #6366f1;
  --brand-2: #8b5cf6;
  --brand-3: #06b6d4;
  --brand-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --brand-grad-soft: linear-gradient(135deg, rgba(99,102,241,.08), rgba(139,92,246,.08));
  --hero-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #db2777 100%);
  --gradient: var(--hero-grad); /* backward-compat alias */
  --primary: #6366f1;            /* backward-compat alias */

  /* Surfaces (light glass theme) */
  --bg: #f5f7fb;
  --bg-tint: radial-gradient(1200px 600px at -10% -20%, rgba(99,102,241,.10), transparent 60%),
             radial-gradient(900px 600px at 110% 10%, rgba(6,182,212,.08), transparent 60%);
  --card: #ffffff;
  --card-2: #f8fafc;
  --glass: rgba(255, 255, 255, .72);
  --border: rgba(15, 23, 42, .08);
  --border-strong: rgba(15, 23, 42, .14);

  /* Text */
  --text: #0f172a;
  --text-2: #334155;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --text-inverse: #f8fafc;

  /* Status semantics */
  --warn: #f59e0b;     --warn-soft: #fef3c7;   --warn-ink: #92400e;
  --success: #10b981;  --success-soft: #d1fae5; --success-ink: #065f46;
  --info: #0ea5e9;     --info-soft: #e0f2fe;    --info-ink: #075985;
  --danger: #ef4444;   --danger-soft: #fee2e2;  --danger-ink: #991b1b;
  --rose: #f43f5e;
  --teal: #14b8a6;
  --indigo: #6366f1;
  --purple: #8b5cf6;

  /* Shapes */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-full: 999px;

  /* Shadows (soft, layered) */
  --shadow-1: 0 1px 2px rgba(15,23,42,.04), 0 1px 1px rgba(15,23,42,.03);
  --shadow-2: 0 4px 14px rgba(15,23,42,.06), 0 2px 4px rgba(15,23,42,.04);
  --shadow-3: 0 12px 28px rgba(15,23,42,.10), 0 4px 8px rgba(15,23,42,.04);
  --shadow-glow: 0 8px 30px rgba(99,102,241,.25);

  /* Motion */
  --ease: cubic-bezier(.22, 1, .36, 1);
  --bounce: cubic-bezier(.34, 1.56, .64, 1);
  --dur-1: 180ms;
  --dur-2: 280ms;
  --dur-3: 420ms;

  /* Nav */
  --topbar-h: 56px;
  --nav-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  font-feature-settings: 'cv11','ss01','ss03';
  color: var(--text);
  line-height: 1.55;
  background: var(--bg);
  background-image: var(--bg-tint);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
body {
  padding-bottom: calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

a { color: var(--brand-1); text-decoration: none; transition: color var(--dur-1) var(--ease); }
a:hover { color: var(--brand-2); }

/* ===== Layout container ===== */
.container {
  width: 100%; max-width: 980px; margin: 0 auto;
  padding: 14px 16px 0;
  padding-bottom: calc(var(--nav-h) + 32px + env(safe-area-inset-bottom));
}
.wrap { min-height: 100vh; padding-bottom: calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); }

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  height: var(--topbar-h);
  background: rgba(255,255,255,.78);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar .tb-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--brand-grad);
  display: grid; place-items: center; color: #fff; font-size: 18px;
  box-shadow: 0 4px 12px rgba(99,102,241,.35);
}
.topbar .tb-title { font-weight: 600; font-size: 16px; letter-spacing: -.01em; }
.topbar .tb-spacer { flex: 1; }
.topbar .tb-user { color: var(--text-muted); font-size: 13px; }
.topbar .tb-back, .topbar .tb-logout {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 7px 12px; border-radius: 999px; font-size: 13px;
  color: var(--text-2); background: rgba(15,23,42,.04);
  transition: all var(--dur-1) var(--ease);
}
.topbar .tb-back:hover, .topbar .tb-logout:hover {
  background: rgba(15,23,42,.08); color: var(--text); text-decoration: none;
}

/* ===== Welcome / hero card ===== */
.welcome-card {
  position: relative;
  background: var(--hero-grad);
  color: #fff;
  border-radius: var(--r-xl);
  padding: 20px 22px;
  margin: 8px 0 16px;
  box-shadow: var(--shadow-glow);
  overflow: hidden;
  animation: rise var(--dur-3) var(--ease) both;
}
.welcome-card::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(380px 200px at 110% -10%, rgba(255,255,255,.30), transparent 60%),
              radial-gradient(280px 180px at -10% 120%, rgba(255,255,255,.15), transparent 60%);
  pointer-events: none;
}
.welcome-card h2 {
  margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em;
  display: flex; align-items: center; gap: 10px;
}
.welcome-card p { margin: 6px 0 0; opacity: .92; font-size: 14px; }

/* ===== Stats grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}
.stat-card {
  position: relative; background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
  animation: rise var(--dur-3) var(--ease) both;
  animation-delay: var(--d, 0ms);
}
.stat-card:nth-child(1) { --d: 60ms; }
.stat-card:nth-child(2) { --d: 120ms; }
.stat-card:nth-child(3) { --d: 180ms; }
.stat-card:nth-child(4) { --d: 240ms; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.stat-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; font-size: 20px;
  flex-shrink: 0;
}
.stat-num {
  font-size: 26px; font-weight: 700; letter-spacing: -.02em;
  line-height: 1; color: var(--text);
}
.stat-lbl { font-size: 12px; color: var(--text-muted); margin-top: 2px; font-weight: 500; }

/* ===== Tabs (sliding pill indicator) ===== */
.tabs {
  display: flex; gap: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 4px;
  margin: 0 0 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-1);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1; min-width: max-content;
  padding: 9px 18px;
  text-align: center;
  font-size: 13px; font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--r-full);
  transition: all var(--dur-2) var(--ease);
  white-space: nowrap;
}
.tab:hover { color: var(--text); text-decoration: none; background: rgba(15,23,42,.04); }
.tab.active {
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 6px 16px rgba(99,102,241,.32);
}

/* ===== Ticket card ===== */
.ticket-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  margin: 0 0 10px;
  color: inherit;
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
  animation: rise var(--dur-3) var(--ease) both;
}
.ticket-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  border-color: var(--border-strong);
  text-decoration: none;
}
.ticket-card.shared { border-left: 4px solid var(--teal); }
.tc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.ticket-no { font-size: 12px; font-weight: 700; color: var(--text-muted); letter-spacing: .04em; }
.tc-subj { font-size: 15px; font-weight: 600; color: var(--text); margin: 4px 0 6px; letter-spacing: -.01em; }
.tc-meta {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--text-muted);
  flex-wrap: wrap;
}
.shared-badge {
  background: #ccfbf1; color: #115e59;
  padding: 3px 9px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
}

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  text-transform: capitalize;
}
.b-submitted   { background: #dbeafe; color: #1e3a8a; }
.b-in_review   { background: #fef3c7; color: #92400e; }
.b-responded   { background: #ddd6fe; color: #5b21b6; }
.b-resolved    { background: var(--success-soft); color: var(--success-ink); }
.b-escalated_to_coordinator,
.b-escalated_to_section_head { background: #ffedd5; color: #9a3412; }
.b-escalated_to_principal    { background: #fecaca; color: #991b1b; }
.b-closed      { background: #e2e8f0; color: #475569; }
.b-rejected    { background: #fee2e2; color: #991b1b; }

/* live pulse for in-progress states */
.b-submitted::before, .b-in_review::before, .b-responded::before,
.b-escalated_to_coordinator::before, .b-escalated_to_section_head::before,
.b-escalated_to_principal::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  margin-right: 1px;
  animation: pulse-dot 1.6s var(--ease) infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: .4; transform: scale(.85); }
  50%      { opacity: 1;  transform: scale(1.15); }
}

.t-complaint  { background: #fee2e2; color: #991b1b; }
.t-feedback   { background: #dcfce7; color: #166534; }
.t-suggestion { background: #e0e7ff; color: #3730a3; }

.p-low    { background: #f1f5f9; color: #475569; }
.p-medium { background: #dbeafe; color: #1e3a8a; }
.p-high   { background: #fef3c7; color: #92400e; }
.p-urgent { background: #fee2e2; color: #991b1b; animation: pulse-urgent 2s infinite; }
@keyframes pulse-urgent {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.35); }
  50%     { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

/* ===== Detail card ===== */
.detail-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-2);
  animation: rise var(--dur-3) var(--ease) both;
}
.dc-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.dc-subj { font-size: 19px; font-weight: 700; margin: 6px 0; letter-spacing: -.02em; color: var(--text); }
.dc-desc { color: var(--text-2); margin: 4px 0 14px; white-space: pre-wrap; font-size: 14px; line-height: 1.6; }
.dc-meta-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr));
  gap: 12px;
  padding: 14px; background: var(--card-2);
  border: 1px solid var(--border); border-radius: var(--r);
  font-size: 13px;
}
.dc-meta-grid > div { display: flex; flex-direction: column; gap: 3px; }
.dc-meta-grid span { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.dc-meta-grid b { color: var(--text); font-weight: 600; font-size: 13px; }

.section-title {
  margin: 22px 0 10px; font-size: 13px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em;
}

/* ===== Chat bubbles ===== */
.chat-thread {
  background: var(--card); border-radius: var(--r-lg);
  padding: 14px; border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-1);
}
.bubble {
  max-width: 84%; padding: 10px 14px; border-radius: 16px;
  font-size: 14px; line-height: 1.5;
  animation: bubble-in var(--dur-3) var(--bounce) both;
}
.bubble.left  { align-self: flex-start; background: #f1f5f9; color: var(--text); border-top-left-radius: 4px; }
.bubble.right { align-self: flex-end; background: var(--brand-grad); color: #fff; border-top-right-radius: 4px; box-shadow: var(--shadow-glow); }
.bubble.right .b-meta { color: rgba(255,255,255,.85); }
.b-meta { font-size: 11px; opacity: .85; margin-bottom: 3px; font-weight: 500; }
.b-text { white-space: pre-wrap; }
.empty-mini { text-align: center; color: var(--text-muted); padding: 16px; font-size: 13px; }
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Timeline ===== */
.timeline {
  position: relative;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px 20px 8px;
  box-shadow: var(--shadow-1);
}
.timeline::before {
  content: ""; position: absolute;
  left: 36px; top: 28px; bottom: 28px;
  width: 2px; background: linear-gradient(to bottom, var(--brand-1), transparent);
  opacity: .35;
}
.tl-item { position: relative; display: flex; gap: 14px; padding: 12px 0 14px 0; animation: rise var(--dur-3) var(--ease) both; }
.tl-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-size: 16px; flex-shrink: 0;
  background: var(--card); border: 2px solid var(--brand-1); z-index: 1;
  box-shadow: 0 0 0 4px rgba(99,102,241,.10);
}
.tl-action { font-weight: 600; color: var(--text); font-size: 14px; }
.tl-note { color: var(--text-2); font-size: 13px; margin-top: 3px; line-height: 1.5; white-space: pre-wrap; }
.tl-time { color: var(--text-faint); font-size: 11px; margin-top: 4px; font-weight: 500; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: var(--r);
  font-size: 14px; font-weight: 600; letter-spacing: -.01em;
  border: 1px solid transparent;
  cursor: pointer; user-select: none;
  transition: all var(--dur-2) var(--ease);
  text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn-primary   { background: var(--brand-grad); color: #fff; box-shadow: var(--shadow-glow); }
.btn-primary:hover { box-shadow: 0 10px 26px rgba(99,102,241,.40); }
.btn-secondary { background: var(--brand-1); color: #fff; box-shadow: 0 4px 12px rgba(99,102,241,.25); }
.btn-success   { background: var(--success); color: #fff; box-shadow: 0 4px 12px rgba(16,185,129,.30); }
.btn-warning   { background: var(--warn); color: #fff; box-shadow: 0 4px 12px rgba(245,158,11,.30); }
.btn-danger    { background: var(--danger); color: #fff; box-shadow: 0 4px 12px rgba(239,68,68,.30); }
.btn-ghost     { background: rgba(15,23,42,.05); color: var(--text-2); }
.btn-ghost:hover { background: rgba(15,23,42,.10); }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 14px 22px; font-size: 15px; }

/* ===== Forms ===== */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.form-control, .form-select, input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  font-size: 14px; font-family: inherit; color: var(--text);
  background: var(--card);
  transition: all var(--dur-2) var(--ease);
}
.form-control:focus, .form-select:focus, input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand-1);
  box-shadow: 0 0 0 4px rgba(99,102,241,.12);
}
.form-help { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
textarea.form-control { min-height: 90px; resize: vertical; line-height: 1.55; }

/* ===== Alerts ===== */
.alert {
  padding: 12px 16px; border-radius: var(--r);
  margin-bottom: 14px; font-size: 14px; line-height: 1.5;
  border: 1px solid; display: flex; gap: 10px; align-items: flex-start;
  animation: rise var(--dur-3) var(--ease) both;
}
.alert-success { background: var(--success-soft); border-color: rgba(16,185,129,.3); color: var(--success-ink); }
.alert-warning { background: var(--warn-soft); border-color: rgba(245,158,11,.3); color: var(--warn-ink); }
.alert-danger  { background: var(--danger-soft); border-color: rgba(239,68,68,.3); color: var(--danger-ink); }
.alert-info    { background: var(--info-soft); border-color: rgba(14,165,233,.3); color: var(--info-ink); }

/* ===== Bottom nav ===== */
.bnav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)) 6px;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
  display: flex; gap: 2px;
  z-index: 30;
  box-shadow: 0 -8px 24px rgba(15,23,42,.06);
}
.bnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px;
  padding: 6px 4px;
  font-size: 10.5px; font-weight: 600; color: var(--text-muted);
  text-decoration: none; border-radius: var(--r);
  transition: all var(--dur-2) var(--ease);
  position: relative;
}
.bnav a .ic, .bnav a .icn { font-size: 20px; display: block; line-height: 1; }
.bnav a:hover { color: var(--text-2); background: rgba(15,23,42,.03); }
.bnav a.active { color: var(--brand-1); }
.bnav a.active::after {
  content: ""; position: absolute; top: 2px; left: 50%; transform: translateX(-50%);
  width: 24px; height: 3px; border-radius: 3px;
  background: var(--brand-grad);
  animation: nav-bar var(--dur-3) var(--ease);
}
@keyframes nav-bar {
  from { width: 0; opacity: 0; }
  to   { width: 24px; opacity: 1; }
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center; padding: 56px 16px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: var(--text-muted); box-shadow: var(--shadow-1);
  animation: rise var(--dur-3) var(--ease) both;
}
.empty-state h3 { color: var(--text-2); margin: 12px 0 4px; font-size: 17px; font-weight: 600; }
.empty-state p { color: var(--text-muted); font-size: 13px; margin: 4px 0; }

/* ===== Action panel ===== */
.action-panel {
  background: var(--card); border-radius: var(--r-xl);
  padding: 18px 20px; margin: 12px 0;
  box-shadow: var(--shadow-2); border: 1px solid var(--border);
  animation: rise var(--dur-3) var(--ease) both;
}
.action-panel h3 { margin: 0 0 14px; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.action-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.action-buttons .btn { flex: 1; min-width: 130px; }

/* ===== Auth pages ===== */
.auth-bg {
  min-height: 100vh; display: grid; place-items: center;
  padding: 24px; background: var(--hero-grad);
  background-attachment: fixed;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--card); border-radius: var(--r-xl);
  padding: 32px 28px;
  box-shadow: 0 30px 60px rgba(15,23,42,.30), 0 10px 20px rgba(15,23,42,.20);
  animation: rise-strong var(--dur-3) var(--bounce) both;
}
.auth-logo { text-align: center; margin-bottom: 22px; }
.auth-logo .icon {
  width: 64px; height: 64px; border-radius: 18px;
  margin: 0 auto 12px;
  display: grid; place-items: center;
  font-size: 30px; color: #fff;
  background: var(--brand-grad);
  box-shadow: 0 12px 30px rgba(99,102,241,.40);
}
.auth-logo h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.auth-logo p { color: var(--text-muted); margin: 0; font-size: 13px; }

/* ===== MPIN ===== */
.mpin-inputs { display: flex; gap: 10px; justify-content: center; margin: 18px 0; }
.mpin-inputs input {
  width: 56px; height: 64px; text-align: center;
  font-size: 26px; font-weight: 700; color: var(--text);
  border: 2px solid var(--border-strong); border-radius: var(--r);
  background: var(--card);
  transition: all var(--dur-2) var(--ease);
}
.mpin-inputs input:focus {
  border-color: var(--brand-1); transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99,102,241,.20), 0 0 0 4px rgba(99,102,241,.10);
}

/* ===== RAILWAY-STYLE PIPELINE (track.php) ===== */
.rail-hero {
  position: relative;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #312e81 100%);
  color: #fff;
  border-radius: var(--r-xl);
  padding: 22px 22px 26px;
  margin: 4px 0 14px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(15,23,42,.30);
}
.rail-hero::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(500px 200px at 80% -20%, rgba(99,102,241,.40), transparent 60%),
              radial-gradient(380px 200px at 0% 120%, rgba(236,72,153,.20), transparent 60%);
  pointer-events: none;
}
.rail-hero-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; position: relative; }
.rail-ticket { font-size: 11px; opacity: .8; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.rail-subject { font-size: 20px; font-weight: 700; letter-spacing: -.02em; margin: 0; }

.rail-live {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: var(--r-full);
  background: rgba(16,185,129,.20); border: 1px solid rgba(16,185,129,.45);
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
}
.rail-live::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: #10b981; box-shadow: 0 0 12px #10b981;
  animation: pulse-live 1.4s var(--ease) infinite;
}
@keyframes pulse-live {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .5; transform: scale(1.25); }
}

/* the rails */
.rail-pipeline {
  position: relative; padding: 26px 4px 8px;
  z-index: 1;
}
.rail-track {
  position: absolute; left: 14px; right: 14px; top: 50px; height: 4px;
  background: rgba(255,255,255,.10);
  border-radius: 4px;
  overflow: hidden;
}
.rail-track-progress {
  position: absolute; left: 0; top: 0; height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #06b6d4 100%);
  border-radius: 4px;
  width: var(--progress, 0%);
  transition: width 1.6s var(--ease);
  box-shadow: 0 0 16px rgba(6,182,212,.5);
}
.rail-stations {
  position: relative; display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.rail-station { text-align: center; position: relative; }
.rail-node {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.20);
  margin: 0 auto 8px;
  display: grid; place-items: center; font-size: 16px;
  position: relative;
  transition: all var(--dur-3) var(--ease);
}
.rail-station.done .rail-node {
  background: #10b981; border-color: #10b981;
  box-shadow: 0 0 0 4px rgba(16,185,129,.20);
}
.rail-station.current .rail-node {
  background: #06b6d4; border-color: #06b6d4;
  box-shadow: 0 0 0 4px rgba(6,182,212,.25), 0 0 24px rgba(6,182,212,.50);
  animation: pulse-station 1.8s var(--ease) infinite;
}
@keyframes pulse-station {
  0%,100% { box-shadow: 0 0 0 0 rgba(6,182,212,.45), 0 0 24px rgba(6,182,212,.50); }
  50%     { box-shadow: 0 0 0 12px rgba(6,182,212,0),  0 0 24px rgba(6,182,212,.30); }
}
.rail-label { font-size: 10.5px; font-weight: 600; opacity: .80; letter-spacing: .02em; line-height: 1.3; }
.rail-station.done .rail-label,
.rail-station.current .rail-label { opacity: 1; }
.rail-time { font-size: 10px; opacity: .55; margin-top: 2px; }

/* the moving train (decorative) */
.rail-train {
  position: absolute; top: 41px;
  left: var(--train, 0%);
  transform: translateX(-50%) translateY(-50%);
  width: 26px; height: 26px;
  background: #fff; color: #06b6d4;
  border-radius: 50%; display: grid; place-items: center;
  font-size: 14px;
  transition: left 1.8s var(--ease);
  box-shadow: 0 6px 16px rgba(0,0,0,.30);
  z-index: 2;
}

/* live elapsed timer */
.rail-elapsed {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-top: 18px;
}
.rail-elapsed-card {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.10);
  border-radius: var(--r); padding: 12px 14px;
}
.rail-elapsed-card .lbl { font-size: 10px; opacity: .7; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.rail-elapsed-card .val { font-size: 18px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ===== Animations ===== */
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes rise-strong {
  from { opacity: 0; transform: translateY(20px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* counter for stat numbers */
.count-up { display: inline-block; }

/* small utilities */
.muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-3 { margin-top: 14px; }
.mt-2 { margin-top: 10px; }

@media (max-width: 540px) {
  .container { padding-left: 12px; padding-right: 12px; }
  .welcome-card { padding: 18px 16px; }
  .welcome-card h2 { font-size: 19px; }
  .stat-num { font-size: 22px; }
  .stat-icon { width: 36px; height: 36px; font-size: 18px; }
  .rail-subject { font-size: 17px; }
  .rail-elapsed-card .val { font-size: 16px; }
  .rail-node { width: 30px; height: 30px; font-size: 13px; }
  .rail-train { width: 22px; height: 22px; font-size: 12px; top: 38px; }
  .rail-label { font-size: 9.5px; }
  .action-buttons .btn { min-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ====================================================================
   Backward-compat aliases for existing PHP class names
   (so dashboards/admin/auth pages keep working without PHP changes)
   ==================================================================== */

/* Generic card (used in old dashboards) */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  margin: 0 0 12px;
  box-shadow: var(--shadow-1);
  animation: rise var(--dur-3) var(--ease) both;
}
.card[style*="background:"], .card[style*="background "] {
  /* When the PHP inlines its own gradient, keep border off and ensure text contrast */
  border-color: transparent;
  box-shadow: var(--shadow-2);
}
.card-title {
  margin: 22px 0 10px; font-size: 13px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em;
}

/* Stat grid (old naming) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}
.stat-card .num   { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1; color: var(--text); }
.stat-card .label { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }
.stat-card .icon-bg {
  position: absolute; right: 14px; top: 14px;
  font-size: 22px; opacity: .85;
}
.stat-card.info    { border-left: 4px solid var(--info); }
.stat-card.warning { border-left: 4px solid var(--warn); }
.stat-card.success { border-left: 4px solid var(--success); }
.stat-card.danger  { border-left: 4px solid var(--danger); }
/* old stat-card was a vertical block, not a flex row */
.stat-card:not(.stats-grid > .stat-card) { display: block; position: relative; }
.stat-grid .stat-card { display: block; position: relative; padding: 16px 18px; }

/* Complaint cards (old naming used on student home) */
.complaint-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  margin: 0 0 10px;
  color: inherit;
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
  animation: rise var(--dur-3) var(--ease) both;
}
.complaint-card:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-2);
  text-decoration: none;
}
.complaint-card .header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.complaint-card .ticket { font-size: 11px; font-weight: 700; color: var(--text-muted); letter-spacing: .04em; }
.complaint-card .title  { font-size: 15px; font-weight: 600; color: var(--text); margin: 4px 0 6px; letter-spacing: -.01em; }
.complaint-card .meta   { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }
.meta-item { display: inline-flex; align-items: center; gap: 4px; }

/* Empty state (old naming) */
.empty {
  text-align: center; padding: 36px 16px;
  color: var(--text-muted);
}
.empty.card { background: var(--card); border: 1px solid var(--border); }
.empty .ico { font-size: 48px; margin-bottom: 8px; opacity: .8; }
.empty h3 { color: var(--text-2); margin: 8px 0 4px; font-size: 17px; font-weight: 600; }
.empty p { color: var(--text-muted); font-size: 13px; margin: 4px 0; }

/* Flexbox utility classes (used widely in old PHP) */
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 10px; }
.gap-3 { gap: 16px; }

/* Text helpers */
.text-soft { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-lg { font-size: 17px; }
.hide-mobile { display: none; }
@media (min-width: 600px) { .hide-mobile { display: initial; } }
.mt-1 { margin-top: 4px; }

/* Badge variants (old names) */
.type-badge, .type-pill { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: var(--r-full); font-size: 11px; font-weight: 700; }
.type-badge.complaint, .type-pill.complaint { background: #fee2e2; color: #991b1b; }
.type-badge.feedback,  .type-pill.feedback  { background: #dcfce7; color: #166534; }
.type-badge.suggestion,.type-pill.suggestion{ background: #e0e7ff; color: #3730a3; }
.prio-badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: var(--r-full); font-size: 11px; font-weight: 700; }
.prio-badge.low    { background: #f1f5f9; color: #475569; }
.prio-badge.medium { background: #dbeafe; color: #1e3a8a; }
.prio-badge.high   { background: #fef3c7; color: #92400e; }
.prio-badge.urgent { background: #fee2e2; color: #991b1b; animation: pulse-urgent 2s infinite; }
.target-pill { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: var(--r-full); font-size: 11px; background: #f1f5f9; color: var(--text-2); font-weight: 500; }

/* Old MPIN inputs */
.mpin-wrap { display: flex; gap: 10px; justify-content: center; margin: 18px 0; }
.mpin-input, .new-mpin {
  width: 56px; height: 64px; text-align: center;
  font-size: 26px; font-weight: 700; color: var(--text);
  border: 2px solid var(--border-strong); border-radius: var(--r);
  background: var(--card);
  transition: all var(--dur-2) var(--ease);
}
.mpin-input:focus, .new-mpin:focus {
  outline: none; border-color: var(--brand-1); transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99,102,241,.20), 0 0 0 4px rgba(99,102,241,.10);
}

/* Admin tiles */
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 12px; margin: 12px 0; }
.action-tile {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 18px 14px; text-align: center; color: inherit; text-decoration: none;
  box-shadow: var(--shadow-1); transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
  display: block;
}
.action-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); text-decoration: none; }
.action-tile .ico { font-size: 32px; margin-bottom: 6px; }
.action-tile .label { font-size: 13px; font-weight: 600; color: var(--text); margin-top: 4px; }
.action-tile .sub { font-size: 11px; color: var(--text-muted); }

/* Tables */
.tbl, .table-card { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-1); }
.tbl th, .tbl td, .table-card th, .table-card td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
.tbl th, .table-card th { background: var(--card-2); color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.tbl tr:hover td, .table-card tr:hover td { background: rgba(99,102,241,.02); }

/* "ring" accent (e.g. avatar outline) */
.ring { box-shadow: 0 0 0 3px rgba(99,102,241,.20); }

/* Status badge fallbacks if old code calls statusBadge with different markup */
.badge.success { background: var(--success-soft); color: var(--success-ink); }
.badge.warning { background: var(--warn-soft); color: var(--warn-ink); }
.badge.danger  { background: var(--danger-soft); color: var(--danger-ink); }
.badge.info    { background: var(--info-soft); color: var(--info-ink); }
