:root {
    --primary-color: #0d9488;
    /* Default TaskCloud Color */
    --primary-glow: rgba(13, 148, 136, 0.25);
    --accent-color: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.2);
    --bg-color: #0f172a;
    /* Dark mode background */
    --surface-color: rgba(30, 41, 59, 0.55);
    --card-bg: rgba(30, 41, 59, 0.45);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-glow: rgba(13, 148, 136, 0.25);
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 14px;
    /* Reduced base font size */
    background-image:
        radial-gradient(circle at 10% 30%, rgba(13, 148, 136, 0.12), transparent 40%),
        radial-gradient(circle at 90% 70%, rgba(59, 130, 246, 0.12), transparent 40%);
}

/* =========================================
   LOGIN PAGE — ANIMATED BACKGROUND
   ========================================= */
body.login-page {
    overflow: hidden;
    position: relative;
}

/* Full-screen canvas for particle network */
.login-bg-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* Floating glowing orbs */
.login-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 0;
    pointer-events: none;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
    animation-direction: alternate;
}

.login-orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(13, 148, 136, 0.25) 0%, transparent 70%);
    top: -10%;
    left: -10%;
    animation: orbFloat1 14s ease-in-out infinite alternate;
}

.login-orb-2 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.2) 0%, transparent 70%);
    bottom: -15%;
    right: -15%;
    animation: orbFloat2 18s ease-in-out infinite alternate;
}

.login-orb-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, transparent 70%);
    top: 50%;
    left: 60%;
    animation: orbFloat3 22s ease-in-out infinite alternate;
}

@keyframes orbFloat1 {
    0%   { transform: translate(0, 0) scale(1); }
    33%  { transform: translate(60px, 40px) scale(1.08); }
    66%  { transform: translate(20px, 80px) scale(0.95); }
    100% { transform: translate(80px, 20px) scale(1.05); }
}

@keyframes orbFloat2 {
    0%   { transform: translate(0, 0) scale(1); }
    33%  { transform: translate(-70px, -30px) scale(1.1); }
    66%  { transform: translate(-30px, -90px) scale(0.92); }
    100% { transform: translate(-90px, -50px) scale(1.06); }
}

@keyframes orbFloat3 {
    0%   { transform: translate(0, 0) scale(1); }
    50%  { transform: translate(-80px, 60px) scale(1.12); }
    100% { transform: translate(40px, -70px) scale(0.9); }
}

/* =========================================
   LOGIN SCREEN (GLASSMORPHISM)
   ========================================= */
.login-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 
        0 12px 30px -10px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.02) inset;
    transition: var(--transition-smooth);
    position: relative;
    z-index: 1;
}

.card:hover {
    border-color: var(--border-color-glow);
    box-shadow: 
        0 20px 45px -15px rgba(0, 0, 0, 0.6),
        0 0 35px -10px var(--primary-glow),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    transform: translateY(-2px);
}

.login-card {
    background: var(--card-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(13, 148, 136, 0.25);
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 0 60px -20px var(--primary-glow);
    animation: slideUpFade 0.6s ease-out forwards;
    position: relative;
    z-index: 1;
    transition: var(--transition-smooth);
}

.login-card:hover {
    border-color: rgba(13, 148, 136, 0.4);
    box-shadow:
        0 30px 60px -12px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(255, 255, 255, 0.06) inset,
        0 0 70px -15px var(--primary-glow);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.3), rgba(59, 130, 246, 0.2));
    border: 1px solid rgba(13, 148, 136, 0.4);
    color: #5eead4;
    margin-bottom: 16px;
    box-shadow: 0 0 20px rgba(13, 148, 136, 0.2);
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(13, 148, 136, 0.2); }
    50%       { box-shadow: 0 0 35px rgba(13, 148, 136, 0.45); }
}

.login-header h1 {
    font-size: 24px;
    /* Reduced from 28px */
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(to right, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.form-group {
    margin-bottom: 24px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 12.5px;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    transition: var(--transition-smooth);
    outline: none;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(15, 23, 42, 0.8);
}

.form-group select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 12px) center;
    padding-right: 36px;
    cursor: pointer;
}

.btn-primary {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--primary-color), #0f766e);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    text-decoration: none;
    text-align: center;
    width: 100%;
    box-shadow: 
        0 4px 12px rgba(13, 148, 136, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 6px 20px rgba(13, 148, 136, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    filter: brightness(1.1);
}

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

.error-message {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 24px;
    border: 1px solid rgba(239, 68, 68, 0.2);
    text-align: center;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 24px 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.divider span {
    padding: 0 10px;
    color: var(--text-secondary);
    font-size: 14px;
}

.btn-sso {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
    text-decoration: none;
    text-align: center;
    width: 100%;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.btn-sso:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.btn-sso:active {
    transform: translateY(0) scale(0.98);
}

.btn-sso.active {
    background: linear-gradient(135deg, var(--primary-color), #0f766e) !important;
    color: white !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
}

.btn-sso.active:hover {
    filter: brightness(1.1);
}

/* Inline action buttons */
.btn-action {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 6px 14px;
    background-color: rgba(13, 148, 136, 0.1);
    color: var(--primary-color);
    border: 1px solid rgba(13, 148, 136, 0.2);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-action:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
    transform: translateY(-1px);
}

.btn-action:active {
    transform: translateY(0) scale(0.96);
}

.btn-success {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 6px 14px;
    background-color: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    text-decoration: none;
}

.btn-success:hover {
    background-color: #10b981;
    color: white;
    border-color: #10b981;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    transform: translateY(-1px);
}

.btn-success:active {
    transform: translateY(0) scale(0.96);
}

.btn-danger {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 6px 14px;
    background-color: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    text-decoration: none;
}

.btn-danger:hover {
    background-color: #ef4444;
    color: white;
    border-color: #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

.btn-danger:active {
    transform: translateY(0) scale(0.96);
}

/* =========================================
   DASHBOARD LAYOUT
   ========================================= */
.dashboard-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: 70px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 30%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tenant-indicator {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    background: var(--primary-color);
    color: white;
    box-shadow: 0 0 12px var(--primary-glow);
    border: 1px solid rgba(255, 255, 255, 0.1);
    -webkit-text-fill-color: initial;
    letter-spacing: 0.5px;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #0f766e);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    box-shadow: 0 0 10px var(--primary-glow);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: var(--transition-smooth);
    user-select: none;
}

.user-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px var(--primary-glow);
}

.user-info {
    text-align: right;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.user-role {
    font-size: 12px;
    color: var(--text-secondary);
}

.btn-logout {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
}

.btn-logout:hover {
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
    transform: scale(1.05);
}

/* Notifications Bell and Dropdown */
.notifications-bell {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    position: relative;
    padding: 8px;
    display: flex;
    align-items: center;
    outline: none;
    transition: var(--transition-smooth);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
}

.notifications-bell:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
    transform: scale(1.05);
}

.notifications-bell .bell-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--error-color);
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #1e293b;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}

.notifications-dropdown {
    position: absolute;
    top: 42px;
    right: 0;
    width: 320px;
    background: #1e293b;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    padding: 12px 0;
    animation: slideUpFade 0.2s ease-out forwards;
}

/* Knowledge Base Cards */
.kb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.kb-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.kb-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    border-color: rgba(13, 148, 136, 0.5);
}

.kb-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.kb-card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.kb-card-meta {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.kb-card-footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Analytics KPIs and Charts */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.kpi-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    transition: transform 0.3s ease;
    position: relative; /* Habilitado para posicionar tooltips absolutos */
}

/* Tooltip Informativo para KPI Cards */
.kpi-info-tooltip {
    position: absolute;
    top: 12px;
    right: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1;
    z-index: 10;
    transition: color 0.2s ease, transform 0.2s ease;
}

.kpi-info-tooltip:hover {
    color: var(--primary-color);
    transform: scale(1.1);
}

.kpi-info-tooltip .tooltip-text {
    visibility: hidden;
    width: 240px;
    background-color: var(--surface-color);
    color: var(--text-primary);
    text-align: left;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    position: absolute;
    z-index: 99;
    right: -4px;
    top: calc(100% + 8px);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateY(-8px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
    font-size: 12px;
    line-height: 1.4;
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
    pointer-events: none; /* Evita que estorbe al pasar el mouse por fuera */
}

/* Triángulo/Flecha del Tooltip */
.kpi-info-tooltip .tooltip-text::after {
    content: "";
    position: absolute;
    bottom: 100%;
    right: 8px;
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent var(--border-color) transparent;
}

.kpi-info-tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.kpi-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.kpi-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--primary-color);
    margin: 12px 0;
}

.kpi-label {
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.chart-container {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}

/* Search Bars */
.search-container {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-input {
    flex: 1;
    max-width: 400px;
    padding: 8px 12px 8px 36px;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    transition: var(--transition-smooth);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background-color: rgba(15, 23, 42, 0.4);
}

.filter-select {
    width: 100%;
    padding: 8px 12px;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    box-sizing: border-box;
    cursor: pointer;
    transition: var(--transition-smooth);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 12px) center;
    padding-right: 36px;
}

.filter-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background-color: rgba(15, 23, 42, 0.4);
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.form-grid-full {
    grid-column: span 2;
}

.form-group select {
    width: 100%;
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition-smooth);
}

.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background-color: rgba(15, 23, 42, 0.6);
}

.form-group select option {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

/* Buttons */
/* Tables */
.data-table-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    margin-top: 24px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 
        0 10px 25px -5px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.02) inset;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.data-table th,
.data-table td {
    padding: 8px 14px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
    transition: background-color 0.2s ease;
}

.data-table th {
    background: rgba(255, 255, 255, 0.015);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.8px;
}

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

.data-table tbody tr {
    transition: var(--transition-fast);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.025);
}

/* Centralized Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.badge-success {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge-neutral {
    background: rgba(148, 163, 184, 0.12);
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.badge-primary {
    background: rgba(13, 148, 136, 0.12);
    color: #2dd4bf;
    border: 1px solid rgba(13, 148, 136, 0.25);
}

.dashboard-body {
    display: flex;
    flex: 1;
}

.sidebar {
    width: 220px;
    /* Reduced from 230px */
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    padding: 16px 0;
    /* Less vertical padding */
    backdrop-filter: blur(10px);
    position: sticky;
    top: 70px;
    height: calc(100vh - 70px);
    overflow-y: auto;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 2px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    margin: 0 10px;
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12.5px;
    transition: var(--transition-smooth);
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    color: var(--text-primary);
    background: rgba(13, 148, 136, 0.1);
    border-left-color: var(--primary-color);
    transform: translateX(2px);
}

.main-content {
    flex: 1;
    padding: 16px 24px;
    /* Reduced padding from 40px to give more space for tables */
    max-width: 1600px;
    /* Increased from 1200px to allow wider tables */
    margin: 0 auto;
    width: 100%;
}

.welcome-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    /* Sleeker corner radius */
    padding: 20px 24px;
    /* More compact padding */
    margin-bottom: 24px;
    animation: slideUpFade 0.5s ease-out;
}

.welcome-card h2 {
    font-size: 22px;
    /* Reduced from 32px */
    margin-bottom: 8px;
}

.welcome-card p {
    color: var(--text-secondary);
    font-size: 13px;
    /* Reduced from 16px */
    line-height: 1.5;
}

/* Custom Sleek Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
    /* Horizontal scrollbar thickness */
}

::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.4);
    border-radius: 8px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Animations */
@keyframes slideUpFade {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* KB Modal Reader */
.kb-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    justify-content: center;
    align-items: center;
    padding: 20px;
    animation: fadeIn 0.25s ease-out forwards;
}

.kb-modal-content {
    background: #1e293b;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 100%;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 32px;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.kb-modal-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s;
}

.kb-modal-close:hover {
    color: var(--text-primary);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

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

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

/* =========================================
   SUPPORT CHATBOT WIDGET
   ========================================= */
#chatbot-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #0f766e);
    box-shadow: 0 8px 24px var(--primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    transition: var(--transition-smooth);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

#chatbot-bubble:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 12px 28px var(--primary-glow);
}

#chatbot-bubble .online-indicator {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--success-color);
    border: 2px solid #1e293b;
    animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

#chatbot-window {
    display: flex;
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    height: 520px;
    border-radius: 16px;
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-color);
    box-shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
}

#chatbot-window.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.chatbot-header {
    background: linear-gradient(135deg, var(--primary-color), #0f766e);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.chatbot-reset-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: var(--transition-smooth);
    padding: 6px;
    display: flex;
    align-items: center;
    border-radius: 50%;
}

.chatbot-reset-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.chatbot-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: var(--transition-smooth);
}

.chatbot-close-btn:hover {
    transform: rotate(90deg);
    color: rgba(255, 255, 255, 0.8);
}

.chatbot-messages-container {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.chatbot-messages-container::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
}

.chatbot-messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

.chatbot-msg {
    display: flex;
    gap: 8px;
    align-items: start;
    max-width: 85%;
}

.chatbot-msg.user-side {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chatbot-msg.bot-side {
    align-self: flex-start;
}

.chatbot-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.chatbot-msg-avatar.bot {
    background: var(--primary-color);
}

.chatbot-msg-avatar.user {
    background: #475569;
}

.chatbot-msg-bubble {
    padding: 10px 14px;
    font-size: 13.5px;
    line-height: 1.4;
    word-break: break-word;
    position: relative;
}

.chatbot-msg-bubble.bot {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 0 12px 12px 12px;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    width: 100%;
}

.chatbot-msg-bubble.bot::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 10px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 6px solid rgba(30, 41, 59, 0.7);
}

.chatbot-msg-bubble.user {
    background: var(--primary-color);
    border-radius: 12px 0 12px 12px;
    color: white;
    box-shadow: 0 4px 10px var(--primary-glow);
}

.chatbot-msg-bubble.user::before {
    content: '';
    position: absolute;
    right: -6px;
    top: 10px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 6px solid var(--primary-color);
}

.chatbot-quick-options {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chatbot-quick-btn {
    text-align: left;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(13, 148, 136, 0.08);
    border: 1px solid rgba(13, 148, 136, 0.2);
    color: var(--primary-color);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
    font-weight: 500;
}

.chatbot-quick-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--primary-glow);
}

.chatbot-input-area {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 8px;
    background: rgba(15, 23, 42, 0.4);
}

.chatbot-input-field {
    flex: 1;
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13.5px;
    outline: none;
    transition: var(--transition-smooth);
}

.chatbot-input-field:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(15, 23, 42, 0.8);
}

.chatbot-send-btn {
    background: var(--primary-color);
    border: none;
    color: white;
    padding: 0 16px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px var(--primary-glow);
}

.chatbot-send-btn:hover {
    background: #0f766e;
    transform: scale(1.05);
}

.chatbot-send-btn:active {
    transform: scale(0.95);
}

.chat-btn-option {
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid var(--primary-color);
    background: none;
    color: var(--primary-color);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.chat-btn-option:hover {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 8px var(--primary-glow);
}

/* Typing Dots Animation */
.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 0 12px 12px 12px;
    border: 1px solid var(--border-color);
    width: auto;
    align-self: flex-start;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    display: inline-block;
    animation: blinkDots 1.4s infinite both;
}

.typing-dots span:nth-child(2) {
    animation-delay: .2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: .4s;
}

@keyframes blinkDots {
    0% { opacity: .2; }
    20% { opacity: 1; }
    100% { opacity: .2; }
}

/* Asegurar que las imágenes dentro de la base de conocimiento y playbooks sean responsivas */
.ql-editor img,
[id^="playbook-content-"] img,
.kb-modal-content img,
.chatbot-msg-bubble img,
#chatbot-messages img {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    margin: 12px 0;
    display: block;
    cursor: zoom-in;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
}

.ql-editor img:hover,
[id^="playbook-content-"] img:hover,
.kb-modal-content img:hover,
.chatbot-msg-bubble img:hover,
#chatbot-messages img:hover {
    transform: scale(1.015);
    box-shadow: 0 8px 24px rgba(13, 148, 136, 0.35);
}

/* ============================================================================
   K. CUSTOM PREMIUM NOTIFICATIONS STYLING
   ============================================================================ */

.notifications-dropdown {
    position: absolute;
    top: 45px !important;
    right: -10px !important;
    width: 350px !important;
    background: rgba(15, 23, 42, 0.96) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 16px !important;
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05) !important;
    z-index: 1000;
    padding: 16px 0 8px 0 !important;
    animation: slideUpFade 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.notifications-bell {
    position: relative;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 10px !important;
    padding: 8px !important;
    color: var(--text-primary) !important;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notifications-bell:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: var(--primary-color) !important;
    transform: translateY(-1px);
}

.notifications-bell .bell-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--error-color);
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #0f172a !important; /* aligns with layout */
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
    animation: pulseBadge 2s infinite ease-in-out;
}

@keyframes pulseBadge {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1.15); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.notif-item {
    transition: all 0.2s ease !important;
}

.notif-item:hover {
    background: rgba(255, 255, 255, 0.035) !important;
}

.notif-item:hover .notif-icon-wrap {
    transform: scale(1.1) rotate(5deg);
    background: rgba(255, 255, 255, 0.06);
}

.notif-item:hover .notif-action-link {
    text-decoration: none;
    opacity: 0.95;
}

.notif-item:hover .notif-action-link i {
    transform: translateX(3px);
}

.notif-action-link i {
    transition: transform 0.2s ease;
}


/* =============================================================================
   RESPONSIVE — MOBILE & TABLET (PWA Ready)
   Breakpoints: Tablet ≤1024px | Mobile ≤768px | Small ≤480px
   ============================================================================= */

/* -----------------------------------------------
   TABLET (≤ 1024px)
   ----------------------------------------------- */
@media (max-width: 1024px) {

    /* Topbar */
    .topbar {
        padding: 0 16px;
        height: 60px;
    }

    /* Sidebar más estrecho */
    .sidebar {
        width: 190px;
        top: 60px;
        height: calc(100vh - 60px);
    }

    /* Contenido con menos padding */
    .main-content {
        padding: 14px 18px;
    }

    /* KPI grid de 3 columnas */
    .kpi-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 14px;
    }

    /* Charts: una columna */
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Form grid: una columna */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .form-grid-full {
        grid-column: span 1;
    }

    /* KB grid: 2 columnas */
    .kb-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    /* Chatbot más estrecho */
    #chatbot-window {
        width: 320px;
        height: 480px;
    }
}


/* -----------------------------------------------
   MOBILE (≤ 768px)
   ----------------------------------------------- */
@media (max-width: 768px) {

    /* TOPBAR */
    .topbar {
        padding: 0 12px;
        height: 56px;
        gap: 8px;
    }

    .brand {
        font-size: 16px;
        gap: 8px;
    }

    /* Ocultar nombre de usuario en pantallas pequeñas */
    .user-info {
        display: none;
    }

    /* Ocultar tenant indicator en mobile */
    .tenant-indicator {
        display: none;
    }

    .user-menu {
        gap: 8px;
    }

    /* LAYOUT PRINCIPAL: sidebar se convierte en nav inferior */
    .dashboard-body {
        flex-direction: column;
        padding-bottom: 64px; /* espacio para nav inferior */
    }

    /* SIDEBAR → Barra de navegación inferior fija */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 60px;
        top: auto;
        border-right: none;
        border-top: 1px solid var(--border-color);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        background: rgba(15, 23, 42, 0.92);
        z-index: 90;
        overflow: hidden;
        padding: 0;
    }

    .sidebar-nav {
        display: flex;
        flex-direction: row;
        align-items: center;
        height: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0 4px;
        gap: 2px;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }

    .sidebar-nav::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }

    .sidebar-nav li {
        flex-shrink: 0;
        margin-bottom: 0;
    }

    /* Separadores horizontales — ocultar en mobile */
    .sidebar-nav li[style*="border-top"] {
        display: none;
    }

    .sidebar-nav a {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 6px 10px;
        margin: 0;
        border-left: none;
        border-bottom: 3px solid transparent;
        border-radius: 8px 8px 0 0;
        font-size: 9px;
        gap: 3px;
        min-width: 58px;
        text-align: center;
        line-height: 1.2;
    }

    .sidebar-nav a svg {
        margin-right: 0 !important;
        width: 18px;
        height: 18px;
    }

    .sidebar-nav a:hover,
    .sidebar-nav a.active {
        transform: none;
        border-left-color: transparent;
        border-bottom-color: var(--primary-color);
        background: rgba(13, 148, 136, 0.12);
    }

    /* CONTENIDO PRINCIPAL */
    .main-content {
        padding: 12px;
        width: 100%;
    }

    /* WELCOME CARD */
    .welcome-card {
        padding: 14px 16px;
        margin-bottom: 16px;
    }

    .welcome-card h2 {
        font-size: 17px;
        margin-bottom: 4px;
    }

    .welcome-card p {
        font-size: 12px;
    }

    /* KPI GRID: 2 columnas */
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 16px;
    }

    .kpi-card {
        padding: 14px 12px;
    }

    .kpi-value {
        font-size: 26px;
        margin: 6px 0;
    }

    .kpi-label {
        font-size: 10px;
        letter-spacing: 0.5px;
    }

    /* CHARTS: una columna, altura reducida */
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .chart-container {
        padding: 14px;
    }

    /* TABLAS: scroll horizontal */
    .data-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-top: 16px;
        border-radius: 10px;
    }

    .data-table {
        min-width: 600px; /* Fuerza scroll horizontal antes de comprimir */
        font-size: 11.5px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
        white-space: nowrap;
    }

    /* Ocultar columnas menos importantes en mobile */
    .data-table .col-hide-mobile {
        display: none;
    }

    /* BUSCADOR */
    .search-container {
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 14px;
    }

    .search-input {
        max-width: 100%;
        width: 100%;
    }

    /* FORMULARIOS */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .form-grid-full {
        grid-column: span 1;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Evita zoom automático en iOS al enfocar inputs */
        padding: 10px 12px;
    }

    /* BOTONES */
    .btn-primary {
        padding: 12px 16px;
        font-size: 14px;
    }

    .btn-action,
    .btn-success,
    .btn-danger {
        padding: 8px 12px;
        font-size: 12px;
    }

    /* KB GRID: una columna */
    .kb-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .kb-modal-content {
        padding: 20px 16px;
        border-radius: 12px;
        max-height: 90vh;
    }

    /* NOTIFICACIONES DROPDOWN */
    .notifications-dropdown {
        width: calc(100vw - 24px) !important;
        right: -60px !important;
        left: 12px !important;
    }

    /* LOGIN PAGE */
    .login-card {
        padding: 28px 20px;
        border-radius: 16px;
        max-width: 100%;
    }

    .login-header h1 {
        font-size: 20px;
    }

    /* CHATBOT: pantalla completa en mobile */
    #chatbot-window {
        bottom: 70px;
        right: 8px;
        left: 8px;
        width: auto;
        height: 60vh;
        border-radius: 16px;
    }

    #chatbot-bubble {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }

    /* CARDS */
    .card {
        padding: 16px;
        border-radius: 12px;
    }

    .card:hover {
        transform: none; /* Evita jitter en touch */
    }

    /* Tooltips: ocultar en móvil (no hay hover) */
    .kpi-info-tooltip .tooltip-text {
        display: none;
    }

    /* Safe area para notch/home bar de iPhone */
    .sidebar {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(60px + env(safe-area-inset-bottom));
    }

    .dashboard-body {
        padding-bottom: calc(64px + env(safe-area-inset-bottom));
    }
}


/* -----------------------------------------------
   SMALL MOBILE (≤ 480px)
   ----------------------------------------------- */
@media (max-width: 480px) {

    /* KPI: 1 columna */
    .kpi-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    /* Topbar ultra compacta */
    .topbar {
        height: 52px;
        padding: 0 10px;
    }

    .brand {
        font-size: 15px;
    }

    /* Contenido con padding mínimo */
    .main-content {
        padding: 8px;
    }

    .welcome-card {
        padding: 12px;
        margin-bottom: 12px;
    }

    .welcome-card h2 {
        font-size: 15px;
    }

    /* Login */
    .login-card {
        padding: 20px 16px;
    }

    .login-header {
        margin-bottom: 20px;
    }

    .login-header h1 {
        font-size: 18px;
    }

    .login-logo {
        width: 46px;
        height: 46px;
    }

    /* Badges más compactos */
    .status-badge,
    .badge {
        font-size: 9px;
        padding: 3px 6px;
    }

    /* Sidebar nav: íconos más pequeños */
    .sidebar-nav a {
        min-width: 50px;
        padding: 5px 8px;
        font-size: 8px;
    }

    .sidebar-nav a svg {
        width: 16px;
        height: 16px;
    }

    /* Chatbot más alto */
    #chatbot-window {
        height: 70vh;
    }
}


/* -----------------------------------------------
   UTILIDADES TÁCTILES GLOBALES (todos los tamaños)
   ----------------------------------------------- */
@media (hover: none) and (pointer: coarse) {

    /* En dispositivos táctiles, quitar efectos hover de cards para evitar estados pegajosos */
    .card:hover,
    .kpi-card:hover,
    .kb-card:hover,
    .data-table tbody tr:hover {
        transform: none;
        box-shadow: none;
    }

    /* Aumentar área de toque de botones */
    .btn-action,
    .btn-success,
    .btn-danger {
        min-height: 40px;
        padding: 8px 14px;
    }

    /* Quitar hover de sidebar */
    .sidebar-nav a:hover {
        transform: none;
    }

    /* Scrolling suave en móvil */
    .data-table-container,
    .sidebar-nav,
    .chatbot-messages-container {
        -webkit-overflow-scrolling: touch;
    }
}