/* ================================================================
   AI Coaching Portal — Professional Design System
   Design: Sidebar nav, Inter type, Navy/Indigo palette
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

/* ── Design tokens ───────────────────────────────────────────── */
:root {
  /* Brand */
  --navy:          #0F1729;
  --navy-mid:      #1C2744;
  --navy-soft:     #253258;
  --indigo:        #4F46E5;
  --indigo-hover:  #4338CA;
  --indigo-soft:   #EEF2FF;
  --indigo-mid:    #C7D2FE;

  /* Semantics */
  --emerald:       #059669;
  --emerald-soft:  #ECFDF5;
  --amber:         #D97706;
  --amber-soft:    #FFFBEB;
  --red:           #DC2626;
  --red-soft:      #FEF2F2;
  --sky:           #0284C7;
  --sky-soft:      #F0F9FF;
  --whatsapp:      #25D366;

  /* Neutrals */
  --white:         #FFFFFF;
  --gray-50:       #F8FAFC;
  --gray-100:      #F1F5F9;
  --gray-200:      #E2E8F0;
  --gray-300:      #CBD5E1;
  --gray-400:      #94A3B8;
  --gray-500:      #64748B;
  --gray-600:      #475569;
  --gray-700:      #334155;
  --gray-800:      #1E293B;
  --gray-900:      #0F172A;

  /* Surface */
  --bg:            #F8FAFC;
  --surface:       #FFFFFF;
  --surface-raised:#FFFFFF;
  --border:        #E2E8F0;
  --border-strong: #CBD5E1;

  /* Text */
  --text-primary:  #0F172A;
  --text-secondary:#475569;
  --text-muted:    #94A3B8;
  --text-inverse:  #FFFFFF;

  /* Sidebar */
  --sidebar-bg:       #0F1729;
  --sidebar-width:    240px;
  --sidebar-text:     #94A3B8;
  --sidebar-active-bg:#1C2744;
  --sidebar-active:   #FFFFFF;
  --sidebar-hover-bg: rgba(255,255,255,0.05);

  /* Elevation */
  --shadow-sm:  0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow:     0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md:  0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg:  0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  /* Geometry */
  --radius-sm:  4px;
  --radius:     8px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  18px;
  --radius-full:9999px;
}

/* ── Base ────────────────────────────────────────────────────── */
html { font-size: 15px; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  min-height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  border-right: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand-icon {
  width: 32px; height: 32px;
  background: var(--indigo);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand-icon i { color: white; font-size: 15px; }
.sidebar-brand-name { font-size: 14px; font-weight: 600; color: white; line-height: 1.2; }
.sidebar-brand-sub  { font-size: 11px; color: var(--sidebar-text); margin-top: 1px; }

.sidebar-section-label {
  padding: 16px 20px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--gray-500);
  text-transform: uppercase;
}
.sidebar-nav { padding: 8px 12px; flex: 1; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 400;
  transition: background 0.12s, color 0.12s;
  margin-bottom: 1px;
}
.sidebar-nav a i { width: 16px; font-size: 14px; opacity: 0.7; flex-shrink: 0; }
.sidebar-nav a:hover { background: var(--sidebar-hover-bg); color: #E2E8F0; }
.sidebar-nav a:hover i { opacity: 1; }
.sidebar-nav a.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); font-weight: 500; }
.sidebar-nav a.active i { opacity: 1; color: var(--indigo-mid); }
.sidebar-nav a .badge {
  margin-left: auto;
  background: var(--indigo);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
}
.sidebar-user:hover { background: var(--sidebar-hover-bg); }
.sidebar-avatar {
  width: 30px; height: 30px;
  border-radius: var(--radius-full);
  background: var(--indigo);
  color: white;
  font-size: 11px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-user-name { font-size: 12.5px; color: #E2E8F0; font-weight: 500; line-height: 1.3; }
.sidebar-user-role { font-size: 11px; color: var(--gray-500); }
.sidebar-user-menu {
  display: none;
  position: absolute;
  bottom: 44px; left: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  padding: 6px;
  z-index: 200;
}
.sidebar-user:hover .sidebar-user-menu { display: block; }
.sidebar-user-menu a {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-primary);
  font-size: 13px;
}
.sidebar-user-menu a:hover { background: var(--gray-100); }
.sidebar-user-menu a.danger { color: var(--red); }
.sidebar-user-menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ── Main layout ─────────────────────────────────────────────── */
.page-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Remove old navbar */
.navbar { display: none !important; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar-breadcrumb span { color: var(--text-primary); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-icon-btn {
  position: relative;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.12s;
  font-size: 15px;
}
.topbar-icon-btn:hover { background: var(--gray-100); color: var(--text-primary); }
.topbar-icon-btn .badge {
  position: absolute; top: 4px; right: 4px;
  background: var(--red);
  color: white;
  font-size: 9px;
  padding: 1px 4px;
  border-radius: var(--radius-full);
  font-weight: 700;
  min-width: 14px;
  text-align: center;
}

.main-wrap { padding: 28px; flex: 1; max-width: 1200px; width: 100%; }

/* ── Page header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}
.page-title span {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 8px;
  font-style: normal;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Stat cards ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat-label i { font-size: 12px; }
.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.5px;
}
.stat-sub {
  font-size: 11.5px;
  color: var(--emerald);
  margin-top: 5px;
  font-weight: 500;
}
.stat-sub.warn { color: var(--amber); }
.stat-sub.danger { color: var(--red); }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.card-title i { color: var(--indigo); font-size: 14px; }

/* ── Grid layouts ────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--gray-50);
}
thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

/* ── Badges / Pills ──────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.pill-green  { background: var(--emerald-soft); color: var(--emerald); }
.pill-amber  { background: var(--amber-soft);   color: var(--amber); }
.pill-red    { background: var(--red-soft);      color: var(--red); }
.pill-purple { background: var(--indigo-soft);   color: var(--indigo); }
.pill-teal   { background: #ECFEFF;              color: #0891B2; }
.pill-gray   { background: var(--gray-100);      color: var(--gray-600); }
.pill-navy   { background: var(--navy-mid);      color: #94A3B8; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.12s, box-shadow 0.12s, border-color 0.12s;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1.4;
}
.btn-primary {
  background: var(--indigo);
  color: white;
  border-color: var(--indigo);
}
.btn-primary:hover { background: var(--indigo-hover); border-color: var(--indigo-hover); }
.btn-teal {
  background: var(--emerald);
  color: white;
  border-color: var(--emerald);
}
.btn-teal:hover { background: #047857; }
.btn-red {
  background: var(--red);
  color: white;
  border-color: var(--red);
}
.btn-red:hover { background: #B91C1C; }
.btn-outline {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-secondary);
}
.btn-outline:hover { background: var(--gray-100); color: var(--text-primary); }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--gray-100); }
.btn-whatsapp {
  background: var(--whatsapp);
  color: white;
  border-color: var(--whatsapp);
}
.btn-whatsapp:hover { background: #1EAD57; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 7px; font-size: 11px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }
.btn i { font-size: 12px; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--surface);
  font-family: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-muted); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 13.5px;
  border: 1px solid;
}
.alert-success { background: var(--emerald-soft); color: #065F46; border-color: #6EE7B7; }
.alert-error   { background: var(--red-soft);     color: #991B1B; border-color: #FCA5A5; }
.alert-info    { background: var(--sky-soft);     color: #075985; border-color: #7DD3FC; }
.alert-close   { margin-left: auto; background: none; border: none; cursor: pointer; font-size: 16px; color: inherit; opacity: 0.6; }
.alert-close:hover { opacity: 1; }

/* ── Progress bar ────────────────────────────────────────────── */
.progress-bar { background: var(--gray-200); border-radius: var(--radius-full); height: 6px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--radius-full); background: var(--indigo); transition: width 0.4s ease; }
.progress-fill.green  { background: var(--emerald); }
.progress-fill.amber  { background: var(--amber); }
.progress-fill.red    { background: var(--red); }

/* ── Avatar ──────────────────────────────────────────────────── */
.avatar {
  width: 34px; height: 34px;
  border-radius: var(--radius-full);
  background: var(--indigo-soft);
  color: var(--indigo);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.av-purple { background: var(--indigo-soft);  color: var(--indigo); }
.av-teal   { background: #ECFEFF;             color: #0891B2; }
.av-amber  { background: var(--amber-soft);   color: var(--amber); }
.av-green  { background: var(--emerald-soft); color: var(--emerald); }

/* ── Utility ─────────────────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 14px; }
.mt-3 { margin-top: 22px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 14px; }
.mb-3 { margin-bottom: 22px; }
.text-sm     { font-size: 12.5px; }
.text-xs     { font-size: 11px; }
.text-muted  { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }

/* ── Divider ─────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 520px;
  max-width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 30px; height: 30px;
  border: none;
  background: var(--gray-100);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: var(--text-muted);
  transition: background 0.12s;
}
.modal-close:hover { background: var(--gray-200); color: var(--text-primary); }

/* ── Section label ───────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* ── WhatsApp panel ──────────────────────────────────────────── */
.wa-panel {
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.wa-panel-title {
  font-size: 13px;
  font-weight: 600;
  color: #166534;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.wa-log {
  font-size: 12.5px;
  padding: 7px 10px;
  background: white;
  border-radius: var(--radius);
  margin-bottom: 5px;
  border-left: 3px solid var(--whatsapp);
  color: var(--text-secondary);
}
.wa-log.outbound { border-left-color: var(--indigo); }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state i {
  font-size: 32px;
  margin-bottom: 12px;
  display: block;
  color: var(--gray-300);
}
.empty-state p { font-size: 14px; }

/* ── Login page ──────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  padding: 20px;
  margin-left: 0 !important;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  width: 420px;
  max-width: 100%;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.4);
  border: 1px solid var(--border);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-icon {
  width: 52px; height: 52px;
  background: var(--indigo);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.login-logo-icon i { color: white; font-size: 22px; }
.login-logo h1 { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.login-logo p  { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.login-demo {
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.8;
}
.login-demo strong { color: var(--indigo); }

/* Role selector pills */
.role-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.role-pill {
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all 0.12s;
  background: var(--surface);
}
.role-pill:hover { border-color: var(--indigo); color: var(--indigo); }
.role-pill.active { background: var(--indigo); color: white; border-color: var(--indigo); }

/* ── Super admin nav override ────────────────────────────────── */
.super-sidebar { --sidebar-bg: #0A0F1E; --sidebar-active-bg: #131929; }
.super-sidebar .sidebar-brand-icon { background: #6366F1; }


/* ================================================================
   RESPONSIVE — Mobile, Tablet, Desktop
   Unified single pass — no conflicts
   ================================================================ */

/* ── Backdrop overlay for mobile sidebar ─────────────────────── */
#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 99;
  backdrop-filter: blur(2px);
  -webkit-tap-highlight-color: transparent;
}
#sidebar-backdrop.active { display: block; }

/* ── Bottom navigation (hidden on desktop) ──────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1.5px solid var(--border);
  z-index: 88;
  box-shadow: 0 -2px 16px rgba(0,0,0,0.08);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav-inner {
  display: flex;
  height: 56px;
}
.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  padding: 6px 2px 4px;
  border-top: 2.5px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}
.bnav-item i { font-size: 17px; display: block; }
.bnav-item.active { color: var(--indigo); border-top: 2.5px solid var(--indigo); }
.bnav-badge {
  position: absolute;
  top: 4px; left: 50%; margin-left: 5px;
  background: var(--red); color: white;
  font-size: 9px; font-weight: 700;
  padding: 1px 4px;
  border-radius: 99px;
  min-width: 14px; text-align: center;
  line-height: 1.4; pointer-events: none;
}

/* ── Prevent body scroll when sidebar open on mobile ────────── */
body.sidebar-open { overflow: hidden; }

/* ═══════════════════════════════════════════
   TABLET (769px – 1024px)
   Narrower sidebar, 2-col stats
═══════════════════════════════════════════ */
@media (min-width: 769px) and (max-width: 1024px) {
  :root { --sidebar-width: 200px; }
  .main-wrap { padding: 20px 18px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .form-row { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════
   MOBILE  (≤ 768px)
   Sidebar = drawer, bottom nav, app feel
═══════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Prevent horizontal overflow */
  html { overflow-x: hidden; }
  body {
    overflow-x: hidden;
    /* Room for fixed bottom nav */
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* ── Sidebar becomes slide-in drawer ── */
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 270px !important;
    height: 100% !important;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.4,0,0.2,1);
    box-shadow: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 32px rgba(0,0,0,0.35);
  }
  .sidebar-nav a { padding: 11px 14px; font-size: 14px; margin-bottom: 2px; }
  .sidebar-nav a i { font-size: 15px; width: 18px; }
  .sidebar-brand { padding: 16px 16px 14px; }

  /* ── Full-width page, no sidebar offset ── */
  .page-wrapper {
    margin-left: 0 !important;
    width: 100%;
  }

  /* ── Topbar mobile ── */
  .topbar {
    padding: 0 12px;
    height: 50px;
    position: sticky;
    top: 0;
    z-index: 50;
  }
  .topbar-breadcrumb span { font-size: 14px; font-weight: 600; }

  /* Show hamburger button */
  #sidebar-toggle { display: flex !important; }

  /* ── Main content ── */
  .main-wrap {
    padding: 14px 12px 16px;
    max-width: 100%;
  }

  /* ── Page header stacks ── */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
  }
  .page-header > .btn,
  .page-header > button {
    width: 100%;
    justify-content: center;
  }
  .page-title { font-size: 17px; }

  /* ── Stats: 2 col ── */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 14px;
  }
  .stat-card { padding: 12px 10px; border-radius: var(--radius); }
  .stat-value { font-size: 22px; letter-spacing: -0.5px; }
  .stat-label { font-size: 10.5px; gap: 4px; }
  .stat-sub { font-size: 11px; }

  /* ── Cards ── */
  .card { padding: 14px 12px; border-radius: var(--radius-md); }
  .card-title { font-size: 13px; margin-bottom: 10px; }

  /* ── Grids ── */
  .grid-2 { grid-template-columns: 1fr !important; gap: 10px; }
  .grid-3 { grid-template-columns: 1fr !important; gap: 10px; }
  .form-row { grid-template-columns: 1fr !important; gap: 10px; }

  /* ── Tables ── */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
  }
  table { min-width: 460px; font-size: 12px; }
  thead th { padding: 8px 10px; font-size: 10px; }
  tbody td { padding: 10px 10px; }

  /* ── Buttons — bigger tap area ── */
  .btn { min-height: 40px; font-size: 13px; }
  .btn-sm { min-height: 34px; font-size: 12px; padding: 6px 10px; }
  .btn-xs { min-height: 30px; font-size: 11px; padding: 4px 8px; }

  /* ── Forms — prevent iOS zoom (needs 16px) ── */
  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 16px !important;
    padding: 10px 11px;
    min-height: 44px;
    border-radius: var(--radius);
  }
  .form-group textarea { min-height: 80px; }
  .form-group label { font-size: 13px; margin-bottom: 5px; }

  /* ── Alerts ── */
  div[style*="padding: 0 28px"],
  div[style*="padding:0 28px"] {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* ── Modals → bottom sheet ── */
  [id$="-modal"] {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  [id$="-modal"] > div,
  .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 18px 18px 0 0 !important;
    max-height: 92vh !important;
    margin: 0 !important;
    padding: 20px 16px 28px !important;
  }

  /* ── Inline width-fixed modals ── */
  div[style*="width:520px"] > div,
  div[style*="width:540px"] > div,
  div[style*="width:480px"] > div,
  div[style*="width:460px"] > div {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 18px 18px 0 0 !important;
  }

  /* ── Show bottom navigation ── */
  .bottom-nav { display: block; }

  /* ── Messages page: stack ── */
  .grid-2[style*="240px 1fr"] {
    display: block !important;
  }

  /* ── Pills slightly bigger ── */
  .pill { padding: 4px 10px; font-size: 11.5px; }

  /* ── Topbar icons ── */
  .topbar-icon-btn { width: 36px; height: 36px; }

  /* ── Sidebar user menu - prevent overflow ── */
  .sidebar-user-menu { left: 0; right: 0; width: auto; }

  /* ── Login page ── */
  .login-wrap { align-items: flex-start; padding: 24px 14px 40px; }
  .login-card { padding: 24px 18px; }

  /* ── Footer ── */
  footer { padding: 12px 14px; font-size: 11px; }

  /* ── Section labels ── */
  .sidebar-section-label { padding: 14px 16px 5px; }

  /* ── Page wrapper flash padding ── */
  .page-wrapper > div[style] { padding: 0 12px !important; }
}

/* ═══════════════════════════════════════════
   SMALL PHONES  (≤ 380px)
═══════════════════════════════════════════ */
@media (max-width: 380px) {
  .main-wrap { padding: 10px 10px 14px; }
  .topbar { padding: 0 8px; height: 48px; }
  .stats-grid { gap: 7px; }
  .stat-value { font-size: 20px; }
  .stat-card { padding: 11px 8px; }
  .bnav-item i { font-size: 15px; }
  .bnav-item { font-size: 9px; }
  .page-title { font-size: 16px; }
  .card { padding: 12px 10px; }
  .btn { min-height: 38px; }
}

/* ── Auto-dismiss flash utility ─────────────────────────────── */
.alert-fade-out { opacity: 0 !important; transition: opacity 0.4s ease !important; }


/* ── Logo & Watermark ────────────────────────────────────────── */

/* Sidebar logo */
.sidebar-brand {
  padding: 14px 14px 10px !important;
  border-bottom: none !important;
}
.sidebar-brand img {
  height: 38px;
  width: auto;
  object-fit: contain;
  display: block;
  /* Invert/brighten for dark sidebar */
  filter: brightness(1) invert(0);
}

/* Page watermark — subtle logo on every content page */
.main-wrap::before {
  content: '';
  position: fixed;
  bottom: 80px;
  right: 30px;
  width: 180px;
  height: 60px;
  background-image: url('../logo-nav.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.04;
  pointer-events: none;
  z-index: 0;
}

/* Print watermark */
@media print {
  .main-wrap::before {
    opacity: 0.08 !important;
    position: fixed;
    bottom: 20px;
    right: 20px;
  }
  /* Logo on printed invoices */
  .print-logo {
    display: block !important;
  }
}

/* Login page logo sizing */
.login-logo img {
  height: 80px;
  width: auto;
  max-width: 280px;
  object-fit: contain;
  margin: 0 auto 12px;
  display: block;
}

/* Footer logo */
footer img {
  height: 26px;
  width: auto;
  object-fit: contain;
  opacity: 0.6;
  display: inline-block;
  vertical-align: middle;
}

/* Topbar logo (mobile - when sidebar is hidden) */
.topbar-logo {
  display: none;
  height: 28px;
  width: auto;
  object-fit: contain;
}
@media (max-width: 768px) {
  .topbar-logo { display: block; }
}
