/* ============================================================
   IFC KidZone – Admin Panel Stylesheet v3.0
   Professional dark theme — no emoji dependencies
   ============================================================ */

:root {
  --admin-bg:          #0d1117;
  --admin-surface:     #161b22;
  --admin-surface2:    #1c2128;
  --admin-surface3:    #21262d;
  --admin-border:      #30363d;
  --admin-border-lt:   #3d444d;
  --admin-text:        #e6edf3;
  --admin-text-sec:    #b1bac4;
  --admin-text-muted:  #7d8590;

  --sidebar-bg:        #0d1117;
  --sidebar-border:    #21262d;
  --sidebar-text:      #8b949e;
  --sidebar-active:    #4a90c4;
  --sidebar-active-bg: rgba(74,144,196,.12);

  --topbar-bg:         #161b22;

  --brand-primary:     #4a90c4;
  --brand-dark:        #3a7fb5;
  --brand-light:       rgba(74,144,196,.12);
  --brand-hover:       rgba(74,144,196,.2);

  --accent-green:      #3fb950;
  --accent-green-bg:   rgba(63,185,80,.12);
  --accent-red:        #f85149;
  --accent-red-bg:     rgba(248,81,73,.12);
  --accent-yellow:     #d29922;
  --accent-yellow-bg:  rgba(210,153,34,.12);
  --accent-purple:     #a371f7;
  --accent-purple-bg:  rgba(163,113,247,.12);
  --accent-orange:     #e3752e;
  --accent-orange-bg:  rgba(227,117,46,.12);

  --radius:    8px;
  --radius-sm: 6px;
  --shadow:    0 8px 24px rgba(0,0,0,.6);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.4);
  --transition: .15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; overflow-y: scroll; scrollbar-gutter: stable; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--admin-bg);
  color: var(--admin-text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--brand-primary); text-decoration: none; }
a:hover { color: #79b8e0; text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 200; transition: transform var(--transition); overflow-y: auto;
}

.sidebar-brand {
  padding: 1.1rem 1.2rem .9rem;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: .7rem;
  flex-shrink: 0;
}
.sidebar-brand-logo { height: 34px; width: auto; object-fit: contain; border-radius: 4px; }
.sidebar-brand-logo-placeholder {
  width: 34px; height: 34px; background: rgba(255,255,255,.05);
  border: 1px solid var(--sidebar-border); border-radius: 6px;
  display: flex; align-items: center; justify-content: center; font-size: .9rem; flex-shrink: 0;
  color: var(--admin-text-muted);
}
.sidebar-brand-text { font-size: .95rem; font-weight: 700; color: var(--admin-text); line-height: 1.25; }
.sidebar-brand-text span { display: block; font-size: .67rem; font-weight: 400; color: var(--sidebar-text); margin-top: .1rem; letter-spacing: .02em; }

.sidebar-nav { padding: .5rem 0; flex: 1; }
.sidebar-section {
  font-size: .62rem; text-transform: uppercase; letter-spacing: .12em;
  color: rgba(255,255,255,.22); padding: .9rem 1.2rem .2rem;
}
.sidebar-nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .52rem 1.2rem; color: var(--sidebar-text);
  font-size: .84rem; border-left: 2px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.sidebar-nav a:hover { background: rgba(255,255,255,.04); color: var(--admin-text); text-decoration: none; }
.sidebar-nav a.active {
  background: var(--sidebar-active-bg); color: var(--admin-text);
  border-left-color: var(--sidebar-active); text-decoration: none;
}
.sidebar-nav a .nav-icon {
  width: 15px; height: 15px; flex-shrink: 0; opacity: .7;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-nav a.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: .8rem 1.2rem; border-top: 1px solid var(--sidebar-border);
  font-size: .73rem; color: var(--admin-text-muted); flex-shrink: 0;
}
.sidebar-footer strong { color: var(--admin-text-sec); font-size: .8rem; }
.sidebar-footer a { color: rgba(255,255,255,.35); }
.sidebar-footer a:hover { color: var(--admin-text); text-decoration: none; }

/* ── Main content ──────────────────────────────────────────── */
.main-content { margin-left: 240px; flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--sidebar-border);
  padding: .75rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,.04);
}
.topbar-title { font-size: .95rem; font-weight: 600; color: var(--admin-text); }
.topbar-right { display: flex; align-items: center; gap: .8rem; }
.topbar-user { font-size: .8rem; color: var(--admin-text-muted); }
.topbar-user strong { color: var(--admin-text-sec); }
.hamburger {
  display: none;
  background: none; border: none;
  cursor: pointer; color: var(--admin-text);
  padding: .3rem;
  align-items: center; justify-content: center;
  border-radius: 6px;
  transition: background var(--transition);
}
.hamburger:hover { background: rgba(255,255,255,.06); }

.content-area { padding: 1.5rem; flex: 1; }

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .8rem; margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.25rem; font-weight: 700; color: var(--admin-text); }
.page-header-meta { font-size: .82rem; color: var(--admin-text-muted); }

/* ── Stats cards ────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(180px,1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius);
  padding: 1.1rem 1.1rem;
  display: flex; align-items: flex-start; gap: .9rem;
}
.stat-icon {
  width: 2.6rem; height: 2.6rem; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon.blue   { background: rgba(74,144,196,.15); color: var(--brand-primary); }
.stat-icon.green  { background: var(--accent-green-bg);  color: var(--accent-green); }
.stat-icon.yellow { background: var(--accent-yellow-bg); color: var(--accent-yellow); }
.stat-icon.red    { background: var(--accent-red-bg);    color: var(--accent-red); }
.stat-icon.purple { background: var(--accent-purple-bg); color: var(--accent-purple); }
.stat-icon.orange { background: var(--accent-orange-bg); color: var(--accent-orange); }
.stat-icon svg { width: 1.2rem; height: 1.2rem; }
.stat-body .stat-label { font-size: .7rem; color: var(--admin-text-muted); text-transform: uppercase; letter-spacing: .06em; }
.stat-body .stat-value { font-size: 1.65rem; font-weight: 800; line-height: 1.1; color: var(--admin-text); margin-top: .1rem; }

/* ── Card ────────────────────────────────────────────────────── */
.card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem; overflow: hidden;
}
.card-header {
  padding: .85rem 1.2rem; border-bottom: 1px solid var(--admin-border);
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  background: var(--admin-surface2);
}
.card-header h2 { font-size: .9rem; font-weight: 700; color: var(--admin-text); }
.card-body { padding: 1.2rem; }
.card-footer {
  padding: .75rem 1.2rem; border-top: 1px solid var(--admin-border);
  background: var(--admin-surface2); font-size: .8rem; color: var(--admin-text-muted);
}

/* ── Table ───────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
table.data-table th {
  background: var(--admin-surface2); padding: .6rem 1rem;
  text-align: left; font-size: .68rem; text-transform: uppercase;
  letter-spacing: .07em; color: var(--admin-text-muted);
  border-bottom: 1px solid var(--admin-border); white-space: nowrap;
  font-weight: 600;
}
table.data-table td {
  padding: .7rem 1rem; border-bottom: 1px solid rgba(48,54,61,.6);
  vertical-align: middle; color: var(--admin-text);
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover td { background: rgba(74,144,196,.05); }
.no-data { text-align: center; color: var(--admin-text-muted); padding: 3rem 1rem; font-size: .88rem; }

/* Stacked-card layout for action-heavy tables is defined in the
   mobile media query below (class="data-table stacked-mobile"). */

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: .18rem .6rem; border-radius: 99px;
  font-size: .69rem; font-weight: 600; white-space: nowrap; letter-spacing: .02em;
}
.badge-success { background: var(--accent-green-bg);  color: var(--accent-green); }
.badge-warning { background: var(--accent-yellow-bg); color: var(--accent-yellow); }
.badge-danger  { background: var(--accent-red-bg);    color: var(--accent-red); }
.badge-info    { background: var(--brand-light);       color: var(--brand-primary); }
.badge-purple  { background: var(--accent-purple-bg); color: var(--accent-purple); }
.badge-gray    { background: rgba(125,133,144,.15);   color: var(--admin-text-muted); }

/* ── Role badges ─────────────────────────────────────────────── */
.role-badge {
  display: inline-block; font-size: .67rem; font-weight: 700;
  padding: .15rem .5rem; border-radius: 99px; color: #fff; white-space: nowrap;
}
.role-superadmin  { background: #7c3aed; }
.role-admin       { background: #2563eb; }
.role-team_leader { background: #0d9488; }
.role-registration{ background: #16a34a; }
.role-checker     { background: #b45309; }
.role-facilitator { background: #0891b2; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .5rem 1rem; border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: .84rem; font-weight: 500; cursor: pointer; white-space: nowrap; font-family: inherit;
  text-decoration: none; transition: background var(--transition), border-color var(--transition), color var(--transition);
  line-height: 1.4;
}
.btn:active { transform: scale(.98); }
.btn svg { width: .9em; height: .9em; }

.btn-primary {
  background: var(--brand-primary); color: #fff; border-color: var(--brand-primary);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; text-decoration: none; }

.btn-success {
  background: var(--accent-green); color: #fff; border-color: var(--accent-green);
}
.btn-success:hover { background: #2da044; color: #fff; text-decoration: none; }

.btn-danger {
  background: var(--accent-red); color: #fff; border-color: var(--accent-red);
}
.btn-danger:hover { background: #da3633; color: #fff; text-decoration: none; }

.btn-warning {
  background: var(--accent-yellow); color: #fff; border-color: var(--accent-yellow);
}
.btn-warning:hover { background: #b88316; color: #fff; text-decoration: none; }

.btn-outline {
  background: transparent; color: var(--admin-text-sec);
  border-color: var(--admin-border);
}
.btn-outline:hover { background: var(--admin-surface3); color: var(--admin-text); text-decoration: none; }

.btn-sm  { padding: .3rem .7rem; font-size: .78rem; }
.btn-lg  { padding: .65rem 1.4rem; font-size: .92rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

.btn-group { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .82rem; font-weight: 600; color: var(--admin-text-sec); margin-bottom: .35rem; }
.form-control {
  display: block; width: 100%;
  padding: .52rem .85rem;
  background: var(--admin-surface2);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-sm);
  color: var(--admin-text); font-size: .875rem; font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none; border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(74,144,196,.2);
}
.form-control::placeholder { color: var(--admin-text-muted); }

/* Invalid-field highlighting (js/forms.js + server-rendered .is-invalid) */
.form-control.is-invalid,
.is-invalid > .form-control { border-color: var(--accent-red); box-shadow: 0 0 0 3px rgba(248,81,73,.2); }
.invalid-msg { display: none; font-size: .75rem; color: var(--accent-red); margin-top: .25rem; font-weight: 500; }
select.form-control { appearance: none; cursor: pointer; }
.form-hint { font-size: .75rem; color: var(--admin-text-muted); margin-top: .25rem; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 180px; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem;
  font-size: .85rem; border: 1px solid transparent;
  display: flex; align-items: flex-start; gap: .6rem;
}
.alert-icon { flex-shrink: 0; width: 1rem; height: 1rem; margin-top: .05rem; }
.alert-info    { background: var(--brand-light); border-color: rgba(74,144,196,.3); color: #79b8e0; }
.alert-success { background: var(--accent-green-bg); border-color: rgba(63,185,80,.3); color: var(--accent-green); }
.alert-warning { background: var(--accent-yellow-bg); border-color: rgba(210,153,34,.3); color: var(--accent-yellow); }
.alert-danger  { background: var(--accent-red-bg); border-color: rgba(248,81,73,.3); color: #ff7b72; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.65);
  z-index: 500; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--admin-surface); border: 1px solid var(--admin-border-lt);
  border-radius: var(--radius); box-shadow: var(--shadow);
  width: calc(100% - 2rem); max-height: 90vh; overflow-y: auto;
  animation: modalIn .18s ease;
}
@keyframes modalIn { from { opacity:0; transform:scale(.96) translateY(-8px); } to { opacity:1; transform:none; } }
.modal-header {
  padding: .9rem 1.2rem; border-bottom: 1px solid var(--admin-border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--admin-surface2);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--admin-text); }
.modal-close {
  background: none; border: none; color: var(--admin-text-muted); cursor: pointer;
  font-size: .9rem; width: 1.8rem; height: 1.8rem; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: rgba(255,255,255,.08); color: var(--admin-text); }
.modal-body { padding: 1.2rem; }
.modal-footer {
  padding: .85rem 1.2rem; border-top: 1px solid var(--admin-border);
  display: flex; justify-content: flex-end; gap: .6rem;
  background: var(--admin-surface2);
}

/* ── Overlay / Sidebar mobile ────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 199;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tab-bar { display: flex; border-bottom: 1px solid var(--admin-border); margin-bottom: 1rem; gap: 0; }
.tab-btn {
  padding: .6rem 1.1rem; background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--admin-text-muted); cursor: pointer; font-size: .85rem; font-weight: 500;
  font-family: inherit; transition: color var(--transition), border-color var(--transition);
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--admin-text); }
.tab-btn.active { color: var(--brand-primary); border-bottom-color: var(--brand-primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Progress bars ───────────────────────────────────────────── */
.progress-bar-wrap { background: var(--admin-surface2); border-radius: 99px; height: 6px; overflow: hidden; flex: 1; }
.progress-bar { height: 100%; border-radius: 99px; background: var(--brand-primary); transition: width .3s ease; }

/* ── Stars display ───────────────────────────────────────────── */
.star-display { display: inline-flex; gap: .1rem; align-items: center; }
.star-filled  { color: var(--accent-yellow); font-size: .9rem; }
.star-empty   { color: var(--admin-surface3); font-size: .9rem; }

/* ── Dashboard specific ──────────────────────────────────────── */
.dash-date { color: var(--admin-text-muted); font-size: .84rem; }
.dash-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1rem; margin-bottom: 1.25rem;
}
@media (max-width: 768px) { .dash-grid { grid-template-columns: 1fr; } }

.group-row { display:flex; align-items:center; gap:.7rem; margin-bottom:.7rem; }
.group-dot { display:inline-block; width:.55rem; height:.55rem; border-radius:50%; flex-shrink:0; }
.group-row-label { font-size:.84rem; color:var(--admin-text); min-width:120px; display:flex; align-items:center; gap:.4rem; }
.group-row-bar-wrap { flex:1; background:var(--admin-surface2); border-radius:99px; height:5px; overflow:hidden; }
.group-row-bar { height:100%; border-radius:99px; transition:width .4s ease; }
.group-row-count { font-size:.84rem; min-width:1.5rem; text-align:right; color:var(--admin-text-sec); font-weight:600; }

.pending-row {
  display:flex; align-items:center; justify-content:space-between;
  padding:.6rem 0; border-bottom:1px solid var(--admin-border);
}
.pending-row:last-child { border-bottom:none; }
.pending-name { font-weight:600; font-size:.88rem; color:var(--admin-text); }
.pending-meta { font-size:.73rem; color:var(--admin-text-muted); margin-top:.1rem; }

/* ── Search bar ──────────────────────────────────────────────── */
.search-bar {
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
  padding: .85rem 1.2rem; background: var(--admin-surface2);
  border-bottom: 1px solid var(--admin-border);
}
.search-bar .form-control { flex: 1; min-width: 160px; max-width: 340px; }
.ls-stats { font-size: .73rem; color: var(--admin-text-muted); margin-left: auto; }

/* ── Check-In Station (checker.php) ─────────────────────────── */
.ck-wrap { max-width: 840px; margin: 0 auto; padding: 1rem; }
.ck-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.2rem; flex-wrap: wrap; gap: .5rem;
  padding: .9rem 0;
}
.ck-header h1 { font-size: 1.3rem; font-weight: 700; color: var(--admin-text); }

.method-tabs { display: flex; gap: .4rem; margin-bottom: 1rem; }
.method-tab {
  flex: 1; text-align: center; padding: .6rem .5rem;
  border-radius: var(--radius-sm); background: var(--admin-surface2);
  border: 1px solid var(--admin-border); cursor: pointer;
  font-weight: 600; font-size: .82rem; color: var(--admin-text-muted);
  transition: all var(--transition);
}
.method-tab:hover { background: var(--admin-surface3); color: var(--admin-text); }
.method-tab.active { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }

/* Camera viewer */
.camera-box {
  position: relative; background: #111; border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 4/3; max-height: 360px;
}
/* Video fills the box — this is the live feed the user sees */
.camera-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Canvas sits transparently on top — ONLY draws the green detection box,
   does NOT drawImage() the video frame (that would black-out the live feed) */
.camera-box canvas {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
}
.camera-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: #fff; pointer-events: none;
}
.scan-frame {
  width: 200px; height: 200px; border: 2px solid rgba(255,255,255,.85); border-radius: 12px;
  box-shadow: 0 0 0 2000px rgba(0,0,0,.35);
}
.scan-label {
  margin-top: 1.2rem; font-size: .85rem; background: rgba(0,0,0,.55);
  padding: .3rem .85rem; border-radius: 99px; letter-spacing: .01em;
}

.result-panel { animation: fadeIn .2s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }

/* ── QR Code display ──────────────────────────────────────────── */
.qr-display {
  display: flex; justify-content: center; align-items: center;
  background: #fff; padding: 1.25rem; border-radius: 8px;
  margin: 1rem 0;
}
.qr-display canvas, .qr-display img { display: block !important; }

/* ── SearchSelect widget ─────────────────────────────────────── */
.ss-wrap { position: relative; }
.ss-input { cursor: text; }
.ss-input.ss-has-value { font-weight: 500; color: var(--admin-text); }
.ss-dropdown {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 400;
  background: var(--admin-surface); border: 1px solid var(--admin-border-lt);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  max-height: 230px; overflow-y: auto; box-shadow: var(--shadow);
}
.ss-dropdown.open { display: block; }
.ss-item {
  padding: .52rem .9rem; cursor: pointer; font-size: .85rem;
  border-bottom: 1px solid rgba(48,54,61,.5); color: var(--admin-text);
  transition: background var(--transition);
}
.ss-item:last-child { border-bottom: none; }
.ss-item:hover, .ss-item.ss-active { background: var(--admin-surface2); }
.ss-item.ss-selected { color: var(--brand-primary); font-weight: 600; }
.ss-item mark { background: none; color: var(--brand-primary); font-weight: 700; padding: 0; }
.ss-no-results { padding: .52rem .9rem; font-size: .82rem; color: var(--admin-text-muted); font-style: italic; }
.ss-clear {
  position: absolute; right: .6rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--admin-text-muted); cursor: pointer;
  font-size: .75rem; padding: .1rem .3rem; border-radius: 3px; line-height: 1;
  transition: color var(--transition); display: none; z-index: 1;
}
.ss-clear:hover { color: var(--accent-red); }
.ss-wrap:has(.ss-input.ss-has-value) .ss-clear { display: block; }

/* Cards clip content (overflow:hidden) for rounded corners, which cuts off
   an open search-select dropdown when it sits in a short filter card.
   Let any card containing a search-select show its overflow so the
   dropdown can extend past the card edge. */
.card:has(.ss-wrap) { overflow: visible; }

/* ── Pagination ───────────────────────────────────────────────── */
.pagination { display: flex; gap: .3rem; flex-wrap: wrap; padding: .75rem 1.2rem; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: var(--radius-sm);
  font-size: .82rem; border: 1px solid var(--admin-border); color: var(--admin-text-sec);
}
.pagination a { cursor: pointer; }
.pagination a:hover { background: var(--admin-surface3); text-decoration: none; color: var(--admin-text); }
.pagination .current { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }
.pagination .pg-disabled { opacity: .4; pointer-events: none; }
.pagination .pg-gap { border-color: transparent; color: var(--admin-text-muted); }

/* ── Login page ───────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  flex-direction: column; padding: 1.5rem; background: var(--admin-bg);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--admin-surface); border: 1px solid var(--admin-border);
  border-radius: 10px; padding: 2.2rem 2rem; box-shadow: var(--shadow);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo img { height: 56px; width: auto; margin: 0 auto .9rem; }
.login-logo h1 { font-size: 1.35rem; font-weight: 700; color: var(--admin-text); }
.login-logo p  { color: var(--admin-text-muted); font-size: .88rem; margin-top: .25rem; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile & Tablet
   Breakpoints: 900px tablet, 640px phone, 400px tiny
   ══════════════════════════════════════════════════════════════ */

/* ── Tablet & small laptop (≤ 900px) ─────────────────────────── */
@media (max-width: 900px) {
  /* Sidebar slides off-screen — toggled via JS .open class */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,.6);
    z-index: 300;
  }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 299; }
  .sidebar-overlay.open { display: block; }

  /* Content fills full width */
  .main-content { margin-left: 0 !important; }

  /* Hamburger visible */
  .hamburger { display: flex !important; }

  .content-area { padding: 1rem; }
  .dash-grid { grid-template-columns: 1fr; }
}

/* ── Phone (≤ 640px) ─────────────────────────────────────────── */
@media (max-width: 640px) {
  html { font-size: 14px; }

  /* === TOPBAR === */
  .topbar { padding: .55rem .8rem; gap: .5rem; }
  .topbar-title { font-size: .88rem; }
  /* Hide name, keep role badge, hide account/logout (in sidebar) */
  .topbar-user strong { display: none; }
  .topbar-right > a.btn { display: none; }

  /* === CONTENT AREA === */
  .content-area { padding: .65rem; }

  /* === PAGE HEADER — stack vertically === */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: .5rem;
    margin-bottom: .9rem;
  }
  .page-header h1 { font-size: 1.05rem; }
  .page-header-meta { font-size: .74rem; }
  .page-header .btn-group {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
  }
  .page-header .btn-group .btn { flex: 1; min-width: 100px; text-align: center; }

  /* === STAT CARDS — 2 per row === */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: .55rem;
    margin-bottom: 1rem;
  }
  .stat-card { padding: .7rem .75rem; gap: .5rem; }
  .stat-icon { width: 1.9rem; height: 1.9rem; }
  .stat-icon svg { width: .9rem; height: .9rem; }
  .stat-body .stat-label { font-size: .62rem; }
  .stat-body .stat-value { font-size: 1.25rem; }

  /* === CARDS === */
  .card { margin-bottom: .9rem; }
  .card-header {
    padding: .65rem .9rem;
    flex-wrap: wrap;
    gap: .4rem;
  }
  .card-header h2 { font-size: .9rem; }
  .card-body { padding: .75rem .9rem !important; }
  .card-footer { padding: .65rem .9rem; flex-wrap: wrap; gap: .4rem; }

  /* === TABLES — scroll horizontally === */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0;
    /* Force scroll hint on mobile */
    background:
      linear-gradient(to right, var(--admin-surface) 30%, rgba(22,27,34,0)),
      linear-gradient(to right, rgba(22,27,34,0), var(--admin-surface) 70%)
      0 100%,
      radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.3), transparent),
      radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.3), transparent)
      0 100%;
    background-repeat: no-repeat;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
  }
  .data-table th,
  .data-table td {
    white-space: nowrap;
    font-size: .78rem;
    padding: .5rem .6rem;
  }
  /* Remove any min-widths that prevent scroll */
  .data-table { min-width: unset; }

  /* Hide less-important columns on phones via class */
  .data-table .col-hide-phone { display: none; }

  /* ── Stacked card layout (class="data-table stacked-mobile") ──
     Each row becomes a card: column headers move into per-cell
     labels (set by JS), actions sit full-width at the bottom. */
  .data-table.stacked-mobile,
  .data-table.stacked-mobile tbody,
  .data-table.stacked-mobile tr,
  .data-table.stacked-mobile td { display: block; width: 100%; }
  .data-table.stacked-mobile thead { display: none; }
  .data-table.stacked-mobile tr {
    background: var(--admin-surface);
    border: 1px solid var(--admin-border);
    border-radius: 10px;
    margin-bottom: .7rem;
    overflow: hidden;
  }
  .data-table.stacked-mobile tbody tr:hover td { background: transparent; }
  .data-table.stacked-mobile td {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; text-align: right;
    white-space: normal !important;
    border: none !important;
    border-bottom: 1px solid rgba(48,54,61,.5) !important;
    padding: .55rem .85rem !important;
    font-size: .82rem;
  }
  .data-table.stacked-mobile td::before {
    content: attr(data-label);
    flex: 0 0 38%; text-align: left;
    font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--admin-text-muted);
  }
  /* Actions cell → full-width button row, no label, sits at card bottom */
  .data-table.stacked-mobile td:last-child {
    justify-content: flex-start; gap: .4rem; flex-wrap: wrap;
    text-align: left;
    border-bottom: none !important;
    border-top: 1px solid var(--admin-border) !important;
    background: var(--admin-surface2);
    padding: .6rem .85rem !important;
  }
  .data-table.stacked-mobile td:last-child::before { content: none; }
  /* "No data" / empty rows: show as a plain centred card, no label */
  .data-table.stacked-mobile td.no-data { justify-content: center; text-align: center; }
  .data-table.stacked-mobile td.no-data::before { content: none; }

  /* === FORMS === */
  .form-row { flex-direction: column; gap: 0; }
  .form-row .form-group { width: 100%; }
  .form-group { margin-bottom: .7rem; }
  .form-control { font-size: .9rem; padding: .5rem .75rem; }
  .form-label { font-size: .78rem; }

  /* === SEARCH BAR === */
  .search-bar {
    padding: .6rem .9rem;
    gap: .4rem;
  }
  .search-bar .form-control {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }
  .ls-stats { margin-left: 0; width: 100%; }

  /* === FILTER BARS (inside cards) === */
  .filter-bar,
  .card-body form[method="GET"] {
    flex-direction: column;
    align-items: stretch;
    gap: .5rem;
  }
  .card-body form[method="GET"] .form-group { min-width: 0 !important; width: 100%; }
  .card-body form[method="GET"] select,
  .card-body form[method="GET"] input { width: 100% !important; max-width: 100% !important; }
  .card-body form[method="GET"] button,
  .card-body form[method="GET"] a.btn { width: 100%; text-align: center; }

  /* === MODALS — slide up from bottom === */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal,
  .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideUp .22s ease !important;
  }
  @keyframes modalSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }
  .modal-footer {
    flex-direction: column-reverse;
    gap: .4rem;
  }
  .modal-footer .btn { width: 100%; text-align: center; justify-content: center; }

  /* === BUTTONS === */
  .btn-group { flex-wrap: wrap; gap: .3rem; }
  .btn { padding: .45rem .75rem; font-size: .83rem; }
  .btn-sm { padding: .3rem .55rem; font-size: .73rem; }
  .btn-lg { padding: .75rem 1.2rem; font-size: 1rem; }

  /* === PAGINATION === */
  .pagination { padding: .55rem .9rem; gap: .2rem; flex-wrap: wrap; }
  .pagination a,
  .pagination .current { padding: .35rem .55rem; font-size: .75rem; min-width: 1.75rem; }

  /* === GRIDS — all collapse to single column === */
  .perf-grid,
  .mci-grid,
  .charts-grid,
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 340px"],
  [style*="grid-template-columns: 1fr 320px"],
  [style*="grid-template-columns: 1fr 330px"],
  [style*="grid-template-columns: 1fr 360px"] {
    grid-template-columns: 1fr !important;
  }

  /* === ROLE BADGES — smaller === */
  .role-badge { font-size: .6rem; padding: .12rem .4rem; }

  /* === BADGE === */
  .badge { font-size: .65rem; padding: .15rem .45rem; }

  /* === EXPORT FIELD LIST — single column === */
  .export-field-list { grid-template-columns: 1fr; }

  /* === CALENDAR HEATMAP === */
  .cal-grid { grid-template-columns: repeat(7, 20px); gap: 2px; }
  .cal-cell { width: 20px; height: 20px; font-size: .52rem; border-radius: 3px; }
  .cal-dow  { font-size: .52rem; }

  /* === PERFORMANCE stars page === */
  .star-btn, .sstar-btn { font-size: 1.1rem; }

  /* === QR display === */
  .qr-display { text-align: center; }
  .qr-display img { max-width: 220px; margin: 0 auto; }

  /* === Facilitator check-in tabs === */
  .mode-tab   { padding: .75rem .5rem; font-size: .85rem; }
  .method-tab { padding: .5rem .3rem;  font-size: .76rem; }
}

/* ── Very tiny phones (≤ 400px) ─────────────────────────────── */
@media (max-width: 400px) {
  html { font-size: 13px; }
  .stats-grid { grid-template-columns: 1fr; }
  .content-area { padding: .5rem; }
  .topbar { padding: .5rem .6rem; }
}
