/* ==========================================================================
   SWEATBOX Internal Web — dark + gold, mobile view
   ========================================================================== */
:root {
  --bg: #111111;
  --accent: #FFD600;
  --accent-dim: #cbaa00;
  --card: #1F2937;
  --card-2: #232833;
  --card-3: #2C313C;
  --line: #333a46;
  --text: #ffffff;
  --text-gray: #9CA3AF;
  --text-dim: #6b7280;
  --success: #10B981;
  --warning: #F59E0B;
  --error: #EF4444;
  --info: #3B82F6;
  --radius: 16px;
  --radius-sm: 12px;
  --frame: 430px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
  background: #000;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* phone frame centered on desktop, fullscreen on mobile */
#app {
  position: relative;
  width: 100%;
  max-width: var(--frame);
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 500px) {
  body { padding: 0; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 50% 0%, #1a1a1a, #000 70%); }
  #app {
    height: min(920px, 96dvh);
    border-radius: 34px;
    box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 0 10px #1c1c1e, 0 0 0 11px #333;
    overflow: hidden;
  }
}

/* ---------- scroll content ---------- */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 26px;
  -webkit-overflow-scrolling: touch;
}
.content::-webkit-scrollbar { width: 0; }

/* ---------- header ---------- */
.app-header {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
  padding: 16px 14px 12px;
  background: #151515;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.header-title { font-size: 16px; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: .5px; flex: 1; text-align: center; }
.header-spacer, .header-right { width: 38px; display: inline-flex; justify-content: center; }
.icon-btn {
  width: 38px; height: 38px; border: none; background: transparent; color: var(--text);
  border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(255,255,255,.06); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  flex: 0 0 auto;
  display: flex;
  background: #171717;
  border-top: 1px solid rgba(255,255,255,.06);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-decoration: none; color: var(--text-gray); font-size: 11px; font-weight: 500;
  padding: 6px 0; border-radius: 10px;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--accent); }

/* ---------- generic ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
}
.hint { color: var(--text-gray); font-size: 12.5px; text-align: center; margin-top: 10px; }
.warn-text { color: var(--warning); }

.center-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 48px 16px; gap: 10px; color: var(--text-gray);
}
.center-state h3 { color: var(--text); font-size: 17px; }
.center-state p { font-size: 13.5px; max-width: 260px; }
.state-icon { width: 64px; height: 64px; color: var(--text-dim); }
.state-icon svg { width: 100%; height: 100%; }

.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.15);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.mini-empty { color: var(--text-gray); text-align: center; font-size: 13.5px; padding: 20px; }

/* ---------- buttons ---------- */
.btn {
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  font-family: inherit; font-weight: 600; font-size: 15px; padding: 13px 18px;
  transition: transform .05s, opacity .15s; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #111; }
.btn-primary:hover { background: #ffdf33; }
.btn-ghost { background: transparent; color: var(--text-gray); border: 1px solid var(--line); }
.btn-danger { background: var(--error); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--accent); color: var(--accent); }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.link-btn { background: none; border: none; color: var(--accent); font-family: inherit;
  font-size: 13px; cursor: pointer; align-self: flex-end; padding: 2px 0; }

/* ---------- fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--text-gray); font-weight: 500; }
.field input {
  background: var(--card-3); border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 13px 14px; color: var(--text); font-family: inherit; font-size: 15px; width: 100%;
}
.field input:focus { outline: none; border-color: var(--accent); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 46px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-gray); cursor: pointer; padding: 8px; }
.pw-toggle svg { width: 20px; height: 20px; }
.form-card { padding: 20px; }

/* ==========================================================================
   AUTH
   ========================================================================== */
.screen-auth { justify-content: flex-start; }
.auth-bg {
  position: absolute; inset: 0;
  background: url('../assets/bg_login.jpg') center/cover no-repeat;
  filter: grayscale(.2);
}
.auth-overlay { position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(17,17,17,.55) 0%, rgba(17,17,17,.85) 55%, #111 100%); }
.auth-content {
  position: relative; z-index: 2; flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; padding: 42px 24px 24px;
}
.auth-brand { text-align: center; margin-bottom: auto; padding-top: 24px; }
.auth-logo { width: 150px; max-width: 60%; height: auto; margin: 0 auto; display: block; }
.auth-tagline { color: var(--accent); font-size: 13px; margin-top: 12px; letter-spacing: .3px; }
.auth-card {
  background: rgba(24,24,27,.9); backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 22px; padding: 24px 20px; display: flex; flex-direction: column;
  margin-top: 32px;
}
.auth-card h2 { font-size: 22px; }
.auth-sub { color: var(--text-gray); font-size: 13px; margin: 4px 0 20px; }
.auth-card .btn-primary { margin-top: 18px; }
.auth-foot { text-align: center; color: var(--text-dim); font-size: 11px; margin-top: 20px; }

/* ==========================================================================
   GREETING / DATE
   ========================================================================== */
.greeting { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.greeting-hi { color: var(--text-gray); font-size: 13px; }
.greeting-name { font-size: 20px; font-weight: 700; }
.today-date { color: var(--text-gray); font-size: 13px; margin: 8px 0 16px; }

.avatar {
  border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #111; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}

/* ==========================================================================
   STAFF CLOCK
   ========================================================================== */
.clock-face { text-align: center; padding: 26px 16px; margin-bottom: 14px; }
.clock-time { font-size: 44px; font-weight: 700; letter-spacing: 1px; font-variant-numeric: tabular-nums; }
.clock-status { margin-top: 8px; font-size: 13px; color: var(--text-gray);
  display: inline-block; padding: 4px 14px; border-radius: 20px; background: var(--card-3); }
.clock-status.active { color: var(--success); }
.clock-status.done { color: var(--accent); }

.chips-row { display: flex; gap: 12px; margin-bottom: 14px; }
.time-chip { flex: 1; background: var(--card); border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 4px; align-items: center; }
.chip-label { font-size: 12px; color: var(--text-gray); }
.chip-value { font-size: 22px; font-weight: 700; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.chip-value.ok { color: var(--text); }

.location-card { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.location-card.ok { border: 1px solid rgba(16,185,129,.4); }
.location-card.warn { border: 1px solid rgba(245,158,11,.4); }
.location-card.err { border: 1px solid rgba(239,68,68,.4); }
.loc-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--card-3);
  display: flex; align-items: center; justify-content: center; color: var(--accent); flex: 0 0 auto; }
.loc-icon svg { width: 22px; height: 22px; }
.loc-body { flex: 1; min-width: 0; }
.loc-title { font-weight: 600; font-size: 14px; }
.loc-sub { font-size: 12px; color: var(--text-gray); margin-top: 2px; }

.clock-btn {
  width: 100%; border: none; border-radius: 18px; cursor: pointer; font-family: inherit;
  font-weight: 700; font-size: 18px; padding: 20px; display: flex; align-items: center;
  justify-content: center; gap: 10px; color: #111;
}
.clock-btn svg { width: 24px; height: 24px; }
.clock-btn.clock-in { background: var(--accent); }
.clock-btn.clock-out { background: var(--error); color: #fff; }
.clock-btn.done { background: var(--card-3); color: var(--text-gray); }
.clock-btn:disabled { opacity: .5; cursor: not-allowed; }
.clock-btn:active:not(:disabled) { transform: scale(.99); }

/* ==========================================================================
   HISTORY
   ========================================================================== */
.hist-list { display: flex; flex-direction: column; gap: 12px; }
.hist-card { padding: 14px 16px; }
.hist-date { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.hist-day { font-weight: 600; font-size: 14px; }
.hist-branch { color: var(--text-gray); font-size: 12px; }
.badge { font-size: 10.5px; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.badge-warn { background: rgba(245,158,11,.18); color: var(--warning); }
.hist-times { display: flex; align-items: center; gap: 12px; }
.hist-time { display: flex; flex-direction: column; }
.hist-time .lbl { font-size: 11px; color: var(--text-gray); }
.hist-time .val { font-size: 18px; font-weight: 700; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.hist-time .val.ok { color: var(--text); }
.hist-divider { width: 1px; height: 28px; background: var(--line); }
.hist-status { margin-left: auto; font-size: 12px; color: var(--accent); font-weight: 600; }

/* ==========================================================================
   COACH CLASSES
   ========================================================================== */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 10px; }
.section-head h3 { font-size: 15px; font-weight: 700; }
.count-pill { background: var(--card-3); color: var(--text-gray); font-size: 12px;
  padding: 3px 12px; border-radius: 20px; font-weight: 600; }
.date-group-label { color: var(--accent); font-size: 12.5px; font-weight: 600; margin: 14px 0 8px; }

.class-list { display: flex; flex-direction: column; gap: 12px; }
.class-card {
  width: 100%; text-align: left; border: none; cursor: pointer; font-family: inherit;
  color: var(--text); display: flex; flex-direction: column; gap: 10px;
}
.class-card:active { transform: scale(.995); }
.cc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cc-name { font-weight: 700; font-size: 15px; }
.cc-meta { display: flex; flex-wrap: wrap; gap: 12px; color: var(--text-gray); font-size: 12px; }
.cc-meta span { display: inline-flex; align-items: center; gap: 4px; }
.cc-meta svg { width: 14px; height: 14px; }

.chip { font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 10px; }
.chip-done { background: rgba(156,163,175,.18); color: var(--text-gray); }
.chip-live { background: rgba(16,185,129,.18); color: var(--success); }

.occupancy { display: flex; align-items: center; gap: 10px; }
.occ-bar { flex: 1; height: 8px; border-radius: 8px; background: var(--card-3); overflow: hidden; }
.occ-fill { height: 100%; border-radius: 8px; }
.occ-fill.ok { background: var(--success); }
.occ-fill.warn { background: var(--warning); }
.occ-fill.full { background: var(--error); }
.occ-label { font-size: 12px; font-weight: 600; color: var(--text-gray); white-space: nowrap; }
.occ-label.warn { color: var(--warning); }
.occ-label.full { color: var(--error); }

/* ---------- class detail ---------- */
.class-hero { margin-bottom: 16px; display: flex; flex-direction: column; gap: 10px; }
.ch-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ch-top h2 { font-size: 19px; }
.ch-meta { display: flex; flex-wrap: wrap; gap: 12px; color: var(--text-gray); font-size: 12.5px; }
.ch-meta span { display: inline-flex; align-items: center; gap: 4px; }
.ch-meta svg { width: 15px; height: 15px; }

.action-grid { display: flex; gap: 12px; margin-bottom: 4px; }
.action-tile {
  flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 8px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--text); cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600;
}
.action-tile:active { transform: scale(.98); }
.at-icon { width: 26px; height: 26px; color: var(--accent); }
.at-icon svg { width: 100%; height: 100%; }

.participant-list { display: flex; flex-direction: column; gap: 10px; }
.participant { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.participant.present { border: 1px solid rgba(16,185,129,.3); }
.p-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.p-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-sub { font-size: 12px; color: var(--text-gray); }
.present-badge { display: inline-flex; align-items: center; gap: 4px; color: var(--success);
  font-size: 12px; font-weight: 700; }
.present-badge svg { width: 15px; height: 15px; }
.absent-badge { font-size: 12px; color: var(--text-dim); }

.finish-btn { margin-top: 20px; }

/* ==========================================================================
   QR SCAN-IN
   ========================================================================== */
.qr-info { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.qr-class { color: var(--accent); font-weight: 700; font-size: 15px; }
.qr-meta { color: var(--text-gray); font-size: 12.5px; display: inline-flex; gap: 12px; align-items: center; }
.qr-meta svg { width: 14px; height: 14px; vertical-align: -2px; }
.qr-frame {
  background: #fff; border-radius: 20px; padding: 18px; margin: 0 auto 20px; width: fit-content;
  box-shadow: 0 0 40px rgba(255,214,0,.25);
}
.qr-frame svg { display: block; width: 240px; height: 240px; }
.qr-status {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  background: var(--card); border-radius: var(--radius); border: 1.5px solid var(--info); margin-bottom: 16px;
}
.qr-status.success { border-color: var(--success); }
.qr-status.timeout { border-color: var(--error); }
.qs-icon { width: 40px; height: 40px; border-radius: 50%; background: rgba(59,130,246,.2);
  display: flex; align-items: center; justify-content: center; color: var(--info); flex: 0 0 auto; font-size: 20px; }
.qr-status.success .qs-icon { background: rgba(16,185,129,.2); color: var(--success); }
.qr-status.timeout .qs-icon { background: rgba(239,68,68,.2); color: var(--error); }
.qs-icon svg { width: 22px; height: 22px; }
.qs-text { flex: 1; display: flex; flex-direction: column; }
.qs-title { font-weight: 600; font-size: 14px; }
.qs-sub { font-size: 12px; color: var(--text-gray); }
.qs-timer { font-size: 14px; font-weight: 700; color: var(--text-gray); font-variant-numeric: tabular-nums; }
.qs-timer.warn { color: var(--warning); }
.qr-instruction { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qr-instruction svg { width: 32px; height: 32px; color: var(--accent); }
.qr-instruction h3 { font-size: 15px; }
.qr-instruction p { color: var(--text-gray); font-size: 12.5px; }

/* ==========================================================================
   PROFILE
   ========================================================================== */
.profile-hero { text-align: center; padding: 20px 0 24px; display: flex;
  flex-direction: column; align-items: center; gap: 10px; }
.profile-hero h2 { font-size: 20px; }
.role-badge { background: var(--accent); color: #111; font-size: 11px; font-weight: 700;
  padding: 4px 14px; border-radius: 20px; letter-spacing: .5px; }
.profile-list { padding: 4px 16px; margin-bottom: 16px; }
.profile-row { display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,.05); gap: 12px; }
.profile-row:last-child { border-bottom: none; }
.pr-label { color: var(--text-gray); font-size: 13px; }
.pr-value { font-size: 13.5px; font-weight: 500; text-align: right; word-break: break-word; }
.menu-row {
  display: flex; align-items: center; gap: 14px; padding: 16px; margin-bottom: 12px;
  text-decoration: none; color: var(--text); border: none; width: 100%; cursor: pointer;
  font-family: inherit; font-size: 14.5px; font-weight: 500; background: var(--card);
}
.menu-row.danger { color: var(--error); }
.mr-icon { width: 22px; height: 22px; color: var(--accent); flex: 0 0 auto; }
.menu-row.danger .mr-icon { color: var(--error); }
.mr-icon svg { width: 100%; height: 100%; }
.mr-text { flex: 1; text-align: left; }
.mr-chev { width: 20px; height: 20px; color: var(--text-dim); }
.mr-chev svg { width: 100%; height: 100%; }
.app-version { text-align: center; color: var(--text-dim); font-size: 11px; margin-top: 10px; }

/* ==========================================================================
   MODAL / TOAST / LOADING / CAMERA
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; padding: 22px;
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.modal-backdrop.show { opacity: 1; pointer-events: auto; }
.modal {
  width: 100%; max-width: 380px; background: var(--card-2); border-radius: 20px; padding: 22px;
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.94); opacity: .6; } to { transform: scale(1); opacity: 1; } }
.modal h3 { font-size: 18px; margin-bottom: 8px; }
.modal p { color: var(--text-gray); font-size: 13.5px; margin-bottom: 16px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-actions .btn { flex: 1; }
.modal-tall { display: flex; flex-direction: column; max-height: 80dvh; }

.search-wrap { position: relative; margin-bottom: 12px; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text-gray); }
.search-wrap input { width: 100%; background: var(--card-3); border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: 12px 12px 12px 40px; color: var(--text);
  font-family: inherit; font-size: 14px; }
.search-wrap input:focus { outline: none; border-color: var(--accent); }
.wi-results { flex: 1; overflow-y: auto; min-height: 120px; margin-bottom: 8px; }
.wi-hint { color: var(--text-gray); font-size: 13px; text-align: center; padding: 24px 8px; }
.wi-item { display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,.05); }
.wi-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wi-name { font-weight: 600; font-size: 14px; }
.wi-sub { font-size: 12px; color: var(--text-gray); }

#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  z-index: 90; background: var(--card-3); color: var(--text); padding: 12px 20px;
  border-radius: 12px; font-size: 13.5px; font-weight: 500; max-width: 88%; text-align: center;
  opacity: 0; pointer-events: none; transition: all .25s; box-shadow: 0 10px 30px rgba(0,0,0,.4);
  border-left: 3px solid var(--info);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.toast-success { border-left-color: var(--success); }
#toast.toast-error { border-left-color: var(--error); }
#toast.toast-info { border-left-color: var(--info); }

#loading-overlay {
  position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.55);
  display: none; align-items: center; justify-content: center; backdrop-filter: blur(2px);
}
#loading-overlay.show { display: flex; }
.loading-box { background: var(--card-2); border-radius: 18px; padding: 26px 34px;
  display: flex; flex-direction: column; align-items: center; gap: 14px; }
.loading-text { font-size: 13.5px; color: var(--text-gray); }

/* camera */
.camera-modal .camera-box { width: 100%; max-width: 400px; background: var(--card-2);
  border-radius: 20px; padding: 16px; }
.camera-head { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; font-weight: 600; font-size: 15px; }
.camera-head .icon-btn { font-size: 18px; }
.camera-view { position: relative; width: 100%; aspect-ratio: 3/4; background: #000;
  border-radius: 14px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.camera-view video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-fallback { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--text-gray); }
.cam-fallback svg { width: 48px; height: 48px; }
.camera-actions { margin-top: 14px; }
.camera-hint { color: var(--text-dim); font-size: 11.5px; text-align: center; margin-top: 10px; }

/* reduce motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* focus visible */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
