:root {
  /* --- PALETA PREMIUM (Gold & Greyscale) --- */
  --bg-body: #F8F9FA;
  --bg-sidebar: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-hover: #F2F2F2;

  --text-main: #111111;
  --text-secondary: #666666;
  --text-light: #999999;

  --border: #EAEAEA;
  --border-strong: #D1D1D1;

  /* Brand Colors */
  --gold: #C6A87C;
  --gold-dim: rgba(198, 168, 124, 0.15);
  --gold-dark: #9C825C;

  /* Functional Colors */
  --success: #2E7D32;
  --success-bg: rgba(46, 125, 50, 0.08);
  --warning: #ED6C02;
  --warning-bg: rgba(237, 108, 2, 0.08);
  --danger: #D32F2F;

  --shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.08);

  --font: "Onest", sans-serif;
  --radius: 16px;
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

[data-theme="dark"] {
  --bg-body: #0A0A0A;
  --bg-sidebar: #111111;
  --bg-card: #161616;
  --bg-hover: #222222;

  --text-main: #F4F4F4;
  --text-secondary: #A0A0A0;
  --text-light: #555555;

  --border: #2A2A2A;
  --border-strong: #444444;

  --gold: #D4B88C;
  --gold-dim: rgba(212, 184, 140, 0.1);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font);
  outline: none;
}

body {
  background-color: var(--bg-body);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  overflow: hidden;
  transition: var(--transition);
}

/* --- SIDEBAR --- */
.sidebar {
  width: 270px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  z-index: 20;
  transition: var(--transition);
}

.brand {
  padding: 0 12px 32px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  background: var(--text-main);
  color: var(--bg-sidebar);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.brand-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-label {
  font-size: 11px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  padding: 0 12px 12px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  font-size: 14px;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--gold-dim);
  color: var(--gold);
  font-weight: 600;
}

.nav-item i {
  font-size: 18px;
}

.user-card {
  margin-top: auto;
  background: var(--bg-hover);
  padding: 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

/* --- MAIN --- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Header */
.header {
  height: 72px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-body);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.date-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.date-picker:hover {
  border-color: var(--border-strong);
  color: var(--text-main);
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-circle:hover {
  background: var(--bg-hover);
  transform: translateY(-2px);
}

.btn-gold {
  background: var(--gold);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 30px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(198, 168, 124, 0.3);
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-gold:hover {
  background: var(--gold-dark);
  transform: translateY(-1px);
}

/* Scroll Area */
.dashboard-scroll {
  padding: 32px;
  overflow-y: auto;
  height: calc(100vh - 72px);
}

/* Grid Layouts */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 2.5fr 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

/* Adjusted for wider chart */
.grid-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--border-strong);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.card-action {
  font-size: 12px;
  color: var(--gold);
  font-weight: 600;
  cursor: pointer;
}

/* KPI Widgets */
.kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -1px;
}

.kpi-footer {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 11px;
}

.bg-up {
  background: var(--success-bg);
  color: var(--success);
}

.bg-down {
  background: var(--warning-bg);
  color: var(--warning);
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-light);
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 16px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
}

tr:last-child td {
  border-bottom: none;
}

.avatar-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-sm {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
}

.txt-bold {
  font-weight: 600;
  display: block;
  font-size: 14px;
}

.txt-light {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
}

.status-pill {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.st-done {
  background: var(--bg-hover);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
}

.st-booked {
  background: var(--gold-dim);
  color: var(--gold);
  border: 1px solid transparent;
}

/* List Items */
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.list-row:last-child {
  border-bottom: none;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-hover);
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 3px;
}

@media (max-width: 1200px) {

  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }
}

/* --- ESTILOS EXTRA PARA NOTIFICACIONES Y ENLACES --- */

/* Reset para enlaces del sidebar para que hereden los estilos del div original */
a.nav-item,
a.user-card {
  text-decoration: none;
  color: inherit;
  display: flex;
}

/* Panel de Notificaciones (Slide-in) */
.notification-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
  z-index: 900;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.notification-overlay.active {
  opacity: 1;
  visibility: visible;
}

.notification-sidebar {
  position: fixed;
  top: 0;
  right: -350px;
  /* Oculto inicialmente */
  width: 320px;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 1000;
  transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: -5px 0 25px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.notification-sidebar.active {
  right: 0;
}

.notif-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.notif-list {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.notif-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  transition: background 0.2s;
  cursor: pointer;
}

.notif-item:hover {
  background: var(--bg-hover);
}

.notif-item.unread {
  background: var(--gold-dim);
  /* Fondo dorado muy sutil para no leídos */
}

.notif-icon {
  width: 36px;
  height: 36px;
  background: var(--bg-body);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  flex-shrink: 0;
}

.notif-content h4 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-main);
}

.notif-content p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.notif-time {
  font-size: 10px;
  color: var(--text-light);
  margin-top: 6px;
  display: block;
}

/* Asegura que el punto rojo se posicione respecto al botón */
.btn-circle {
  position: relative;
}

/* --- BRAND LOGO STYLES --- */
.brand {
  padding: 10px 12px 40px 12px;
  /* Aumentamos un poco el espacio inferior */
  display: flex;
  justify-content: center;
  /* Centra el logo horizontalmente */
  align-items: center;
}

.brand-img {
  max-width: 80px;
  /* Ajusta este valor según el ancho de tu logo original */
  width: 100%;
  height: auto;
  object-fit: contain;
  /* Filtro opcional para modo oscuro: si tu logo es negro y quieres que se vea blanco en dark mode */
}

/* Si tu logo es oscuro y necesitas que resalte en el modo oscuro, añade esto: */
[data-theme="dark"] .brand-img {
  filter: brightness(0) invert(1);
  /* Esto vuelve el logo negro a blanco */
  opacity: 0.9;
}

/* --- BRANCH SELECTOR (Sidebar) --- */
.branch-selector-wrapper {
  margin: 0 16px 24px 16px;
  /* Espaciado debajo del logo */
  position: relative;
  display: flex;
  align-items: center;
}

.branch-select {
  width: 100%;
  padding: 10px 32px 10px 36px;
  /* Espacio para iconos izq/der */
  appearance: none;
  /* Quitar flecha nativa fea del navegador */
  -webkit-appearance: none;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-main);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
}

.branch-select:hover {
  border-color: var(--gold-dim);
  background: var(--bg-card);
}

.branch-select:focus {
  border-color: var(--gold);
  outline: none;
  box-shadow: 0 0 0 3px var(--gold-dim);
}

.branch-icon-left {
  position: absolute;
  left: 12px;
  color: var(--gold);
  font-size: 16px;
  pointer-events: none;
}

.branch-icon-right {
  position: absolute;
  right: 12px;
  color: var(--text-secondary);
  font-size: 12px;
  pointer-events: none;
}

/* --- CUSTOM DROPDOWN (BRANCH) --- */
.custom-dropdown {
  margin: 0 16px 24px 16px;
  position: relative;
  user-select: none;
  z-index: 100;
}

.dropdown-trigger {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  padding: 10px 12px 10px 36px;
  border-radius: 12px;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition);
}

.dropdown-trigger:hover {
  border-color: var(--gold);
  background: var(--bg-card);
}

.dropdown-icon-left {
  position: absolute;
  left: 12px;
  color: var(--gold);
  font-size: 18px;
}

.dropdown-icon-right {
  font-size: 12px;
  color: var(--text-secondary);
  transition: transform 0.3s;
}

/* El Menú de Opciones */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-hover);
  display: none;
  /* Oculto por defecto */
  flex-direction: column;
  overflow: hidden;
  animation: fadeInDown 0.2s ease-out;
}

.dropdown-menu.active {
  display: flex;
}

#branchDropdown.active .dropdown-icon-right {
  transform: rotate(180deg);
}

.dropdown-item {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.dropdown-item:hover {
  background: var(--gold-dim);
  color: var(--gold);
  padding-left: 20px;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- ANIMACIÓN DE ENTRADA PREMIUM --- */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Clase universal para animar el contenido principal */
.animate-page {
  animation: fadeInUp 0.6s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

/* Opcional: Retraso para los elementos hijos para un efecto escalonado */
.grid-4,
.grid-3,
.grid-2 {
  animation: fadeInUp 0.8s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

/* --- RESPONSIVE MOBILE & TABLET (Top & Sidebar) --- */

/* Botón Hamburguesa (Oculto en Desktop) */
.menu-toggle-btn {
  display: none;
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-main);
  cursor: pointer;
  margin-right: 16px;
}

/* Overlay para oscurecer el fondo cuando abre el menú */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 990;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* MEDIA QUERY: Tablets y Móviles (Menos de 1024px) */
@media (max-width: 1024px) {

  /* 1. Sidebar Off-Canvas */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    /* Escondido a la izquierda */
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex !important;
    /* Forzar display flex si estaba none */
  }

  .sidebar.active {
    transform: translateX(0);
    /* Mostrar */
  }

  /* 2. Header Ajustado */
  .header {
    padding: 0 16px;
    /* Menos padding */
    justify-content: space-between;
  }

  .menu-toggle-btn {
    display: block;
    /* Mostrar botón menú */
  }

  /* Ocultar textos largos en móvil */
  .header h2 {
    font-size: 16px !important;
  }

  .header p {
    display: none;
  }

  /* Ocultar subtítulo */

  /* Ajustar herramientas del header */
  .date-picker span {
    display: none;
  }

  /* Ocultar fecha texto, dejar icono */
  .date-picker {
    padding: 8px;
  }

  .btn-gold {
    padding: 8px 16px;
    font-size: 12px;
  }

  .btn-gold i {
    font-size: 16px;
  }

  /* 3. Contenido Principal Full Width */
  .main-content {
    width: 100%;
    margin-left: 0;
  }

  /* Ajuste de Grids para que no se rompan */
  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr !important;
    /* Todo a 1 columna */
  }

  /* Ajuste de Tarjetas */
  .card {
    padding: 16px;
  }
}