:root {
  /* PeerPays-inspired palette */
  --navy: #0b2c4b;
  --navy-600: #123a61;
  --teal: #37b0a2;
  --teal-600: #2c9488;
  --teal-tint: rgba(55, 176, 162, 0.1);
  --navy-tint: rgba(11, 44, 75, 0.05);
  --yellow: #facc15;

  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e5e7eb;
  --border-strong: #d5dce4;

  --text: #0b2c4b;
  --text-2: #334155;
  --muted: #7c8ba1;

  --success: #16a34a;
  --success-bg: rgba(22, 163, 74, 0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --warn: #d97706;
  --warn-bg: rgba(250, 204, 21, 0.15);

  --brand-gradient: linear-gradient(135deg, #0b2c4b, #37b0a2);
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(11, 44, 75, 0.06);
  --shadow: 0 6px 24px rgba(11, 44, 75, 0.08);
  --shadow-lg: 0 20px 50px rgba(11, 44, 75, 0.18);

  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-2);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Keep the layout fixed on phones: no double-tap zoom, no text auto-resize. */
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  line-height: 1.2;
}
.btn:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-600); }
.btn-success { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn-success:hover { background: var(--teal-600); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.icon-btn:hover { color: var(--text); }

/* ---------- Login ---------- */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(55, 176, 162, 0.18), transparent 60%),
    radial-gradient(1000px 500px at 110% 110%, rgba(11, 44, 75, 0.12), transparent 55%),
    var(--bg);
}
.login-shell {
  width: 100%;
  max-width: 940px;
  min-height: 560px;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

/* Hero panel */
.login-hero {
  position: relative;
  background: linear-gradient(150deg, #0b2c4b 0%, #123a61 45%, #2c9488 130%);
  color: #fff;
  padding: 40px 40px 32px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.login-hero-top { display: flex; align-items: center; gap: 12px; position: relative; z-index: 2; }
.login-hero-logo { background: #fff; }
.login-hero-brand { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.login-hero-brand span { opacity: 0.7; font-weight: 500; }
.login-hero-mid { position: relative; z-index: 2; }
.login-hero-mid h2 { font-size: 30px; line-height: 1.2; margin: 0 0 14px; font-weight: 800; letter-spacing: -0.02em; }
.login-hero-mid p { margin: 0 0 22px; color: rgba(255, 255, 255, 0.8); font-size: 14.5px; line-height: 1.6; max-width: 380px; }
.login-hero-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.login-hero-list li { position: relative; padding-left: 30px; font-size: 14px; color: rgba(255, 255, 255, 0.92); font-weight: 500; }
.login-hero-list li::before {
  content: '✓';
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff;
}
.login-hero-foot { position: relative; z-index: 2; font-size: 12px; color: rgba(255, 255, 255, 0.6); letter-spacing: 0.3px; }
.orb { position: absolute; border-radius: 50%; filter: blur(2px); opacity: 0.5; z-index: 1; }
.orb-1 { width: 220px; height: 220px; background: radial-gradient(circle, rgba(55,176,162,0.55), transparent 70%); top: -60px; right: -60px; }
.orb-2 { width: 180px; height: 180px; background: radial-gradient(circle, rgba(250,204,21,0.28), transparent 70%); bottom: -50px; left: -40px; }
.orb-3 { width: 120px; height: 120px; background: radial-gradient(circle, rgba(255,255,255,0.18), transparent 70%); top: 45%; right: 12%; }

/* Form panel */
.login-form {
  padding: 48px 44px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  justify-content: center;
}
.login-form-brand { display: none; align-items: center; gap: 10px; margin-bottom: 6px; font-weight: 700; color: var(--text); }
.login-form-brand b { color: var(--teal-600); }
.login-form h1 { margin: 0; font-size: 26px; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.login-sub { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.login-form .field label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.btn-lg { padding: 13px 18px; font-size: 15px; border-radius: 12px; margin-top: 6px; }

/* Password field with show/hide */
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { padding-right: 62px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; color: var(--teal-600);
  font-size: 12.5px; font-weight: 700; cursor: pointer; padding: 6px 8px;
  border-radius: 6px; font-family: inherit;
}
.pw-toggle:hover { background: var(--teal-tint); }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.login-card .brand { margin-bottom: 10px; }
.brand h1 { font-size: 18px; margin: 0; color: var(--text); font-weight: 700; letter-spacing: -0.02em; }
.brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.brand-mark {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: var(--brand-gradient);
  color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.brand-logo {
  width: 42px; height: 42px;
  border-radius: 11px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-by { font-size: 13px; font-weight: 600; color: var(--teal-600); }
.login-card .brand-by { font-size: 15px; }

/* ---------- Inputs ---------- */
input, select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: #aeb9c7; }
input:focus, select:focus, textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-tint);
}
textarea { resize: vertical; }

.error-text { color: var(--danger); font-size: 13px; margin: 4px 0 0; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 30;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* Account menu */
.menu-wrap { position: relative; }
.icon-round {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: grid; place-items: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.icon-round:hover { background: var(--surface-2); border-color: var(--teal); }
.menu-dots { font-size: 22px; line-height: 1; margin-top: -6px; font-weight: 700; }
.dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 40;
  padding: 6px;
}
.dropdown-head { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.dropdown-status { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.dropdown-user { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.dropdown-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand-gradient); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; text-transform: uppercase; flex-shrink: 0;
}
.dropdown-user-meta { display: flex; flex-direction: column; min-width: 0; }
.dropdown-name { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dropdown-role { font-size: 11px; color: var(--teal-600); font-weight: 600; text-transform: capitalize; }
.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
}
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-bg); }

/* Floating action button (mobile) */
.fab {
  display: none;
  position: fixed;
  right: 18px; bottom: 18px;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--navy);
  color: #fff;
  font-size: 30px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(11, 44, 75, 0.35);
  z-index: 25;
}
.fab:active { transform: scale(0.95); }
.add-mobile { display: none; }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill-ok { background: var(--success-bg); border-color: transparent; color: var(--success); }
.pill-ok .dot { background: var(--success); box-shadow: 0 0 0 3px rgba(22,163,74,0.2); }
.pill-warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.pill-warn .dot { background: var(--yellow); }
.pill-bad { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.pill-bad .dot { background: var(--danger); }

/* ---------- Container ---------- */
.container { max-width: 1240px; margin: 0 auto; padding: 28px; }

/* ---------- Stats ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.stat-value { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -0.02em; line-height: 1.15; }
.stat-sub { font-size: 11.5px; color: var(--muted); }
.stat-profit {
  background: var(--brand-gradient);
  border-color: transparent;
  color: #fff;
}
.stat-profit .stat-label,
.stat-profit .stat-sub { color: rgba(255, 255, 255, 0.75); }
.stat-profit .stat-value { color: #fff; }

/* ---------- WhatsApp panel ---------- */
.wa-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}
.wa-panel-text h2 { margin: 0 0 8px; font-size: 18px; color: var(--text); font-weight: 700; }
.wa-panel-text { max-width: 580px; }
.wa-qr-wrap {
  width: 208px; height: 208px;
  border-radius: 16px;
  background: #fff;
  display: grid; place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border);
  padding: 8px;
}
.wa-qr-wrap img { width: 100%; height: 100%; object-fit: contain; }
.wa-qr-placeholder { color: var(--muted); font-size: 13px; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.search { flex: 1; min-width: 240px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters select { width: auto; cursor: pointer; }

/* ---------- Gift card tiles (compact) ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}
.gcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}
.gcard::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 3px;
  background: var(--brand-gradient);
}
.gcard:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--border-strong); }

.gcard-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Used / available toggle */
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .slider {
  width: 36px; height: 21px; border-radius: 999px;
  background: var(--border-strong); position: relative; flex-shrink: 0;
  transition: background 0.15s ease;
}
.switch .slider::before {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 17px; height: 17px; border-radius: 50%; background: #fff;
  box-shadow: var(--shadow-sm); transition: transform 0.15s ease;
}
.switch input:checked + .slider { background: var(--muted); }
.switch input:checked + .slider::before { transform: translateX(15px); }
.switch-label { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.switch input:checked ~ .switch-label { color: var(--text-2); }

.gcard-label {
  font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600;
}
.copy-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 6px 6px 11px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.copy-row:hover { border-color: var(--teal); background: var(--teal-tint); }
.copy-col { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text); }
.gcard-number { font-size: 14.5px; font-weight: 600; letter-spacing: 0.5px; word-break: break-all; }
.gcard-pin { font-size: 14px; font-weight: 600; letter-spacing: 0.5px; word-break: break-all; }
.copy-btn2 {
  flex-shrink: 0;
  border: none;
  background: var(--navy);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.copy-btn2:hover { background: var(--teal); }

.gcard-meta {
  display: flex; flex-wrap: wrap; align-items: center;
  font-size: 12.5px; color: var(--text-2); font-weight: 500;
}
.gcard-meta b { color: var(--text); font-weight: 700; }
.gcard-meta .sep { color: var(--border-strong); margin: 0 7px; }
.gcard-sub { font-size: 11px; color: var(--muted); }

.gcard-actions { display: flex; gap: 6px; margin-top: 2px; }
.gcard-actions .btn { flex: 1; min-width: 0; padding: 7px 8px; }

.badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-available { background: var(--teal-tint); color: var(--teal-600); }
.badge-sold { background: var(--success-bg); color: var(--success); }
.badge-used { background: #eef1f5; color: var(--muted); }
.badge-expired { background: var(--danger-bg); color: var(--danger); }

.source-tag { font-size: 12px; color: var(--text-2); font-weight: 500; }
.source-whatsapp { color: var(--teal-600); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }

.empty-state { padding: 56px; text-align: center; }
.empty-state p { margin: 6px 0; }

/* ---------- Users list ---------- */
.users-stats { grid-template-columns: repeat(4, 1fr); max-width: 760px; }
.users-list { display: flex; flex-direction: column; gap: 10px; }
.user-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.user-row.inactive { opacity: 0.62; }
.user-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--brand-gradient); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 17px; text-transform: uppercase; flex-shrink: 0;
}
.user-info { min-width: 0; flex: 1; }
.user-name { font-size: 15px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-uname { font-size: 12.5px; color: var(--muted); }
.user-meta { font-size: 12px; color: var(--text-2); margin-top: 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-meta.muted { color: var(--muted); margin-top: 3px; }
.user-cards b { color: var(--text); font-weight: 700; }
.wa-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
}
.wa-chip .wa-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.wa-on { background: var(--success-bg); color: var(--success); }
.wa-off { background: #eef1f5; color: var(--muted); }
.user-badges { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.role-badge {
  font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; text-transform: capitalize;
}
.role-admin { background: var(--navy-tint); color: var(--navy); }
.role-user { background: var(--teal-tint); color: var(--teal-600); }
.status-dot-badge { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.status-active { background: var(--success-bg); color: var(--success); }
.status-disabled { background: var(--danger-bg); color: var(--danger); }
.user-actions { display: flex; gap: 6px; flex-shrink: 0; }
.you-tag { font-size: 10.5px; font-weight: 700; color: var(--teal-600); background: var(--teal-tint); padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.4px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(11, 44, 75, 0.45);
  display: grid; place-items: center;
  z-index: 50;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-card {
  width: 100%; max-width: 540px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 92vh; overflow: auto;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 17px; color: var(--text); font-weight: 700; }
.modal-body { padding: 22px; display: flex; flex-direction: column; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 15px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 26px; left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 13px 20px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  font-size: 14px;
  font-weight: 500;
}
.toast.ok { background: var(--teal); }
.toast.err { background: var(--danger); }

@media (max-width: 820px) {
  .login-shell { grid-template-columns: 1fr; max-width: 460px; min-height: 0; }
  .login-hero { padding: 30px 26px 26px; gap: 22px; }
  .login-hero-mid h2 { font-size: 24px; margin-bottom: 12px; }
  .login-hero-mid p { font-size: 13.5px; margin-bottom: 18px; }
  .login-hero-list { gap: 10px; }
  .login-hero-foot { display: none; }
  .login-form { padding: 30px 26px 34px; }
}

@media (max-width: 860px) {
  .container { padding: 16px 14px; }
  .add-desktop { display: none; }

  /* Prevent iOS Safari from auto-zooming when a field gains focus
     (it zooms on any input whose font-size is below 16px). */
  input:not([type='checkbox']):not([type='radio']),
  textarea { font-size: 16px; }
  .users-stats { grid-template-columns: repeat(3, 1fr); }
  .users-stats .stat-card { min-width: 0; }
  .user-row { flex-wrap: wrap; gap: 10px; }
  .user-info { flex-basis: calc(100% - 58px); }
  .user-badges { order: 3; }
  .user-actions { order: 4; margin-left: auto; }
  .add-mobile { display: block; }
  .fab { display: grid; }
  .brand-sub { display: none; }
  #wa-pill { display: none; }

  /* Compact horizontal-scroll stats strip */
  .stats-grid {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    margin: 0 -14px 16px;
    padding: 0 14px 4px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  .stats-grid::-webkit-scrollbar { display: none; }
  .stat-card { min-width: 46%; scroll-snap-align: start; }
  .stat-value { font-size: 20px; }

  .wa-panel { flex-direction: column; align-items: stretch; padding: 18px; }
  .wa-qr-wrap { width: 100%; height: auto; aspect-ratio: 1; max-width: 240px; margin: 0 auto; }
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .toolbar { gap: 10px; }
  .toolbar .filters { width: 100%; flex-wrap: nowrap; gap: 8px; }
  .toolbar .filters select {
    flex: 1;
    min-width: 0;
    padding: 9px 6px;
    font-size: 12px;
    border-radius: 9px;
  }
}

@media (max-width: 620px) {
  .cards-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .topbar { padding: 10px 14px; }
  .topbar .brand h1 { font-size: 15px; }
  .brand-logo { width: 38px; height: 38px; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-card { max-width: 100%; border-radius: 20px 20px 0 0; max-height: 94vh; }
  .toast { left: 16px; right: 16px; transform: none; text-align: center; }
}
