﻿/* ============================================================
   SYNERA CLÍNICA — HOJA DE ESTILOS PRINCIPAL
   ============================================================ */

/* ============================================================
   VARIABLES CSS
   ============================================================ */
:root {
    /* Paleta Synera */
    --accent: #5b8fa8;
    --accent-light: #7aacb5;
    --gold: #d4a94e;
    --gold-light: #e8c87a;
    --green: #4cb89a;
    --red: #e05c5c;

    /* Neutros */
    --bg: #f4f6fb;
    --white: #ffffff;
    --text: #1a2535;
    --text-soft: #3a4a5c;
    --muted: #8a96a8;
    --border: #e8edf5;
    --border-dark: #d0d8e8;
    --surface: #f8fafc;

    /* Sidebar */
    --sidebar-bg: #0f1f2e;
    --sidebar-w: 260px;

    /* Feedback */
    --success-bg: #edfcf2;
    --success-text: #2f9e44;
    --warning-bg: #fff9e6;
    --warning-text: #f08c00;
    --danger-bg: #fff0f0;
    --danger-text: #e03e3e;

    /* Sombras */
    --shadow-sm: 0 1px 3px rgba(15, 31, 46, 0.05);
    --shadow: 0 2px 16px rgba(15, 31, 46, 0.07);
    --shadow-md: 0 4px 16px rgba(15, 31, 46, 0.10);
    --shadow-lg: 0 8px 30px rgba(15, 31, 46, 0.12);
    --shadow-xl: 0 16px 50px rgba(15, 31, 46, 0.16);

    /* Tipografía */
    --font-body: 'DM Sans', 'Segoe UI', system-ui, sans-serif;
    --font-display: 'Playfair Display', Georgia, serif;

    --text-xs: 0.6875rem;
    --text-sm: 0.8125rem;
    --text-base: 0.9375rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;

    /* Bordes */
    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Transiciones */
    --t-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-base: 220ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-slow: 380ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Card */
    --card-radius: 16px;
}

/* ============================================================
   RESET Y BASE
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
}

body.app-page {
    display: flex;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    font-family: var(--font-body);
    cursor: pointer;
}

img,
svg {
    display: block;
}


/* ============================================================
   LOGIN
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    background: linear-gradient(160deg,
            #5b8fa8 0%,
            #7aacb5 30%,
            #b8c9a3 60%,
            #d4b87a 85%,
            #c9a55a 100%);
}

.login-wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.login-card {
    background: var(--white);
    width: 40%;
    min-width: 380px;
    min-height: 100vh;
    padding: 0 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-branding-new {
    flex: 1;
}

.login-logo-header {
    margin-bottom: 28px;
}

.synera-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
}

.logo-icon {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.logo-text .synera {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text);
    text-transform: uppercase;
}

.logo-text .clinica {
    font-size: 11px;
    letter-spacing: 3px;
    color: var(--muted);
    text-transform: uppercase;
    margin-top: 2px;
    font-weight: 400;
}

.form-header {
    margin-bottom: 28px;
}

.form-header h2 {
    font-size: 30px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.form-header p {
    font-size: var(--text-sm);
    color: var(--muted);
}

.form-group {
    margin-bottom: 16px;
}

.input-wrapper {
    position: relative;
}

.input-wrapper input {
    width: 100%;
    padding: 13px 44px 13px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-family: var(--font-body);
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color var(--t-base), box-shadow var(--t-base), background var(--t-base);
}

.input-wrapper input::placeholder {
    color: var(--muted);
    opacity: 0.8;
}

.input-wrapper input:focus {
    border-color: var(--accent-light);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(122, 172, 181, 0.18);
}

.input-icon,
.toggle-password {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    display: flex;
    align-items: center;
    background: none;
    border: none;
    padding: 0;
}

.input-icon {
    pointer-events: none;
}

.toggle-password {
    cursor: pointer;
    transition: color var(--t-fast);
}

.toggle-password:hover {
    color: var(--accent);
}

.form-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    font-size: var(--text-sm);
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-soft);
    cursor: pointer;
    user-select: none;
}

.checkbox-container input[type='checkbox'] {
    appearance: none;
    -webkit-appearance: none;
    width: 15px;
    height: 15px;
    border: 2px solid var(--gold);
    border-radius: var(--radius-full);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.checkbox-container input[type='checkbox']:checked::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: var(--radius-full);
    background: var(--gold);
}

.forgot-password {
    color: var(--gold);
    font-size: var(--text-sm);
    font-weight: 500;
}

.forgot-password:hover {
    text-decoration: underline;
}

.btn-login {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: var(--radius-full);
    font-size: var(--text-base);
    font-weight: 600;
    font-family: var(--font-body);
    color: var(--white);
    letter-spacing: 0.5px;
    background: linear-gradient(90deg, var(--gold-light) 0%, var(--gold) 50%, #c9956a 100%);
    box-shadow: 0 4px 16px rgba(212, 169, 78, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity var(--t-base), transform var(--t-fast), box-shadow var(--t-base);
}

.btn-login:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

.btn-login:active {
    transform: scale(0.98);
}

.btn-login.loading {
    pointer-events: none;
    opacity: 0.8;
}

.spinner {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.login-alert {
    padding: 11px 16px;
    border-radius: var(--radius-md);
    background: #fee2e2;
    color: #b91c1c;
    font-size: var(--text-sm);
    font-weight: 500;
    margin-bottom: 18px;
    border: 1px solid #fca5a5;
    animation: shake 0.4s;
}

.login-alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: #6ee7b7;
}

@media (max-width: 768px) {
    .login-wrapper {
        flex-direction: column;
    }

    .login-card {
        width: 100%;
        min-width: unset;
        padding: 60px 40px;
    }

    .login-branding-new {
        display: none;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 50px 24px;
    }
}


/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    padding: 0 0 24px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Logo */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    margin-bottom: 8px;
    flex-shrink: 0;
}

.sidebar-logo svg,
.sidebar-logo .logo-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.logo-info .name {
    font-weight: 700;
    font-size: 15px;
    color: var(--white);
    letter-spacing: 0.5px;
    line-height: 1.1;
}

.logo-info .tagline {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.38);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 3px;
}

/* Secciones */
.nav-section,
.nav-section-title {
    padding: 16px 16px 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.25);
    user-select: none;
    display: block;
}

/* Ítems de nav */
.nav-item,
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    margin: 2px 10px;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
    border: 1px solid transparent;
    position: relative;
}

.nav-item:hover,
.nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.88);
}

.nav-item.active,
.nav-link.active {
    background: linear-gradient(135deg, rgba(91, 143, 168, 0.30), rgba(212, 169, 78, 0.12));
    color: var(--white);
    font-weight: 600;
    border-color: rgba(91, 143, 168, 0.35);
}

/* Ícono */
.nav-item .icon,
.nav-item .nav-icon,
.nav-link .icon,
.nav-link .nav-icon {
    width: 20px;
    min-width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: currentColor;
    flex-shrink: 0;
}

.nav-item .icon svg,
.nav-link .nav-icon svg,
.nav-link svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

/* Footer sidebar */
.sidebar-bottom,
.sidebar-footer {
    margin-top: auto;
    padding: 16px 16px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    flex-shrink: 0;
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
}

.user-card,
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--t-fast);
}

.user-card:hover,
.sidebar-user:hover {
    background: rgba(255, 255, 255, 0.06);
}

.user-avatar,
.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--accent), var(--green));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--white);
    flex-shrink: 0;
}

.user-info .u-name,
.sidebar-user-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--white);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info .u-role,
.sidebar-user-role {
    font-size: var(--text-xs);
    color: rgba(255, 255, 255, 0.35);
}

.logout-btn,
.logout-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-top: 4px;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    text-decoration: none;
    transition: color var(--t-fast), background var(--t-fast);
}

.logout-btn:hover,
.logout-link:hover {
    color: #f08080;
    background: rgba(224, 92, 92, 0.08);
}

.logout-btn svg,
.logout-link svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
}


/* ============================================================
   TOPBAR / PAGE HEADER
   ============================================================ */
.main,
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg);
    padding: 0;
}

.topbar,
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 16px;
    flex-wrap: nowrap;
    min-width: 0;
    border-radius: 0;
    margin-bottom: 0;
    box-shadow: var(--shadow-sm);
}

.topbar-title,
.page-header-left {
    flex-shrink: 0;
}

.topbar-title h1,
.page-title {
    font-family: var(--font-display);
    font-size: 20px;
    color: var(--text);
    font-weight: 600;
    letter-spacing: -0.2px;
    margin: 0;
}

.topbar-title p,
.page-subtitle {
    font-size: var(--text-xs);
    color: var(--muted);
    margin-top: 2px;
}

/* Buscador */
.search-box {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 9px 14px;
    gap: 8px;
    transition: border-color var(--t-base);
}

.search-box:focus-within {
    border-color: var(--accent-light);
    box-shadow: 0 0 0 3px rgba(122, 172, 181, 0.14);
}

.search-box svg {
    width: 15px;
    height: 15px;
    color: var(--muted);
    flex-shrink: 0;
}

.search-box input {
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--text);
    outline: none;
    width: 200px;
}

.search-box input::placeholder {
    color: var(--muted);
}

/* Lado derecho del topbar */
.topbar-right,
.header-actions,
.user-info-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    margin-left: auto;
}

/* Botones ícono */
.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    color: var(--text-soft);
    flex-shrink: 0;
    transition: background var(--t-fast), border-color var(--t-fast);
}

.icon-btn:hover {
    background: var(--border);
    border-color: var(--border-dark);
}

.icon-btn svg {
    width: 17px;
    height: 17px;
    stroke: currentColor;
}

/* Badge notificaciones */
.badge,
.badge-count {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    background: var(--red);
    border-radius: var(--radius-full);
    border: 2px solid var(--white);
}

/* Usuario topbar */
.top-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color var(--t-fast), background var(--t-fast);
}

.top-user:hover {
    border-color: var(--border-dark);
}

.top-user-avatar,
.user-avatar-header {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent), var(--gold));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--white);
    flex-shrink: 0;
}

.top-user-info .tu-name,
.user-info-header strong {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text);
    display: block;
    line-height: 1.2;
}

.top-user-info .tu-role,
.user-info-header small {
    font-size: var(--text-xs);
    color: var(--muted);
    display: block;
}

/* Toggle sidebar (mobile) */
.sidebar-toggle {
    display: none;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--white);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
    flex-shrink: 0;
    transition: background var(--t-fast);
}

.sidebar-toggle:hover {
    background: var(--surface);
}


/* ============================================================
   CONTENIDO
   ============================================================ */
.content {
    padding: 24px 28px 40px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Compatibilidad con main-content sin .content */
.main-content>*:not(.page-header):not(.topbar) {
    margin: 0 28px;
}

.main-content>*:not(.page-header):not(.topbar):first-child {
    margin-top: 24px;
}


/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--card-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
    animation: fadeUp 0.4s ease both;
}

.stat-card:nth-child(1) {
    animation-delay: 0.05s;
}

.stat-card:nth-child(2) {
    animation-delay: 0.12s;
}

.stat-card:nth-child(3) {
    animation-delay: 0.19s;
}

.stat-card:nth-child(4) {
    animation-delay: 0.26s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-dark);
    color: var(--text);
}

.stat-card.featured {
    background: linear-gradient(135deg, #e8b84b 0%, #c9956a 100%);
    border: none;
    box-shadow: 0 4px 20px rgba(212, 169, 78, 0.28);
}

.stat-card.featured .stat-label,
.stat-card.featured .stat-sub,
.stat-card.featured .stat-icon,
.stat-card.featured .stat-num {
    color: var(--white) !important;
}

.stat-card.featured .stat-change {
    color: rgba(255, 255, 255, 0.8) !important;
}

.stat-card.featured .stat-icon {
    background: rgba(255, 255, 255, 0.2) !important;
}

.stat-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 14px;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    font-size: 20px;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 20px;
    height: 20px;
    stroke: var(--accent);
}

.stat-change {
    font-size: var(--text-xs);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 2px;
}

.stat-change.up {
    color: var(--green);
}

.stat-change.down {
    color: var(--red);
}

.stat-num {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text);
}

.stat-sub {
    font-size: var(--text-xs);
    color: var(--muted);
    margin-top: 2px;
}

.sparkline {
    margin-top: 12px;
    height: 40px;
}

.doctor-pills {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.pill {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: var(--text-xs);
    color: var(--muted);
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.dot.green {
    background: var(--green);
}

.dot.amber {
    background: var(--gold);
}

.dot.red {
    background: var(--red);
}

/* Stat card clickeable (otras páginas) */
.stat-card.stat-blue .stat-icon {
    background: #eef2ff;
    color: #3b5bdb;
}

.stat-card.stat-green .stat-icon {
    background: #effcf6;
    color: #099268;
}

.stat-card.stat-orange .stat-icon {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.stat-card.stat-purple .stat-icon {
    background: #f3e8ff;
    color: #7c3aed;
}

.stat-card.stat-red .stat-icon {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.stat-arrow {
    margin-left: auto;
    color: var(--border-dark);
    transition: color var(--t-base), transform var(--t-base);
}

.stat-card:hover .stat-arrow {
    color: var(--accent);
    transform: translateX(4px);
}


/* ============================================================
   SEGUNDA FILA (Gráfico + Historias)
   ============================================================ */
.second-row {
    display: grid;
    grid-template-columns: 1fr 290px;
    gap: 16px;
    align-items: start;
}

.chart-card,
.historias-card,
.content-card {
    background: var(--white);
    border-radius: var(--card-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    animation: fadeUp 0.45s ease 0.28s both;
}

.historias-card {
    display: flex;
    flex-direction: column;
}

/* Card header genérico */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-wrap: nowrap;
    gap: 12px;
}

/* En content-card el header tiene borde inferior */
.content-card>.card-header {
    padding: 18px 24px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    flex-shrink: 0;
}

.card-sub {
    font-size: var(--text-xs);
    color: var(--muted);
    margin-top: 2px;
}

.card-header h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.view-all {
    font-size: var(--text-xs);
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--accent);
    transition: background var(--t-fast), color var(--t-fast);
    white-space: nowrap;
    text-decoration: none;
    flex-shrink: 0;
}

.view-all:hover {
    background: var(--accent);
    color: var(--white);
}

/* Lista historias */
.historias-list {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.historia-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    transition: opacity var(--t-fast);
}

.historia-item:first-child {
    padding-top: 0;
}

.historia-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.historia-item:hover {
    opacity: 0.75;
}

.historia-info .h-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text);
}

.historia-info .h-date {
    font-size: var(--text-xs);
    color: var(--muted);
    margin-top: 1px;
}

.historia-action {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--accent);
    flex-shrink: 0;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}

.historia-action:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--white);
}

.historia-action svg {
    width: 13px;
    height: 13px;
    stroke: currentColor;
}


/* ============================================================
   TABLA DE CITAS
   ============================================================ */
.table-card {
    background: var(--white);
    border-radius: var(--card-radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    animation: fadeUp 0.45s ease 0.28s both;
}

.tab-row {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    margin-left: auto;
}

.tab-btn {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 500;
    font-family: var(--font-body);
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: pointer;
    color: var(--muted);
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
    white-space: nowrap;
}

.tab-btn:hover {
    background: var(--border);
    color: var(--text-soft);
}

.tab-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--white);
}

/* Tablas */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

.table-card table {
    margin-top: 16px;
    background: transparent;
    box-shadow: none;
}

table thead th,
.table-card thead th {
    padding: 10px 14px;
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    background: transparent;
    border-bottom: 2px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

table tbody tr,
.table-card tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--t-fast);
}

table tbody tr:hover,
.table-card tbody tr:hover {
    background: var(--surface);
}

table tbody tr:last-child,
.table-card tbody tr:last-child {
    border-bottom: none;
}

table tbody td,
.table-card tbody td {
    padding: 13px 14px;
    font-size: var(--text-sm);
    color: var(--text);
    vertical-align: middle;
    border: none;
}

table td strong {
    color: var(--text);
    font-weight: 600;
}

.doc-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.doc-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent), var(--green));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--white);
    flex-shrink: 0;
}

.doc-name {
    font-weight: 600;
    font-size: var(--text-sm);
    line-height: 1.2;
}

.doc-user {
    font-size: var(--text-xs);
    color: var(--muted);
}

/* Badges de estado */
.status-badge,
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.status-badge.active,
.badge-success {
    background: #e8f7f3;
    color: var(--green);
}

.status-badge.pending,
.badge-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.status-badge.cancelled,
.badge-danger {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.status-badge.completada {
    background: var(--success-bg);
    color: var(--success-text);
}

.badge-primary {
    background: #eef2ff;
    color: #3b5bdb;
}

/* Acciones tabla */
.action-links {
    display: flex;
    gap: 10px;
}

.action-link {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    text-decoration: none;
    transition: opacity var(--t-fast);
}

.action-link:hover {
    opacity: 0.7;
    text-decoration: underline;
}

.action-link.del {
    color: var(--red);
}

.action-btns {
    display: flex;
    gap: 6px;
    align-items: center;
}

.btn-icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
    transition: background var(--t-fast), color var(--t-fast);
}

.btn-icon svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
}

.btn-edit-icon {
    color: var(--accent);
}

.btn-edit-icon:hover {
    background: rgba(91, 143, 168, 0.1);
}

.btn-info-icon {
    color: var(--green);
}

.btn-info-icon:hover {
    background: rgba(76, 184, 154, 0.1);
}

.btn-danger-icon {
    color: var(--danger-text);
}

.btn-danger-icon:hover {
    background: var(--danger-bg);
}

.btn-success-icon {
    color: var(--success-text);
}

.btn-success-icon:hover {
    background: var(--success-bg);
}

.btn-warning-icon {
    color: var(--warning-text);
}

.btn-warning-icon:hover {
    background: var(--warning-bg);
}

/* Fila urgente */
.row-urgent {
    background: #fff7f7 !important;
}

.urgent-pulse {
    display: inline-block;
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--danger-text);
    padding: 2px 8px;
    background: var(--white);
    border-radius: var(--radius-xs);
    border: 1px solid var(--danger-bg);
    animation: urgentPulse 1s infinite alternate;
}

@keyframes urgentPulse {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0.7;
        transform: scale(0.96);
    }
}

.pulse-red {
    animation: pulseRed 2s infinite;
}

@keyframes pulseRed {
    0% {
        box-shadow: 0 0 0 0 rgba(224, 62, 62, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(224, 62, 62, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(224, 62, 62, 0);
    }
}


/* ============================================================
   BOTONES
   ============================================================ */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: var(--font-body);
    color: var(--white);
    background: linear-gradient(135deg, var(--accent), #3d6b82);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(91, 143, 168, 0.3);
    transition: transform var(--t-fast), box-shadow var(--t-base), opacity var(--t-fast);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(91, 143, 168, 0.4);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: var(--font-body);
    color: var(--text-soft);
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--t-fast), background var(--t-fast);
}

.btn-secondary:hover {
    border-color: var(--border-dark);
    background: var(--surface);
}

.btn-sm {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    font-size: var(--text-xs);
    font-weight: 600;
    font-family: var(--font-body);
    color: var(--accent);
    background: rgba(91, 143, 168, 0.08);
    border: 1px solid rgba(91, 143, 168, 0.2);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: background var(--t-fast), border-color var(--t-fast);
}

.btn-sm:hover {
    background: rgba(91, 143, 168, 0.16);
    border-color: rgba(91, 143, 168, 0.35);
}


/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 31, 46, 0.48);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal-overlay.modal-open {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.28s ease both;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(-16px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text);
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    font-size: 20px;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--t-fast), color var(--t-fast);
}

.modal-close:hover {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.modal-body {
    padding: 24px 28px;
}

.modal-footer {
    padding: 16px 28px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid var(--border);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group-modal {
    margin-bottom: 18px;
}

.form-group-modal label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: 6px;
}

.form-group-modal input,
.form-group-modal select {
    width: 100%;
    padding: 11px 16px;
    font-size: var(--text-sm);
    font-family: var(--font-body);
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color var(--t-base), box-shadow var(--t-base), background var(--t-base);
}

.form-group-modal input::placeholder {
    color: var(--muted);
}

.form-group-modal input:focus,
.form-group-modal select:focus {
    border-color: var(--accent-light);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(122, 172, 181, 0.16);
}


/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: var(--text-sm);
    font-weight: 500;
    animation: alertIn 0.35s ease both;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid #a3e6bc;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid #fca5a5;
}

@keyframes alertIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ============================================================
   SETTINGS DROPDOWN
   ============================================================ */
.settings-popup {
    position: fixed;
    width: 220px;
    background: #3d6b82;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity var(--t-base), transform var(--t-base), visibility var(--t-base);
    padding: 6px 0;
    overflow: hidden;
}

.settings-popup--open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.settings-popup-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 500;
    transition: background var(--t-fast);
    cursor: pointer;
}

.settings-popup-item svg {
    display: none;
}

.settings-popup-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.settings-popup-logout {
    color: #f98080 !important;
}

.settings-popup-logout:hover {
    background: rgba(224, 92, 92, 0.15) !important;
}

.settings-popup-header,
.settings-popup-divider {
    display: none;
}

.settings-overlay {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 9998;
    display: none;
}

.settings-overlay--active {
    display: block;
}


/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 48px 20px !important;
}

.empty-state-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--muted);
}

.empty-state-content svg {
    color: var(--border-dark);
    width: 48px;
    height: 48px;
}

.empty-state-content p {
    font-size: var(--text-sm);
}


/* ============================================================
   BÚSQUEDA STANDALONE
   ============================================================ */
.search-wrapper {
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
}

.search-input {
    width: 100%;
    max-width: 380px;
    padding: 10px 16px 10px 40px;
    font-size: var(--text-sm);
    font-family: var(--font-body);
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%238a96a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 14px center;
    transition: border-color var(--t-base), box-shadow var(--t-base), background var(--t-base);
}

.search-input::placeholder {
    color: var(--muted);
}

.search-input:focus {
    border-color: var(--accent-light);
    background-color: var(--white);
    box-shadow: 0 0 0 3px rgba(122, 172, 181, 0.16);
}


/* ============================================================
   QUICK MESSAGES
   ============================================================ */
.quick-msg {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-full);
    background: var(--surface);
    border: 1.5px solid var(--border);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-soft);
    cursor: pointer;
    user-select: none;
    transition: background var(--t-base), border-color var(--t-base), color var(--t-base), transform var(--t-base), box-shadow var(--t-base);
}

.quick-msg:hover {
    background: rgba(91, 143, 168, 0.08);
    border-color: rgba(91, 143, 168, 0.35);
    color: #3d6b82;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}


/* ============================================================
   DASHBOARD SECUNDARIO
   ============================================================ */
.dashboard-secondary-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
}

.recent-list {
    padding: 10px 24px 20px;
}

.recent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--surface);
}

.recent-item:last-child {
    border-bottom: none;
}

.recent-item-info {
    display: flex;
    flex-direction: column;
}

.recent-item-info strong {
    font-size: var(--text-sm);
    color: var(--text);
}


/* ============================================================
   ANIMACIONES
   ============================================================ */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1280px) {
    .second-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .content,
    .main-content>*:not(.page-header):not(.topbar) {
        margin-left: 20px;
        margin-right: 20px;
    }

    .topbar,
    .page-header {
        padding: 14px 20px;
    }
}

@media (max-width: 992px) {
    .dashboard-secondary-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--t-slow);
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
    }

    .main,
    .main-content {
        margin-left: 0 !important;
    }

    .sidebar-toggle {
        display: flex !important;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .second-row {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .topbar,
    .page-header {
        flex-wrap: nowrap;
    }

    .search-box input {
        width: 140px;
    }

    .user-info-header .top-user-info,
    .user-info-header>div {
        display: none;
    }

    .content {
        padding: 16px 16px 32px;
        gap: 14px;
    }

    table thead th,
    table tbody td {
        padding: 10px 12px;
        font-size: var(--text-xs);
    }

    .modal {
        max-width: 100%;
        margin: 0 10px;
    }
}

@media (max-width: 480px) {

    .topbar,
    .page-header {
        padding: 12px 16px;
    }

    .search-box {
        display: none;
    }

    .login-card {
        padding: 50px 24px;
    }
}