/* =============================================
   WhatsApp API Panel — Design System v3
   ============================================= */

/* ---- Variables ---- */
:root {
  --green: #25D366;
  --green-dark: #128C7E;
  --green-light: #dcf8c6;
  --teal: #075E54;

  --sidebar-bg: #0f172a;
  --sidebar-width: 260px;

  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;

  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;

  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);

  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
  --transition: 0.18s ease;

  /* Backward-compatible aliases */
  --primary-color: #25D366;
  --primary-dark: #128C7E;
  --primary-light: #dcf8c6;
  --whatsapp-green: #25D366;
  --whatsapp-green-dark: #128C7E;
  --whatsapp-green-light: #dcf8c6;
  --whatsapp-teal: #075E54;
  --whatsapp-light-gray: #f1f5f9;
  --whatsapp-blue: #3b82f6;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --info-color: #3b82f6;
  --border-color: #e2e8f0;
  --light-bg: #f1f5f9;
  --card-bg: #ffffff;
  --shadow-xl: 0 10px 40px rgba(0,0,0,0.12);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  font-size: 14px;
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition);
  overflow: hidden;
}

/* Logo */
.sidebar-logo {
  padding: 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 38px; height: 38px;
  background: var(--green);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-icon svg { width: 22px; height: 22px; fill: white; }

.sidebar-logo-text {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.sidebar-logo-text span {
  display: block;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.4);
  font-weight: 400;
  margin-top: 1px;
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  padding: 0.75rem;
  overflow-y: auto;
  scrollbar-width: none;
}

.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section {
  margin-bottom: 0.25rem;
}

.nav-section-title {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.28);
  padding: 0.875rem 0.625rem 0.4rem;
}

.nav-item { margin-bottom: 1px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.575rem 0.625rem;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.55);
  font-size: 0.8375rem;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
}

.nav-link:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.88);
}

.nav-link.active {
  background: rgba(37,211,102,0.12);
  color: var(--green);
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--green);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.nav-icon svg { width: 17px; height: 17px; fill: currentColor; }

/* User Footer */
.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.375rem;
}

.user-avatar {
  width: 34px; height: 34px;
  background: var(--green);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-info-text h6 {
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255,255,255,0.88);
  margin: 0;
  line-height: 1.3;
}

.user-info-text small {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.35);
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.4);
  font-size: 0.78rem;
  transition: all var(--transition);
  width: 100%;
}

.logout-btn:hover {
  background: rgba(239,68,68,0.12);
  color: #fca5a5;
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 999;
  backdrop-filter: blur(2px);
}

/* =============================================
   MAIN LAYOUT
   ============================================= */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.sidebar-toggle {
  display: none;
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: var(--radius-sm);
  align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
  font-size: 1rem;
}

.sidebar-toggle:hover { background: var(--bg); color: var(--text); }

.page-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.topbar-user {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

/* Content Area */
.content-body {
  padding: 1.5rem;
  flex: 1;
}

/* =============================================
   CARDS
   ============================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 0.875rem 1.125rem;
  border-bottom: 1px solid var(--border);
  background: transparent;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--radius) var(--radius) 0 0;
}

.card-body { padding: 1.125rem; }
.card-body.p-0 { padding: 0; }

/* Stat Cards */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.125rem;
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--green);
}

.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-card.blue::before { background: var(--info); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.info::before { background: var(--info); }

.stat-card-body { flex: 1; }

.stat-value {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.stat-label {
  font-size: 0.71rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  background: rgba(37,211,102,0.1);
  color: var(--green);
  flex-shrink: 0;
  margin-left: 0.75rem;
}

.stat-card.blue .stat-icon { background: rgba(59,130,246,0.1); color: var(--info); }
.stat-card.success .stat-icon { background: rgba(16,185,129,0.1); color: var(--success); }
.stat-card.warning .stat-icon { background: rgba(245,158,11,0.1); color: var(--warning); }
.stat-card.danger .stat-icon { background: rgba(239,68,68,0.1); color: var(--danger); }
.stat-card.info .stat-icon { background: rgba(59,130,246,0.1); color: var(--info); }

/* Legacy stats-card class (for dashboard) */
.stats-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.125rem;
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stats-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.stats-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--green);
}

.stats-card.success::before { background: var(--success); }
.stats-card.info::before { background: var(--info); }
.stats-card.warning::before { background: var(--warning); }
.stats-card.danger::before { background: var(--danger); }

.stats-content { flex: 1; }

.stats-number {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.stats-label {
  font-size: 0.71rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.stats-icon {
  width: 44px; height: 44px;
  background: rgba(37,211,102,0.1);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  color: var(--green);
  flex-shrink: 0;
  margin-left: 0.75rem;
}

.stats-card.success .stats-icon { background: rgba(16,185,129,0.1); color: var(--success); }
.stats-card.info .stats-icon { background: rgba(59,130,246,0.1); color: var(--info); }
.stats-card.warning .stats-icon { background: rgba(245,158,11,0.1); color: var(--warning); }
.stats-card.danger .stats-icon { background: rgba(239,68,68,0.1); color: var(--danger); }

/* =============================================
   TABLES
   ============================================= */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8375rem;
}

.table th {
  padding: 0.6875rem 1rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 0.8125rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr { transition: background var(--transition); }
.table-hover tbody tr:hover { background: rgba(37,211,102,0.03); }

.table-light th { background: #f8fafc; }

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive > .table { min-width: 600px; }

/* =============================================
   BUTTONS
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.475rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.8375rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all var(--transition);
  line-height: 1.5;
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); opacity: 1; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; pointer-events: none; }

.btn-primary { background: var(--green); border-color: var(--green); color: white; }
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); color: white; }

.btn-success { background: var(--success); border-color: var(--success); color: white; }
.btn-success:hover { background: #059669; border-color: #059669; color: white; }

.btn-danger { background: var(--danger); border-color: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; color: white; }

.btn-warning { background: var(--warning); border-color: var(--warning); color: white; }
.btn-warning:hover { background: #d97706; border-color: #d97706; color: white; }

.btn-info { background: var(--info); border-color: var(--info); color: white; }
.btn-info:hover { background: #2563eb; border-color: #2563eb; color: white; }

.btn-secondary { background: var(--text-muted); border-color: var(--text-muted); color: white; }
.btn-secondary:hover { background: #475569; border-color: #475569; color: white; }

.btn-light { background: var(--bg); border-color: var(--border); color: var(--text); }
.btn-light:hover { background: var(--border); color: var(--text); }

.btn-outline-primary { background: transparent; border-color: var(--green); color: var(--green); }
.btn-outline-primary:hover { background: var(--green); color: white; }

.btn-outline-success { background: transparent; border-color: var(--success); color: var(--success); }
.btn-outline-success:hover { background: var(--success); color: white; }

.btn-outline-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); color: white; }

.btn-outline-warning { background: transparent; border-color: var(--warning); color: var(--warning); }
.btn-outline-warning:hover { background: var(--warning); color: white; }

.btn-outline-info { background: transparent; border-color: var(--info); color: var(--info); }
.btn-outline-info:hover { background: var(--info); color: white; }

.btn-outline-secondary { background: transparent; border-color: var(--border); color: var(--text-muted); }
.btn-outline-secondary:hover { background: var(--bg); border-color: var(--text-light); color: var(--text); }

.btn-sm { padding: 0.3rem 0.625rem; font-size: 0.775rem; border-radius: 6px; }
.btn-lg { padding: 0.625rem 1.25rem; font-size: 0.9375rem; border-radius: var(--radius); }

/* =============================================
   BADGES
   ============================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem 0.55rem;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.4;
}

.badge.bg-success, .bg-success { background: rgba(16,185,129,0.12) !important; color: #065f46 !important; }
.badge.bg-danger,  .bg-danger  { background: rgba(239,68,68,0.12)  !important; color: #991b1b !important; }
.badge.bg-warning, .bg-warning { background: rgba(245,158,11,0.12) !important; color: #92400e !important; }
.badge.bg-info,    .bg-info    { background: rgba(59,130,246,0.12)  !important; color: #1e3a8a !important; }
.badge.bg-primary, .bg-primary { background: rgba(37,211,102,0.12)  !important; color: #065f46 !important; }
.badge.bg-secondary,.bg-secondary { background: rgba(100,116,139,0.12) !important; color: var(--text-muted) !important; }

.text-dark { color: var(--text) !important; }

/* =============================================
   FORMS
   ============================================= */
.form-label {
  display: block;
  font-size: 0.8375rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.375rem;
}

.form-control, .form-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8375rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  line-height: 1.5;
  appearance: none;
  -webkit-appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2364748b'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  background-size: 16px;
  padding-right: 2rem;
}

.form-control:focus, .form-select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(37,211,102,0.15);
}

.form-control::placeholder { color: var(--text-light); }

textarea.form-control { resize: vertical; min-height: 100px; }

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.form-check-input {
  width: 16px; height: 16px;
  accent-color: var(--green);
  cursor: pointer;
  flex-shrink: 0;
}

.form-check-label { font-size: 0.8375rem; cursor: pointer; }

.form-text {
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  display: block;
}

.invalid-feedback {
  font-size: 0.775rem;
  color: var(--danger);
  margin-top: 0.25rem;
}

/* Input Group */
.input-group { display: flex; }
.input-group .form-control { border-radius: 0; }
.input-group .form-control:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .form-control:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group-text {
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-right: none;
  font-size: 0.8375rem;
  color: var(--text-muted);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  white-space: nowrap;
  display: flex;
  align-items: center;
}

/* Row/Col grid */
.row { display: flex; flex-wrap: wrap; margin-left: -0.75rem; margin-right: -0.75rem; }
.row > * { padding-left: 0.75rem; padding-right: 0.75rem; }

.col-1  { width: 8.333%; }
.col-2  { width: 16.666%; }
.col-3  { width: 25%; }
.col-4  { width: 33.333%; }
.col-5  { width: 41.666%; }
.col-6  { width: 50%; }
.col-7  { width: 58.333%; }
.col-8  { width: 66.666%; }
.col-9  { width: 75%; }
.col-10 { width: 83.333%; }
.col-11 { width: 91.666%; }
.col-12 { width: 100%; }

@media (min-width: 576px) {
  .col-sm-6  { width: 50%; }
  .col-sm-12 { width: 100%; }
}

@media (min-width: 768px) {
  .col-md-2 { width: 16.666%; }
  .col-md-3 { width: 25%; }
  .col-md-4 { width: 33.333%; }
  .col-md-6 { width: 50%; }
  .col-md-8 { width: 66.666%; }
  .col-md-9 { width: 75%; }
  .col-md-10{ width: 83.333%; }
  .col-md-12{ width: 100%; }
}

@media (min-width: 992px) {
  .col-lg-2 { width: 16.666%; }
  .col-lg-3 { width: 25%; }
  .col-lg-4 { width: 33.333%; }
  .col-lg-6 { width: 50%; }
  .col-lg-8 { width: 66.666%; }
  .col-lg-9 { width: 75%; }
  .col-lg-10{ width: 83.333%; }
  .col-lg-12{ width: 100%; }
}

@media (min-width: 1200px) {
  .col-xl-3 { width: 25%; }
  .col-xl-4 { width: 33.333%; }
  .col-xl-6 { width: 50%; }
}

/* =============================================
   ALERTS
   ============================================= */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8375rem;
  border: none;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  position: relative;
}

.alert-success  { background: rgba(16,185,129,0.08);  color: #065f46; border-left: 3px solid var(--success); }
.alert-danger   { background: rgba(239,68,68,0.08);   color: #991b1b; border-left: 3px solid var(--danger); }
.alert-warning  { background: rgba(245,158,11,0.08);  color: #92400e; border-left: 3px solid var(--warning); }
.alert-info     { background: rgba(59,130,246,0.08);  color: #1e3a8a; border-left: 3px solid var(--info); }

.alert-dismissible { padding-right: 2.5rem; }
.btn-close {
  position: absolute; top: 0.625rem; right: 0.75rem;
  background: none; border: none; cursor: pointer;
  opacity: 0.5; font-size: 1rem; line-height: 1;
  transition: opacity var(--transition);
  color: currentColor;
}
.btn-close:hover { opacity: 1; }
.btn-close::before { content: '×'; }

/* =============================================
   PAGINATION
   ============================================= */
.pagination {
  display: flex;
  align-items: center;
  gap: 3px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.page-link {
  display: flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px;
  padding: 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--text-muted);
  transition: all var(--transition);
  background: var(--surface);
}

.page-link:hover { background: var(--bg); border-color: var(--green); color: var(--green); }
.page-item.active .page-link { background: var(--green); border-color: var(--green); color: white; }
.page-item.disabled .page-link { opacity: 0.4; pointer-events: none; }

/* Pagination sm */
.pagination-sm .page-link { min-width: 28px; height: 28px; font-size: 0.75rem; }

/* =============================================
   MODALS (Bootstrap compat)
   ============================================= */
.modal-content {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 1rem 1.125rem;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 0.9375rem; font-weight: 600; }

.modal-body { padding: 1.125rem; }

.modal-footer {
  padding: 0.875rem 1.125rem;
  border-top: 1px solid var(--border);
  gap: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* =============================================
   CODE / PRE
   ============================================= */
code {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.8125rem;
  background: #f1f5f9;
  padding: 0.15rem 0.375rem;
  border-radius: 4px;
  color: #e11d48;
}

pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 0.8125rem;
  line-height: 1.7;
}

pre code { background: none; padding: 0; color: inherit; }

.text-success code { color: #25D366; }
.text-info code { color: #34B7F1; }

/* =============================================
   STATUS INDICATORS
   ============================================= */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online { background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,0.2); }
.status-dot.offline { background: var(--danger); }
.status-dot.warning { background: var(--warning); }
.status-dot.connecting {
  background: var(--info);
  animation: blink 1.4s ease-in-out infinite;
}

.status-indicator {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-indicator.bg-success { background: var(--success) !important; animation: pulse-ring 2s ease infinite; }
.status-indicator.bg-danger  { background: var(--danger) !important; }

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); }
  70%  { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

/* =============================================
   QR CODE
   ============================================= */
#qr-section {
  background: #f8fafc;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}

#qr-code img {
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  max-width: 100%;
}

/* =============================================
   SPINNER
   ============================================= */
.spinner-border {
  display: inline-block;
  width: 2rem; height: 2rem;
  border: 0.22em solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-border-sm { width: 1rem; height: 1rem; border-width: 0.15em; }

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

.visually-hidden {
  position: absolute; clip: rect(0,0,0,0);
  width: 1px; height: 1px; overflow: hidden; white-space: nowrap;
}

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */
.toast-container {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  z-index: 9999;
  display: flex; flex-direction: column;
  gap: 0.5rem; max-width: 350px;
}

.toast-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: flex-start; gap: 0.625rem;
  animation: toastIn 0.25s ease;
}

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

@keyframes toastIn { from { opacity: 0; transform: translateX(12px); } }

/* =============================================
   LOGIN PAGE
   ============================================= */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 40%, #064e3b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 32px 64px rgba(0,0,0,0.35);
  overflow: hidden;
  animation: loginSlide 0.45s ease-out;
}

@keyframes loginSlide {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-header {
  background: linear-gradient(135deg, #0f172a 0%, #075E54 100%);
  padding: 2rem 1.75rem;
  text-align: center;
}

.login-header-icon {
  width: 60px; height: 60px;
  background: var(--green);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  box-shadow: 0 8px 24px rgba(37,211,102,0.35);
}

.login-header-icon svg { width: 34px; height: 34px; fill: white; }

.login-header h2 {
  color: white; font-size: 1.1875rem; font-weight: 700; margin: 0;
}

.login-header p {
  color: rgba(255,255,255,0.55); font-size: 0.8125rem; margin: 0.375rem 0 0;
}

.login-body { padding: 1.75rem; }

.login-body .form-group { margin-bottom: 1.125rem; }

.login-body .form-control {
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
}

.login-body .form-label { font-size: 0.8125rem; margin-bottom: 0.375rem; }

.login-btn {
  width: 100%;
  background: var(--green);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6875rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.login-btn:hover {
  background: var(--green-dark);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(37,211,102,0.3);
}

/* =============================================
   UTILITIES
   ============================================= */
.text-success  { color: var(--success)   !important; }
.text-danger   { color: var(--danger)    !important; }
.text-warning  { color: var(--warning)   !important; }
.text-info     { color: var(--info)      !important; }
.text-muted    { color: var(--text-muted)!important; }
.text-primary  { color: var(--green)     !important; }
.text-white    { color: white            !important; }
.text-center   { text-align: center   !important; }
.text-end      { text-align: right    !important; }
.text-start    { text-align: left     !important; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fw-bold     { font-weight: 700 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-medium   { font-weight: 500 !important; }
.fw-normal   { font-weight: 400 !important; }

.fs-6        { font-size: 0.875rem !important; }
.fs-5        { font-size: 1rem     !important; }

.small, small { font-size: 0.775rem; }

.d-flex   { display: flex   !important; }
.d-block  { display: block  !important; }
.d-grid   { display: grid   !important; }
.d-inline { display: inline !important; }
.d-inline-flex { display: inline-flex !important; }
.d-none   { display: none   !important; }

.align-items-center   { align-items: center         !important; }
.align-items-start    { align-items: flex-start      !important; }
.align-items-end      { align-items: flex-end        !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center  { justify-content: center        !important; }
.justify-content-end     { justify-content: flex-end      !important; }
.justify-content-start   { justify-content: flex-start    !important; }
.flex-wrap    { flex-wrap: wrap    !important; }
.flex-column  { flex-direction: column !important; }
.flex-shrink-0{ flex-shrink: 0     !important; }
.flex-fill    { flex: 1 1 auto     !important; }

.gap-1 { gap: 0.25rem  !important; }
.gap-2 { gap: 0.5rem   !important; }
.gap-3 { gap: 0.75rem  !important; }
.gap-4 { gap: 1rem     !important; }

.w-100  { width: 100%  !important; }
.h-100  { height: 100% !important; }
.mw-100 { max-width: 100%; }

.mb-0 { margin-bottom: 0    !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem  !important; }
.mb-3 { margin-bottom: 0.75rem !important; }
.mb-4 { margin-bottom: 1rem    !important; }
.mb-5 { margin-bottom: 1.5rem  !important; }

.mt-0 { margin-top: 0    !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem  !important; }
.mt-3 { margin-top: 0.75rem !important; }
.mt-4 { margin-top: 1rem    !important; }

.me-1 { margin-right: 0.25rem !important; }
.me-2 { margin-right: 0.5rem  !important; }
.me-3 { margin-right: 0.75rem !important; }

.ms-0    { margin-left: 0       !important; }
.ms-1    { margin-left: 0.25rem !important; }
.ms-2    { margin-left: 0.5rem  !important; }
.ms-auto { margin-left: auto    !important; }

.p-0  { padding: 0          !important; }
.p-2  { padding: 0.5rem     !important; }
.p-3  { padding: 0.75rem    !important; }
.p-4  { padding: 1rem       !important; }

.py-1 { padding-top: 0.25rem  !important; padding-bottom: 0.25rem  !important; }
.py-2 { padding-top: 0.5rem   !important; padding-bottom: 0.5rem   !important; }
.py-3 { padding-top: 0.75rem  !important; padding-bottom: 0.75rem  !important; }
.py-4 { padding-top: 1rem     !important; padding-bottom: 1rem     !important; }
.py-5 { padding-top: 1.5rem   !important; padding-bottom: 1.5rem   !important; }

.px-2 { padding-left: 0.5rem  !important; padding-right: 0.5rem  !important; }
.px-3 { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
.px-4 { padding-left: 1rem    !important; padding-right: 1rem    !important; }

.pt-2 { padding-top: 0.5rem !important; }
.pb-2 { padding-bottom: 0.5rem !important; }

.rounded    { border-radius: var(--radius-sm) !important; }
.rounded-0  { border-radius: 0               !important; }
.rounded-circle { border-radius: 50%         !important; }
.rounded-pill { border-radius: 100px         !important; }

.border     { border: 1px solid var(--border) !important; }
.border-0   { border: none                    !important; }
.border-top { border-top: 1px solid var(--border) !important; }

.bg-light   { background: #f8fafc             !important; }
.bg-dark    { background: #0f172a             !important; }
.bg-white   { background: white               !important; }
.bg-success { background: rgba(16,185,129,0.12) !important; color: #065f46 !important; }
.bg-danger  { background: rgba(239,68,68,0.12)  !important; color: #991b1b !important; }
.bg-warning { background: rgba(245,158,11,0.12) !important; color: #92400e !important; }
.bg-info    { background: rgba(59,130,246,0.12) !important; color: #1e3a8a !important; }

.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow    { box-shadow: var(--shadow)    !important; }

.overflow-hidden { overflow: hidden !important; }
.overflow-auto   { overflow: auto   !important; }

.position-relative { position: relative !important; }
.position-absolute { position: absolute !important; }
.position-sticky   { position: sticky   !important; }
.top-0 { top: 0 !important; }

.opacity-50 { opacity: 0.5 !important; }
.opacity-75 { opacity: 0.75 !important; }

.text-decoration-none { text-decoration: none !important; }

.img-fluid { max-width: 100%; height: auto; }

/* Responsive helpers */
@media (min-width: 768px) {
  .text-md-end { text-align: right !important; }
  .mt-md-0    { margin-top: 0     !important; }
  .d-md-flex  { display: flex     !important; }
  .d-md-none  { display: none     !important; }
  .d-md-block { display: block    !important; }
}

@media (min-width: 992px) {
  .d-lg-none  { display: none   !important; }
  .d-lg-block { display: block  !important; }
  .d-lg-flex  { display: flex   !important; }
}

/* h1-h6 helpers */
.h1, .h2, .h3, .h4, .h5, .h6 { font-weight: 600; line-height: 1.3; color: var(--text); }
.h1 { font-size: 1.75rem; }
.h2 { font-size: 1.5rem; }
.h3 { font-size: 1.25rem; }
.h4 { font-size: 1.125rem; }
.h5 { font-size: 1rem; }
.h6 { font-size: 0.875rem; }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .content-body { padding: 1rem; }
}

@media (max-width: 575px) {
  .topbar { padding: 0 0.875rem; }
  .content-body { padding: 0.75rem; }
  .card-body { padding: 0.875rem; }
  .stat-value { font-size: 1.375rem; }
  .stats-number { font-size: 1.375rem; }
  .login-body { padding: 1.25rem; }
  .login-header { padding: 1.5rem 1.25rem; }
}

/* =============================================
   PRINT
   ============================================= */
@media print {
  .sidebar, .topbar, .btn, .pagination, .sidebar-toggle, .sidebar-overlay { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
}

/* =============================================
   ACCESSIBILITY
   ============================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
