/* ============================================
   TUNY NET - HOME PAGE HYBRID DESIGN
   ============================================

   Propiedad de: Alexis Reyes Arias
   © 2024-2026

   ============================================ */

/* ============================================
   MAIN SCREEN OVERRIDE
   ============================================ */

#mainScreen {
    background: #FFFFFF !important;
    overflow: hidden !important;
}

.home-layout {
    display: flex;
    width: 100%;
    height: 100vh;
    position: relative;
}

/* ============================================
   COMPACT SIDEBAR (ICONS ONLY)
   ============================================ */

.sidebar {
    width:220px;
    background: linear-gradient(180deg, #1E5BA8 0%, #1565C0 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1rem;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.08);
    position: relative;
    z-index: 100;
    flex-shrink: 0;
}

.sidebar-header {
    width: 100%;
    padding: 0.5rem;
    display: flex;
    justify-content: center;
    margin-bottom: 2.5rem;
}

.sidebar-logo-icon {
    width: 55px;
    height: auto;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
    transition: transform 0.3s ease;
}

.sidebar-logo-icon:hover {
    transform: scale(1.05);
}

.sidebar-nav {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0 0.75rem;
}

.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: 48px;
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
    transform: translateX(2px);
}

.sidebar-link.active {
    background: rgba(255, 255, 255, 0.20);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60%;
    background: white;
    border-radius: 0 4px 4px 0;
}

/* Sidebar Link Wrapper for hover menus */
.sidebar-link-wrapper {
    position: relative;
    width: 100%;
}

/* Sidebar Mega Menu (appears on hover) */
.sidebar-mega-menu {
    position: absolute;
    left: 100%;
    top: 0;
    min-width: 580px;
    max-width: none;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
    padding: 1rem;
    margin-left: 15px;
    max-height: 85vh;
    overflow-y: visible;
}

.sidebar-link-wrapper:hover .sidebar-mega-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.sidebar-mega-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1565C0;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid #E5E9F0;
    margin-bottom: 0.75rem;
}

.sidebar-submenu-group {
    margin-bottom: 1.5rem;
}

.sidebar-submenu-group:last-child {
    margin-bottom: 0;
}

.sidebar-submenu-header {
    font-size: 0.85rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    background: #F8FAFB;
    border-radius: 6px;
}

.sidebar-submenu-link {
    display: block;
    padding: 0.65rem 0.75rem;
    color: #334155;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: 6px;
    margin-bottom: 0.25rem;
    border-left: 3px solid transparent;
}

.sidebar-submenu-link:hover {
    background: #F1F5F9;
    color: #1565C0;
    border-left-color: #1565C0;
    transform: translateX(4px);
}

.sidebar-submenu-link.has-children::after {
    content: '›';
    float: right;
    font-size: 1.2rem;
    color: #94A3B8;
    font-weight: 700;
}

/* Sidebar Submenu Item (wrapper for sub-submenus) */
.sidebar-submenu-item {
    position: relative;
}

/* Sub-Submenu (third level) */
.sidebar-sub-submenu {
    position: absolute;
    left: 100%;
    top: 0;
    min-width: 240px;
    max-width: 300px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 3000;
    padding: 0.75rem;
    margin-left: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.sidebar-submenu-item:hover > .sidebar-sub-submenu {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.sidebar-sub-link {
    display: block;
    padding: 0.6rem 0.75rem;
    color: #475569;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: 6px;
    margin-bottom: 0.2rem;
    border-left: 3px solid transparent;
}

.sidebar-sub-link:hover {
    background: #EFF6FF;
    color: #1565C0;
    border-left-color: #1565C0;
    transform: translateX(3px);
}

.sidebar-sub-link.has-children::after {
    content: '›';
    float: right;
    font-size: 1.1rem;
    color: #94A3B8;
    font-weight: 700;
}

/* Fourth level */
.sidebar-sub-submenu.sidebar-level-3 {
    background: #F8FAFB;
}

/* Scrollbar styles for sub-submenus */
.sidebar-sub-submenu::-webkit-scrollbar {
    width: 5px;
}

.sidebar-sub-submenu::-webkit-scrollbar-track {
    background: #F1F5F9;
    border-radius: 3px;
}

.sidebar-sub-submenu::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 3px;
}

.sidebar-sub-submenu::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

/* Scrollbar styles for sidebar mega menu */
.sidebar-mega-menu::-webkit-scrollbar {
    width: 6px;
}

.sidebar-mega-menu::-webkit-scrollbar-track {
    background: #F1F5F9;
    border-radius: 3px;
}

.sidebar-mega-menu::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 3px;
}

.sidebar-mega-menu::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

.sidebar-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

/* Tooltip on hover */
.sidebar-link::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    margin-left: 18px;
    padding: 0.55rem 1rem;
    background: #2C3E50;
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 8px;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-8px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.sidebar-link::before {
    content: '';
    position: absolute;
    left: 100%;
    margin-left: 11px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 7px 6px 0;
    border-color: transparent #2C3E50 transparent transparent;
    opacity: 0;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.sidebar-link.active::before {
    display: block;
}

.sidebar-link:hover::after {
    opacity: 1;
    transform: translateX(0);
}

.sidebar-link:hover::before {
    opacity: 1;
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */

.home-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: #F8FAFB;
}

/* ============================================
   TOP BAR
   ============================================ */

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2.5rem;
    background: white;
    border-bottom: 1px solid #E5E9F0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.top-bar-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.greeting {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1E293B;
    margin: 0;
    line-height: 1.3;
}

.greeting #userName {
    color: #1565C0;
}

.date-time {
    font-size: 0.95rem;
    color: #64748B;
    margin: 0;
    font-weight: 500;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Time Display */
.time-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: #F1F5F9;
    border-radius: 10px;
    color: #475569;
    font-weight: 600;
    font-size: 0.95rem;
}

.time-icon {
    width: 18px;
    height: 18px;
    color: #1565C0;
}

/* User Menu Container */
.user-menu-container {
    position: relative;
}

.user-menu-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #1565C0 0%, #1E88E5 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px rgba(21, 101, 192, 0.25);
}

.user-menu-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(21, 101, 192, 0.35);
}

.user-avatar {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    line-height: 1;
}

/* User Dropdown Menu */
.user-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    min-width: 220px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    padding: 0.5rem 0;
    border: 1px solid #E5E9F0;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    color: #334155;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background: #F8FAFB;
    color: #1565C0;
}

.dropdown-item-logout {
    color: #DC2626 !important;
}

.dropdown-item-logout:hover {
    background: #FEF2F2 !important;
    color: #B91C1C !important;
}

.dropdown-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.dropdown-divider {
    height: 1px;
    background: #E5E9F0;
    margin: 0.5rem 0;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border: none;
    background: #F1F5F9;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: #475569;
    transition: all 0.2s ease;
}

.mobile-menu-toggle:hover {
    background: #E2E8F0;
}

.mobile-menu-toggle svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   WELCOME BANNER
   ============================================ */

.welcome-banner {
    background: linear-gradient(135deg, #1565C0 0%, #1E88E5 100%);
    padding: 2.5rem 2.5rem;
    margin: 1.5rem 2.5rem;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(21, 101, 192, 0.2);
}

.welcome-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
    border-radius: 50%;
}

.banner-content {
    position: relative;
    z-index: 2;
}

.banner-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
}

.banner-subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    font-weight: 400;
    line-height: 1.5;
}

/* ============================================
   STATISTICS CARDS GRID
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    padding: 0 2.5rem 2.5rem 2.5rem;
}

/* Stat Card */
.stat-card {
    background: white;
    border-radius: 14px;
    padding: 1.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #E5E9F0;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #1565C0 0%, #1E88E5 100%);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

.stat-card:hover::before {
    transform: scaleY(1);
}

.stat-card-primary {
    background: linear-gradient(135deg, #1565C0 0%, #1E88E5 100%);
    border: none;
    color: white;
}

.stat-card-primary .stat-title,
.stat-card-primary .stat-value {
    color: white;
}

.stat-card-primary .stat-change {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.stat-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #64748B;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: #1E293B;
    margin: 0;
    line-height: 1;
}

.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    width: fit-content;
}

.stat-change-positive {
    background: #DCFCE7;
    color: #16A34A;
}

.stat-change-negative {
    background: #FEE2E2;
    color: #DC2626;
}

.stat-arrow {
    width: 14px;
    height: 14px;
}

/* ============================================
   FOOTER
   ============================================ */

.home-footer {
    padding: 1.5rem 2.5rem;
    text-align: center;
    color: #64748B;
    font-size: 0.875rem;
    border-top: 1px solid #E5E9F0;
    background: white;
    margin-top: auto;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .top-bar {
        padding: 1.25rem 2rem;
    }

    .welcome-banner {
        margin: 1.5rem 2rem;
        padding: 2rem;
    }

    .stats-grid {
        padding: 0 2rem 2rem 2rem;
        gap: 1.25rem;
    }

    .sidebar-mega-menu {
        max-width: 300px;
    }
}

@media (max-width: 768px) {
    .home-layout {
        position: relative;
    }

    .sidebar {
        position: fixed;
        left: -70px;
        top: 0;
        height: 100vh;
        transition: left 0.3s ease;
        z-index: 1000;
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .home-content {
        width: 100%;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .sidebar-mega-menu {
        display: none;
    }

    .top-bar {
        padding: 1rem 1.25rem;
        flex-wrap: wrap;
    }

    .top-bar-left {
        width: 100%;
        margin-bottom: 1rem;
    }

    .greeting {
        font-size: 1.5rem;
    }

    .top-bar-right {
        width: 100%;
        justify-content: space-between;
    }

    .time-display {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    .welcome-banner {
        margin: 1.25rem 1.25rem;
        padding: 1.75rem 1.5rem;
    }

    .banner-title {
        font-size: 1.5rem;
    }

    .banner-subtitle {
        font-size: 0.9rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        padding: 0 1.25rem 1.25rem 1.25rem;
        gap: 1rem;
    }

    .stat-card {
        padding: 1.5rem;
    }

    .stat-value {
        font-size: 2rem;
    }

    .home-footer {
        padding: 1.25rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .greeting {
        font-size: 1.25rem;
    }

    .banner-title {
        font-size: 1.25rem;
    }

    .stat-value {
        font-size: 1.75rem;
    }

    .user-dropdown {
        right: -10px;
        min-width: 200px;
    }

    .back-button {
        background: #F1F5F9;
        border: none;
        border-radius: 10px;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        cursor: pointer;
        margin-right: 1rem;
        transition: all 0.2s ease;
    }

    .back-button:hover {
        background: #E2E8F0;
    }
}

/* ==========================================================
   AÑADIDO: OVERLAY "CARGANDO..." PARA TARJETAS DE ESTADÍSTICAS
   ========================================================== */

.stat-card.is-loading{
  position: relative;
  pointer-events: none;
}

.stat-card.is-loading .stat-body{
  opacity: 0.25;
  filter: blur(0.5px);
}

.stat-card.is-loading canvas{
  visibility: hidden;
}

.stat-card.is-loading::after{
  content: "Cargando...";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: #1565C0;
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 14px;
  z-index: 10;
}

.stat-card.is-loading::before{
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  margin-left: -60px;
  margin-top: -11px;
  border-radius: 50%;
  border: 3px solid rgba(21,101,192,0.25);
  border-top-color: #1565C0;
  animation: statSpin 0.8s linear infinite;
  z-index: 11;
}

@keyframes statSpin{
  to { transform: rotate(360deg); }
}

/* ==========================================================
   IA UI (Insights / Alertas / Forecast / Reportes / Chat)
   (MEJORADO - tipo captura)
   ========================================================== */

:root{
  --ai-bg: #F6F8FB;
  --ai-card: #FFFFFF;
  --ai-text: #101828;
  --ai-muted: #667085;
  --ai-border: rgba(16,24,40,.08);
  --ai-shadow: 0 10px 25px rgba(16,24,40,.08);
  --ai-shadow-sm: 0 6px 16px rgba(16,24,40,.08);

  --ai-blue: #2E6FF2;

  --ai-warn-bg: #FFF7E6;
  --ai-warn-br: #F5C97B;
  --ai-warn-tx: #7A4B00;

  --ai-ok-bg: #ECFDF3;
  --ai-ok-br: #ABEFC6;
  --ai-ok-tx: #067647;

  --ai-bad-bg: #FEF3F2;
  --ai-bad-br: #FECDCA;
  --ai-bad-tx: #B42318;
}

/* Alínea el fondo del contenido a dashboard */
.home-content{
  background: var(--ai-bg);
}

/* Alert bar */
.ai-alert-bar{
  position: sticky;
  top: 0;
  z-index: 500;

  margin: 0 2.5rem;
  margin-top: 1rem;

  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;

  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--ai-warn-br);
  background: var(--ai-warn-bg);
  color: var(--ai-warn-tx);
  box-shadow: var(--ai-shadow-sm);
}

.ai-alert-left{
  display:flex;
  align-items:center;
  gap: 10px;
  min-width: 0;
}

#aiAlertBarText{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-alert-close{
  border: 1px solid rgba(122,75,0,.25);
  background: rgba(255,255,255,.6);
  color: var(--ai-warn-tx);
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 900;
}

.ai-alert-close:hover{
  filter: brightness(0.99);
}

/* Grid IA: izquierda (insights) + derecha (forecast) + wide abajo */
.ai-grid{
  display:grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 18px;
  padding: 0 2.5rem 2.5rem 2.5rem;
  align-items: start;
}

.ai-card{
  background: var(--ai-card);
  border: 1px solid var(--ai-border);
  border-radius: 16px;
  box-shadow: var(--ai-shadow);
  padding: 14px;
}

.ai-card-wide{
  grid-column: 1 / -1;
}

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

.ai-card-title{
  margin:0;
  font-size: 16px;
  font-weight: 900;
  color: var(--ai-text);
}

.ai-actions{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items:center;
  justify-content:flex-end;
}

.ai-btn{
  border: 1px solid var(--ai-border);
  background: #fff;
  color: var(--ai-text);
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 900;
  box-shadow: 0 2px 8px rgba(16,24,40,.06);
  transition: transform .15s ease, filter .15s ease;
}

.ai-btn:hover{
  transform: translateY(-1px);
  filter: brightness(0.99);
}

.ai-btn:disabled{
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.ai-btn-primary{
  background: var(--ai-blue);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 10px 25px rgba(46,111,242,.18);
}

.ai-select{
  border:1px solid var(--ai-border);
  background:#fff;
  border-radius:12px;
  padding: 8px 10px;
  font-weight:900;
  color: var(--ai-text);
}

.ai-pill{
  background: var(--ai-blue);
  color:#fff;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 900;
  border: 1px solid rgba(255,255,255,.18);
}

.ai-box{
  background: #F9FAFB;
  border: 1px solid var(--ai-border);
  border-radius: 12px;
  padding: 12px;
  color: var(--ai-text);
  white-space: pre-wrap;
  line-height: 1.5;
  min-height: 76px;
}

.ai-subtitle{
  margin-top: 12px;
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ai-muted);
  font-weight: 900;
}

.ai-muted{
  color: var(--ai-muted);
  font-weight: 650;
  font-size: 0.95rem;
}

.ai-alert-list{
  margin: 0;
  padding-left: 18px;
  color: var(--ai-text);
}

.ai-alert-list li{
  margin: 6px 0;
}

/* Forecast grid (2x2) como en la captura */
.ai-forecast-grid{
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 10px;
}

.ai-kpi{
  border: 1px solid var(--ai-border);
  background:#fff;
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 6px 16px rgba(16,24,40,.06);
}

.ai-kpi-label{
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ai-muted);
  font-weight: 900;
}

.ai-kpi-value{
  font-size: 22px;
  font-weight: 900;
  color: var(--ai-text);
  margin-top: 6px;
}

.ai-kpi-sub{
  margin-top: 6px;
  font-size: 12px;
  color: var(--ai-muted);
  line-height: 1.25;
}

/* Badges opcionales (si los usas en ai.js con innerHTML) */
.ai-badge{
  display:inline-flex;
  align-items:center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid;
  font-weight: 900;
  font-size: 11px;
  vertical-align: middle;
}

.ai-badge.is-over{
  background: var(--ai-ok-bg);
  border-color: var(--ai-ok-br);
  color: var(--ai-ok-tx);
}

.ai-badge.is-low{
  background: var(--ai-bad-bg);
  border-color: var(--ai-bad-br);
  color: var(--ai-bad-tx);
}

/* Report textarea */
.ai-textarea{
  width:100%;
  min-height:260px;
  resize:vertical;
  border: 1px solid var(--ai-border);
  border-radius: 12px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95rem;
  line-height: 1.45;
  background:#fff;
  margin-top: 10px;
}

/* Chat */
.ai-chat-fab{
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #1565C0 0%, #1E88E5 100%);
  color:#fff;
  font-weight: 950;
  cursor:pointer;
  box-shadow: 0 12px 30px rgba(21,101,192,0.35);
  z-index: 5000;
}

.ai-chat-panel{
  position: fixed;
  right: 22px;
  bottom: 90px;
  width: 360px;
  max-width: calc(100vw - 44px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background:#fff;
  border:1px solid var(--ai-border);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.18);
  overflow:hidden;
  display:none;
  z-index: 5000;
}

.ai-chat-panel.open{ display:block; }

.ai-chat-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 14px;
  background: #F9FAFB;
  border-bottom:1px solid var(--ai-border);
}

.ai-chat-title{
  font-weight: 950;
  color: var(--ai-text);
}

.ai-chat-close{
  border:none;
  background:#E2E8F0;
  color:#0F172A;
  width:32px;
  height:32px;
  border-radius:10px;
  cursor:pointer;
  font-size:20px;
  line-height:32px;
  font-weight: 950;
}

.ai-chat-messages{
  padding: 12px;
  height: calc(100% - 112px);
  overflow:auto;
  background:#fff;
}

.ai-msg{
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 12px;
  margin: 8px 0;
  line-height: 1.45;
  white-space: pre-wrap;
  font-weight: 650;
}

.ai-msg-bot{
  background:#F1F5F9;
  border:1px solid var(--ai-border);
  color: var(--ai-text);
}

.ai-msg-user{
  background:#EFF6FF;
  border:1px solid rgba(46,111,242,.18);
  color: var(--ai-text);
  margin-left:auto;
}

.ai-chat-form{
  display:flex;
  gap: 10px;
  padding: 12px;
  border-top:1px solid var(--ai-border);
  background:#fff;
}

.ai-chat-input{
  flex:1;
  border:1px solid var(--ai-border);
  border-radius:12px;
  padding: 10px 12px;
  font-weight: 800;
}

.ai-chat-send{
  border:none;
  background: var(--ai-blue);
  color:#fff;
  border-radius:12px;
  padding: 10px 12px;
  cursor:pointer;
  font-weight: 950;
}

/* Responsive IA */
@media (max-width: 1024px){
  .ai-grid{ padding: 0 2rem 2rem 2rem; }
  .ai-alert-bar{ margin: 0 2rem; margin-top: 1rem; }
}

@media (max-width: 900px){
  .ai-grid{ grid-template-columns: 1fr; }
  .ai-card-wide{ grid-column: auto; }
}

@media (max-width: 768px){
  .ai-grid{
    grid-template-columns: 1fr;
    padding: 0 1.25rem 1.25rem 1.25rem;
  }
  .ai-alert-bar{ margin: 0 1.25rem; margin-top: 1rem; }
  .ai-forecast-grid{ grid-template-columns: 1fr; }
}
