/* ── Braine.ai Admin Panel ── Light Theme ── */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f7f8fc;
  --bg-surface: #f0f2f8;
  --bg-surface-hover: #e8ebf3;
  --bg-surface-active: #dfe3ee;
  --border: #e2e5ef;
  --border-hover: #c8cde0;
  --text-primary: #1B2A4A;
  --text-secondary: #4a5578;
  --text-muted: #8892ad;
  --accent: #1A7AF8;
  --accent-hover: #1565d8;
  --accent-light: #e8f1fe;
  --accent-dim: rgba(26,122,248,0.10);
  --success: #16a34a;
  --success-dim: rgba(22,163,74,0.10);
  --warning: #e5890a;
  --warning-dim: rgba(229,137,10,0.10);
  --danger: #dc2626;
  --danger-dim: rgba(220,38,38,0.10);
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-width: 260px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --shadow-sm: 0 1px 3px rgba(27,42,74,0.06);
  --shadow-md: 0 4px 12px rgba(27,42,74,0.08);
  --shadow-lg: 0 8px 30px rgba(27,42,74,0.12);
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }

/* ══════════════════════════════════════════
   LOGIN
   ══════════════════════════════════════════ */
.login-layout {
  display: flex;
  height: 100vh;
  background: #0b1628;
}

/* ── Left Panel ── */
.login-visual {
  flex: 0 0 55%;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(26,122,248,0.25) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(26,122,248,0.15) 0%, transparent 50%),
    linear-gradient(160deg, #0b1628 0%, #0f2042 40%, #122a54 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 2rem;
}

/* Grid pattern overlay */
.login-visual::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(26,122,248,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26,122,248,0.05) 1px, transparent 1px);
  background-size: 40px 40px;
  z-index: 1;
}

/* Glowing orb */
.login-visual::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(26,122,248,0.2) 0%, transparent 70%);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  animation: pulse-glow 4s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
  50% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
}

.login-mascota {
  width: 320px;
  height: auto;
  filter: drop-shadow(0 10px 40px rgba(26,122,248,0.3));
  position: relative;
  z-index: 2;
  animation: float 5s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}

.login-visual-info {
  position: relative;
  z-index: 2;
  text-align: center;
  margin-top: 2rem;
  max-width: 400px;
}
.login-visual-info h2 {
  color: #ffffff;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.3rem;
}
.login-visual-info .tagline {
  color: rgba(255,255,255,0.5);
  font-size: 0.95rem;
  margin-bottom: 2rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 500;
}

.login-features {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  text-align: left;
}
.login-feature {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  color: rgba(255,255,255,0.85);
  font-size: 0.9rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  backdrop-filter: blur(8px);
  transition: background 0.2s, border-color 0.2s;
}
.login-feature:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(26,122,248,0.3);
}
.login-feature-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(26,122,248,0.3), rgba(26,122,248,0.1));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #5ba3fc;
}
.login-feature-icon svg { width: 18px; height: 18px; }
.login-feature span { line-height: 1.4; font-weight: 500; }

/* ── Right Panel (Form) ── */
.login-form-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--bg-primary);
  position: relative;
}

.login-form-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
}
.login-logo {
  height: 80px;
  margin-bottom: 2rem;
}
.login-form-card h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 0.35rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.login-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.login-form-card .form-group { text-align: left; }

/* Input with icon */
.input-icon-wrap {
  position: relative;
}
.input-icon-wrap svg {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}
.input-icon-wrap input {
  padding-left: 2.75rem !important;
}

/* Login button */
.btn-login {
  background: linear-gradient(135deg, #1A7AF8, #1565d8);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius);
  border: none;
  width: 100%;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(26,122,248,0.3);
  transition: box-shadow 0.2s, transform 0.15s;
  font-family: var(--font);
}
.btn-login:hover {
  box-shadow: 0 6px 24px rgba(26,122,248,0.4);
  transform: translateY(-1px);
}
.btn-login:active { transform: translateY(0); }

/* Footer */
.login-footer {
  position: absolute;
  bottom: 1.5rem;
  left: 0; right: 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ══════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════ */
.form-group {
  margin-bottom: 1.25rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
}
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--bg-primary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  padding: 0.6rem 0.85rem;
  background: var(--danger-dim);
  border-radius: var(--radius);
  border: 1px solid rgba(220,38,38,0.15);
}

/* ══════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, box-shadow 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(26,122,248,0.25);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-surface); border-color: var(--border-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--accent); background: var(--accent-dim); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-block { width: 100%; padding: 0.75rem; font-size: 0.95rem; }

/* ══════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════ */
#sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
}
.sidebar-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo {
  width: 100%;
  max-width: 220px;
  height: auto;
}
#sidebarNav {
  flex: 1;
  padding: 0.75rem 0.75rem;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius);
  margin-bottom: 2px;
  transition: all 0.15s;
}
.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}
.nav-item.active {
  color: var(--accent);
  background: var(--accent-light);
  font-weight: 600;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-user {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ══════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════ */
#mainContent {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
}

/* ── Top Banner ── */
.banner-wrap {
  position: relative;
  overflow: hidden;
}
.top-banner {
  width: 100%;
  height: 140px;
  object-fit: cover;
  object-position: center 40%;
  display: block;
}
.banner-controls {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.35rem;
  opacity: 0;
  transition: opacity 0.2s;
}
.banner-wrap:hover .banner-controls { opacity: 1; }
.banner-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.9);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s;
}
.banner-btn:hover {
  background: #fff;
  color: var(--accent);
}

/* Banner editing mode */
.banner-editing .top-banner {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}
.banner-editing .banner-controls { display: none; }
.banner-toolbar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(27,42,74,0.85);
  backdrop-filter: blur(8px);
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}
.banner-toolbar-hint {
  color: rgba(255,255,255,0.8);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.banner-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.banner-toolbar-label {
  color: rgba(255,255,255,0.8);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.banner-toolbar-label input[type="range"] {
  width: 100px;
  accent-color: var(--accent);
}

/* Banner restore button */
.banner-restore-btn {
  position: absolute;
  top: 50%; right: 1rem;
  transform: translateY(-50%);
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font);
  transition: background 0.15s;
}
.banner-restore-btn:hover {
  background: var(--accent-light);
}

#topBar {
  position: relative;
  padding: 1.25rem 2rem;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}
#topBar h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}
#pageContainer {
  flex: 1;
  padding: 1.5rem 2rem;
}
.page-section {
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════
   STATS GRID
   ══════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
}

/* ══════════════════════════════════════════
   HEALTH GRID
   ══════════════════════════════════════════ */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.health-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
}
.health-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.health-dot.ok { background: var(--success); box-shadow: 0 0 8px rgba(22,163,74,0.4); }
.health-dot.fail { background: var(--danger); box-shadow: 0 0 8px rgba(220,38,38,0.4); }
.health-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ══════════════════════════════════════════
   DATA TABLE
   ══════════════════════════════════════════ */
.data-table-wrap {
  overflow-x: auto;
  margin-bottom: 1rem;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  padding: 0.8rem 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  background: var(--bg-secondary);
}
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td {
  background: var(--bg-surface);
}
.data-table .text-truncate {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ══════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════ */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: var(--success-dim); color: var(--success); }
.badge-warning { background: var(--warning-dim); color: var(--warning); }
.badge-danger { background: var(--danger-dim); color: var(--danger); }
.badge-info { background: var(--accent-dim); color: var(--accent); }
.badge-muted { background: rgba(136,146,173,0.12); color: var(--text-muted); }

/* Icon action buttons */
.action-btns {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  justify-content: center;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}
.icon-btn:hover {
  border-color: var(--border-hover);
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}
.icon-btn svg {
  width: 15px;
  height: 15px;
}
.icon-btn-edit:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}
.icon-btn-delete:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-dim);
}
.icon-btn-view:hover {
  color: var(--success);
  border-color: var(--success);
  background: var(--success-dim);
}

/* Area type badge */
.area-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--accent-dim);
  color: var(--accent);
  white-space: nowrap;
}
.area-badge-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}
.area-badge-icon svg {
  width: 14px;
  height: 14px;
}

/* Area type custom select */
.area-select {
  position: relative;
  width: 100%;
}
.area-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-primary);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.area-select-trigger:hover {
  border-color: var(--accent);
}
.area-select.open .area-select-trigger {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.area-select-value {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-primary);
}
.area-select-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.area-select-icon svg {
  width: 18px;
  height: 18px;
}
.area-select-arrow {
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.area-select.open .area-select-arrow {
  transform: rotate(180deg);
}
.area-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 1000;
  overflow: hidden;
}
.area-select.open .area-select-dropdown {
  display: block;
}
.area-select-search-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.area-select-search {
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  font-size: 0.85rem;
  color: var(--text-primary);
}
.area-select-search::placeholder {
  color: var(--text-muted);
}
.area-select-options {
  max-height: 240px;
  overflow-y: auto;
  padding: 0.35rem 0;
}
.area-select-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.1s;
}
.area-select-option:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}
.area-select-option.selected {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
}
.area-select-options::-webkit-scrollbar {
  width: 5px;
}
.area-select-options::-webkit-scrollbar-track {
  background: transparent;
}
.area-select-options::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ══════════════════════════════════════════
   CONFIDENCE BAR
   ══════════════════════════════════════════ */
.confidence-bar {
  width: 60px; height: 6px;
  background: var(--bg-surface-active);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.4rem;
}
.confidence-bar-fill {
  height: 100%;
  border-radius: 3px;
}

/* ══════════════════════════════════════════
   PAGINATION
   ══════════════════════════════════════════ */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
}
.pagination .btn { min-width: 36px; }
.pagination .page-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ══════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(27,42,74,0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 1.5rem; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ══════════════════════════════════════════
   FILTER BAR
   ══════════════════════════════════════════ */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  align-items: flex-end;
}
.filter-bar .form-group { margin-bottom: 0; }
.filter-bar select, .filter-bar input {
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
}

/* ══════════════════════════════════════════
   WHATSAPP SECTION
   ══════════════════════════════════════════ */
.wa-status-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  text-align: center;
  max-width: 480px;
  margin: 0 auto 2rem;
  box-shadow: var(--shadow-md);
}
.wa-status-card h3 { margin-bottom: 1rem; color: var(--text-primary); }
.wa-qr-frame {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: inline-block;
  margin: 1rem 0;
  border: 2px solid var(--border);
}
.wa-qr-frame img { display: block; width: 280px; height: 280px; }
.wa-connected-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 1rem 0;
}
.wa-phone {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.wa-divider {
  color: var(--text-muted);
  margin: 1rem 0;
  font-size: 0.85rem;
}
.wa-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

/* ══════════════════════════════════════════
   SECTION HEADER
   ══════════════════════════════════════════ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.section-header h3 { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }

/* ══════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════ */
#toastContainer {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  color: #fff;
  animation: slideUp 0.3s ease;
  max-width: 360px;
  box-shadow: var(--shadow-md);
}
.toast-success { background: #16a34a; }
.toast-error { background: #dc2626; }
.toast-info { background: #1A7AF8; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════
   LOADING
   ══════════════════════════════════════════ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}
.empty-state p { font-size: 0.95rem; }

/* ══════════════════════════════════════════
   SETTINGS
   ══════════════════════════════════════════ */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}
.settings-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.settings-card h4 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}
.settings-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.85rem;
}
.settings-row .label { color: var(--text-muted); }
.settings-row .value { color: var(--text-secondary); font-weight: 600; }

/* ══════════════════════════════════════════
   MODAL SIZES
   ══════════════════════════════════════════ */
.modal.modal-lg { max-width: 780px; }
.modal.modal-md { max-width: 640px; }

/* ══════════════════════════════════════════
   TEMPLATE BUILDER
   ══════════════════════════════════════════ */
.tpl-builder { display: flex; flex-direction: column; gap: 0.25rem; }
.tpl-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.75rem; }
.tpl-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.tpl-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.5rem;
}
.tpl-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}
.tpl-section-title small {
  font-weight: 400;
  color: var(--text-muted);
}

/* ── Template Cards Grid ── */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.tpl-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.tpl-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.tpl-card-inactive { opacity: 0.7; }
.tpl-card-inactive:hover { opacity: 1; }

.tpl-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.tpl-card-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tpl-card-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.tpl-card-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.tpl-card-body {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  min-height: 2.8em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.tpl-card-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.tpl-card-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.7rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* ── WhatsApp Phone Preview ── */
.tpl-phone-preview {
  display: flex;
  justify-content: center;
  padding: 1rem;
}
.tpl-phone-screen {
  background: #e5ddd5;
  border-radius: 12px;
  padding: 1rem;
  width: 100%;
  max-width: 360px;
  min-height: 120px;
  position: relative;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}
.tpl-phone-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: url("data:image/svg+xml,%3Csvg width='200' height='200' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3Cpattern id='p' width='40' height='40' patternUnits='userSpaceOnUse'%3E%3Ccircle cx='20' cy='20' r='0.8' fill='rgba(0,0,0,0.03)'/%3E%3C/pattern%3E%3C/defs%3E%3Crect width='200' height='200' fill='url(%23p)'/%3E%3C/svg%3E");
  pointer-events: none;
}
.tpl-phone-screen > * { position: relative; z-index: 1; }

.tpl-prev-header {
  background: #ffffff;
  border-radius: 8px 8px 0 0;
  padding: 0.75rem 1rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: #1B2A4A;
}
.tpl-prev-media {
  background: linear-gradient(135deg, #c3dafe 0%, #93b5f0 100%);
  border-radius: 8px 8px 0 0;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
}
.tpl-prev-media svg { width: 32px; height: 32px; }
.tpl-prev-media span { font-size: 0.85rem; font-weight: 500; }
.tpl-prev-media.tpl-prev-doc {
  background: linear-gradient(135deg, #fde68a 0%, #f59e0b 100%);
}

.tpl-prev-body {
  background: #ffffff;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: #333;
  line-height: 1.5;
  border-radius: 0;
}
.tpl-phone-screen > .tpl-prev-body:first-child {
  border-radius: 8px 8px 0 0;
}

.tpl-prev-footer {
  background: #ffffff;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  color: #8696a0;
}

.tpl-prev-buttons {
  margin-top: 2px;
}
.tpl-prev-btn {
  background: #ffffff;
  text-align: center;
  padding: 0.6rem;
  color: #00a884;
  font-weight: 500;
  font-size: 0.85rem;
  cursor: default;
  border-top: 1px solid #e9edef;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.tpl-prev-btn:last-child {
  border-radius: 0 0 8px 8px;
}
.tpl-prev-btn svg { width: 14px; height: 14px; stroke: #00a884; }

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */
@media (max-width: 768px) {
  .login-visual { display: none; }
  #sidebar { width: 100%; position: relative; }
  #mainContent { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .top-banner { height: 100px; }
  .tpl-row-3 { grid-template-columns: 1fr; }
  .tpl-row-2 { grid-template-columns: 1fr; }
  .tpl-grid { grid-template-columns: 1fr; }
  .modal.modal-lg { max-width: 95%; }
}
