/* ============================================================
   Capestone — Mandate Management System
   Theme: white + dark blue, with motion.
   ============================================================ */
:root {
  --navy-900: #061023;
  --navy-800: #0a1f44;
  --navy-700: #112a5c;
  --navy-600: #1b3a7a;
  --navy-500: #2b4fa2;
  --blue-400: #3b6fd4;
  --blue-300: #5b8def;
  --accent: #39c2d7;
  --accent-soft: #e6f7fb;
  --white: #ffffff;
  --paper: #f5f8ff;
  --ink: #0b1b3a;
  --muted: #5a6b8c;
  --line: #e2e8f5;
  --good: #1aa06d;
  --warn: #e0a106;
  --bad: #d64545;
  --shadow: 0 10px 40px rgba(10, 31, 68, 0.12);
  --shadow-sm: 0 4px 16px rgba(10, 31, 68, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --speed: 0.45s;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-400); text-decoration: none; }
a:hover { color: var(--navy-700); }

/* ---------- Animations ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
@keyframes floatGlow {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.55; }
  50%      { transform: translate(30px, -20px) scale(1.08); opacity: 0.8; }
}
@keyframes popIn {
  0% { opacity: 0; transform: scale(0.92); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

.reveal { opacity: 0; animation: fadeUp var(--speed) cubic-bezier(.2,.7,.2,1) forwards; }
.reveal.d1 { animation-delay: .06s; }
.reveal.d2 { animation-delay: .12s; }
.reveal.d3 { animation-delay: .18s; }
.reveal.d4 { animation-delay: .24s; }
.reveal.d5 { animation-delay: .30s; }
.reveal.d6 { animation-delay: .36s; }

/* Animated gradient text */
.gradient-text {
  background: linear-gradient(90deg, var(--navy-800), var(--blue-400), var(--accent), var(--navy-700));
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 6s linear infinite;
}

/* ---------- Layout: white sidebar on the left ---------- */
:root { --sidebar-w: 248px; }
body.has-sidebar { padding-left: var(--sidebar-w); }
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 60; width: var(--sidebar-w);
  display: flex; flex-direction: column; gap: 18px; padding: 22px 16px 18px;
  background: var(--white); border-right: 1px solid var(--line);
  box-shadow: 4px 0 24px rgba(10, 31, 68, 0.05); overflow-y: auto;
}
.sidebar .brand { display: block; padding: 0 6px 4px; }
.sidebar .brand-logo { display: block; width: 100%; max-width: 190px; height: auto; margin: 0 auto; }
.side-cta { justify-content: center; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px; color: var(--muted);
  font-size: .95rem; font-weight: 600; transition: background .2s, color .2s;
}
.side-nav a svg, .side-logout svg {
  width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.side-nav a:hover { background: var(--paper); color: var(--navy-700); }
.side-nav a.active { background: var(--accent-soft); color: var(--navy-800); }
.side-nav a.active::before {
  content: ""; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--navy-600);
}
.side-foot { margin-top: auto; display: grid; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-chip .avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--navy-700), var(--blue-400)); color: var(--white);
  display: grid; place-items: center; font-weight: 700; font-size: .9rem;
}
.uc-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.uc-name { font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uc-role { font-size: .78rem; color: var(--muted); }
.side-logout { justify-content: center; gap: 8px; }
.topbar, .sidebar-scrim { display: none; }

.page { max-width: 1200px; margin: 0 auto; padding: 32px 28px 80px; }

.page-head { margin-bottom: 26px; }
.page-head h1 { font-size: 2rem; font-weight: 800; letter-spacing: -.5px; }
.page-head p { color: var(--muted); margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; cursor: pointer; font: inherit; font-weight: 600;
  padding: 10px 18px; border-radius: var(--radius-sm);
  transition: transform .15s, box-shadow .2s, background .2s;
  font-size: .94rem;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(100deg, var(--navy-700), var(--blue-400));
  color: var(--white); box-shadow: 0 6px 18px rgba(27,58,122,.35);
}
.btn-primary:hover { box-shadow: 0 10px 26px rgba(27,58,122,.45); color: var(--white); }
.btn-accent { background: var(--accent); color: var(--navy-900); }
.btn-accent:hover { filter: brightness(1.05); }
.btn-ghost { background: rgba(255,255,255,.14); color: var(--white); }
.btn-ghost:hover { background: rgba(255,255,255,.24); color: var(--white); }
.btn-outline { background: var(--white); color: var(--navy-700); border: 1.5px solid var(--line); }
.btn-outline:hover { border-color: var(--blue-400); }
.btn-danger { background: #fdecec; color: var(--bad); }
.btn-danger:hover { background: #fbdada; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 20px; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }

.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 22px;
  border: 1px solid var(--line);
  transition: transform .25s cubic-bezier(.2,.7,.2,1), box-shadow .25s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.card h3 { font-size: 1.05rem; margin-bottom: 14px; color: var(--navy-800); }

.kpi-card {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--white), var(--paper));
}
.kpi-card::after {
  content: ""; position: absolute; right: -40px; top: -40px;
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(57,194,215,.22), transparent 70%);
}
.kpi-card .label {
  font-size: .82rem; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); font-weight: 600;
}
.kpi-card .value {
  font-size: 2.1rem; font-weight: 800; margin-top: 8px; color: var(--navy-800);
}
.kpi-card .sub { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.kpi-card .icon {
  position: absolute; top: 20px; right: 20px; font-size: 1.4rem;
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--navy-600);
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; background: var(--white); }
table.data th {
  text-align: left; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); padding: 14px 16px;
  border-bottom: 2px solid var(--line); background: var(--paper);
}
table.data td { padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: .92rem; }
table.data tbody tr { transition: background .15s; animation: fadeIn .4s ease; }
table.data tbody tr:hover { background: var(--accent-soft); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 30px; font-size: .78rem; font-weight: 600;
}
.badge.mandated  { background: #eef2fb; color: var(--navy-600); }
.badge.kickoff   { background: #e3f2ff; color: #1868c7; }
.badge.completed { background: #e6f7ef; color: var(--good); }
.badge.rework    { background: #fff4e0; color: var(--warn); }
.badge.modify    { background: #f0eafc; color: #7a4ad6; }
.badge.dropoff   { background: #fdecec; color: var(--bad); }
.badge.advance   { background: #e3f2ff; color: #1868c7; }
.badge.partial   { background: #fff4e0; color: var(--warn); }
.badge.final     { background: #e6f7ef; color: var(--good); }
.badge.received  { background: #e6f7ef; color: var(--good); }
.badge.pending   { background: #fff4e0; color: var(--warn); }
.badge.overdue   { background: #fdecec; color: var(--bad); }
.badge.critical  { background: #fde2e2; color: #b42318; }
.badge.high      { background: #fff4e0; color: #b25c00; }
.badge.medium    { background: #eef2fb; color: var(--navy-600); }
.badge.low       { background: #eef7ef; color: var(--good); }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .85rem; font-weight: 600; color: var(--navy-700); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); font: inherit; color: var(--ink);
  background: var(--white); transition: border .2s, box-shadow .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--blue-400);
  box-shadow: 0 0 0 4px rgba(59,111,212,.12);
}
.field .hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.field input[readonly], .field input:disabled {
  background: var(--paper); color: var(--muted); cursor: not-allowed;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* ---------- Auth pages: centered card on a glossy navy background ---------- */
.auth-wrap {
  position: relative; overflow: hidden; min-height: 100vh; box-sizing: border-box;
  display: grid; place-items: center; padding: 40px 20px;
  background:
    radial-gradient(120% 80% at 50% -10%, #2b4fa2 0%, rgba(43,79,162,0) 60%),
    radial-gradient(90% 70% at 100% 110%, #1b3a7a 0%, rgba(27,58,122,0) 60%),
    linear-gradient(160deg, #0a1f44 0%, #061023 100%);
}
/* Soft glossy highlights that drift slowly behind the card. */
.auth-gloss { position: absolute; inset: 0; pointer-events: none; }
.auth-gloss span { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; }
.auth-gloss .g1 { width: 520px; height: 520px; left: -140px; top: -160px; background: #3b6fd4; animation: glossDrift 16s ease-in-out infinite; }
.auth-gloss .g2 { width: 420px; height: 420px; right: -120px; bottom: -140px; background: #39c2d7; opacity: .35; animation: glossDrift 20s ease-in-out infinite reverse; }
.auth-gloss .g3 { width: 300px; height: 300px; right: 18%; top: 8%; background: #c9a13b; opacity: .22; animation: glossDrift 24s ease-in-out infinite; }
/* A diagonal sheen sweeping across the page. */
.auth-wrap::before {
  content: ""; position: absolute; inset: -50% -20%; pointer-events: none;
  background: linear-gradient(115deg, transparent 42%, rgba(255,255,255,.07) 50%, transparent 58%);
  animation: glossSweep 9s ease-in-out infinite;
}
@keyframes glossDrift { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(60px, 40px) scale(1.08); } }
@keyframes glossSweep { 0% { transform: translateX(-40%); } 60%, 100% { transform: translateX(40%); } }

.auth-main {
  position: relative; width: 100%; max-width: 440px; box-sizing: border-box; padding: 40px 40px 30px;
  display: flex; flex-direction: column; gap: 22px;
  background: var(--white); border: 1px solid rgba(255,255,255,.7); border-radius: 22px;
  box-shadow: 0 30px 80px rgba(3, 9, 24, .45), inset 0 1px 0 rgba(255,255,255,.9);
  animation: popIn .5s ease both;
}
.auth-brand { align-self: center; }
.auth-logo { display: block; width: 170px; height: auto; }
.auth-card { width: 100%; }
.auth-card h1 { font-size: 1.7rem; font-weight: 800; color: var(--navy-800); letter-spacing: -.3px; text-align: center; }
.auth-card .sub { color: var(--muted); margin: 6px 0 24px; text-align: center; }
.auth-card .field input { height: 48px; }
.auth-card .switch { margin-top: 18px; font-size: .92rem; color: var(--muted); text-align: center; }
.auth-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 20px; }
.auth-row a, .auth-back { font-weight: 600; font-size: .92rem; }
.auth-back { display: block; width: fit-content; margin: 18px auto 0; }
.btn-block { width: 100%; justify-content: center; padding-top: 14px; padding-bottom: 14px; font-size: 1rem; }
.auth-card .btn-primary { background: var(--navy-800); box-shadow: 0 8px 20px rgba(10, 31, 68, .18); }
.auth-card .btn-primary:hover { background: var(--navy-700); }
.auth-foot { font-size: .82rem; color: var(--muted); text-align: center; padding-top: 16px; border-top: 1px solid var(--line); }
.auth-foot:empty { display: none; }

@media (max-width: 640px) {
  .auth-wrap { padding: 24px 16px; }
  .auth-main { padding: 30px 22px 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-gloss span, .auth-wrap::before, .auth-main { animation: none; }
}

/* ---------- Toast ---------- */
#toast-host {
  position: fixed; top: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  min-width: 240px; max-width: 360px; padding: 14px 18px; border-radius: var(--radius-sm);
  color: var(--white); box-shadow: var(--shadow); animation: slideInRight .35s ease;
  font-size: .92rem; font-weight: 500;
}
.toast.ok  { background: linear-gradient(100deg, var(--good), #27b37c); }
.toast.err { background: linear-gradient(100deg, var(--bad), #e06b6b); }
.toast.info{ background: linear-gradient(100deg, var(--navy-700), var(--blue-400)); }

/* ---------- Side panel (rework / dropoff) ---------- */
.panel-overlay {
  position: fixed; inset: 0; background: rgba(6,16,35,.45);
  opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 150;
}
.panel-overlay.open { opacity: 1; pointer-events: auto; }
.side-panel {
  position: fixed; top: 0; right: 0; height: 100vh; width: 420px; max-width: 92vw;
  background: var(--white); box-shadow: -20px 0 50px rgba(6,16,35,.25);
  transform: translateX(100%); transition: transform .35s cubic-bezier(.2,.7,.2,1);
  z-index: 160; padding: 28px; overflow-y: auto;
}
.side-panel.open { transform: translateX(0); }
.side-panel .panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.side-panel .panel-head h3 { font-size: 1.3rem; }
.side-panel .close-x { cursor: pointer; font-size: 1.5rem; color: var(--muted); background: none; border: none; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(6,16,35,.5);
  display: none; place-items: center; z-index: 170; padding: 20px;
}
.modal-overlay.open { display: grid; animation: fadeIn .25s ease; }
.modal {
  background: var(--white); border-radius: var(--radius); padding: 28px;
  width: 100%; max-width: 460px; animation: popIn .3s ease; box-shadow: var(--shadow);
}
.modal h3 { margin-bottom: 14px; }

/* ---------- Misc ---------- */
.section-head { display: flex; justify-content: space-between; align-items: center; margin: 32px 0 16px; }
.section-head h2 { font-size: 1.4rem; font-weight: 700; }
.pill { font-size: .72rem; padding: 3px 10px; border-radius: 20px; background: var(--accent-soft); color: var(--navy-600); font-weight: 700; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 40px; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .spacer { flex: 1; }
/* ---------- Filter bar (mandates list) ---------- */
.filter-bar { padding: 16px 18px; margin-bottom: 18px; }
.filter-bar.card:hover { transform: none; box-shadow: var(--shadow-sm); }
.filter-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.filter-row .spacer { flex: 1; }
.filter-row.chips {
  gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line);
}

.search-box {
  display: flex; align-items: center; gap: 8px; flex: 1 1 260px; max-width: 360px;
  height: 42px; padding: 0 10px 0 12px; border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); background: var(--white); cursor: text;
  transition: border-color .2s, box-shadow .2s;
}
.search-box:focus-within { border-color: var(--blue-400); box-shadow: 0 0 0 4px rgba(59,111,212,.12); }
.search-box svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search-box input { flex: 1; min-width: 0; border: none; outline: none; font: inherit; color: var(--ink); background: transparent; }
.search-clear {
  display: none; border: none; background: var(--paper); color: var(--muted);
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-size: 1rem; line-height: 1;
}
.search-clear:hover { background: var(--line); color: var(--ink); }

.seg {
  display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-sm);
  background: var(--paper); border: 1px solid var(--line); overflow-x: auto; max-width: 100%;
}
.seg-btn {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  border: none; background: transparent; cursor: pointer; font: inherit;
  font-size: .85rem; font-weight: 600; color: var(--muted);
  padding: 7px 12px; border-radius: 8px; transition: background .2s, color .2s, box-shadow .2s;
}
.seg-btn:hover { color: var(--navy-700); }
.seg-btn.active { background: var(--white); color: var(--navy-800); box-shadow: 0 2px 8px rgba(10,31,68,.12); }

.chip {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font: inherit;
  font-size: .85rem; font-weight: 600; color: var(--ink); background: var(--white);
  padding: 7px 8px 7px 13px; border: 1.5px solid var(--line); border-radius: 999px;
  transition: border-color .2s, background .2s, color .2s, transform .15s;
}
.chip:hover { border-color: var(--blue-300); transform: translateY(-1px); }
.chip.active { background: var(--navy-700); border-color: var(--navy-700); color: var(--white); }
.chip .count {
  min-width: 22px; padding: 1px 7px; border-radius: 999px; text-align: center;
  background: var(--paper); color: var(--muted); font-size: .75rem;
}
.chip.active .count { background: rgba(255,255,255,.2); color: var(--white); }
.chip.active .sdot { box-shadow: 0 0 0 2px rgba(255,255,255,.6); }

.sdot, .pdot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sdot.mandated { background: var(--navy-600); }
.sdot.kickoff { background: #1868c7; }
.sdot.completed { background: var(--good); }
.sdot.rework { background: var(--warn); }
.sdot.modify { background: #7a4ad6; }
.sdot.dropoff { background: var(--bad); }
.pdot.critical { background: #b42318; }
.pdot.high { background: #e07a10; }
.pdot.medium { background: var(--blue-400); }
.pdot.low { background: var(--good); }

.result-count { font-size: .85rem; color: var(--muted); }

@media (max-width: 640px) {
  .search-box { max-width: none; flex-basis: 100%; }
  .seg { flex-basis: 100%; }
  .seg-btn { flex: 1 0 auto; justify-content: center; gap: 4px; padding: 7px 6px; font-size: .8rem; }
}

.skeleton {
  background: linear-gradient(90deg, #eef2fb 25%, #f7faff 50%, #eef2fb 75%);
  background-size: 400px 100%; animation: shimmer 1.4s infinite; border-radius: 8px;
}

/* Admin-only ribbon */
.admin-only-tag {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--white); background: var(--navy-700); padding: 3px 10px; border-radius: 6px;
}

/* Incentives (moved to bottom of dashboard) */
.incentives {
  margin-top: 40px; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(120deg, var(--navy-800), var(--navy-600));
  color: var(--white); padding: 28px; position: relative;
}
.incentives h2 { color: var(--white); }
.incentives .inc-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 16px; margin-top: 18px; }
.incentives .inc-item { background: rgba(255,255,255,.1); border-radius: var(--radius-sm); padding: 16px; }
.incentives .inc-item .v { font-size: 1.6rem; font-weight: 800; }
.incentives .inc-item .l { color: #c7d6f5; font-size: .85rem; }

/* ---------- Page loading screen + AJAX progress bar ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.page-loader {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center;
  /* Translucent so the page shows through, with a light blur for legibility. */
  background: radial-gradient(circle at 50% 40%, rgba(255,255,255,.72), rgba(245,248,255,.55) 70%);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: opacity .35s ease, visibility .35s ease;
  /* Fail-safe: never leave a page covered, even if JavaScript fails. */
  animation: plFailsafe 0s linear 8s forwards;
}
.page-loader.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.page-loader.is-active {
  opacity: 1; visibility: visible; animation: none;
  transition: opacity .2s ease, visibility 0s;   /* appear at once when leaving a page */
}
@keyframes plFailsafe { to { opacity: 0; visibility: hidden; pointer-events: none; } }

.pl-inner { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.pl-logo {
  width: 214px; height: auto; animation: plBreathe 2.4s ease-in-out infinite;
  /* A white card keeps the logo crisp over the translucent loader backdrop. */
  background: var(--white); padding: 14px 22px; border-radius: 18px;
  box-shadow: 0 12px 32px rgba(10,31,68,.14);
}
@keyframes plBreathe {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.04); opacity: .85; }
}
/* Five bars rising in turn — the logo's growth chart in motion. */
.pl-bars { display: flex; align-items: flex-end; gap: 6px; height: 34px; }
.pl-bars span {
  width: 8px; height: 100%; border-radius: 4px; transform-origin: bottom;
  background: linear-gradient(180deg, var(--accent), var(--navy-600));
  animation: plRise 1s ease-in-out infinite;
}
.pl-bars span:nth-child(1) { animation-delay: 0s; }
.pl-bars span:nth-child(2) { animation-delay: .12s; }
.pl-bars span:nth-child(3) { animation-delay: .24s; }
.pl-bars span:nth-child(4) { animation-delay: .36s; }
.pl-bars span:nth-child(5) { animation-delay: .48s; background: linear-gradient(180deg, #e0b04a, #c98f1f); }
@keyframes plRise {
  0%, 100% { transform: scaleY(.3); }
  50%      { transform: scaleY(1); }
}

/* Slim bar across the top while background (AJAX) requests are in flight. */
.ajax-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1001;
  overflow: hidden; pointer-events: none; opacity: 0; transition: opacity .3s ease;
}
.ajax-bar.active { opacity: 1; }
.ajax-bar::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 35%;
  background: linear-gradient(90deg, transparent, var(--accent), var(--blue-400));
  transform: translateX(-100%);
}
.ajax-bar.active::before { animation: ajaxSlide 1.1s ease-in-out infinite; }
@keyframes ajaxSlide {
  from { transform: translateX(-100%); }
  to   { transform: translateX(290%); }
}

@media (prefers-reduced-motion: reduce) {
  .pl-logo, .pl-bars span, .ajax-bar.active::before { animation: none; }
  .pl-bars span { transform: scaleY(.7); }
  .ajax-bar.active::before { transform: none; width: 100%; }
}


/* =====================================================================
   Responsive: landscape tablets, portrait tablets and phones
   ===================================================================== */
body { overflow-x: clip; }   /* safety net: never scroll sideways */

.nav-toggle { display: none; }

/* KPI cards: 4 across on desktop, 2×2 on tablets, stacked on phones. */
.grid.kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Fee inputs on the mandate detail page. */
#fees-body input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 8px; font: inherit;
  color: var(--ink); background: var(--white); text-align: right;
  transition: border-color .2s, box-shadow .2s;
}
#fees-body input:focus { outline: none; border-color: var(--blue-400); box-shadow: 0 0 0 3px rgba(59,111,212,.12); }

@media (max-width: 980px) {
  .grid.kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Portrait tablets and phones: top bar + sidebar as a slide-in drawer. */
@media (max-width: 900px) {
  body.has-sidebar { padding-left: 0; }
  .topbar {
    position: sticky; top: 0; z-index: 50; display: flex; align-items: center;
    height: 64px; padding: 0 16px; background: var(--white);
    border-bottom: 1px solid var(--line); box-shadow: var(--shadow-sm);
  }
  .topbar .brand-logo { display: block; height: 44px; width: auto; }
  .nav-toggle {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 5px;
    margin-left: auto; width: 44px; height: 44px; padding: 0 11px; cursor: pointer;
    border: 1px solid var(--line); border-radius: 10px; background: var(--white);
  }
  .nav-toggle:hover { background: var(--paper); }
  .nav-toggle span {
    display: block; height: 2px; border-radius: 2px; background: var(--navy-800);
    transition: transform .25s ease, opacity .2s ease;
  }
  .nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle.open span:nth-child(2) { opacity: 0; }
  .nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .sidebar {
    width: min(var(--sidebar-w), 84vw); transform: translateX(-100%);
    transition: transform .25s ease; box-shadow: none;
  }
  .sidebar-scrim {
    display: block; position: fixed; inset: 0; z-index: 55; background: rgba(6,16,35,.4);
    opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s ease;
  }
  body.nav-open .sidebar { transform: none; box-shadow: 12px 0 40px rgba(6,16,35,.25); }
  body.nav-open .sidebar-scrim { opacity: 1; visibility: visible; }
  body.nav-open { overflow: hidden; }
}

/* Phones. */
@media (max-width: 640px) {
  .page { padding: 20px 16px 56px; }
  .page-head { margin-bottom: 18px; }
  .page-head h1 { font-size: 1.6rem; }
  .section-head { margin: 26px 0 12px; }
  .section-head h2 { font-size: 1.2rem; }
  .card { padding: 18px 16px; }
  .incentives { padding: 22px 18px; }
  .modal { padding: 22px 18px; }
  .side-panel { width: 100vw; max-width: 100vw; padding: 22px 18px; }
  .filter-row .btn-primary { flex: 1 1 100%; justify-content: center; }

  /* Tables marked .stack become one card per row, labelled from data-label. */
  table.data.stack thead { display: none; }
  table.data.stack, table.data.stack tbody { display: block; width: 100%; }
  table.data.stack tr {
    display: flex; flex-direction: column; padding: 14px 16px;
    border-bottom: 1px solid var(--line);
  }
  table.data.stack tbody tr:hover { background: transparent; }
  table.data.stack td { display: block; border: none; padding: 5px 0; }
  table.data.stack td[data-label] {
    display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right;
  }
  table.data.stack td[data-label]::before {
    content: attr(data-label); flex: none; text-align: left;
    font-size: .72rem; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; color: var(--muted);
  }
  table.data.stack td.cell-title { order: -1; padding-bottom: 8px; font-size: 1rem; }
  table.data.stack td.cell-action { padding-top: 10px; }
  table.data.stack td.cell-action .btn { width: 100%; justify-content: center; }
}

@media (max-width: 520px) {
  .grid.kpi { grid-template-columns: 1fr; }
}

/* ---------- Admin Center: incentive policy ---------- */
.label-sm {
  font-size: .78rem; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  color: var(--muted); margin: 14px 0 8px;
}
.role-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.role-chip { position: relative; cursor: pointer; }
.role-chip input { position: absolute; opacity: 0; pointer-events: none; }
.role-chip span {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--white); font-size: .82rem; font-weight: 600;
  color: var(--ink); transition: background .2s, border-color .2s, color .2s;
}
.role-chip span::before {
  content: ""; width: 14px; height: 14px; border-radius: 4px; flex: none;
  border: 1.5px solid var(--line); background: var(--white);
}
.role-chip:hover span { border-color: var(--blue-300); }
.role-chip input:checked + span { background: var(--navy-700); border-color: var(--navy-700); color: var(--white); }
.role-chip input:checked + span::before {
  border-color: var(--accent); background: var(--accent)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%230a1f44' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/12px no-repeat;
}
.role-chip input:focus-visible + span { box-shadow: 0 0 0 3px rgba(59,111,212,.3); }

.check-line { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--ink); cursor: pointer; }
.check-line input { width: 16px; height: 16px; accent-color: var(--navy-700); }

.suffix-input {
  display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); background: var(--white); padding: 0 10px; height: 40px;
  transition: border-color .2s, box-shadow .2s;
}
.suffix-input:focus-within { border-color: var(--blue-400); box-shadow: 0 0 0 4px rgba(59,111,212,.12); }
.suffix-input input {
  border: none; outline: none; font: inherit; color: var(--ink); background: transparent;
  width: 80px; text-align: right; padding: 0;
}
.field .suffix-input input { border: none; padding: 0; box-shadow: none; width: 100px; }
.suffix-input span { color: var(--muted); font-size: .88rem; }
.suffix-input .pre { font-size: .8rem; }

table.bands { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
table.bands th {
  text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); padding: 0 6px 6px;
}
table.bands td { padding: 4px 6px 4px 0; }
.icon-btn {
  width: 32px; height: 32px; border: none; border-radius: 8px; cursor: pointer;
  background: var(--paper); color: var(--muted); font-size: 1.1rem; line-height: 1;
}
.icon-btn:hover { background: #fdecec; color: var(--bad); }

.targets-wrap { max-height: 360px; overflow-y: auto; }
.target-input {
  width: 140px; padding: 7px 10px; border: 1.5px solid var(--line); border-radius: 8px;
  font: inherit; text-align: right; color: var(--ink);
}
.target-input:focus { outline: none; border-color: var(--blue-400); box-shadow: 0 0 0 3px rgba(59,111,212,.12); }

@media (max-width: 640px) {
  .targets-wrap { max-height: none; }
  .suffix-input input { width: 64px; }
}

/* ---------- Password show/hide + inline form errors ---------- */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 46px; }
.field .pw-wrap input { padding-right: 46px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; display: grid; place-items: center;
  border: none; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
}
.pw-toggle:hover { background: var(--paper); color: var(--navy-700); }
.pw-toggle:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(59,111,212,.3); }
.pw-toggle svg {
  width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.pw-toggle .eye-off { display: none; }
.pw-toggle.is-visible .eye { display: none; }
.pw-toggle.is-visible .eye-off { display: block; }

.field input.is-invalid, .field select.is-invalid {
  border-color: var(--bad); box-shadow: 0 0 0 3px rgba(214,69,69,.12);
}
.form-error {
  display: flex; align-items: center; gap: 8px; margin: -4px 0 14px; padding: 10px 12px;
  border-radius: var(--radius-sm); background: #fdecec; color: var(--bad);
  font-size: .88rem; font-weight: 600; animation: fadeIn .2s ease;
}
.form-error::before {
  content: "!"; flex: none; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; background: var(--bad); color: var(--white);
  font-size: .75rem; font-weight: 800;
}

/* ---------- Admin Center: inline edit rows, users ---------- */
.cell-actions { white-space: nowrap; text-align: right; }
.cell-actions .btn + .btn { margin-left: 4px; }
.inline-input {
  width: 100%; min-width: 0; padding: 7px 10px; border: 1.5px solid var(--line); border-radius: 8px;
  font: inherit; color: var(--ink); background: var(--white);
}
.inline-input:focus { outline: none; border-color: var(--blue-400); box-shadow: 0 0 0 3px rgba(59,111,212,.12); }
tr.editing td { background: var(--accent-soft); }
.pw-row { display: flex; gap: 8px; align-items: center; }
.pw-row .pw-wrap { flex: 1; min-width: 0; }
.users-wrap { max-height: 520px; overflow-y: auto; }
.users-toolbar { margin-bottom: 12px; }
.check-inline { display: inline-flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--muted); cursor: pointer; }
.check-inline input { width: 16px; height: 16px; accent-color: var(--navy-600); }
tr.row-inactive td { color: var(--muted); }
tr.row-inactive td b { text-decoration: line-through; }
.modal-wide { max-width: 620px; max-height: calc(100vh - 40px); overflow-y: auto; }

@media (max-width: 640px) {
  table.data.stack td.cell-actions {
    display: flex; justify-content: flex-end; gap: 8px; padding-top: 10px; text-align: right;
  }
  table.data.stack td.cell-actions .btn { flex: 1; justify-content: center; }
  table.data.stack tr.editing td[data-label] { flex-direction: column; align-items: stretch; text-align: left; }
  .users-wrap { max-height: none; }
}
