:root {
  --green-dark:  #0a5f40;
  --green-mid:   #0d7a52;
  --green-light: #4ade80;
  --blue-mid:    #2563eb;
  --blue-light:  #60a5fa;
  --purple-dark: #5b21b6;
  --purple-mid:  #7c3aed;
  --purple-light:#a78bfa;
  --cream:       #f0f4f1;
  --white:       #ffffff;
}

* { margin:0; padding:0; box-sizing:border-box; }

html, body {
  height: 100%;
  background-color: #f0fdf4;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  opacity: 1;
  transition: opacity 0.2s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.page-leaving {
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* ── BACKGROUND ── */
.bg-layer {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 70% 60% at 5% 80%,  rgba(10,95,64,0.07)  0%, transparent 55%),
    radial-gradient(ellipse 55% 45% at 95% 10%, rgba(37,99,235,0.06)  0%, transparent 50%),
    radial-gradient(ellipse 40% 40% at 75% 90%, rgba(124,58,237,0.04) 0%, transparent 50%),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(10,95,64,0.03)   0%, transparent 60%);
  pointer-events: none;
}
.bg-grid {
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(10,95,64,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(10,95,64,0.025) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
}

/* ── NAVBAR ── */
nav {
  position: sticky; top: 0; z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 32px;
  height: 56px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(10,95,64,0.1);
  box-shadow: 0 1px 20px rgba(10,95,64,0.06);
  flex-shrink: 0;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.nav-logo {
  width: 32px; height: 32px;
  border-radius: 9px;
  object-fit: cover;
  border: 1.5px solid rgba(10,95,64,0.2);
  flex-shrink: 0;
}
.nav-text { display:flex; flex-direction:column; line-height:1.15; min-width: 0; }
.nav-title { font-size:0.88rem; font-weight:800; color:var(--green-dark); white-space: nowrap; }
.nav-sub   { font-size:0.65rem; color:#8a9a93; font-weight:600; letter-spacing:0.5px; white-space: nowrap; }

.nav-right { display:flex; align-items:center; gap:10px; flex-shrink: 0; }


#portal-clock {
  font-family: 'DM Mono', monospace;
  font-size: 0.8rem;
  color: #5a7a6e;
  font-weight: 500;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
#nav-login-hint {
  font-size: 0.76rem;
  color: #8a9a93;
  font-weight: 600;
  white-space: nowrap;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border-radius: 9px;
  background: rgba(10,95,64,0.06);
  border: 1px solid rgba(10,95,64,0.1);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--green-dark);
  white-space: nowrap;
}
.user-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0a5f40, #22c55e);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  flex-shrink: 0;
}
.nav-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9px;
  border: 1.5px solid rgba(220,38,38,0.25);
  color: #dc2626;
  background: rgba(220,38,38,0.04);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(.34,1.56,.64,1);
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.nav-logout:hover {
  background: rgba(220,38,38,0.09);
  border-color: rgba(220,38,38,0.45);
  transform: translateY(-1px);
}
.nav-logout:active {
  transform: translateY(0) scale(0.97);
  transition: all 0.1s ease;
}

/* ── MAIN ── */
main {
  position: relative; z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 24px 20px;
  gap: 18px;
  min-height: 0;
}

/* ── HERO TEXT ── */
.portal-header {
  text-align: center;
  animation: fadeUp 0.5s cubic-bezier(.16,1,.3,1) both;
}
@keyframes fadeUp {
  from { opacity:0; transform: translateY(16px); }
  to   { opacity:1; transform: translateY(0); }
}
.portal-eyebrow {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: #8a9a93;
  margin-bottom: 4px;
}
.portal-title {
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  font-weight: 800;
  color: var(--green-dark);
  letter-spacing: -0.5px;
  line-height: 1.15;
}
.portal-title span {
  background: linear-gradient(90deg, var(--green-dark), #22c55e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.portal-sub {
  font-size: 0.82rem;
  color: #7a9e8e;
  margin-top: 4px;
}


/* ── HIERARCHY BAR ── */
.hierarchy-bar {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.7);
  border: 1.5px solid rgba(10,95,64,0.1);
  border-radius: 12px;
  padding: 10px 18px;
  max-width: 860px;
  width: 100%;
  box-shadow: 0 2px 10px rgba(10,95,64,0.05);
  animation: fadeUp 0.6s cubic-bezier(.16,1,.3,1) 0.1s both;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.h-step {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  justify-content: center;
  min-width: 80px;
}
.h-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.h-icon.superadmin,
.h-icon.admin,
.h-icon.hr,
.h-icon.ops {
  background: linear-gradient(135deg, #0a5f40, #22c55e);
  box-shadow: 0 3px 8px rgba(10,95,64,0.25);
}
.h-label { font-size: 0.72rem; font-weight: 700; color: #1a1a1a; }
.h-sub   { font-size: 0.62rem; color: #8a9a93; font-weight: 500; }
.h-arrow {
  color: rgba(10,95,64,0.25);
  font-size: 0.95rem;
  flex-shrink: 0;
  padding: 0 3px;
}
.h-divider {
  width: 1px; height: 32px;
  background: rgba(10,95,64,0.1);
  margin: 0 10px;
  flex-shrink: 0;
}

/* ── MODULE CARDS GRID ── */
.modules-grid-all {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 1060px;
  animation: fadeUp 0.55s cubic-bezier(.16,1,.3,1) 0.08s both;
}

/* ── MODULE CARD BASE ── */
.module-card {
  position: relative;
  background: var(--white);
  border-radius: 18px;
  padding: 24px 24px 20px;
  text-decoration: none;
  border: 1.5px solid transparent;
  box-shadow:
    0 2px 10px rgba(0,0,0,0.05),
    0 0 0 1px rgba(0,0,0,0.04);
  overflow: hidden;
  cursor: pointer;
  transition:
    transform 0.28s cubic-bezier(.34,1.56,.64,1),
    box-shadow 0.28s cubic-bezier(.16,1,.3,1),
    border-color 0.2s ease,
    background 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.module-card:focus-visible {
  outline: 3px solid var(--green-dark);
  outline-offset: 3px;
}
.module-card:hover {
  transform: translateY(-5px) scale(1.01);
  box-shadow:
    0 18px 48px rgba(0,0,0,0.11),
    0 0 0 1px rgba(0,0,0,0.05);
}
.module-card:active {
  transform: translateY(-2px) scale(0.99);
  box-shadow:
    0 6px 20px rgba(0,0,0,0.07),
    0 0 0 1px rgba(0,0,0,0.04);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.module-card.hr:hover        { border-color: rgba(10,95,64,0.35);   background: rgba(10,95,64,0.015); }
.module-card.ops:hover       { border-color: rgba(37,99,235,0.35);  background: rgba(37,99,235,0.015); }
.module-card.dashboard:hover { border-color: rgba(10,95,64,0.35);  background: rgba(10,95,64,0.015); }

.module-card.loading {
  pointer-events: none;
  opacity: 0.75;
}
.module-card.loading .module-cta::after {
  content: '';
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: cardSpin 0.7s linear infinite;
  margin-left: 4px;
}
@keyframes cardSpin { to { transform: rotate(360deg); } }

/* ── CARD DECORATIVE CIRCLE ── */
.card-circle {
  position: absolute;
  width: 150px; height: 150px;
  border-radius: 50%;
  top: -50px; right: -50px;
  opacity: 0.06;
  pointer-events: none;
}
.hr        .card-circle { background: var(--green-dark); }
.ops       .card-circle { background: var(--green-dark); }
.dashboard .card-circle { background: var(--green-dark); }

/* ── ICON WRAP ── */
.module-icon-wrap {
  width: 46px; height: 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hr        .module-icon-wrap { background: linear-gradient(135deg, #0a5f40, #22c55e); box-shadow: 0 5px 16px rgba(10,95,64,0.28); }
.ops       .module-icon-wrap { background: linear-gradient(135deg, #0a5f40, #22c55e); box-shadow: 0 5px 16px rgba(10,95,64,0.28); }
.dashboard .module-icon-wrap { background: linear-gradient(135deg, #0a5f40, #22c55e); box-shadow: 0 5px 16px rgba(10,95,64,0.28); }

/* ── MODULE BODY TEXT ── */
.module-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.hr        .module-label { color: #a0c4a8; }
.ops       .module-label { color: #a0c4a8; }
.dashboard .module-label { color: #a0c4a8; }

.module-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f1a14;
  letter-spacing: -0.3px;
  line-height: 1.2;
}
.module-desc {
  font-size: 0.78rem;
  color: #8a9a93;
  margin-top: 4px;
  line-height: 1.5;
}

/* ── FEATURE PILLS ── */
.module-features {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}
.feature-pill {
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.67rem;
  font-weight: 700;
}
.hr        .feature-pill { background: rgba(10,95,64,0.07);   color: #0a5f40; border: 1px solid rgba(10,95,64,0.12); }
.ops       .feature-pill { background: rgba(10,95,64,0.07);   color: #0a5f40; border: 1px solid rgba(10,95,64,0.12); }
.dashboard .feature-pill { background: rgba(10,95,64,0.07);   color: #0a5f40; border: 1px solid rgba(10,95,64,0.12); }

/* ── ARROW CTA ── */
.module-cta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  margin-top: auto;
  padding-top: 6px;
  opacity: 0.45;
  transform: translateX(0);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(.34,1.56,.64,1), gap 0.25s ease;
}
.hr        .module-cta { color: var(--green-dark); }
.ops       .module-cta { color: var(--green-dark); }
.dashboard .module-cta { color: var(--green-dark); }
.module-card:hover .module-cta {
  opacity: 1;
  transform: translateX(4px);
  gap: 10px;
}

/* ── ROLE HINT BADGE ── */
.role-hint {
  position: absolute;
  top: 14px; right: 14px;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 3px 9px;
  border-radius: 20px;
}
.hr        .role-hint { background: rgba(10,95,64,0.08);   color: #0a5f40; border: 1px solid rgba(10,95,64,0.15); }
.ops       .role-hint { background: rgba(10,95,64,0.08);   color: #0a5f40; border: 1px solid rgba(10,95,64,0.15); }
.dashboard .role-hint { background: rgba(10,95,64,0.08);   color: #0a5f40; border: 1px solid rgba(10,95,64,0.15); }

/* ── SUPER ADMIN CARD ── */
.module-card.dashboard {
  background: linear-gradient(160deg, #ffffff 0%, #f0faf5 100%);
  border-color: rgba(10,95,64,0.12);
}

/* ── SCANNER SHORTCUT ── */
.scanner-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: 30px;
  background: rgba(255,255,255,0.8);
  border: 1.5px solid rgba(10,95,64,0.15);
  box-shadow: 0 2px 10px rgba(10,95,64,0.07);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--green-dark);
  transition: all 0.25s cubic-bezier(.34,1.56,.64,1);
  animation: fadeUp 0.6s cubic-bezier(.16,1,.3,1) 0.15s both;
  -webkit-tap-highlight-color: transparent;
}
.scanner-chip:hover {
  background: #fff;
  border-color: rgba(10,95,64,0.3);
  box-shadow: 0 5px 18px rgba(10,95,64,0.12);
  transform: translateY(-2px) scale(1.03);
}
.scanner-chip:active {
  transform: translateY(0) scale(0.98);
  transition: all 0.1s ease;
}
.scan-live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 5px #4ade80;
  animation: blink 2s infinite;
}
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0.3; } }

/* ── SESSION BAR ── */
.session-bar {
  position: fixed;
  top: 64px; left: 50%;
  transform: translateX(-50%) translateY(-16px);
  background: #0a5f40;
  color: #fff;
  padding: 8px 18px;
  border-radius: 30px;
  font-size: 0.78rem;
  font-weight: 700;
  visibility: hidden;
  opacity: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 200;
  box-shadow: 0 6px 22px rgba(10,95,64,0.3);
  transition: opacity 0.5s ease, transform 0.45s cubic-bezier(.34,1.56,.64,1), visibility 0.5s;
  white-space: nowrap;
}
.session-bar.show {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
/* When .show is removed, it slides back up and fades — handled by base transition */
.session-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 5px #4ade80;
  animation: blink 2s infinite;
}
.session-bar a {
  color: #a7f3d0;
  text-decoration: none;
  font-weight: 800;
  margin-left: 4px;
  border-bottom: 1px solid rgba(167,243,208,0.4);
  transition: color 0.15s ease;
}
.session-bar a:hover { color: #fff; }

/* ── RIPPLE ── */
.ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  animation: rippleAnim 0.55s linear;
  pointer-events: none;
  z-index: 10;
}
.hr        .ripple { background: rgba(10,95,64,0.12); }
.ops       .ripple { background: rgba(37,99,235,0.10); }
.dashboard .ripple { background: rgba(10,95,64,0.12); }
@keyframes rippleAnim { to { transform: scale(4); opacity: 0; } }

/* ── PAGE TRANSITION ── */
.page-leaving {
  animation: pageOut 0.28s cubic-bezier(.16,1,.3,1) forwards;
  pointer-events: none;
}
@keyframes pageOut {
  from { opacity: 1; transform: scale(1) translateY(0); }
  to   { opacity: 0; transform: scale(0.98) translateY(-8px); }
}

/* ── LOGOUT MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: #fff;
  border-radius: 18px;
  padding: 32px 32px 24px;
  max-width: 340px; width: 100%;
  text-align: center;
  box-shadow: 0 24px 56px rgba(0,0,0,0.18);
  animation: cardIn 0.3s cubic-bezier(.16,1,.3,1);
}
@keyframes cardIn {
  from { opacity:0; transform: scale(0.95) translateY(12px); }
  to   { opacity:1; transform: scale(1) translateY(0); }
}
.modal-box h3 { font-size:1.1rem; font-weight:800; color:#1a1a1a; margin:12px 0 5px; }
.modal-box p  { font-size:0.83rem; color:#8a9a93; }
.modal-buttons { display: flex; gap: 10px; margin-top: 20px; }
.modal-cancel, .modal-confirm {
  flex: 1; padding: 12px;
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700; font-size: 0.86rem;
  cursor: pointer; border: none;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.modal-cancel  { background: #f0f4f1; color: #5a7a6e; }
.modal-cancel:hover  { background: #e4ebe6; }
.modal-confirm { background: linear-gradient(135deg,#dc2626,#ef4444); color:#fff; box-shadow: 0 4px 12px rgba(220,38,38,0.25); }
.modal-confirm:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(220,38,38,0.3); }

/* ── ACCESS TOAST ── */
#_access-toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #dc2626;
  color: #fff;
  padding: 10px 20px;
  border-radius: 99px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.83rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 9px;
  box-shadow: 0 8px 26px rgba(220,38,38,.35);
  opacity: 0;
  pointer-events: none;
  transition: all .35s cubic-bezier(.16,1,.3,1);
  z-index: 9999;
  max-width: calc(100vw - 32px);
  white-space: nowrap;
}
#_access-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── SESSION EXPIRED TOAST ── */
#_expired-toast {
  position: fixed;
  top: 70px; left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: #92400e;
  color: #fff;
  padding: 9px 18px;
  border-radius: 99px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 20px rgba(146,64,14,.3);
  opacity: 0;
  pointer-events: none;
  transition: all .35s cubic-bezier(.16,1,.3,1);
  z-index: 9999;
  max-width: calc(100vw - 32px);
  white-space: nowrap;
}
#_expired-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── LOGO FALLBACK ── */
.nav-logo-fallback {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #0a5f40, #22c55e);
  border: 1.5px solid rgba(10,95,64,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

/* ── OFFLINE TOAST ── */
#_offline-toast {
  position: fixed;
  top: 70px; left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: #1e293b;
  color: #fff;
  padding: 9px 18px;
  border-radius: 99px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: all .35s cubic-bezier(.16,1,.3,1);
  z-index: 9999;
  max-width: calc(100vw - 32px);
}
#_offline-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ═══════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════ */

/* ── TABLET: ≤ 900px ── */
@media (max-width: 900px) {
  .modules-grid,
  .modules-grid-all {
    grid-template-columns: repeat(2, 1fr);
    max-width: 700px;
  }

  /* Third card spans full width on tablet */
  .modules-grid-all .module-card:nth-child(3),
  .modules-grid .module-card:nth-child(3) {
    grid-column: 1 / -1;
    max-width: 340px;
    justify-self: center;
  }

  nav {
    height: auto;
    min-height: 54px;
    padding: 10px 20px;
  }
  .nav-right { gap: 8px; }
}

/* ── LARGE PHONE / SMALL TABLET: ≤ 680px ── */
@media (max-width: 680px) {
  nav {
    padding: 10px 16px;
    height: auto;
    min-height: 54px;
  }

  /* Hide clock & login hint to free up space */
  #portal-clock    { display: none; }
  #nav-login-hint  { display: none; }
  .nav-sub         { display: none; }

  .modules-grid,
  .modules-grid-all {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  /* Third card back to full width */
  .modules-grid-all .module-card:nth-child(3),
  .modules-grid .module-card:nth-child(3) {
    grid-column: 1 / -1;
    max-width: none;
    justify-self: auto;
  }

  .module-card {
    padding: 18px 16px 14px;
    gap: 10px;
    border-radius: 16px;
  }

  main { padding: 16px 14px 14px; gap: 14px; }
}

/* ── PHONE: ≤ 480px ── */
@media (max-width: 480px) {
  /* Navbar: single row, compact */
  nav {
    padding: 0 14px;
    height: 52px;
    min-height: 52px;
  }
  .nav-title { font-size: 0.82rem; }
  .nav-sub   { display: none; }
  #portal-clock   { display: none; }
  #nav-login-hint { display: none; }

  /* Stack cards 1-column */
  .modules-grid,
  .modules-grid-all {
    grid-template-columns: 1fr;
    gap: 12px;
    max-width: 100%;
  }
  .modules-grid-all .module-card:nth-child(3),
  .modules-grid .module-card:nth-child(3) {
    grid-column: auto;
    max-width: none;
    justify-self: auto;
  }

  /* Compact cards */
  .module-card {
    padding: 18px 16px 14px;
    gap: 10px;
    border-radius: 14px;
  }
  .module-card:hover {
    transform: none;
  }
  .module-card:active {
    transform: scale(0.98);
  }
  .module-title    { font-size: 1rem; }
  .module-desc     { font-size: 0.75rem; line-height: 1.45; }
  .module-features { gap: 4px; }
  .feature-pill    { font-size: 0.62rem; padding: 2px 7px; }
  .module-cta      { font-size: 0.74rem; opacity: 0.65; }
  .module-card:active .module-cta { opacity: 1; }

  .role-hint {
    top: 10px; right: 10px;
    font-size: 0.54rem;
    letter-spacing: 1px;
    padding: 3px 7px;
  }
  .module-icon-wrap {
    width: 40px; height: 40px;
    border-radius: 12px;
  }
  .module-icon-wrap svg { width: 20px; height: 20px; }

  /* Hierarchy bar — centered icons with labels */
  .h-step > div:last-child { display: flex; flex-direction: column; align-items: center; }

  /* Session bar — compact pill */
  .session-bar {
    top: 60px;
    max-width: calc(100% - 32px);
    font-size: 0.68rem;
    padding: 5px 12px;
    gap: 5px;
    border-radius: 20px;
    white-space: nowrap;
  }
  .session-bar strong { font-size: 0.68rem; }
  .session-bar a { font-size: 0.68rem; margin-left: 2px; }

  /* Toasts */
  #_access-toast,
  #_expired-toast,
  #_offline-toast {
    max-width: calc(100% - 24px);
    white-space: normal;
    border-radius: 12px;
    text-align: center;
    justify-content: center;
    font-size: 0.78rem;
  }

  main { padding: 14px 12px 16px; gap: 12px; }

  .portal-title { font-size: 1.45rem; }
  .portal-sub   { font-size: 0.78rem; }
  .portal-eyebrow { font-size: 0.6rem; letter-spacing: 2px; }
}

/* ── VERY SMALL PHONES: ≤ 360px ── */
@media (max-width: 360px) {
  nav { padding: 0 10px; }
  main { padding: 12px 10px 14px; }
  .module-card { padding: 16px 14px 12px; border-radius: 12px; }
  .module-title { font-size: 0.95rem; }
  .module-desc  { font-size: 0.72rem; }
  .portal-title { font-size: 1.25rem; }
}

/* ── TALL PHONES (short content, large screen): center vertically ── */
@media (max-height: 700px) and (max-width: 480px) {
  main {
    justify-content: flex-start;
    padding-top: 12px;
  }
}

/* ── TOUCH DEVICES: remove hover lift (feels weird on touch) ── */
@media (hover: none) and (pointer: coarse) {
  .module-card:hover {
    transform: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05), 0 0 0 1px rgba(0,0,0,0.04);
    border-color: transparent;
    background: var(--white);
  }
  .module-card.hr:hover        { border-color: transparent; background: var(--white); }
  .module-card.ops:hover       { border-color: transparent; background: var(--white); }
  .module-card.dashboard:hover { border-color: transparent; background: linear-gradient(160deg, #ffffff 0%, #f0faf5 100%); }
  .module-card:hover .module-cta { opacity: 0.45; transform: none; gap: 6px; }
  .module-card:active {
    transform: scale(0.97);
    box-shadow: 0 4px 14px rgba(0,0,0,0.09), 0 0 0 1px rgba(0,0,0,0.04);
  }
  .scanner-chip:hover { transform: none; box-shadow: 0 2px 10px rgba(10,95,64,0.07); background: rgba(255,255,255,0.8); }
}


/* ── SMALL MOBILE: ≤ 560px ── */
@media (max-width: 560px) {
  .nav-right { display: none !important; }
  nav {
    padding: 0 14px;
    height: 52px;
    min-height: 52px;
  }
  .nav-sub { display: none; }

  /* Hide hierarchy bar on mobile */
  .hierarchy-bar { display: none; }

  /* Session bar compact */
  .session-bar {
    font-size: 0.67rem;
    padding: 5px 11px;
    gap: 5px;
    top: 60px;
  }
}