/* ─── FONTS ─────────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap');

/* ─── ROOT VARIABLES ─────────────────────────────────────────────────────────── */
:root {
  --gold:        #F5C842;
  --gold-light:  #FFE082;
  --gold-dark:   #C9A227;
  --bg:          #0A0A0F;
  --surface:     #111118;
  --surface2:    #18181F;
  --surface3:    #1E1E28;
  --border:      rgba(245,200,66,0.12);
  --border-sub:  rgba(255,255,255,0.06);
  --text:        #F0F0F5;
  --text-muted:  #8888A0;
  --green:       #00D68F;
  --red:         #FF4D6D;
  --blue:        #4D9FFF;
  --purple:      #A855F7;
  --sidebar-w:   256px;
  --radius:      14px;
  --radius-sm:   8px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --shadow-gold: 0 4px 20px rgba(245,200,66,0.25);
  --transition:  0.18s ease;
}

/* ─── RESET ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
}
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-light); }
img { max-width: 100%; }
button, input, select, textarea { font-family: inherit; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* ─── LAYOUT ─────────────────────────────────────────────────────────────────── */
.app-layout { display: flex; width: 100%; height: 100vh; overflow: hidden; }

/* ─── SIDEBAR ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}

.sidebar-logo {
  padding: 22px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; color: #0A0A0F;
  flex-shrink: 0;
}
.logo-text { font-size: 16px; font-weight: 700; color: var(--text); line-height: 1.2; }
.logo-text span { color: var(--gold); }
.logo-sub { font-size: 10px; color: var(--text-muted); letter-spacing: 0.5px; margin-top: 1px; }

.store-switcher {
  margin: 14px 14px 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  display: flex; align-items: center; gap: 9px;
  cursor: pointer;
  transition: border-color var(--transition);
}
.store-switcher:hover { border-color: rgba(245,200,66,0.3); }
.store-dot { width: 7px; height: 7px; background: var(--gold); border-radius: 50%; box-shadow: 0 0 6px var(--gold); flex-shrink: 0; }
.store-name { font-size: 12px; font-weight: 500; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.store-arrow { color: var(--text-muted); font-size: 10px; }

.nav-section { flex: 1; overflow-y: auto; padding: 14px 0 0; }
.nav-label {
  font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  color: rgba(245,200,66,0.4);
  padding: 0 20px; margin-bottom: 4px; margin-top: 14px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 20px;
  color: var(--text-muted);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border-left: 2px solid transparent;
  text-decoration: none;
}
.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active {
  color: var(--gold);
  background: rgba(245,200,66,0.07);
  border-left-color: var(--gold);
}
.nav-icon { width: 17px; text-align: center; font-size: 13px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 10px; font-weight: 700;
}
.nav-badge.danger { background: rgba(255,77,109,0.2); color: var(--red); }
.nav-badge.gold   { background: rgba(245,200,66,0.15); color: var(--gold); }

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--border);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-sub);
}
.user-avatar-sm {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #0A0A0F;
  flex-shrink: 0;
}
.user-info-name { font-size: 12px; font-weight: 600; }
.user-info-role { font-size: 10px; color: var(--text-muted); }
.logout-btn {
  margin-left: auto;
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 13px; padding: 4px;
  transition: color var(--transition);
}
.logout-btn:hover { color: var(--red); }

/* ─── MAIN CONTENT ───────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.page-body { padding: 26px 30px; flex: 1; }

/* ─── TOP BAR ────────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.page-title { font-size: 22px; font-weight: 700; }
.page-title .accent { color: var(--gold); }
.page-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.topbar-right { display: flex; gap: 10px; align-items: center; }

/* ─── BUTTONS ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-gold {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: #0A0A0F;
  box-shadow: var(--shadow-gold);
}
.btn-gold:hover { filter: brightness(1.1); color: #0A0A0F; }
.btn-ghost {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border-sub);
}
.btn-ghost:hover { border-color: var(--border); }
.btn-danger { background: rgba(255,77,109,0.15); color: var(--red); border: 1px solid rgba(255,77,109,0.2); }
.btn-danger:hover { background: rgba(255,77,109,0.25); }
.btn-success { background: rgba(0,214,143,0.15); color: var(--green); border: 1px solid rgba(0,214,143,0.2); }
.btn-success:hover { background: rgba(0,214,143,0.25); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; width: 34px; height: 34px; justify-content: center; }

/* ─── CARDS ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border-sub);
  border-radius: var(--radius);
  padding: 22px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.card-title { font-size: 15px; font-weight: 700; }
.card-action { font-size: 12px; color: var(--gold); cursor: pointer; font-weight: 500; }
.card-action:hover { color: var(--gold-light); }

.card.featured { border-color: rgba(245,200,66,0.25); }
.card.featured::before {
  content: '';
  display: block;
  height: 2px;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold));
  margin: -22px -22px 22px;
  border-radius: var(--radius) var(--radius) 0 0;
}

/* ─── STAT CARDS ─────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-sub);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card:hover { border-color: var(--border); transform: translateY(-2px); }
.stat-card.featured { border-color: rgba(245,200,66,0.25); }
.stat-card.featured::after {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold));
}
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stat-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.si-gold   { background: rgba(245,200,66,0.15); color: var(--gold); }
.si-green  { background: rgba(0,214,143,0.15);  color: var(--green); }
.si-red    { background: rgba(255,77,109,0.15); color: var(--red); }
.si-blue   { background: rgba(77,159,255,0.15); color: var(--blue); }
.si-purple { background: rgba(168,85,247,0.15); color: var(--purple); }
.stat-badge {
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 20px;
}
.sb-up   { background: rgba(0,214,143,0.15); color: var(--green); }
.sb-down { background: rgba(255,77,109,0.15); color: var(--red); }
.sb-warn { background: rgba(245,200,66,0.15); color: var(--gold); }
.sb-info { background: rgba(77,159,255,0.15); color: var(--blue); }
.stat-value { font-size: 24px; font-weight: 700; margin-bottom: 3px; }
.stat-label { font-size: 12px; color: var(--text-muted); }

/* ─── TABLES ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted); padding: 0 0 12px;
  text-align: left; border-bottom: 1px solid var(--border-sub);
  white-space: nowrap;
}
tbody td {
  padding: 11px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 13px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.02); }
th:not(:first-child), td:not(:first-child) { padding-left: 12px; }

/* ─── AVATAR ─────────────────────────────────────────────────────────────────── */
.avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.avatar-lg { width: 48px; height: 48px; border-radius: 12px; font-size: 16px; }
.avatar-xl { width: 64px; height: 64px; border-radius: 16px; font-size: 20px; }
.cell-with-avatar { display: flex; align-items: center; gap: 10px; }
.cell-name { font-weight: 500; font-size: 13px; }
.cell-sub  { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ─── BADGES ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge-green  { background: rgba(0,214,143,0.15);  color: var(--green); }
.badge-yellow { background: rgba(245,200,66,0.15); color: var(--gold); }
.badge-orange { background: rgba(255,165,0,0.15);  color: orange; }
.badge-red    { background: rgba(255,77,109,0.15); color: var(--red); }
.badge-blue   { background: rgba(77,159,255,0.15); color: var(--blue); }
.badge-purple { background: rgba(168,85,247,0.15); color: var(--purple); }
.badge-muted  { background: rgba(255,255,255,0.07); color: var(--text-muted); }

/* ─── FORMS ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; letter-spacing: 0.3px; }
.form-control {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border-sub);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color var(--transition);
  outline: none;
}
.form-control:focus { border-color: rgba(245,200,66,0.4); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ─── MODAL ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow);
}
.modal-lg { max-width: 720px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 18px; padding: 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border-sub); }

/* ─── FILTERS BAR ────────────────────────────────────────────────────────────── */
.filters-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.search-input {
  flex: 1; min-width: 200px;
  background: var(--surface2);
  border: 1px solid var(--border-sub);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 14px 9px 36px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238888A0' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}
.search-input:focus { border-color: rgba(245,200,66,0.4); }
.filter-select {
  background: var(--surface2);
  border: 1px solid var(--border-sub);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 14px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

/* ─── TABS ───────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; margin-bottom: 18px; flex-wrap: wrap; }
.tab-btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600;
  cursor: pointer; border: none;
  background: var(--surface2);
  color: var(--text-muted);
  transition: all var(--transition);
  display: flex; align-items: center; gap: 6px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { background: rgba(245,200,66,0.12); color: var(--gold); }
.tab-count {
  background: rgba(255,255,255,0.08);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
}

/* ─── INLINE STATS BAR ───────────────────────────────────────────────────────── */
.stats-bar {
  display: flex; gap: 20px;
  padding: 14px 18px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.stats-bar-item { display: flex; flex-direction: column; gap: 2px; }
.stats-bar-val { font-size: 16px; font-weight: 700; }
.stats-bar-lbl { font-size: 11px; color: var(--text-muted); }

/* ─── PAGINATION ─────────────────────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: 6px;
  margin-top: 18px; justify-content: center;
}
.page-btn {
  width: 32px; height: 32px;
  background: var(--surface2);
  border: 1px solid var(--border-sub);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  text-decoration: none;
}
.page-btn:hover { border-color: var(--border); color: var(--text); }
.page-btn.active { background: rgba(245,200,66,0.12); border-color: rgba(245,200,66,0.3); color: var(--gold); }
.page-btn.disabled { opacity: 0.4; pointer-events: none; }

/* ─── TOAST NOTIFICATIONS ────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border-sub);
  box-shadow: var(--shadow);
  font-size: 13px; font-weight: 500;
  min-width: 280px; max-width: 380px;
  animation: slideIn 0.3s ease;
}
.toast.success { border-color: rgba(0,214,143,0.3); }
.toast.error   { border-color: rgba(255,77,109,0.3); }
.toast.warning { border-color: rgba(245,200,66,0.3); }
.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast.success .toast-icon { color: var(--green); }
.toast.error   .toast-icon { color: var(--red); }
.toast.warning .toast-icon { color: var(--gold); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ─── EMPTY STATE ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 40px; margin-bottom: 14px; opacity: 0.4; }
.empty-state-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.empty-state-sub { font-size: 13px; }

/* ─── CHARTS ─────────────────────────────────────────────────────────────────── */
.chart-wrap { position: relative; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

/* ─── PROGRESS BARS ──────────────────────────────────────────────────────────── */
.progress-bar-wrap { margin-bottom: 12px; }
.progress-bar-header { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 5px; }
.progress-bar-label { color: var(--text-muted); }
.progress-bar-val { font-weight: 600; }
.progress-track { background: var(--surface2); border-radius: 4px; height: 6px; }
.progress-fill { height: 6px; border-radius: 4px; transition: width 0.5s ease; }

/* ─── WHATSAPP BUTTON ────────────────────────────────────────────────────────── */
.wa-btn {
  width: 32px; height: 32px;
  background: rgba(0,214,143,0.12);
  color: var(--green);
  border: none; border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px;
  transition: background var(--transition);
  text-decoration: none;
}
.wa-btn:hover { background: rgba(0,214,143,0.25); color: var(--green); }

/* ─── EXPIRING LIST ──────────────────────────────────────────────────────────── */
.expiring-list { display: flex; flex-direction: column; gap: 9px; }
.expiring-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-sub);
  transition: border-color var(--transition);
}
.expiring-item:hover { border-color: var(--border); }
.expiring-info { flex: 1; min-width: 0; }
.expiring-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.expiring-plan { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ─── GRID LAYOUTS ───────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
.grid-chart { display: grid; grid-template-columns: 1fr 340px; gap: 18px; }
.grid-bottom { display: grid; grid-template-columns: 1fr 320px; gap: 18px; }

/* ─── ALERT ──────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
}
.alert-success { background: rgba(0,214,143,0.1); border: 1px solid rgba(0,214,143,0.2); color: var(--green); }
.alert-error   { background: rgba(255,77,109,0.1); border: 1px solid rgba(255,77,109,0.2); color: var(--red); }
.alert-warning { background: rgba(245,200,66,0.1); border: 1px solid rgba(245,200,66,0.2); color: var(--gold); }
.alert-info    { background: rgba(77,159,255,0.1);  border: 1px solid rgba(77,159,255,0.2);  color: var(--blue); }

/* ─── CHECKBOX ───────────────────────────────────────────────────────────────── */
.checkbox-wrap { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-wrap input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--gold); cursor: pointer; }

/* ─── DROPDOWN ───────────────────────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  display: none;
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  min-width: 160px;
  z-index: 200;
  box-shadow: var(--shadow);
}
.dropdown-menu.open { display: block; }
.dropdown-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px; color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.dropdown-item:hover { background: var(--surface2); color: var(--text); }
.dropdown-item.danger:hover { color: var(--red); }
.dropdown-divider { height: 1px; background: var(--border-sub); margin: 4px 0; }

/* ─── MOBILE NAV (hamburger + backdrop) ──────────────────────────────────────── */
.mobile-topbar { display: none; }
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 900;
  backdrop-filter: blur(2px);
}
.sidebar-backdrop.open { display: block; }
.hamburger-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  font-size: 17px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-chart { grid-template-columns: 1fr; }
  .grid-bottom { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  /* Layout: allow vertical scroll on phones */
  html, body { height: auto; min-height: 100vh; overflow: visible; overflow-x: hidden; }
  body { display: block; }
  .app-layout { height: auto; min-height: 100vh; overflow: visible; display: block; }
  .main-content { height: auto; overflow: visible; width: 100%; }
  .page-body { padding: 14px; }

  /* Sidebar becomes a slide-in drawer */
  .sidebar {
    position: fixed; top: 0; left: 0;
    width: 270px; height: 100vh;
    transform: translateX(-100%);
    transition: transform .28s ease;
    z-index: 1000;
    overflow-y: auto;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }
  .sidebar.open { transform: translateX(0); }

  /* Mobile top bar with hamburger + brand */
  .mobile-topbar {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 800;
  }
  .mobile-topbar .mt-title { font-weight: 700; font-size: 16px; }
  .mobile-topbar .mt-title span { color: var(--gold); }

  /* Stat / general grids */
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }

  /* Topbar inside pages stacks */
  .topbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .topbar-right { flex-wrap: wrap; }
  .topbar-right .btn, .topbar-right form { flex: 1 1 auto; }
  .topbar-right .btn { justify-content: center; }

  /* Filters stack full width */
  .filters-bar { flex-direction: column; align-items: stretch; }
  .search-input { width: 100%; }
  .filter-select { width: 100%; }

  /* Tabs scroll horizontally instead of wrapping into a tall block */
  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .tab-btn { flex-shrink: 0; }

  /* Inline stats bar wraps */
  .stats-bar { flex-wrap: wrap; gap: 14px; }

  /* ── TABLES → CARDS ─────────────────────────────────────────────────────────
     Each row becomes a card; each cell shows its column name (data-label). */
  .table-wrap { overflow-x: visible; }
  .table-wrap table,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tfoot { display: block; }
  .table-wrap tfoot tr { background: transparent; border: none; }
  .table-wrap tr {
    background: var(--surface2);
    border: 1px solid var(--border-sub);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    padding: 12px 14px;
  }
  .table-wrap tbody tr:hover td { background: transparent; }
  .table-wrap td {
    border: none !important;
    padding: 7px 0 !important;
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; text-align: right;
  }
  .table-wrap td::before {
    content: attr(data-label);
    font-size: 11px; font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .4px;
    text-align: left; flex-shrink: 0;
  }
  /* First cell (name/primary) becomes the card header, full width, no label */
  .table-wrap td:first-child,
  .table-wrap td.primary-cell {
    display: block; text-align: left;
    padding-bottom: 10px !important;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border-sub) !important;
  }
  .table-wrap td:first-child::before,
  .table-wrap td.primary-cell::before { display: none; }
  /* Bulk-select checkboxes aren't useful on phones — hide that column */
  .table-wrap td.select-cell { display: none; }
  .table-wrap td.actions-cell { padding-top: 10px !important; }
  .table-wrap td.actions-cell > div { justify-content: flex-end; flex-wrap: wrap; }

  /* Modals fit small screens */
  .modal { width: 94vw; max-width: 94vw; margin: 16px auto; max-height: 88vh; overflow-y: auto; }

  /* Invoice prints/views fine; nudge padding */
  .stat-value { font-size: 20px; }
}

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