:root {
  --primary: #7C6FF7;
  --primary-dark: #5A52D5;
  --primary-glow: rgba(124, 111, 247, 0.25);
  --accent: #FF6B9D;
  --success: #4ECB71;
  --success-bg: rgba(78, 203, 113, 0.15);
  --danger: #FF5C5C;
  --danger-bg: rgba(255, 92, 92, 0.15);
  --warning: #FFB547;
  --bg: #0D0C1D;
  --bg2: #111027;
  --surface: #1A1835;
  --surface2: #231F3D;
  --surface3: #2D284F;
  --glass: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text: #FFFFFF;
  --text-secondary: rgba(255, 255, 255, 0.55);
  --text-muted: rgba(255, 255, 255, 0.3);
  --radius: 18px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --nav-height: 72px;
  --header-height: 60px;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ── SCROLLBAR ─────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 2px; }

/* ── HEADER ────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: linear-gradient(135deg, #0D0C1D 0%, #1A1835 100%);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  z-index: 100;
  backdrop-filter: blur(20px);
}

.app-header .logo {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.app-header h1 {
  font-size: 18px; font-weight: 700;
  background: linear-gradient(135deg, #fff 0%, var(--primary) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  flex: 1;
}

.header-action {
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; padding: 8px; border-radius: var(--radius-xs);
  font-size: 20px; transition: color 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.header-action:active { color: var(--primary); }

/* ── BOTTOM NAV ────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid var(--glass-border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted);
  font-size: 10px; font-weight: 600; letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: color 0.2s;
  padding-bottom: 4px;
}

.nav-item .nav-icon {
  font-size: 22px;
  transition: transform 0.2s;
}

.nav-item.active { color: var(--primary); }
.nav-item.active .nav-icon { transform: translateY(-2px); }

/* ── MAIN CONTENT ──────────────────────────────── */
.main-content {
  padding-top: var(--header-height);
  padding-bottom: calc(var(--nav-height) + 16px);
  min-height: 100dvh;
}

.tab-panel { display: none; padding: 20px 16px; }
.tab-panel.active { display: block; }

/* ── SECTION TITLE ─────────────────────────────── */
.section-title {
  font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px; margin-top: 24px;
}
.section-title:first-child { margin-top: 0; }

/* ── CARDS ─────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card-glass {
  background: var(--glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 16px;
}

/* ── BUTTONS ───────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px;
  border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all 0.18s;
  white-space: nowrap;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow);
}
.btn-primary:active { transform: scale(0.97); box-shadow: 0 2px 8px var(--primary-glow); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--glass-border);
  color: var(--text-secondary);
}
.btn-outline:active { border-color: var(--primary); color: var(--primary); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(255,92,92,0.2);
}
.btn-danger:active { background: rgba(255,92,92,0.3); }

.btn-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(78,203,113,0.2);
}

.btn-full { width: 100%; }

.btn-sm {
  padding: 7px 12px;
  font-size: 12px; border-radius: var(--radius-xs);
}

.btn-icon {
  padding: 9px; border-radius: var(--radius-xs);
  background: var(--glass); border: 1px solid var(--glass-border);
  color: var(--text-secondary); cursor: pointer;
  font-size: 16px; line-height: 1;
  transition: all 0.15s;
}
.btn-icon:active { color: var(--danger); border-color: var(--danger); }

/* ── ACTION GRID ───────────────────────────────── */
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

/* ── MEMBER LIST ───────────────────────────────── */
.member-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.member-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
  text-transform: uppercase;
}

.member-info { flex: 1; min-width: 0; }
.member-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-sub { font-size: 11px; color: var(--text-muted); }

/* ── SESSION CARD ──────────────────────────────── */
.session-card {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}

.session-card::before {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 3px; height: 100%;
  background: linear-gradient(to bottom, var(--primary), var(--accent));
}

.session-date {
  font-size: 16px; font-weight: 700; margin-bottom: 2px;
}

.session-name {
  font-size: 12px; color: var(--text-secondary); margin-bottom: 10px;
}

.session-stats {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
}

.stat-badge {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 600;
}

.stat-badge.present { color: var(--success); }
.stat-badge.absent { color: var(--danger); }

.progress-bar {
  height: 4px;
  background: var(--surface3);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(to right, var(--success), #2ECC71);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.session-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}

/* ── STATS ROW ─────────────────────────────────── */
.stats-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 10px; margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
}

.stat-card .value {
  font-size: 28px; font-weight: 800; line-height: 1;
  margin-bottom: 4px;
}

.stat-card .label {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}

/* ── EMPTY STATE ───────────────────────────────── */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; line-height: 1.5; }

/* ── MODAL ─────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: flex-end;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal-sheet {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 90dvh;
  overflow-y: auto;
}

.modal-overlay.open .modal-sheet { transform: translateY(0); }

.modal-handle {
  width: 36px; height: 4px;
  background: var(--surface3);
  border-radius: 2px;
  margin: 0 auto 20px;
}

.modal-title {
  font-size: 17px; font-weight: 700; margin-bottom: 16px;
}

/* ── FORM ──────────────────────────────────────── */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px; font-family: inherit;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus { border-color: var(--primary); }
.form-control::placeholder { color: var(--text-muted); }

input[type="date"].form-control::-webkit-calendar-picker-indicator {
  filter: invert(0.5);
}

/* ── TOAST ─────────────────────────────────────── */
#toast-container {
  position: fixed; top: calc(var(--header-height) + 10px);
  left: 16px; right: 16px;
  z-index: 300; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  display: flex; align-items: center; gap: 10px;
  animation: toastIn 0.3s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--primary); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-10px); }
}

/* ── FILE INPUT ────────────────────────────────── */
.file-drop {
  border: 2px dashed var(--glass-border);
  border-radius: var(--radius);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.file-drop:hover, .file-drop.drag-over {
  border-color: var(--primary);
  background: var(--primary-glow);
}

.file-drop input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

.file-drop-icon { font-size: 36px; margin-bottom: 10px; }
.file-drop-text { font-size: 14px; color: var(--text-secondary); }
.file-drop-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── CHIP ──────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px; font-weight: 600;
}

.chip-primary { background: var(--primary-glow); color: var(--primary); }
.chip-success { background: var(--success-bg); color: var(--success); }
.chip-danger { background: var(--danger-bg); color: var(--danger); }

/* ── SEARCH ────────────────────────────────────── */
.search-wrap {
  position: relative; margin-bottom: 12px;
}

.search-wrap .icon {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); font-size: 16px; pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; font-family: inherit;
  padding: 10px 12px 10px 38px;
  outline: none; transition: border-color 0.2s;
}

.search-input:focus { border-color: var(--primary); }
.search-input::placeholder { color: var(--text-muted); }

/* ── TOGGLE ────────────────────────────────────── */
.toggle {
  width: 44px; height: 26px;
  background: var(--surface3);
  border-radius: 13px;
  position: relative; cursor: pointer;
  border: none; transition: background 0.25s;
  flex-shrink: 0;
}

.toggle::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.25s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.toggle.on { background: var(--success); }
.toggle.on::after { transform: translateX(18px); }

/* ── LOADER ────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── DESKTOP TWEAKS ────────────────────────────── */
@media (min-width: 600px) {
  .tab-panel { max-width: 640px; margin: 0 auto; }
  .action-grid { grid-template-columns: repeat(4, 1fr); }
}
