:root {
  --accent: #b00020;
  --muted: #70757a;
  --line: rgba(18,21,33,.08);
  --side-width: 260px;
  --side-collapsed: 60px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --text: #3c4043;
}

body { margin: 0; font-family: 'Inter', sans-serif; background: #fff; color: var(--text); overflow: hidden; }

/* TOPBAR ESTILO GOOGLE */
.topbar {
  height: 65px; background: #fff; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; border-bottom: 1px solid var(--line); position: relative; z-index: 1000;
}
.brand { display: flex; align-items: center; gap: 15px; }
.btn-toggle { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); padding: 8px; border-radius: 50%; transition: 0.2s; }
.btn-toggle:hover { background: #f1f3f4; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }

/* PERFIL DERECHA */
.user-menu-container { position: relative; }
.user-info-top { 
  display: flex; align-items: center; gap: 12px; padding: 5px 5px 5px 15px; 
  border-radius: 50px; cursor: pointer; border: 1px solid transparent; position: relative;
}
.user-info-top:hover { background: #f8f9fa; border-color: var(--line); }

.text-right { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-role { font-size: 11px; color: var(--muted); }
.user-avatar { 
  width: 34px; height: 34px; background: var(--accent); color: #fff; 
  border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold;
}

/* Badge de estado (Puntito verde) */
.status-indicator {
  position: absolute; bottom: 4px; right: 4px; width: 10px; height: 10px;
  background: #10b981; border: 2px solid #fff; border-radius: 50%;
}

/* DROPDOWN */
.user-dropdown {
  position: absolute; top: 110%; right: 0; width: 280px; background: #fff;
  border-radius: 16px; box-shadow: 0 4px 15px rgba(0,0,0,0.15); display: none;
  flex-direction: column; z-index: 1001; overflow: hidden;
}
.user-dropdown.active { display: flex; animation: fadeIn 0.2s ease; }

.dropdown-header { padding: 20px; text-align: center; border-bottom: 1px solid var(--line); }
.user-avatar-big { width: 60px; height: 60px; background: var(--accent); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; margin: 0 auto 10px; }
.dropdown-item { width: 100%; padding: 12px; border: none; background: none; text-align: left; cursor: pointer; border-radius: 8px; }
.dropdown-item:hover { background: #f8f9fa; }

/* LAYOUT PRINCIPAL */
.appShell { display: flex; height: calc(100vh - 65px); width: 100%; }
.stack { flex: 1; overflow-y: auto; background: #fff; }

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

/* --- RESTAURACIÓN DE ESTILO: LOGO Y TEXTOS --- */
.brand h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: .2px;
  background: linear-gradient(135deg, var(--text), #6b7280);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2, #ff5252));
  box-shadow: 0 0 0 5px rgba(176, 0, 32, 0.1);
}

/* --- RESTAURACIÓN: BOTONES --- */
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px rgba(176, 0, 32, 0.25);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

/* --- TOASTS --- */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 15px 25px;
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10001;
    transform: translateY(0);
    transition: all 0.3s ease;
    font-weight: 500;
}

.toast.hidden {
    display: none;
    transform: translateY(20px) scale(0.9);
    opacity: 0;
}
.toast-ok { background: #2e7d32; border-left: 5px solid #1b5e20; }
.toast-error { background: #d32f2f; border-left: 5px solid #b71c1c; }

/* --- LOADER GLOBAL --- */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    background: rgba(255, 255, 255, 0.4); 
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s;
    opacity: 1;
    visibility: visible;
}

.loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loaderBox {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    text-align: center;
}

.spinner{
    width:44px;height:44px;border-radius:999px;
    border: 4px solid rgba(18,21,33,.18);
    border-top-color: rgba(176,0,32,.95);
    margin: 2px auto 12px;
    animation: spin 1s linear infinite;
}
@keyframes spin{ to { transform: rotate(360deg); } }

/* --- ERROR SCREEN --- */
.error-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(5px);
}

.error-card {
    background: white;
    padding: 40px;
    border-radius: 16px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease-out;
}

.error-title { color: #b00020; margin-bottom: 10px; font-size: 1.5rem; }
.error-text { color: #64748b; line-height: 1.6; margin-bottom: 30px; }

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

/* --- COMPONENTES DE VISTA --- */
.view { 
    padding: 25px; 
    animation: fadeIn 0.4s ease-out; 
    max-width: 1200px; 
    margin: 0 auto; 
}

.card-main {
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--line);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.cardHd h2 { margin: 0; font-size: 1.25rem; font-weight: 700; color: var(--text); }

.cardBd { padding: 25px; }

/* --- TABLAS --- */
.table-responsive { width: 100%; overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

thead th {
    background: #f8fafc; padding: 12px 15px; text-align: left;
    font-weight: 600; color: var(--muted); text-transform: uppercase;
    font-size: 11px; letter-spacing: 0.5px; border-bottom: 2px solid var(--line);
}

tbody td { padding: 15px; border-bottom: 1px solid var(--line); color: var(--text); vertical-align: middle; }

tbody tr:hover { background-color: #fcfcfc; }

/* --- BOTONES EXTRA --- */
.btn-success {
    background: #16a34a; color: white; border: none; padding: 10px 20px;
    border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer;
    display: inline-flex; align-items: center; gap: 8px; transition: var(--transition);
}

.btn-success:hover { background: #15803d; transform: translateY(-1px); }

/* --- UTILIDADES --- */
.text-center { text-align: center; }
.bold { font-weight: 700; }
.text-muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

.badge-status {
    font-size: 10px;
    font-weight: 800;
    color: #10b981;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}
.badge-status {
        transition: all 0.3s ease;
}
.badge-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 8px #10b981;
    animation: pulse-green 2s infinite;
}
@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Ocultar Sidebar y Topbar cuando estamos en la pantalla de login */
body.is-login .side,
body.is-login .topbar {
    display: none !important;
}

/* Asegurar que el contenido principal ocupe todo el ancho en el login */
body.is-login .appShell {
    grid-template-columns: 1fr !important; /* Quita el espacio del sidebar */
    margin: 0;
    padding: 0;
}

body.is-login .stack {
    padding: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f7f6; /* O el color de fondo de tu login */
}