:root {
    /* PALETA FORESTALES QUERO */
    --ti-navy: #057b57;       /* Verde Institucional (Antes Navy) */
    --ti-blue: #32b74d;       /* Verde Vivo (Antes Blue) */
    --ti-wood: #5b350b;       /* Marr贸n Madera (Nuevo acento) */
    
    --ti-bg: #F4F6F8;
    --ti-white: #FFFFFF;
    --ti-text-main: #1A202C;
    --ti-text-sub: #718096;
    --ti-card-height: 125px;
    --ti-dock-height: 70px;
}

/* 1. LAYOUT PRINCIPAL */
body { margin: 0; padding: 0; font-family: 'Roboto', sans-serif; overscroll-behavior-y: none; }

/* Fondo oscuro para Desktop */
#tid-desktop-bg {
    background-color: #1a1a1a;
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Marco del Dispositivo */
#ti-device-frame {
    width: 100%;
    max-width: 480px;
    height: 90vh;
    background-color: var(--ti-bg);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    border-radius: 20px;
}

/* M脫VIL REAL */
@media (max-width: 768px) {
    #tid-desktop-bg { background-color: var(--ti-bg); display: block; height: auto; }
    #ti-device-frame { max-width: 100%; height: 100dvh; border-radius: 0; box-shadow: none; }
}

/* Utilities */
.ti-hide { display: none !important; }
.ti-layer-top { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 2000; background: var(--ti-bg); }

/* 2. HEADER */
.ti-header {
    flex: 0 0 60px;
    background-color: var(--ti-navy); /* AHORA ES VERDE FORESTAL */
    color: white;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    position: relative;
}

.ti-header-row {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    animation: fadeIn 0.3s ease;
}

.ti-brand-text { font-weight: 700; font-size: 1.1rem; letter-spacing: 0.5px; } /* Ajuste leve para nombre largo */
.ti-h-actions { display: flex; align-items: center; gap: 12px; }
.ti-icon-btn { background: none; border: none; padding: 4px; cursor: pointer; }
#ti-user-avatar { width: 36px; height: 36px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.2); background: white; }
.ti-back-arrow { background: none; border: none; padding: 0; cursor: pointer; display: flex; align-items: center; margin-right: 8px; }
.ti-header-info { flex: 1; display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
.ti-h-title { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ti-h-subtitle { font-size: 0.75rem; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 3. MAIN CONTENT */
.ti-content-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    background-color: var(--ti-bg);
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(var(--ti-dock-height) + 20px);
}

/* 4. VISTAS Y CARDS */
.ti-welcome-header { padding: 20px 16px 10px 16px; }
#ti-greeting { color: var(--ti-text-sub); font-size: 0.9rem; margin: 0; font-weight: 500; }
.ti-welcome-header h1 { color: var(--ti-navy); margin: 4px 0 0 0; font-size: 1.6rem; font-weight: 700; }

.ti-section { margin-bottom: 40px; padding-left: 16px; }
.ti-section-title { 
    color: var(--ti-text-sub); 
    font-size: 0.85rem; 
    font-weight: 700; 
    letter-spacing: 1px; 
    text-transform: uppercase; 
    margin-bottom: 12px; 
}

.ti-hz-scroll {
    display: flex; gap: 12px; overflow-x: auto; padding-right: 16px; padding-bottom: 10px;
    scroll-snap-type: x mandatory; scrollbar-width: none; 
}
.ti-hz-scroll::-webkit-scrollbar { display: none; }

/* CARDS */
.ti-card {
    flex: 0 0 auto; scroll-snap-align: start;
    background: var(--ti-white);
    border-radius: 16px; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.04); 
    overflow: hidden; position: relative; cursor: pointer; transition: transform 0.1s;
    width: 115px; height: 115px;
}
.ti-card:active { transform: scale(0.97); }

.ti-card-hero { }
.ti-hero-img { width: 100%; height: 100%; object-fit: cover; filter: brightness(1); }

.ti-card-func { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px; text-align: center; }
.ti-card-icon { 
    color: var(--ti-blue); /* ICONOS EN VERDE VIVO */
    margin-bottom: 8px; height: 28px; display: flex; align-items: center;
}
.ti-card-label { color: var(--ti-text-main); font-size: 0.8rem; line-height: 1.2; font-weight: 500; }

/* 5. BOTTOM DOCK */
.ti-dock {
    display: grid; grid-template-columns: 1fr 80px 1fr; align-items: center; 
    background: white; height: 60px; padding-bottom: max(env(safe-area-inset-bottom), 10px);
    box-shadow: 0 -5px 20px rgba(0,0,0,0.06);
    z-index: 500; position: relative; width: 100%; overflow: visible; 
}
@media (max-width: 768px) { .ti-dock { position: fixed; bottom: 0; left: 0; } }

.ti-dock-item {
    background: transparent; border: none; display: flex; flex-direction: column; 
    align-items: center; justify-content: center; color: #94A3B8; 
    padding: 0; margin: 0; height: 100%; cursor: pointer; width: 100%;
}
/* ESTADO ACTIVO: MARR脫N MADERA */
.ti-dock-item.active { color: var(--ti-wood); } 

.ti-dock-item svg { width: 22px; height: 22px; margin-bottom: 4px; display: block; }
.ti-dock-item span { font-size: 10px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; line-height: 1; }

.ti-dock-center-wrapper { height: 100%; width: 100%; pointer-events: none; }

/* FAB SCAN - GRADIENTE PERSONALIZADO */
.ti-fab-scan {
    position: absolute; pointer-events: auto; left: 50%; top: -28px; transform: translateX(-50%); 
    width: 56px !important; height: 56px !important; padding: 0 !important; margin: 0 !important;
    border-radius: 50%;
    
    /* GRADIENTE VERDE VIVO A VERDE FORESTAL */
    background: linear-gradient(135deg, #32b74d 0%, #057b57 100%);
    border: 6px solid white; 
    
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 16px rgba(5, 123, 87, 0.4); /* Sombra verdosa */
    cursor: pointer; z-index: 501; box-sizing: content-box; -webkit-appearance: none;
}
.ti-fab-scan:active { transform: translateX(-50%) scale(0.95); }
.ti-fab-scan svg { width: 26px; height: 26px; fill: white; display: block; }

/* 6. LOADER & FEEDBACK */
.ti-spinner {
    width: 40px; height: 40px;
    border: 4px solid #e2e8f0; 
    border-top: 4px solid var(--ti-blue); /* Spinner Verde Vivo */
    border-radius: 50%;
    animation: ti-spin 0.8s linear infinite;
}
@keyframes ti-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.ti-loader-frame {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    display: flex; flex-direction: column; align-items: center; gap: 15px; z-index: 10; width: 100%;
}
.ti-loader-text { color: #94A3B8; font-size: 0.9rem; font-weight: 500; letter-spacing: 0.5px; }

#ti-iframe {
    width: 100%; height: 100%; border: none; display: block; min-height: 80vh;
    opacity: 0; transition: opacity 0.5s ease-in-out; position: relative; z-index: 20;
}

#ti-processing-overlay {
    background: rgba(255, 255, 255, 0.98); 
    display: flex; flex-direction: column; align-items: center; justify-content: center; 
    text-align: center; padding: 30px;
}
.ti-proc-title { margin-top: 20px; color: var(--ti-navy); font-weight: 700; font-size: 1.2rem; }
.ti-proc-sub { margin-top: 8px; color: var(--ti-text-sub); font-size: 0.9rem; }

/* 7. HISTORY & OTHERS */
.ti-history-header { padding: 20px 16px 10px; display: flex; justify-content: space-between; align-items: center; }
.ti-history-header h2 { margin: 0; color: var(--ti-navy); font-size: 1.4rem; }
.ti-btn-text-danger { background: none; border: none; color: #EF4444; font-weight: 600; font-size: 0.85rem; cursor: pointer; }

.ti-hist-group-title { padding: 15px 16px 8px; color: var(--ti-text-sub); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }

.ti-hist-card {
    background: white; padding: 16px; margin-bottom: 1px; display: flex; align-items: center; gap: 12px;
    position: relative; border-bottom: 1px solid #f1f5f9;
}
.ti-hist-icon {
    width: 40px; height: 40px; background: #F1F5F9; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; color: var(--ti-navy); flex-shrink: 0;
}
.ti-hist-content { flex: 1; overflow: hidden; }
.ti-hist-title { color: var(--ti-text-main); font-weight: 600; font-size: 0.95rem; margin-bottom: 2px; }
.ti-hist-sub { color: var(--ti-text-sub); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ti-hist-time { color: #CBD5E1; font-size: 0.7rem; margin-top: 4px; }
.ti-btn-delete { background: none; border: none; color: #94A3B8; padding: 8px; cursor: pointer; }
.ti-empty-state { text-align: center; padding: 40px; color: #94A3B8; font-style: italic; }

/* Animaciones */
.ti-splash-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; }
.ti-logo-anim { width: 140px; margin-bottom: 20px; animation: pulse 2s infinite; } /* Logo un poco m谩s grande */
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

#ti-scan-overlay { background: black; }
.ti-close-fab { 
    position: absolute; top: 20px; right: 20px; z-index: 2001; 
    background: rgba(255,255,255,0.2); color: white; border: none; 
    width: 40px; height: 40px; border-radius: 50%; font-size: 1.2rem; cursor: pointer; 
}
.ti-scan-instruction { 
    position: absolute; bottom: 100px; left: 0; width: 100%; text-align: center; 
    color: white; z-index: 2001; text-shadow: 0 2px 4px rgba(0,0,0,0.5); 
}
#reader { width: 100%; height: 100%; }



/* =========================================
   PARCHE PARA EL ESCÁNER (Forestales Quero)
   ========================================= */

/* 1. Asegurar que el contenedor del lector ocupe todo y centre */
#ti-scan-overlay {
    background-color: #000; /* Fondo negro real detrás de la cámara */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* 2. Forzar al video a ser "Cover" (Pantalla completa sin bordes negros) */
#reader {
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    position: absolute;
    top: 0;
    left: 0;
}

#reader video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important; /* CLAVE: Esto evita que la imagen se estire o se vea "movida" */
}

/* 3. Personalizar el CUADRO DE ESCANEO (El que genera la librería) */
/* Esto apunta al div interno que crea html5-qrcode */
#reader__scan_region {
    /* Borde VERDE FQ en lugar de blanco/amarillo */
    border: 4px solid #32b74d !important; 
    border-radius: 20px !important;
    
    /* Efecto de sombra para oscurecer el resto de la pantalla */
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.6) !important;
    background: transparent !important;
}

/* 4. Ocultar elementos basura de la librería (Textos de error o permisos) */
#reader__dashboard_section_csr span, 
#reader__dashboard_section_swaplink {
    display: none !important;
}

/* 5. Mover la instrucción de texto un poco más arriba para que no tape el dock */
.ti-scan-instruction {
    bottom: 120px !important; /* Subir texto */
    font-weight: 500;
    letter-spacing: 1px;
    background: rgba(0,0,0,0.5);
    padding: 8px 16px;
    border-radius: 20px;
}


/* =======================================================
   FIX QUIRÚRGICO: REPORTE SIN BORDES NI MARCA GOOGLE
   ======================================================= */

/* 1. El contenedor del reporte toma control total ignorando paddings */
#ti-view-report {
    position: absolute !important; /* Flotar sobre el padding del scroll */
    top: 0; 
    left: 0; 
    width: 100%;
    
    /* Ocupar toda la altura disponible del área de contenido */
    height: 100% !important; 
    
    /* El "recorte": Ocultamos lo que se salga de esta caja (el footer) */
    overflow: hidden !important;
    
    margin: 0 !important;
    padding: 0 !important;
    z-index: 10;
}

/* 2. El Iframe crece extra para empujar el footer hacia el abismo */
#ti-iframe {
    /* Altura: 100% + 50px extra. 
       Esto empuja la barra gris de "Looker Studio" fuera del área visible */
    height: calc(100% + 50px) !important; 
    
    width: 100% !important;
    display: block;
    border: none;
    
    /* Fix visual para evitar línea blanca superior */
    margin-top: -1px; 
}