/* =====================================================
   INVENTARIO KJAS & STILO — Sistema de diseño
   ===================================================== */

:root {
    /* Superficies */
    --bg:            #0e0e17;
    --surface-1:     #16161f;
    --surface-2:     #1b1b28;
    --surface-3:     #232333;
    --border:        #2a2a3d;
    --border-soft:   #22222f;

    /* Texto */
    --text-1:        #f2f0ea;
    --text-2:        #a9a7ba;
    --text-3:        #6f6d82;

    /* Acento (latón / dorado sobrio) */
    --gold:          #c9a24b;
    --gold-soft:     #8a7238;
    --gold-bg:       rgba(201, 162, 75, 0.12);
    --gold-contrast: #14120a;

    /* Estados */
    --success:       #7fbf9e;
    --success-bg:    #142620;
    --danger:        #e2919c;
    --danger-bg:     #2a1820;
    --warning:       #e3b563;
    --warning-bg:    #2a2115;
    --info:          #7fa6d9;
    --info-bg:       #16202e;

    /* Niveles de ubicacion (para el camino de nodos y las tarjetas del detalle) */
    --level-piso:    #9b93e8;
    --level-piso-bg: rgba(155, 147, 232, 0.16);
    --level-piso-border: rgba(155, 147, 232, 0.4);
    --level-zona:    #5fbfc4;
    --level-zona-bg: rgba(95, 191, 196, 0.16);
    --level-zona-border: rgba(95, 191, 196, 0.4);
    --level-lugar:   #6fbf9e;
    --level-lugar-bg: rgba(111, 191, 158, 0.16);
    --level-lugar-border: rgba(111, 191, 158, 0.4);

    /* Radios */
    --r-sm:  8px;
    --r-md:  12px;
    --r-lg:  18px;
    --r-full: 999px;

    /* Sombra */
    --shadow-card: 0 1px 2px rgba(0,0,0,.35), 0 10px 28px -14px rgba(0,0,0,.55);
    --shadow-fab:  0 6px 20px -4px rgba(201, 162, 75, 0.45);

    /* Tipografia */
    --font-display: 'Sora', -apple-system, sans-serif;
    --font-body:    'Inter', -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-1);
    -webkit-font-smoothing: antialiased;
    padding-bottom: 84px;
}

h1, h2, h3, .font-display {
    font-family: var(--font-display);
    letter-spacing: -0.01em;
}

a { color: inherit; }

button, input, select, textarea { font-family: inherit; }

:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* ===================== LAYOUT ===================== */

.app-topbar {
    border-bottom: 1px solid var(--border-soft);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 20;
}
.app-topbar::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(14,14,23,0.9);
    backdrop-filter: blur(10px);
    border-radius: inherit;
    z-index: -1;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    color: var(--text-1);
}
.app-brand .mark {
    width: 30px; height: 30px;
    border-radius: var(--r-sm);
    background: var(--gold-bg);
    border: 1px solid rgba(201,162,75,0.35);
    display: flex; align-items: center; justify-content: center;
    color: var(--gold);
    overflow: hidden;
}
.app-brand .mark.mark-logo { background: var(--surface-2); border-color: var(--border); }
.app-brand .mark img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.app-brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.app-brand-sub { display: none; font-family: var(--font-body); font-weight: 500; font-size: 11.5px; color: var(--text-3); }

.app-user {
    font-size: 12px;
    color: var(--text-3);
    text-align: right;
    line-height: 1.5;
}
.app-user-name { color: var(--text-2); font-weight: 600; }
.app-user-line2 {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}
.app-user-role {
    color: var(--gold);
    text-transform: capitalize;
}
.app-user-role::after { content: '\00b7'; margin-left: 4px; color: var(--text-3); }
.app-user-logout {
    color: var(--text-3);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.app-user-logout:hover { color: var(--danger); }

main.app-main {
    padding: 20px 18px 8px;
    max-width: 640px;
    margin: 0 auto;
}

/* Punto de anclaje para volver aqui despues de cambiar de pagina en un paginador,
   sin que el header fijo tape el titulo de la seccion. */
.scroll-target { scroll-margin-top: 100px; }

.app-bottomnav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(17,17,26,0.92);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-soft);
    display: flex;
    justify-content: space-around;
    padding: 8px 2px max(8px, env(safe-area-inset-bottom));
    z-index: 20;
    overflow-x: auto;
    scrollbar-width: none;
}
.app-bottomnav::-webkit-scrollbar { display: none; }
.app-bottomnav a {
    color: var(--text-3);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 8px;
    border-radius: var(--r-md);
    transition: background .15s ease, color .15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}
.app-bottomnav a.active { color: var(--gold); background: var(--gold-bg); }
.app-bottomnav svg { width: 19px; height: 19px; }

/* Boton "Más" (⋯): mismo aspecto que los enlaces del nav */
.nav-more-btn {
    color: var(--text-3);
    background: none;
    border: 0;
    font: inherit;
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 8px;
    border-radius: var(--r-md);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background .15s ease, color .15s ease;
}
.nav-more-btn.active, .nav-more-btn[aria-expanded="true"] { color: var(--gold); background: var(--gold-bg); }
.nav-more-btn svg { width: 19px; height: 19px; }

/* Panel del menu "Más": vive fuera del nav (el nav recorta con overflow) y se posiciona por JS */
.nav-more-panel {
    position: fixed;
    z-index: 40;
    min-width: 170px;
    background: var(--surface-2, #16161f);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 6px;
    box-shadow: 0 12px 32px rgba(0,0,0,.45);
}
.nav-more-panel[hidden] { display: none; }
.nav-more-panel a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--r-md);
    color: var(--text-2, var(--text-1));
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
}
.nav-more-panel a:hover { background: var(--surface-3); color: var(--text-1); }
.nav-more-panel a.active { color: var(--gold); background: var(--gold-bg); }
.nav-more-panel svg { width: 17px; height: 17px; }

@media (max-width: 400px) {
    .app-bottomnav a { padding: 6px 6px; font-size: 9.5px; }
    .app-bottomnav svg { width: 18px; height: 18px; }
}

.fab {
    position: fixed;
    bottom: 78px; right: 18px;
    width: 54px; height: 54px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--gold-contrast);
    display: flex; align-items: center; justify-content: center;
    text-decoration: none;
    box-shadow: var(--shadow-fab);
    z-index: 20;
    transition: transform .15s ease;
}
.fab:active { transform: scale(0.94); }
.fab svg { width: 24px; height: 24px; }

/* Grid de resultados del buscador: 1 columna en movil, 2 en escritorio (override en @media 900px mas abajo) */
.search-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ===================== ESCRITORIO ===================== */
@media (min-width: 900px) {
    body { padding-bottom: 0; }

    main.app-main {
        max-width: 1040px;
        padding: 40px 32px 40px;
        margin-top: 66px; /* compensa el header fixed, que ya no reserva espacio en el flujo normal */
    }

    /* El header pasa a ser una sola tarjeta flotante: marca + nav + usuario en una fila.
       Se usa position:fixed (en vez de sticky) para que quede realmente quieto arriba
       sin el parpadeo que puede dar sticky + backdrop-filter al hacer scroll rapido.
       top:0 y sin espacio libre arriba: asi no hay ningun hueco por donde se pueda
       colar contenido al hacer scroll (esa era la causa del bug anterior). */
    .app-topbar {
        position: fixed;
        top: 0;
        left: 32px;
        right: 32px;
        margin: 0;
        border: 1px solid var(--border);
        border-top: none;
        border-radius: 0 0 var(--r-lg) var(--r-lg);
        padding: 12px 22px;
        gap: 12px;
        will-change: transform;
    }
    .app-topbar::before {
        background: rgba(22,22,31,0.85);
    }

    .app-brand-sub { display: block; }

    /* El nav deja de ser una barra fija aparte y pasa a vivir dentro de la
       misma fila del header, entre la marca y el usuario. */
    .app-bottomnav {
        position: static;
        display: flex;
        flex: 1;
        background: transparent;
        border: none;
        padding: 0;
        margin: 0 12px;
        justify-content: flex-start;
        align-items: center;
        gap: 30px;
        overflow: visible;
    }
    .app-bottomnav a {
        position: relative;
        flex-direction: row;
        flex-shrink: 0;
        font-size: 13.5px;
        font-weight: 600;
        padding: 6px 2px;
        gap: 8px;
        border-radius: 0;
    }
    .app-bottomnav a:hover { color: var(--text-1); background: transparent; }
    .app-bottomnav a.active { color: var(--gold); background: transparent; }
    .app-bottomnav a.active::after {
        content: '';
        position: absolute;
        left: 50%;
        bottom: -19px;
        transform: translateX(-50%);
        width: 20px;
        height: 3px;
        border-radius: 2px;
        background: var(--gold);
    }
    .app-bottomnav svg { width: 17px; height: 17px; }
    .nav-more-btn { position: relative; flex-direction: row; font-size: 13.5px; font-weight: 600; padding: 6px 2px; gap: 8px; border-radius: 0; }
    .nav-more-btn:hover { color: var(--text-1); background: transparent; }
    .nav-more-btn.active, .nav-more-btn[aria-expanded="true"] { background: transparent; }
    .nav-more-btn svg { width: 17px; height: 17px; }

    .app-user-role::after { content: none; }
    .app-user-line2 { flex-direction: column; align-items: flex-end; gap: 2px; }

    .fab { bottom: 32px; right: 32px; }

    /* Grillas de 2 columnas para pantallas anchas (las tarjetas que antes eran una sola columna) */
    .grid-desktop-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

    .search-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
}

/* ===================== COMPONENTES ===================== */

.card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px;
    box-shadow: var(--shadow-card);
}

.stat-card {
    flex: 1;
    min-width: 0;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 13px 14px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat-card .stat-icon {
    width: 28px; height: 28px;
    border-radius: var(--r-sm);
    background: var(--gold-bg);
    color: var(--gold);
    display: flex; align-items: center; justify-content: center;
}
.stat-card .stat-icon svg { width: 15px; height: 15px; }
.stat-card .stat-value {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
}
.stat-card .stat-label {
    font-size: 11px;
    color: var(--text-3);
    line-height: 1.3;
}
.stat-card .stat-value { overflow-wrap: break-word; }
.stat-card.alert .stat-value { color: var(--warning); }
.stat-card-link {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--gold);
    text-decoration: none;
    margin-top: 2px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* Fila de estadisticas del dashboard: mismas .stat-card, mas compactas y en una sola fila que envuelve */
.stat-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.stat-grid .stat-card { flex: 1 1 128px; }

/* Cabecera del dashboard con indicador de estado */
.dash-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    padding: 7px 12px;
    font-size: 11.5px;
    color: var(--text-2);
    white-space: nowrap;
}
.status-pill .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-bg);
    flex-shrink: 0;
}

/* Layout principal del dashboard: actividad (ancho) + barra lateral (acciones/alertas) */
.dash-grid { display: flex; flex-direction: column; gap: 16px; }
.dash-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dash-side { display: flex; flex-direction: column; gap: 14px; }

.quick-actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@media (min-width: 900px) {
    .dash-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
}

.quick-action {
    flex: 1;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px 14px;
    text-decoration: none;
    color: var(--text-1);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    transition: border-color .15s ease, transform .1s ease;
}
.quick-action:active { transform: scale(0.98); }
.quick-action .qa-icon {
    width: 34px; height: 34px;
    border-radius: var(--r-sm);
    background: var(--gold-bg);
    color: var(--gold);
    display: flex; align-items: center; justify-content: center;
}
.quick-action .qa-icon svg { width: 18px; height: 18px; }
.quick-action .qa-label { font-size: 13.5px; font-weight: 600; }

/* Ruta de ubicacion — elemento firma de la app: camino de nodos de color */
.location-trail {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    row-gap: 6px;
    font-size: 12.5px;
    color: var(--text-2);
}
.location-trail .seg {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.location-trail .dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.04);
}
.location-trail .connector {
    width: 16px; height: 2px;
    margin: 0 6px;
    border-radius: 2px;
    flex-shrink: 0;
    opacity: 0.8;
}
.location-trail .seg.current { color: var(--gold); font-weight: 600; }
.location-trail .seg.current .dot {
    width: 8px; height: 8px;
    box-shadow: 0 0 0 4px var(--gold-bg);
}
.location-trail.empty { color: var(--text-3); font-style: italic; }

.location-trail.lg { font-size: 14.5px; }
.location-trail.lg .dot { width: 7px; height: 7px; }
.location-trail.lg .seg.current .dot { width: 10px; height: 10px; }
.location-trail.lg .connector { width: 22px; margin: 0 7px; }

/* Linea de tiempo (historial de movimientos) */
.timeline-item { display: flex; gap: 12px; }
.timeline-rail { display: flex; flex-direction: column; align-items: center; width: 10px; flex-shrink: 0; }
.timeline-dot {
    width: 11px; height: 11px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px;
    box-shadow: 0 0 0 4px var(--bg);
}
.timeline-line { flex: 1; width: 2px; background: var(--border); margin-top: 4px; min-height: 16px; }
.timeline-content { flex: 1; min-width: 0; padding-bottom: 16px; }

/* Tarjeta de item (busqueda) */
.item-row {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 13px;
    display: flex;
    gap: 12px;
    align-items: center;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s ease;
}
.item-row:active { border-color: var(--gold-soft); }
.item-row .thumb {
    width: 52px; height: 52px;
    object-fit: cover;
    border-radius: var(--r-md);
    background: var(--surface-3);
    flex-shrink: 0;
}
.item-row .thumb-icon {
    width: 52px; height: 52px;
    border-radius: var(--r-md);
    background: var(--surface-3);
    color: var(--text-3);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.item-row .thumb-icon svg { width: 22px; height: 22px; }
.item-row .info { flex: 1; min-width: 0; }
.item-row .nombre { font-weight: 600; font-size: 14.5px; }
.item-row .meta { color: var(--text-3); font-size: 11px; margin-top: 3px; }

/* Tarjeta de resultado del buscador (estilo "Calculadora de Costos" del cliente) */
.search-card {
    display: block;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 14px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s ease;
}
.search-card:active { border-color: var(--gold-soft); }
.search-card-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-1);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}
.search-card-tags {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    row-gap: 6px;
    column-gap: 12px;
    margin-bottom: 12px;
}
.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    color: var(--text-3);
}
.tag-chip svg { flex-shrink: 0; }
.search-card-stats { display: flex; gap: 8px; }
.stat-pill {
    flex: 1;
    min-width: 0;
    background: var(--surface-3);
    border-radius: var(--r-md);
    padding: 8px 10px;
}
.stat-pill-value {
    font-weight: 700;
    font-size: 13.5px;
    color: var(--gold);
    overflow-wrap: break-word;
}
.stat-pill-label {
    font-size: 10px;
    color: var(--text-3);
    margin-top: 2px;
}

/* Paginador del buscador */
.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 18px;
}
.pager-btn {
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--surface-1);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.pager-btn:hover { border-color: var(--gold-soft); color: var(--text-1); }
.pager-btn.active { background: var(--gold-bg); border-color: var(--gold); color: var(--gold); }
.pager-btn:disabled, .pager-btn.disabled { opacity: .35; cursor: default; pointer-events: none; }
.pager-btn:disabled:hover, .pager-btn.disabled:hover { border-color: var(--border); color: var(--text-2); }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
label.field-label {
    font-size: 12.5px; font-weight: 600; color: var(--text-2);
    display: flex; align-items: center; gap: 5px;
}
.input, select.input, textarea.input {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-1);
    font-size: 15px;
    font-family: var(--font-body);
    appearance: none;
}
select.input {
    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='%23a9a7ba' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 38px;
}
.input:focus, select.input:focus { outline: none; border-color: var(--gold-soft); background: var(--surface-3); }
.input::placeholder { color: var(--text-3); }
.input-file {
    display: flex; align-items: center; gap: 10px;
    border: 1px dashed var(--border);
    border-radius: var(--r-md);
    padding: 12px 14px;
    color: var(--text-3);
    font-size: 13px;
    cursor: pointer;
    background: var(--surface-2);
}
.hint { font-size: 11.5px; color: var(--text-3); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 12px 16px;
    border-radius: var(--r-md);
    border: none;
    font-size: 14.5px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    text-decoration: none;
    transition: opacity .15s ease, transform .1s ease;
}
.btn:active { transform: scale(0.98); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--gold); color: var(--gold-contrast); width: 100%; }
.btn-secondary { background: var(--surface-2); color: var(--text-1); border: 1px solid var(--border); }
.btn-danger-outline { background: transparent; color: var(--danger); border: 1px solid rgba(226,145,156,0.3); }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-icon {
    width: 34px; height: 34px; padding: 0;
    background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
    border-radius: var(--r-sm);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    color: var(--text-2);
    border-radius: var(--r-full);
    padding: 6px 12px;
    font-size: 12px;
}
.chip b { color: var(--gold); font-weight: 600; }
.chip svg { width: 12px; height: 12px; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: var(--r-full);
    font-size: 11px;
    font-weight: 600;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--surface-3); color: var(--text-3); }
.badge-purple { background: var(--level-piso-bg); color: var(--level-piso); }

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    font-size: 13.5px;
    margin-bottom: 14px;
    border: 1px solid transparent;
}
.alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: rgba(127,191,158,0.25); }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(226,145,156,0.25); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: rgba(227,181,99,0.25); }

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 22px 0 10px;
}
.section-title:first-child { margin-top: 0; }

.empty-state {
    color: var(--text-3);
    font-size: 13px;
    text-align: center;
    padding: 30px 14px;
}

.divider { height: 1px; background: var(--border-soft); border: none; margin: 16px 0; }

.disclosure summary {
    cursor: pointer;
    color: var(--gold);
    font-size: 13.5px;
    font-weight: 600;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 0;
}
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary svg { width: 15px; height: 15px; }
.disclosure[open] summary .chev { transform: rotate(90deg); }
.disclosure .chev { transition: transform .15s ease; }

.avatar-thumb {
    border-radius: var(--r-lg);
    background: var(--surface-3);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-3);
    flex-shrink: 0;
    overflow: hidden;
}
.avatar-thumb img { width: 100%; height: 100%; object-fit: cover; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data-table th {
    text-align: left;
    color: var(--text-3);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}
table.data-table td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--border-soft);
}

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-row .bar-label { width: 92px; font-size: 12px; color: var(--text-2); flex-shrink: 0; }
.bar-row .bar-track { flex: 1; height: 8px; background: var(--surface-3); border-radius: var(--r-full); overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: var(--gold); border-radius: var(--r-full); }
.bar-row .bar-value { width: 30px; text-align: right; font-size: 12px; color: var(--text-2); flex-shrink: 0; }

/* Selector de tipo de item (Inventario vs Herramienta) */
.tipo-toggle { flex: 1; cursor: pointer; }
.tipo-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.tipo-toggle-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    padding: 14px 10px;
    border-radius: var(--r-md);
    border: 1.5px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
    transition: border-color .15s ease, background .15s ease;
}
.tipo-toggle-box strong { font-size: 13px; color: var(--text-1); }
.tipo-toggle-box small { font-size: 10.5px; color: var(--text-3); line-height: 1.3; }
.tipo-toggle input:checked + .tipo-toggle-box {
    border-color: var(--gold);
    background: var(--gold-bg);
}
.tipo-toggle input:checked + .tipo-toggle-box strong { color: var(--gold); }

/* Chips de filtro (Buscar: Todos / Herramientas / Inventario) */
.filter-chip {
    padding: 8px 14px;
    border-radius: var(--r-full);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.filter-chip.active { border-color: var(--gold); background: var(--gold-bg); color: var(--gold); }

/* ===================== DETALLE DE ITEM (rediseño) ===================== */

.back-link {
    color: var(--text-3);
    font-size: 13px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.detail-grid { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.detail-main { display: flex; flex-direction: column; gap: 14px; }
.detail-side { display: flex; flex-direction: column; gap: 14px; }

.detail-header-card { display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.detail-header-card .header-stats { align-self: stretch; text-align: left; }
.detail-header-card .search-card-tags { justify-content: center; }

.action-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Tarjetas de "Ubicacion actual" (version tarjeta del location-trail, para el detalle) */
.location-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 420px) {
    .location-cards { grid-template-columns: 1fr; }
}
.location-card {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 10px 12px;
}
.location-card-icon {
    width: 34px; height: 34px;
    border-radius: var(--r-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.18);
}
.location-card-text { display: flex; flex-direction: column; min-width: 0; }
.location-card-text strong { font-size: 13.5px; font-weight: 700; overflow-wrap: break-word; }
.location-card-text small { font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; }

.location-card.lvl-piso  { background: var(--level-piso-bg);  border-color: var(--level-piso-border); }
.location-card.lvl-zona  { background: var(--level-zona-bg);  border-color: var(--level-zona-border); }
.location-card.lvl-lugar { background: var(--level-lugar-bg); border-color: var(--level-lugar-border); }
.location-card.lvl-piso  .location-card-icon { color: var(--level-piso); }
.location-card.lvl-zona  .location-card-icon { color: var(--level-zona); }
.location-card.lvl-lugar .location-card-icon { color: var(--level-lugar); }
.location-card.lvl-piso  .location-card-text small { color: var(--level-piso); opacity: .85; }
.location-card.lvl-zona  .location-card-text small { color: var(--level-zona); opacity: .85; }
.location-card.lvl-lugar .location-card-text small { color: var(--level-lugar); opacity: .85; }

/* Panel "Ubicacion visual" */
.visual-location-head { margin-bottom: 14px; }
.visual-location-head h3 { font-size: 14.5px; margin-bottom: 3px; }
.level-panels {
    display: flex;
    align-items: stretch;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.level-chevron { color: var(--text-3); flex-shrink: 0; align-self: center; }
.level-panel { flex-shrink: 0; min-width: 148px; display: flex; flex-direction: column; gap: 8px; }
.level-panel-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    padding: 3px 8px;
    border-radius: var(--r-full);
    align-self: flex-start;
    white-space: nowrap;
}
.level-panel-label.piso  { color: var(--level-piso);  background: var(--level-piso-bg); }
.level-panel-label.zona  { color: var(--level-zona);  background: var(--level-zona-bg); }
.level-panel-label.lugar { color: var(--level-lugar); background: var(--level-lugar-bg); }

/* Ilustraciones isometricas (pila de pisos / caja de zona) del panel Ubicacion visual */
.iso-illustration { width: 100%; max-width: 148px; }
.iso-illustration svg { width: 100%; height: auto; display: block; }
.iso-caption { font-size: 12px; font-weight: 700; text-align: center; margin-top: 2px; }

.hueco-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 8px;
}
.hueco-cell {
    aspect-ratio: 1;
    min-width: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface-3);
    color: var(--text-3);
    font-size: 11px;
    font-weight: 700;
}
.hueco-cell.active { border-width: 1.5px; }

@media (min-width: 900px) {
    .detail-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; align-items: start; }
    .detail-side { position: sticky; top: 90px; }
}

/* Caja de foto/icono del encabezado del detalle - version con color, no gris apagado */
.item-photo-box {
    width: 84px; height: 84px;
    border-radius: var(--r-lg);
    background: var(--gold-bg);
    color: var(--gold);
    border: 1px solid rgba(201,162,75,0.3);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}
.item-photo-box img { width: 100%; height: 100%; object-fit: cover; }

/* Grilla generica de stat-card, para paginas con muchas metricas chicas (reportes) */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }

/* Empareja dos bloques (titulo + card) lado a lado en escritorio; una sola columna en movil */
.reportes-grid-2 { display: flex; flex-direction: column; }
@media (min-width: 900px) {
    .reportes-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; align-items: start; }
}

/* Fila de tarjetas de estadistica del encabezado (cantidad, fecha de entrada, registrado por...) */
.header-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.header-stats .stat-card { min-width: 0; padding: 12px 12px; }
@media (max-width: 420px) {
    .header-stats { grid-template-columns: repeat(2, 1fr); }
}

/* Tarjeta "bonus" (ej. precio) cuando hay una 4ta: ocupa todo el ancho en vez de
   quedar sola y apretada en 1 de 3 columnas - icono a la izquierda, texto a la derecha. */
.header-stats .stat-card.wide {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

/* ===================== ASISTENTE IA (DeepSeek) ===================== */

.ai-box {
    border: 1px dashed var(--gold-soft);
    background: var(--gold-bg);
    border-radius: var(--r-lg);
    padding: 14px;
    margin-bottom: 18px;
}
.ai-box-head {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--gold);
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 8px;
}
.ai-box textarea.input { resize: vertical; min-height: 56px; }

.ai-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 16px;
    border-radius: var(--r-md);
    border: none;
    background: var(--gold);
    color: var(--gold-contrast);
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 8px;
}
.ai-trigger:disabled { opacity: .6; cursor: default; }

.ai-search-trigger {
    flex-shrink: 0;
    width: auto;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--r-md);
    border: 1px dashed var(--gold-soft);
    background: var(--gold-bg);
    color: var(--gold);
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
}
.ai-search-trigger:disabled { opacity: .6; cursor: default; }

.ai-hint { font-size: 11.5px; color: var(--text-3); margin-top: 8px; }
.ai-hint.error { color: var(--danger); }
.ai-hint.ok { color: var(--success); }

/* Respuesta del panel "Preguntale al asistente" */
.ai-answer {
    background: var(--surface-2);
    border-radius: var(--r-md);
    padding: 12px 14px;
    font-size: 13px;
    color: var(--text-1);
}
.ai-answer p { margin: 0; line-height: 1.5; }
.ai-answer-items { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.ai-answer-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    background: var(--surface-3);
    border-radius: var(--r-sm);
    padding: 8px 10px;
    text-decoration: none;
    color: inherit;
    font-size: 12.5px;
}
.ai-answer-item span { font-weight: 600; overflow-wrap: break-word; }
.ai-answer-item small { color: var(--text-3); font-size: 11px; }

/* ===================== LIGHTBOX (zoom de imagenes) ===================== */

img.zoomable { cursor: zoom-in; }

.lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 6, 10, 0.9);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    cursor: zoom-out;
}
.lightbox-overlay.open { display: flex; }
.lightbox-overlay img {
    max-width: 92vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: var(--r-md);
    box-shadow: 0 20px 60px -20px rgba(0,0,0,0.6);
    cursor: default;
}
.lightbox-close {
    position: fixed;
    top: 18px;
    right: 18px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-1);
    color: var(--text-1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.lightbox-close:hover { color: var(--danger); }

/* ===================== SELECTOR DE LIBRERIA DE ICONOS (tipos_ubicacion) ===================== */

.icon-picker-overlay { align-items: flex-start; padding-top: 60px; cursor: default; }
.icon-picker-panel {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    width: 100%;
    max-width: 640px;
    max-height: 78vh;
    display: flex;
    flex-direction: column;
    cursor: default;
    box-shadow: 0 20px 60px -20px rgba(0,0,0,0.6);
}
.icon-picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-soft);
    flex-shrink: 0;
}
.icon-picker-head h3 { font-size: 15.5px; }
.icon-picker-body { padding: 16px 18px; overflow-y: auto; }
.icon-picker-cat {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-3);
    margin: 18px 0 10px;
}
.icon-picker-cat:first-child { margin-top: 0; }
.icon-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.icon-picker-item {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 10px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--text-1);
}
.icon-picker-item:hover { border-color: var(--gold-soft); }
.icon-picker-item svg { width: 40px; height: auto; }
.icon-picker-item span { font-size: 10.5px; text-align: center; line-height: 1.2; }

.icon-picker-trigger-preview { display: flex; align-items: center; gap: 10px; }
.icon-picker-trigger-preview svg { flex-shrink: 0; }