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

:root {
  --primary:   #0B3B3A;
  --primary-l: #0f5251;
  --accent:    #E8A020;
  --accent-l:  #f5b340;
  --white:     #FFFFFF;
  --bg:        #F3F4F6;
  --card:      #FFFFFF;
  --border:    #E5E7EB;
  --text:      #1F2937;
  --muted:     #6B7280;
  --danger:    #B91C1C;
  --danger-bg: #FEF2F2;
  --success:   #15803D;
  --success-bg:#F0FDF4;
  --warn-bg:   #FFFBEB;
  --warn:      #B45309;
  --purple:    #6D28D9;
  --purple-bg: #F5F3FF;
  --radius:    10px;
  --shadow:    0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);
  --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
}

/* ── LOGIN SCREEN ──────────────────────────────────────────── */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  background: linear-gradient(135deg, #0B3B3A 0%, #0f5251 60%, #1a6b69 100%);
}

.login-card {
  background: var(--white);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .wordmark {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.04em;
}

.login-logo .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.login-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
}

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus { border-color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary   { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-l); }
.btn-accent    { background: var(--accent); color: #1a0f00; }
.btn-accent:hover { background: var(--accent-l); }
.btn-ghost     { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-danger    { background: var(--danger-bg); color: var(--danger); border: 1px solid #fca5a5; }
.btn-danger:hover { background: #fee2e2; }
.btn-success   { background: var(--success-bg); color: var(--success); border: 1px solid #86efac; }
.btn-full      { width: 100%; }
.btn:disabled  { opacity: 0.6; cursor: not-allowed; }
.btn-sm        { padding: 6px 12px; font-size: 12px; }

.login-error {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 12px;
  display: none;
}

/* ── INVITE ACCEPT SCREEN ─────────────────────────────────── */
#invite-screen { display: none; }
#invite-screen.active { display: flex; }

/* ── APP LAYOUT ───────────────────────────────────────────── */

#app-screen { display: none; min-height: 100vh; flex-direction: column; }
#app-screen.active { display: flex; }

.app-header {
  background: var(--primary);
  color: var(--white);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.app-logo {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--white);
}

.app-logo span {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.7;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 999px;
  padding: 5px 12px 5px 5px;
  font-size: 13px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #1a0f00;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.role-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.role-superadmin { background: var(--accent); color: #1a0f00; }
.role-admin      { background: rgba(255,255,255,0.2); color: var(--white); }
.role-viewer     { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.7); }

/* ── TABS ─────────────────────────────────────────────────── */

.app-tabs {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  padding: 0 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  gap: 0;
}

.tab {
  padding: 14px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-badge {
  background: var(--danger);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

/* ── MAIN CONTENT ─────────────────────────────────────────── */

.app-body {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── CARDS ────────────────────────────────────────────────── */

.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ── STAT GRID ────────────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.stat-card .num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-card .lbl {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.stat-card.amber .num { color: var(--warn); }
.stat-card.red    .num { color: var(--danger); }
.stat-card.green  .num { color: var(--success); }
.stat-card.purple .num { color: var(--purple); }
.stat-card.accent .num { color: #b45309; }

/* ── TABLE ────────────────────────────────────────────────── */

.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tbl th {
  background: var(--bg);
  padding: 9px 12px;
  text-align: left;
  font-weight: 700;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.tbl td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #fafafa; }

/* ── BADGES ───────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-verified   { background: var(--success-bg); color: var(--success); }
.badge-unverified { background: var(--warn-bg);    color: var(--warn); }
.badge-banned     { background: var(--danger-bg);  color: var(--danger); }
.badge-high       { background: var(--danger-bg);  color: var(--danger); }
.badge-medium     { background: var(--warn-bg);    color: var(--warn); }
.badge-low        { background: var(--success-bg); color: var(--success); }
.badge-open       { background: #EFF6FF;            color: #1D4ED8; }
.badge-org        { background: #EFF6FF;            color: #1D4ED8; }
.badge-pro        { background: var(--purple-bg);   color: var(--purple); }
.badge-flagged    { background: var(--danger-bg);   color: var(--danger); }
.badge-superadmin { background: var(--accent);      color: #1a0f00; }
.badge-admin      { background: var(--primary);     color: var(--white); }
.badge-viewer     { background: var(--bg);          color: var(--muted); border: 1px solid var(--border); }

/* ── FILTER BAR ───────────────────────────────────────────── */

.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-bar input,
.filter-bar select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  background: var(--white);
}

.filter-bar input:focus,
.filter-bar select:focus { border-color: var(--primary); }

.filter-bar input { min-width: 220px; }

/* ── PAGINATION ───────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}

/* ── MODAL ────────────────────────────────────────────────── */

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open { display: flex; }

.modal-card {
  background: var(--white);
  border-radius: 16px;
  padding: 28px;
  max-width: 460px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.modal-card h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}

.modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ── TOAST ────────────────────────────────────────────────── */

#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--primary);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 99999;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  max-width: 320px;
}

#toast.show { transform: translateY(0); opacity: 1; }
#toast.error { background: var(--danger); }
#toast.success { background: var(--success); }

/* ── EMPTY STATE ──────────────────────────────────────────── */

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 13px;
}

.empty svg { margin-bottom: 12px; opacity: 0.3; }

/* ── SECTION HEADER ───────────────────────────────────────── */

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.section-head h2 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
}

/* ── YOUTH CARD ───────────────────────────────────────────── */

.youth-card {
  background: linear-gradient(135deg, #fffbeb, #fff7ed);
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.youth-card .youth-head {
  font-size: 14px;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 14px;
}

/* ── ACTIONS COLUMN ───────────────────────────────────────── */
.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ── RESPONSIVE ───────────────────────────────────────────── */

@media (max-width: 768px) {
  .app-body { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .app-header { padding: 0 16px; }
  .app-logo span { display: none; }
  .user-pill .user-name { display: none; }
  .login-card { padding: 28px 20px; }
  .filter-bar input { min-width: 160px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card .num { font-size: 1.5rem; }
}