/**
 * Layout Styles
 * App grid, sidebar navigation, page shell, header bar.
 * Responsive breakpoints: tablet (769–1024px) and mobile (≤768px).
 */
/* ── LAYOUT ── */
#app{display:flex;min-height:100vh}
.sidebar{width:220px;background:var(--navy);display:flex;flex-direction:column;flex-shrink:0;border-right:1px solid rgba(255,255,255,.06)}
.main{flex:1;background:var(--surf);overflow-y:auto;overflow-x:hidden;display:flex;flex-direction:column;min-height:0}

/* ── SIDEBAR ── */
.s-logo{padding:22px 20px 18px;display:flex;align-items:center;gap:11px;border-bottom:1px solid rgba(255,255,255,.07)}
.s-logo-icon{width:40px;height:40px;background:transparent;border-radius:10px;display:flex;align-items:center;justify-content:center;flex-shrink:0;overflow:hidden}
.s-logo-icon img{width:100%;height:100%;object-fit:contain}
.s-logo-name{font-family:var(--font-head);color:#fff;font-size:15px;font-weight:700;letter-spacing:-.01em}
.s-logo-sub{font-size:10px;color:rgba(255,255,255,.3);letter-spacing:.08em;text-transform:uppercase;margin-top:1px}
.s-nav{flex:1;padding:16px 10px;overflow-y:auto;scrollbar-width:none;-ms-overflow-style:none}
.s-nav::-webkit-scrollbar{width:0;height:0;display:none}
.s-sec{font-size:10px;color:rgba(255,255,255,.25);letter-spacing:.1em;text-transform:uppercase;padding:0 10px;margin:16px 0 6px}
.ni{display:flex;align-items:center;gap:10px;padding:9px 12px;border-radius:var(--rmd);color:rgba(255,255,255,.5);font-size:13.5px;cursor:pointer;margin-bottom:1px;transition:all .18s;user-select:none;position:relative;border-left:3px solid transparent}
.ni:hover{background:rgba(6,182,212,.12);color:rgba(255,255,255,.92)}
.ni.active{background:rgba(6,182,212,.18);color:#22d3ee;border-left:3px solid #06b6d4}
.ni svg{width:16px;height:16px;flex-shrink:0}
.ni .badge-dot{position:absolute;right:10px;width:18px;height:18px;background:var(--acc2);border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:10px;color:#fff;font-weight:700}
.s-user{padding:12px 10px;border-top:1px solid rgba(255,255,255,.07)}
.s-u-box{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:var(--rmd);background:rgba(255,255,255,.04);margin-bottom:4px}
.s-u-av{width:32px;height:32px;border-radius:50%;background:var(--acc2);display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:700;color:#fff;flex-shrink:0;font-family:var(--font-head)}
.s-u-name{font-size:13px;font-weight:500;color:#fff;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.s-u-role{font-size:10.5px;color:rgba(255,255,255,.35);text-transform:capitalize}

/* ── PAGE SHELL ── */
.page-header{padding:28px 32px 0;display:flex;align-items:flex-start;justify-content:space-between;flex-shrink:0}
.page-content{padding:20px 32px 32px;flex:1}
.page-title{font-family:var(--font-head);font-size:20px;font-weight:700;letter-spacing:-.02em;color:var(--navy)}
.page-sub{font-size:13px;color:var(--muted);margin-top:3px}

/* ── Responsive ─────────────────────────────────────────────── */
/* ── Tablet 769–1024px ─────────────────────────────── */
@media (min-width:769px) and (max-width:1024px){
  .sidebar{ width:190px!important; }
  .s-logo-name{ font-size:14px!important; }
  [style*="grid-template-columns:repeat(4,1fr)"]{ grid-template-columns:1fr 1fr!important; }
  [style*="grid-template-columns:1fr 1fr 260px"]{ grid-template-columns:1fr 1fr!important; }
  [style*="grid-template-columns:1fr 1fr 1fr"]{ grid-template-columns:1fr 1fr!important; }
  [style*="grid-template-columns:1fr 280px"]{ grid-template-columns:1fr!important; }
  [style*="grid-template-columns:1fr 320px"]{ grid-template-columns:1fr!important; }
  [style*="grid-template-columns:1fr 360px"]{ grid-template-columns:1fr!important; }
  [style*="max-width:1060px"]{ max-width:100%!important; }
  [style*="max-width:1020px"]{ max-width:100%!important; }
  .login-left{ padding:36px 28px!important; }
  .login-right{ padding:36px 28px!important; }
}

/* ── Mobile ≤768px ─────────────────────────────────── */
@media (max-width:768px){

  /* App shell: sidebar becomes bottom tab bar */
  .app-shell{ flex-direction:column!important; height:100vh; overflow:hidden; }

  .sidebar{
    width:100%!important; height:auto!important;
    border-right:none!important;
    border-top:1px solid rgba(255,255,255,.08)!important;
    order:2; flex-shrink:0;
  }
  .s-logo{ display:none!important; }
  .s-user{ display:none!important; }
  .s-sec{ display:none!important; }
  .s-nav{
    display:flex!important; flex-direction:row!important;
    padding:6px 8px!important; gap:0!important;
    overflow-x:auto; overflow-y:hidden;
    justify-content:space-around;
  }
  .ni{
    flex-direction:column!important; font-size:9.5px!important;
    padding:5px 8px!important; gap:3px!important;
    min-width:52px; text-align:center;
    border-radius:8px!important; white-space:nowrap;
    flex-shrink:0;
  }
  .ni svg{ width:17px!important; height:17px!important; }
  .notif-badge{position:absolute;right:10px;background:var(--acc2);color:#fff;border-radius:50%;width:18px;height:18px;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:700}
  .badge-dot{position:absolute;right:10px;width:18px;height:18px;background:var(--acc2);border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:10px;color:#fff;font-weight:700}

  /* Main content scrolls, topbar fixed */
  .main{ order:1; flex:1; overflow-y:auto; min-height:0; }
  .topbar{ padding:0 14px!important; height:46px!important; }
  .topbar-user > div:last-child{ display:none; }

  /* Page layout */
  .page-header{ padding:14px 14px 0!important; flex-wrap:wrap; gap:8px; align-items:flex-start; }
  .pt{font-family:var(--font-head);font-size:20px;font-weight:700;letter-spacing:-.02em;color:var(--navy)}
  .ps{font-family:var(--font-body);font-size:13px;color:var(--muted);margin-top:4px}
  .page-content{ padding:12px 10px!important; gap:12px!important; }

  /* Cards */
  .card{ border-radius:10px!important; }

  /* All multi-col grids collapse */
  [style*="grid-template-columns:1fr 1fr"]{  grid-template-columns:1fr!important; }
  [style*="grid-template-columns:1fr 280px"]{ grid-template-columns:1fr!important; }
  [style*="grid-template-columns:1fr 300px"]{ grid-template-columns:1fr!important; }
  [style*="grid-template-columns:1fr 320px"]{ grid-template-columns:1fr!important; }
  [style*="grid-template-columns:1fr 360px"]{ grid-template-columns:1fr!important; }
  [style*="grid-template-columns:1fr 380px"]{ grid-template-columns:1fr!important; }
  [style*="grid-template-columns:1fr 210px"]{ grid-template-columns:1fr!important; }
  [style*="grid-template-columns:1fr 260px"]{ grid-template-columns:1fr!important; }
  [style*="grid-template-columns:1fr 1fr 260px"]{ grid-template-columns:1fr!important; }
  [style*="grid-template-columns:1fr 1fr 1fr"]{ grid-template-columns:1fr!important; }
  [style*="grid-template-columns:repeat(3,1fr)"]{ grid-template-columns:1fr!important; }

  /* Stats: 2 cols on mobile */
  .stats-grid,[style*="grid-template-columns:repeat(4,1fr)"]{ grid-template-columns:1fr 1fr!important; }

  /* Form rows stack — .form-row/.form-row3 are CSS grids, so collapse the columns */
  .form-row,.form-row3{ grid-template-columns:1fr!important; }
  .fg{ min-width:0!important; }
  /* wide tables scroll inside their wrapper, never the page */
  .table-wrap{ max-width:100%!important; }

  /* Tables scroll */
  .twrap{ overflow-x:auto!important; -webkit-overflow-scrolling:touch; }
  .twrap table{ min-width:580px; }

  /* Login: hide left panel, full-width right */
  .login-body{ grid-template-columns:1fr!important; min-height:auto!important; }
  .login-left{ display:none!important; }
  .login-right{ padding:24px 18px!important; min-height:100vh; justify-content:flex-start!important; }
  .glass-card{ padding:20px 18px!important; }

  /* Max widths go full */
  [style*="max-width:780px"],[style*="max-width:860px"],
  [style*="max-width:1060px"],[style*="max-width:1020px"],
  [style*="max-width:740px"]{ max-width:100%!important; }

  /* Stat cards compact */
  .stat,.stat-card{ padding:12px 14px!important; }
  .stat-num,.stat-num{ font-size:22px!important; }

  /* Scanner */
  .scan-zone{ padding:22px 14px!important; }

  /* Filter bar in admin */
  [style*="flex-wrap:wrap"]{ flex-wrap:wrap!important; }

  /* Pass detail sticky col not sticky on mobile */
  [style*="position:sticky"]{ position:static!important; }

  /* Buttons full width in some contexts */
  .page-header .btn{ font-size:12.5px!important; padding:7px 12px!important; }

  /* Overlay/modal cards never exceed the viewport — they scroll internally */
  #confirm-modal>div,#welcome-email-modal>div,#mo-ext-modal>div,
  #user-modal>div,#cl-site-modal>div,#cl-gate-modal>div{
    max-height:92vh!important; overflow:auto!important;
  }
}


/* ── Small phones ≤480px ───────────────────────────── */
@media (max-width:480px){
  .page-header{ padding:12px 12px 0!important; }
  .page-content{ padding:10px 8px 26px!important; }
  .page-title,.pt{ font-size:18px!important; }
  .page-sub,.ps{ font-size:12px!important; }
  /* single-column stats on very small screens */
  .stats-grid,[style*="grid-template-columns:repeat(4,1fr)"]{ grid-template-columns:1fr!important; }
  .stat-num{ font-size:26px!important; }
  .stat-card{ padding:14px 16px!important; }
  /* tighter bottom nav so more tabs fit */
  .ni{ min-width:46px!important; font-size:9px!important; padding:5px 6px!important; }
  .ni svg{ width:16px!important; height:16px!important; }
  /* page-header actions take full width and wrap neatly */
  .page-header > div:last-child{ width:100%; }
  .page-header .btn{ flex:1; justify-content:center; }
}


.user-dropdown{display:none;position:fixed;background:#fff;border:1px solid var(--border);border-radius:12px;box-shadow:0 8px 32px rgba(11,17,32,.14);min-width:210px;width:min(210px,calc(100vw - 24px));z-index:9999;overflow:hidden;animation:dropIn .15s ease}.user-dropdown.open{display:block}@keyframes dropIn{from{opacity:0;transform:translateY(-6px)}to{opacity:1;transform:translateY(0)}}.user-dd-hdr{padding:14px 16px;border-bottom:1px solid var(--border);background:var(--surf)}.user-dd-name{font-weight:700;font-size:14px;color:var(--navy)}.user-dd-role{font-size:12px;color:var(--muted);text-transform:capitalize;margin-top:2px}.user-dd-item{display:flex;align-items:center;gap:10px;padding:11px 16px;font-size:13.5px;color:var(--slate);cursor:pointer;transition:background .15s;font-family:var(--font-body);border:none;background:none;width:100%;text-align:left}.user-dd-item:hover{background:var(--surf);color:var(--navy)}.user-dd-sep{height:1px;background:var(--border)}.user-dd-item.danger{color:var(--red)}
