/* ================================================================
   MexCloud — Hoja de componentes (sobre los tokens del tema)
   Reutilizable por datos1 y adm. Solo tokens semánticos (--color-*,
   --radius-*, etc.), nunca colores crudos. Respeta prefers-reduced-motion.
   ================================================================ */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--font-size);
    line-height: var(--line-height);
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 0.5em; font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
small, .texto-muted { color: var(--color-text-muted); }
.texto-peligro { color: var(--color-danger); }
.file-list-table tbody tr.enlace-expirado { opacity: 0.6; }
code, kbd { font-family: var(--font-mono); font-size: 0.9em; }

:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---- Botones ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.5rem 1rem; font: inherit; font-weight: 500; line-height: 1;
    border: 1px solid transparent; border-radius: var(--radius-md);
    background: var(--color-surface-2); color: var(--color-text);
    cursor: pointer; transition: background var(--transition), border-color var(--transition);
    text-decoration: none;
}
.btn:hover { background: var(--color-border); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); color: var(--color-primary-fg); }
.btn-primary:hover { background: var(--color-primary-h); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--color-border); }
.btn-icono { padding: 0.5rem; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.85rem; }

/* ---- Formularios ---- */
.campo { margin-bottom: 1rem; }
.campo > label { display: block; margin-bottom: 0.35rem; font-weight: 500; color: var(--color-text-2); }
.input, .select, .textarea {
    width: 100%; padding: 0.55rem 0.75rem; font: inherit;
    color: var(--color-text); background: var(--color-surface);
    border: 1px solid var(--color-border); border-radius: var(--radius-md);
    transition: border-color var(--transition);
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--color-primary); outline: none; }
.textarea { min-height: 5rem; resize: vertical; }

/* ---- Tarjetas ---- */
.card {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
    padding: 1.25rem;
}
.card + .card { margin-top: 1rem; }
.card-titulo { margin: 0 0 1rem; font-size: 1.05rem; font-weight: 600; }

/* ---- Insignias / estados ---- */
.badge {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.15rem 0.5rem; font-size: 0.78rem; font-weight: 600;
    border-radius: var(--radius-full); background: var(--color-surface-2); color: var(--color-text-2);
}
.badge-exito { background: color-mix(in srgb, var(--color-success) 18%, transparent); color: var(--color-success); }
.badge-alerta { background: color-mix(in srgb, var(--color-warning) 20%, transparent); color: var(--color-warning); }
.badge-peligro { background: color-mix(in srgb, var(--color-danger) 18%, transparent); color: var(--color-danger); }

/* ---- Barra de progreso / uso de cuota ---- */
.progress { height: 8px; background: var(--color-surface-2); border-radius: var(--radius-full); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--color-primary); transition: width var(--transition); }
.progress.alto > span { background: var(--color-warning); }
.progress.lleno > span { background: var(--color-danger); }

/* ---- Layout app-shell ---- */
/* Altura fija del shell: navbar + sidebar quedan fijos y cada .contenido
   scrollea por dentro (necesario para el breadcrumb sticky y el render
   incremental). 100dvh respeta la barra dinámica del navegador en móvil. */
.app { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.navbar {
    display: flex; align-items: center; gap: 1rem; padding: 0 1rem;
    min-height: var(--navbar-height); flex-wrap: wrap; row-gap: 0.4rem;
    background: var(--color-surface); border-bottom: 1px solid var(--color-border);
    position: sticky; top: 0; z-index: 20;
}
.navbar .crece { flex: 1; }
.app-cuerpo { display: grid; grid-template-columns: var(--sidebar-width) 1fr; min-height: 0; }
.sidebar {
    background: var(--color-sidebar-bg); color: var(--color-sidebar-fg);
    padding: 0.75rem; overflow-y: auto;
}
.sidebar a { display: block; padding: 0.5rem 0.75rem; border-radius: var(--radius-md); color: var(--color-sidebar-fg); }
.sidebar a:hover { background: rgba(255,255,255,0.06); text-decoration: none; }
.sidebar a.activo { background: var(--color-sidebar-act); color: #fff; }
.contenido { padding: 1.5rem; overflow-y: auto; }

/* ---- Marca ---- */
.marca { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 700; color: var(--color-text); }
/* Logo del navbar = botón de Inicio (marca = home) */
.marca-inicio { cursor: pointer; border-radius: var(--radius-md); padding: 0.15rem 0.25rem; transition: opacity 0.12s; }
.marca-inicio:hover { opacity: 0.8; }
.marca-inicio:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.marca svg { flex: none; }
.marca .wordmark { font-size: 1.15rem; letter-spacing: -0.01em; }

/* Bloque de usuario (icono + nombre + salir) en la cabecera. En escritorio va
   a la derecha; en móvil sube al renglón de la marca (ver media query). */
.nav-usuario { display: inline-flex; align-items: center; gap: 0.6rem; min-width: 0; }
.nav-usuario .usuario-nombre { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navbar .nav-tabs { order: 2; margin-left: 0.75rem; }
.navbar .nav-usuario { order: 3; margin-left: auto; }

/* Solo-móvil: oculto en escritorio. `!important` para ganarle al `display` de
   componentes que la usan (`.accion-sel`, `.btn-icono`) definidos más abajo con la
   misma especificidad; simétrico a `.solo-escritorio` (ver media query). */
.solo-movil { display: none !important; }
.hamburguesa { order: 0; }
.drawer-fondo { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.45); display: flex; }
.drawer {
    width: min(80vw, 18rem); background: var(--color-surface); height: 100%;
    box-shadow: 2px 0 16px rgba(0,0,0,0.3); display: flex; flex-direction: column;
    padding: 0.75rem; gap: 0.25rem; overflow-y: auto;
}
.drawer-item {
    display: flex; align-items: center; gap: 0.75rem; width: 100%;
    padding: 0.8rem 0.9rem; border-radius: var(--radius-md); border: 0;
    background: transparent; color: var(--color-text); cursor: pointer; font-size: 1rem;
}
.drawer-item:hover { background: var(--color-surface-2); }
.drawer-item.activo { background: var(--color-primary); color: #fff; }
.drawer-item svg { width: 1.3rem; height: 1.3rem; flex: none; }
.drawer-sep { height: 1px; background: var(--color-border); margin: 0.5rem 0.4rem; }
/* Título del drawer = botón de Inicio (marca = home) */
.drawer-titulo {
    display: flex; align-items: center; gap: 0.6rem; width: 100%;
    padding: 0.6rem 0.9rem; margin-bottom: 0.3rem; border: 0; border-radius: var(--radius-md);
    background: transparent; color: var(--color-text); cursor: pointer; font-weight: 700; font-size: 1.1rem;
}
.drawer-titulo svg { width: 1.6rem; height: 1.6rem; flex: none; }
.drawer-titulo:hover { background: var(--color-surface-2); }
.drawer-titulo.activo { color: var(--color-primary); }

/* ---- Menús desplegables anclados (Agregar / Ver) ---- */
.menu-wrap { position: relative; display: inline-flex; z-index: 40; }
.chevron-abajo { display: inline-flex; transition: transform 0.15s ease; }
.chevron-abajo svg { width: 1rem; height: 1rem; }
.chevron-abajo.abierto { transform: rotate(180deg); }
.menu-pop {
    position: absolute; top: calc(100% + 0.35rem); left: 0; z-index: 50;
    min-width: 12.5rem; max-width: calc(100vw - 1.5rem); padding: 0.35rem;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-md); box-shadow: 0 10px 28px rgba(0,0,0,0.28);
    display: flex; flex-direction: column; gap: 0.1rem;
}
.menu-pop-item {
    display: flex; align-items: center; gap: 0.65rem; width: 100%;
    padding: 0.6rem 0.7rem; border-radius: var(--radius-sm); border: 0;
    background: transparent; color: var(--color-text); cursor: pointer;
    font-size: 0.95rem; text-align: left; white-space: nowrap; margin: 0;
}
.menu-pop-item:hover { background: var(--color-surface-2); }
.menu-pop-item.activo { background: var(--color-primary); color: #fff; }
.menu-pop-item svg { width: 1.2rem; height: 1.2rem; flex: none; }
/* Menú «Compartir» de la barra de selección (app/correo/enlace). En escritorio la
   acción va al final de la barra: el desplegable se ancla a la DERECHA para no
   desbordar. (En móvil, ver la media query: abre hacia arriba y ocupa la barra.) */
.accion-compartir .menu-pop { left: auto; right: 0; }

/* ---- Selector de tema ---- */
.tema-selector { display: inline-flex; align-items: center; gap: 0.4rem; }

/* ---- Gestor de archivos ---- */
.files-layout { display: grid; grid-template-columns: 260px 1fr; gap: 1rem; min-height: 60vh; }
.file-tree { border-right: 1px solid var(--color-border); padding-right: 0.75rem; overflow-y: auto; }
.file-tree ul { list-style: none; margin: 0; padding-left: 0.75rem; }
.file-tree .nodo { display: flex; align-items: center; gap: 0.3rem; padding: 0.3rem 0.4rem; border-radius: var(--radius-sm); }
.file-tree .nodo:hover { background: var(--color-surface-2); }
.file-tree .nodo.activo { background: color-mix(in srgb, var(--color-primary) 12%, transparent); color: var(--color-primary); font-weight: 600; }
.file-tree .nodo.activo .tipo-icono svg { stroke: var(--color-primary); }
/* Línea divisoria entre la carpeta personal y las compartidas. */
.file-tree .nodo.primera-compartida { margin-top: 0.5rem; padding-top: 0.6rem; border-top: 1px solid var(--color-border); }
.file-tree .nodo-etq { display: flex; align-items: center; gap: 0.35rem; flex: 1; min-width: 0; cursor: pointer; }
.file-tree .nodo-etq > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-tree .twisty { flex: none; width: 1rem; display: inline-flex; align-items: center; justify-content: center; color: var(--color-text-muted); cursor: pointer; user-select: none; }
.file-tree .twisty svg { width: 0.7rem; height: 0.7rem; transition: transform var(--transition); }
.file-tree .twisty.abierto svg { transform: rotate(90deg); }
.file-tree .twisty:hover { color: var(--color-text-2); }
.file-tree .twisty-esp { cursor: default; visibility: hidden; }

/* Cabecera FIJA del gestor: envuelve el breadcrumb y (en escritorio) la barra de
   selección, para tenerlos siempre a mano aunque estés varias páginas abajo.
   top negativo = al padding de .contenido, para que con el margen negativo la
   caja quede FLUSH arriba al pegarse; los márgenes negativos cancelan el padding
   de .contenido para que el fondo llegue de borde a borde. */
.cabecera-gestor {
    position: sticky; z-index: 30;
    top: -1.5rem;
    margin: -1.5rem -1.5rem 1rem;
    padding: 0.7rem 1.5rem;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}
.breadcrumb {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem;
    color: var(--color-text-muted);
}
/* Barra de acciones (Agregar/Ver/vista) dentro de la cabecera sticky. */
.barra-acciones-gestor { margin-top: 0.6rem; }
.breadcrumb .btn-atras { margin-right: 0.4rem; }
.breadcrumb .miga { display: inline-flex; align-items: center; gap: 0.15rem; }
.breadcrumb .miga-enlace {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.25rem 0.5rem; border-radius: var(--radius-sm);
    color: var(--color-text-2); text-decoration: none; font-weight: 500;
    transition: background var(--transition), color var(--transition);
}
.breadcrumb .miga-enlace:hover { background: var(--color-surface-2); color: var(--color-text); }
.breadcrumb .miga-actual {
    color: var(--color-text); font-weight: 600;
    background: color-mix(in srgb, var(--color-primary) 10%, transparent);
}
.breadcrumb .miga-inicio svg { width: 1rem; height: 1rem; display: block; }
.breadcrumb .sep { display: inline-flex; align-items: center; color: var(--color-text-muted); opacity: 0.55; }
.breadcrumb .sep svg { width: 0.9rem; height: 0.9rem; display: block; }

.file-list-table { width: 100%; border-collapse: collapse; }
.file-list-table th, .file-list-table td { padding: 0.55rem 0.6rem; text-align: left; border-bottom: 1px solid var(--color-border); }
.file-list-table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--color-text-muted); font-weight: 600; }
.file-list-table tbody tr:hover { background: var(--color-surface-2); }
.file-list-table tbody tr.sel { background: color-mix(in srgb, var(--color-primary) 12%, transparent); }

/* Casilla de selección: checkbox grande y área clicable amplia (toda la celda),
   para que sea fácil de atinar con el mouse o el dedo. */
.file-list-table th.celda-sel, .file-list-table td.celda-sel { width: 3rem; padding: 0; text-align: center; }
.check-sel { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 2.7rem; cursor: pointer; }
.check-sel input[type="checkbox"] { width: 1.3rem; height: 1.3rem; cursor: pointer; accent-color: var(--color-primary); }
.file-list-table .col-acc { text-align: right; white-space: nowrap; width: 1%; }

/* ---- Nombre con icono de tipo y subtítulo ---- */
.tipo-icono { flex: none; display: inline-flex; }
.tipo-icono svg { width: 1.6rem; height: 1.6rem; display: block; }
.tipo-icono .miniatura {
    width: 1.9rem; height: 1.9rem; display: block; object-fit: cover;
    border-radius: var(--radius-sm); background: var(--color-surface-2);
}

/* ---- Visor de PDF (PDF.js) ---- */
.pdf-vista {
    height: 72vh; overflow-y: auto; background: var(--color-surface-2);
    border-radius: var(--radius-md); padding: 0.75rem;
    display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
}
.pdf-vista .pdf-pagina {
    max-width: 100%; height: auto; background: #fff;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25); border-radius: 2px;
}

/* ---- Indicador de cuota ---- */
.cuota-widget { font-size: 0.78rem; }
.cuota-sidebar { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--color-border); }
.cuota-movil { display: none; margin-bottom: 1rem; }
.cuota-cab { display: flex; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem; color: var(--color-text-muted); flex-wrap: wrap; }
.cuota-barra { height: 0.4rem; background: var(--color-surface-2); border-radius: 999px; overflow: hidden; }
.cuota-barra > span { display: block; height: 100%; width: 0; background: var(--color-primary); transition: width var(--transition); }
.cuota-alerta .cuota-barra > span { background: #f59e0b; }
.cuota-peligro .cuota-barra > span { background: var(--color-danger); }
.cuota-alerta .cuota-cab, .cuota-peligro .cuota-cab { color: var(--color-text-2); }
@media (max-width: 768px) { .cuota-movil { display: block; } }

/* ---- Reproductor de audio ---- */
.audio-vista { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 1.5rem 0.5rem; }
.audio-icono svg { width: 4rem; height: 4rem; display: block; }
.audio-nombre { font-weight: 600; text-align: center; overflow-wrap: anywhere; }
.audio-vista audio { max-width: 32rem; }

/* ---- Reproductor de vídeo ---- */
.video-vista { display: flex; justify-content: center; }
.video-vista video { width: 100%; max-height: 72vh; background: #000; border-radius: var(--radius-md); }

/* ---- Vista de CSV/TSV como tabla ---- */
.csv-vista { max-height: 72vh; overflow: auto; border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.csv-tabla { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 0.85rem; }
.csv-tabla th, .csv-tabla td {
    border: 1px solid var(--color-border); padding: 0.35rem 0.6rem;
    text-align: left; white-space: nowrap; max-width: 24rem;
    overflow: hidden; text-overflow: ellipsis;
}
.csv-tabla th { position: sticky; top: 0; background: var(--color-surface-2); font-weight: 600; z-index: 1; }
.csv-tabla tr:nth-child(even) td { background: color-mix(in srgb, var(--color-surface-2) 40%, transparent); }
.enlace-nombre { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.nombre-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.nombre-linea { overflow-wrap: anywhere; }
.subtitulo { display: none; font-size: 0.78rem; color: var(--color-text-muted); }
.file-tree .tipo-icono svg { width: 1.2rem; height: 1.2rem; }

/* ---- Botones de icono ---- */
.btn-icono {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.25rem; height: 2.25rem; flex: none; padding: 0;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    background: transparent; color: var(--color-text-2); cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.btn-icono:hover { background: var(--color-surface-2); color: var(--color-text); }
.btn-icono:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.btn-icono svg { width: 1.2rem; height: 1.2rem; display: block; }
.btn-icono.peligro:hover { color: var(--color-danger); background: color-mix(in srgb, var(--color-danger) 14%, transparent); }
.acciones-iconos { display: inline-flex; align-items: center; gap: 0.15rem; justify-content: flex-end; }
.btn-con-icono { display: inline-flex; align-items: center; gap: 0.45rem; }

/* ---- Barra de acciones sobre la selección ---- */
.barra-seleccion {
    display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
    background: var(--color-surface-2); padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md); margin-top: 0.6rem;
}
.barra-conteo { font-weight: 600; }
.barra-acciones { display: flex; align-items: center; gap: 0.4rem; margin-left: auto; flex-wrap: wrap; }
.accion-sel {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.4rem 0.7rem; border: 1px solid var(--color-border);
    border-radius: var(--radius-sm); background: var(--color-surface);
    color: var(--color-text-2); cursor: pointer; font: inherit; font-size: 0.85rem;
    transition: background var(--transition), color var(--transition);
}
.accion-sel:hover { background: var(--color-surface-2); color: var(--color-text); }
.accion-sel svg { width: 1.1rem; height: 1.1rem; }
.accion-sel.peligro:hover { color: var(--color-danger); border-color: var(--color-danger); }
.btn-con-icono svg { width: 1.05rem; height: 1.05rem; }
.salir-icono { display: none; }
.file-list-table th.col-orden { cursor: pointer; user-select: none; }
.file-list-table th.col-orden:hover { color: var(--color-text-2); }
.file-list-table tbody tr[draggable="true"] { cursor: grab; }

/* Destino de arrastre (mover a carpeta): fila, carpeta de barra lateral o miga. */
.file-list-table tbody tr.drop-activo,
.file-tree .nodo.drop-activo,
.breadcrumb a.drop-activo {
    outline: 2px dashed var(--color-primary); outline-offset: -2px;
    background: color-mix(in srgb, var(--color-primary) 15%, transparent);
    border-radius: var(--radius-sm);
}

.drop-zone {
    border: 2px dashed var(--color-border); border-radius: var(--radius-lg);
    padding: 1.5rem; text-align: center; color: var(--color-text-muted);
    transition: border-color var(--transition), background var(--transition);
}
.drop-zone.activa { border-color: var(--color-primary); background: color-mix(in srgb, var(--color-primary) 8%, transparent); }

/* Selector de carpeta (mover/copiar). Reusa las migas del breadcrumb pero
   neutraliza su comportamiento fijo (dentro del modal es estático). */
.picker-migas { position: static; margin: 0 0 0.75rem; padding: 0; border: 0; background: none; }
.picker-lista { max-height: 45vh; overflow-y: auto; border: 1px solid var(--color-border); border-radius: var(--radius-md); margin-bottom: 1rem; }
.picker-vacio { padding: 0.9rem; margin: 0; }
.picker-item {
    display: flex; align-items: center; gap: 0.6rem; width: 100%;
    padding: 0.6rem 0.7rem; background: none; border: 0;
    border-bottom: 1px solid var(--color-border); color: var(--color-text);
    cursor: pointer; text-align: left; font: inherit;
}
.picker-item:last-child { border-bottom: 0; }
.picker-item:hover { background: var(--color-surface-2); }
.picker-nombre { flex: 1; }
.picker-item .tipo-icono svg { width: 1.3rem; height: 1.3rem; display: block; }
.picker-chevron { color: var(--color-text-muted); display: inline-flex; }
.picker-chevron svg { width: 1rem; height: 1rem; display: block; }

/* Fantasma de conteo al arrastrar varios elementos (imagen de arrastre). Se
   posiciona fuera de vista: solo se usa como setDragImage y se elimina. */
.drag-conteo {
    position: fixed; top: -1000px; left: -1000px;
    padding: 0.3rem 0.6rem; border-radius: var(--radius-md);
    background: var(--color-primary); color: var(--color-primary-fg);
    font-size: 0.85rem; font-weight: 600; white-space: nowrap;
    box-shadow: var(--shadow-md);
}

.upload-progress { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1rem; }
.upload-progress .fila { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; align-items: center; }

/* ---- Modal ---- */
.modal-fondo {
    position: fixed; inset: 0; background: var(--color-overlay);
    display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 50;
}
.modal {
    background: var(--color-surface); color: var(--color-text);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    width: 100%; max-width: 32rem; max-height: 90vh; overflow: auto; padding: 1.5rem;
}
.modal-titulo { margin-top: 0; }
.modal-acciones { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.5rem; }
/* Editor de texto en la web. */
.modal-ancho { max-width: 60rem; }
/* Editor Office (Collabora): ocupa casi toda la ventana. */
.modal-office { max-width: 98vw; width: 98vw; height: 95vh; max-height: 95vh; padding: 0.75rem; overflow: hidden; }
.office-caja { display: flex; flex-direction: column; height: 100%; }
.office-frame { flex: 1 1 auto; width: 100%; border: 0; border-radius: var(--radius-md); background: #fff; }

/* ── Mis Notas (tipo Keep) ─────────────────────────────────────────────── */
/* Colores post-it: pastel con texto oscuro (legible en tema día y noche,
   como un post-it físico). «default» sí sigue el tema de la app. */
.nota-color-default  { --nota-bg: var(--color-surface); --nota-fg: var(--color-text); --nota-bd: var(--color-border); }
.nota-color-rojo     { --nota-bg: #f28b82; --nota-fg: #202124; --nota-bd: #e06055; }
.nota-color-naranja  { --nota-bg: #fbbc04; --nota-fg: #202124; --nota-bd: #e0a800; }
.nota-color-amarillo { --nota-bg: #fff475; --nota-fg: #202124; --nota-bd: #e6d84f; }
.nota-color-verde    { --nota-bg: #ccff90; --nota-fg: #202124; --nota-bd: #a5e673; }
.nota-color-azul     { --nota-bg: #cbf0f8; --nota-fg: #202124; --nota-bd: #a0dbe8; }
.nota-color-morado   { --nota-bg: #d7aefb; --nota-fg: #202124; --nota-bd: #bd8ef0; }
.nota-color-rosa     { --nota-bg: #fdcfe8; --nota-fg: #202124; --nota-bd: #f0a9d0; }
.nota-color-gris     { --nota-bg: #e8eaed; --nota-fg: #202124; --nota-bd: #c8ccd0; }

.notas-cuerpo { display: grid; grid-template-columns: 220px 1fr; min-height: 0; }
.notas-filtros { padding: 1rem 0.5rem; border-right: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 0.15rem; overflow-y: auto; }
.notas-filtro { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.9rem; border: 0; background: transparent; color: var(--color-text); border-radius: 2rem; cursor: pointer; text-align: left; width: 100%; font-size: 0.92rem; }
.notas-filtro:hover { background: var(--color-bg); }
.notas-filtro.activo { background: color-mix(in srgb, var(--color-primary) 16%, transparent); color: var(--color-primary); font-weight: 600; }
.notas-filtro svg { width: 1.15rem; height: 1.15rem; flex: 0 0 auto; }
.notas-filtro-n { font-size: 0.75rem; opacity: 0.6; }

.notas-nueva { max-width: 36rem; margin: 0 auto 1.5rem; }
.notas-nueva-ph { width: 100%; padding: 0.7rem 0.9rem; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-sm); cursor: text; box-sizing: border-box; }
.nota-editor { background: var(--nota-bg); color: var(--nota-fg); border: 1px solid var(--nota-bd); border-radius: var(--radius-md); padding: 0.6rem 0.75rem; box-shadow: var(--shadow-md); }
.nota-titulo-in, .nota-cont-in { width: 100%; background: transparent; border: 0; color: inherit; font-family: inherit; outline: none; box-sizing: border-box; }
.nota-titulo-in { font-weight: 600; font-size: 1rem; margin-bottom: 0.3rem; }
.nota-cont-in { resize: vertical; min-height: 3.5rem; font-size: 0.95rem; white-space: pre-wrap; line-height: 1.4; }
.nota-titulo-in::placeholder, .nota-cont-in::placeholder { color: currentColor; opacity: 0.55; }
.nota-barra { display: flex; align-items: center; gap: 0.35rem; margin-top: 0.5rem; flex-wrap: wrap; }
.nota-colores { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.nota-color-pt { width: 1.35rem; height: 1.35rem; border-radius: 50%; border: 2px solid rgba(0,0,0,0.18); background: var(--nota-bg); cursor: pointer; padding: 0; }
.nota-color-pt.sel { border-color: #202124; box-shadow: 0 0 0 2px #fff inset; }
/* Selector de color como menú (ahorra espacio en la barra, sobre todo en móvil) */
.nota-color-trigger { padding: 0; opacity: 1; }
/* Anillo arcoíris fijo: el color actual coincide con el fondo del editor y se
   camuflaría; este disco siempre es visible y se lee como «colores». */
.nota-color-actual { display: block; width: 1.4rem; height: 1.4rem; border-radius: 50%; border: 1px solid rgba(0,0,0,0.3); background: conic-gradient(#f28b82, #fbbc04, #fff475, #ccff90, #cbf0f8, #d7aefb, #fdcfe8, #f28b82); }
.nota-color-pop { flex-direction: row; flex-wrap: wrap; gap: 0.45rem; width: max-content; min-width: 0; max-width: 14rem; top: auto; bottom: calc(100% + 0.35rem); }
.nota-color-pop .nota-color-pt { width: 1.6rem; height: 1.6rem; }

.notas-grid { columns: 240px; column-gap: 0.9rem; }
.nota-card { break-inside: avoid; width: 100%; margin: 0 0 0.9rem; background: var(--nota-bg); color: var(--nota-fg); border: 1px solid var(--nota-bd); border-radius: var(--radius-md); padding: 0.75rem 0.85rem; cursor: pointer; position: relative; box-shadow: var(--shadow-sm); transition: box-shadow 0.15s; }
.nota-card:hover { box-shadow: var(--shadow-md); }
.nota-card-titulo { font-weight: 600; margin-bottom: 0.25rem; word-break: break-word; padding-right: 1.2rem; }
.nota-card-cont { white-space: pre-wrap; word-break: break-word; font-size: 0.92rem; line-height: 1.4; max-height: 14rem; overflow: hidden; }
.nota-pin { position: absolute; top: 0.5rem; right: 0.5rem; width: 1rem; height: 1rem; opacity: 0.75; display: inline-flex; }
.nota-card-etqs { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.5rem; }
.nota-etq { font-size: 0.72rem; background: rgba(0,0,0,0.09); border-radius: 1rem; padding: 0.12rem 0.55rem; }
.nota-etq-quita { cursor: pointer; }
.nota-etq-quita:hover { background: rgba(0,0,0,0.18); }
.nota-acciones { display: flex; gap: 0.15rem; margin-top: 0.5rem; opacity: 0; transition: opacity 0.15s; }
.nota-card:hover .nota-acciones, .nota-acciones:focus-within { opacity: 1; }
.nota-acc { background: transparent; border: 0; cursor: pointer; color: inherit; opacity: 0.7; width: 1.9rem; height: 1.9rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; padding: 0; }
.nota-acc:hover { background: rgba(0,0,0,0.1); opacity: 1; }
.nota-acc.activo { opacity: 1; }
.nota-acc svg { width: 1.05rem; height: 1.05rem; }
.nota-etq-menu { margin: 0.5rem 0; font-size: 0.9rem; }
.nota-etq-menu summary { cursor: pointer; opacity: 0.85; }
.nota-etq-lista { padding: 0.4rem 0; display: flex; flex-direction: column; gap: 0.2rem; max-height: 12rem; overflow: auto; }
.nota-etq-op { display: flex; align-items: center; gap: 0.5rem; }
.nota-enlaces { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.5rem; }
.nota-enlace { display: flex; flex-direction: column; border: 1px solid var(--nota-bd); border-radius: 0.5rem; background: color-mix(in srgb, var(--nota-fg) 8%, transparent); color: inherit; text-decoration: none; overflow: hidden; }
.nota-enlace:hover { background: color-mix(in srgb, var(--nota-fg) 15%, transparent); }
.nota-enlace-img { width: 100%; height: 120px; object-fit: cover; display: block; background: rgba(0,0,0,0.06); }
.nota-enlace-pie { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.55rem; min-width: 0; }
.nota-favicon { width: 1rem; height: 1rem; flex: 0 0 auto; border-radius: 3px; object-fit: contain; }
.nota-enlace-ic { flex: 0 0 auto; display: inline-flex; opacity: 0.7; }
.nota-enlace-ic svg { width: 1rem; height: 1rem; }
.nota-enlace-txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.nota-enlace-titulo { font-size: 0.85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nota-enlace-dom { font-size: 0.72rem; opacity: 0.65; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nota-chip-recordatorio { display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 0.5rem; font-size: 0.75rem; padding: 0.15rem 0.55rem; border-radius: 1rem; background: color-mix(in srgb, var(--nota-fg) 10%, transparent); }
.nota-chip-recordatorio svg { width: 0.85rem; height: 0.85rem; }
.nota-recordatorio-ctrl { display: flex; align-items: center; gap: 0.5rem; margin: 0.6rem 0; color: var(--nota-fg); }
.nota-recordatorio-ic { display: inline-flex; flex: 0 0 auto; opacity: 0.75; }
.nota-recordatorio-ic svg { width: 1.1rem; height: 1.1rem; }
.nota-fecha-in { flex: 1 1 auto; height: 2rem; }
/* Checklists */
.nota-items { display: flex; flex-direction: column; gap: 0.1rem; min-height: 26vh; }
.nota-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.15rem 0; }
.nota-item input[type=checkbox] { flex: 0 0 auto; width: 1.05rem; height: 1.05rem; accent-color: var(--nota-fg); }
.nota-item-txt { flex: 1 1 auto; min-width: 0; background: transparent; border: 0; border-bottom: 1px solid transparent; color: inherit; font-family: inherit; font-size: 0.95rem; padding: 0.15rem 0; outline: none; }
.nota-item-txt:focus { border-bottom-color: var(--nota-bd); }
.nota-item.hecho .nota-item-txt { text-decoration: line-through; opacity: 0.55; }
.nota-item-mas { display: inline-flex; opacity: 0.6; }
.nota-item-mas svg { width: 1.05rem; height: 1.05rem; }
.nota-items-card { display: flex; flex-direction: column; gap: 0.15rem; margin-top: 0.4rem; }
.nota-item-card { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; }
.nota-item-card .nota-check { display: inline-flex; flex: 0 0 auto; opacity: 0.75; }
.nota-item-card .nota-check svg { width: 0.95rem; height: 0.95rem; }
.nota-item-card.hecho { text-decoration: line-through; opacity: 0.5; }
.nota-mas-items { font-size: 0.78rem; opacity: 0.65; margin-top: 0.15rem; }
/* Imágenes adjuntas */
.nota-imgs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0; }
.nota-img { position: relative; width: 6.5rem; height: 6.5rem; border-radius: 0.5rem; overflow: hidden; border: 1px solid var(--nota-bd); }
.nota-img img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.nota-img-x { position: absolute; top: 2px; right: 2px; display: inline-flex; align-items: center; justify-content: center; width: 1.4rem; height: 1.4rem; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.55); color: #fff; cursor: pointer; }
.nota-img-x svg { width: 0.9rem; height: 0.9rem; }
.nota-imgs-card { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; margin-top: 0.4rem; }
.nota-img-card { width: 3.25rem; height: 3.25rem; object-fit: cover; border-radius: 0.4rem; border: 1px solid var(--nota-bd); }
/* Audios (grabaciones) */
.nota-audios { display: flex; flex-direction: column; gap: 0.35rem; margin: 0.4rem 0; }
.nota-audio { display: flex; align-items: center; gap: 0.4rem; }
.nota-audio audio { flex: 1; min-width: 0; height: 2.2rem; }
.nota-audio-dur { font-size: 0.8rem; opacity: 0.7; flex: none; }
.nota-chip-audio { display: inline-flex; align-items: center; gap: 0.3rem; margin-top: 0.4rem; font-size: 0.8rem; opacity: 0.75; }
.nota-chip-audio svg { width: 0.95rem; height: 0.95rem; }
/* Botón de grabación + cronómetro */
.nota-acc.grabando { color: #e0392b; opacity: 1; background: rgba(224, 57, 43, 0.12); }
.nota-acc.grabando svg { width: 1.3rem; height: 1.3rem; }
.nota-grab-timer { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; font-variant-numeric: tabular-nums; color: #e0392b; }
.nota-grab-dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: #e0392b; animation: nota-grab-pulso 1s ease-in-out infinite; }
@keyframes nota-grab-pulso { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }
/* Visor a pantalla completa */
.nota-img-visor { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.9); padding: 1rem; }
.nota-img-visor img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 0.4rem; cursor: zoom-out; }
.nota-img-visor-x { position: absolute; top: max(0.75rem, env(safe-area-inset-top)); right: 0.75rem; display: inline-flex; align-items: center; justify-content: center; width: 2.5rem; height: 2.5rem; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.15); color: #fff; cursor: pointer; }
.nota-img-visor-x svg { width: 1.4rem; height: 1.4rem; }
/* Arrastrar para reordenar */
.nota-grip { position: absolute; top: 1px; left: 50%; transform: translateX(-50%); display: inline-flex; opacity: 0; cursor: grab; touch-action: none; color: inherit; }
.nota-card:hover .nota-grip { opacity: 0.4; }
.nota-grip:active { cursor: grabbing; }
.nota-grip svg { width: 1.15rem; height: 1.15rem; }
.nota-grip-item { position: static; transform: none; opacity: 0.4; flex: 0 0 auto; }
.nota-grip-item svg { width: 1rem; height: 1rem; }
@media (hover: none) { .nota-grip { opacity: 0.35; } }
body.arrastrando-notas, body.arrastrando-notas * { cursor: grabbing !important; user-select: none !important; }

@media (hover: none) { .nota-acciones { opacity: 1; } }
@media (max-width: 720px) {
    .notas-cuerpo { grid-template-columns: 1fr; }
    .notas-filtros { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--color-border); padding: 0.5rem; gap: 0.3rem; }
    .notas-filtros .notas-filtro { flex: 0 0 auto; }
    .notas-filtros .drawer-sep { flex-basis: 100%; height: 0; margin: 0.15rem 0; border-top: 1px solid var(--color-border); background: none; }
    .notas-filtro { width: auto; white-space: nowrap; }
    .notas-grid { columns: 160px; }
}
.editor-area {
    width: 100%; min-height: 58vh; resize: vertical; box-sizing: border-box;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9rem; line-height: 1.5; tab-size: 4;
    /* Ajuste de línea: las líneas largas se envuelven en vez de exigir scroll
       horizontal (se preservan saltos y espacios; se parten tokens muy largos). */
    white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
    padding: 0.75rem; border: 1px solid var(--color-border); border-radius: var(--radius-md);
    background: var(--color-bg); color: var(--color-text);
}

/* ---- Toasts ---- */
.toast-cont { position: fixed; top: 1rem; right: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 100; max-width: min(90vw, 24rem); }
.toast {
    display: flex; align-items: flex-start; gap: 0.5rem;
    padding: 0.75rem 1rem; border-radius: var(--radius-md);
    background: var(--color-surface); color: var(--color-text);
    border: 1px solid var(--color-border); border-left: 4px solid var(--color-info);
    box-shadow: var(--shadow-md); animation: toast-in var(--transition);
}
.toast > span { flex: 1; }
.toast-accion {
    flex: none; background: none; border: 0; padding: 0; cursor: pointer;
    color: var(--color-primary); font: inherit; font-weight: 600; white-space: nowrap;
}
.toast-accion:hover { text-decoration: underline; }
.toast-exito { border-left-color: var(--color-success); }
.toast-alerta { border-left-color: var(--color-warning); }
.toast-peligro { border-left-color: var(--color-danger); }
@keyframes toast-in { from { opacity: 0; transform: translateX(1rem); } to { opacity: 1; transform: none; } }

/* ---- Utilidades ---- */
.pila { display: flex; flex-direction: column; gap: 1rem; }
.fila { display: flex; align-items: center; gap: 0.75rem; }
.fila-fin { justify-content: flex-end; }
.oculto { display: none !important; }
.centrado { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.panel-login { width: 100%; max-width: 22rem; }

/* ---- Responsive: en móvil, el árbol se oculta y se navega por breadcrumb ---- */
@media (max-width: 768px) {
    /* Barras de botones (nav, herramientas, subtabs) envuelven en vez de
       desbordar la pantalla en celulares. */
    .fila { flex-wrap: wrap; }
    /* Botones de acción de las tablas: solo icono en móvil (la tabla queda
       mucho más angosta y casi no hay que deslizar). */
    .col-acc .btn-con-icono > span:last-child { display: none; }
    .col-acc .btn-con-icono { padding: 0.35rem 0.45rem; }
    .app-cuerpo { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .files-layout { grid-template-columns: 1fr; }
    .file-tree { display: none; }
    .navbar { gap: 0.35rem; padding: 0.4rem 0.55rem; }
    /* Wordmark un pelín menor en móvil para que quepan logo + «Mis archivos»
       (con texto en el dashboard) + salir en un solo renglón hasta ~360px. */
    .navbar .marca .wordmark { font-size: 1rem; }
    /* En móvil las pestañas quedan solo con Mis archivos (dashboard) o vacías;
       el resto vive en la hamburguesa. Va INLINE junto a la marca (no en un
       renglón propio); el usuario se empuja a la derecha. Si no cabe, el
       flex-wrap del navbar lo baja solo. */
    .navbar .nav-tabs { order: 1; flex-basis: auto; margin-left: 0; }
    .navbar .nav-usuario { order: 2; margin-left: auto; }
    .navbar .usuario-nombre { max-width: 6rem; }
    .solo-movil { display: inline-flex !important; }
    .tema-selector .texto-muted { display: none; }
    .salir-texto { display: none; }
    .salir-icono { display: inline-flex; }
    .contenido { padding: 1rem 0.85rem; }
    .cabecera-gestor { top: -1rem; margin: -1rem -0.85rem 0.85rem; padding: 0.55rem 0.85rem; }

    /* Solo en el GESTOR se ocultan las acciones por fila en móvil (pasan a la
       barra inferior de selección). En Papelera/Enlaces/Admin se mantienen. */
    .tabla-gestor .col-acc { display: none; }
    .con-barra { padding-bottom: 5.5rem; }

    /* En móvil no hay arrastrar-y-soltar: se sube con el botón «Subir» o por
       «Compartir con». Se oculta la zona de soltar y «Subir carpeta»
       (webkitdirectory apenas funciona en móvil). */
    .drop-zone { display: none; }
    .solo-escritorio { display: none !important; }

    .barra-seleccion {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
        margin: 0; border-radius: 0; border-top: 1px solid var(--color-border);
        background: var(--color-surface); flex-direction: column; align-items: stretch;
        gap: 0.15rem; padding: 0.3rem 0.4rem;
        padding-bottom: calc(0.3rem + env(safe-area-inset-bottom));
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.18);
    }
    .barra-conteo { text-align: center; font-size: 0.78rem; color: var(--color-text-muted); font-weight: 600; }
    /* Con varias acciones (incl. IA) no caben en una fila: se acomodan en
       varias (wrap) a 4 por fila, para que TODAS se vean sin desplazar. */
    .barra-acciones {
        margin-left: 0; gap: 0.1rem 0; justify-content: center; flex-wrap: wrap;
        min-width: 0; max-width: 100%;
    }
    .accion-sel {
        flex: 0 0 25%; flex-direction: column; gap: 0.15rem;
        border: none; background: transparent; padding: 0.35rem 0.2rem;
        font-size: 0.68rem; color: var(--color-text-2); min-width: 0;
    }
    .accion-sel:hover { background: transparent; }
    .accion-sel:active { background: var(--color-surface-2); }
    .accion-sel svg { width: 1.5rem; height: 1.5rem; }
    .accion-sel .accion-etq { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
    /* «Compartir» como una celda más de la rejilla (4 por fila); su disparador
       llena la celda. `position:static` hace que el desplegable se posicione
       respecto de la barra fija (no del wrap), para abrir ARRIBA y a lo ancho. */
    .barra-acciones .menu-wrap.accion-compartir { position: static; flex: 0 0 25%; display: flex; }
    /* El disparador llena la celda (si no, hereda `flex:0 0 25%` de .accion-sel y
       queda al 25% del wrap → la etiqueta «Compartir» se trunca a «C…»). */
    .barra-acciones .menu-wrap.accion-compartir .accion-sel { flex: 1 1 auto; width: 100%; }
    .barra-seleccion .accion-compartir .menu-pop {
        top: auto; bottom: calc(100% + 0.4rem); left: 0.5rem; right: 0.5rem;
        min-width: 0; max-width: none;
    }
    .barra-seleccion .accion-compartir .menu-pop .menu-pop-item { font-size: 0.95rem; }
    .barra-seleccion .menu-pop .solo-movil { display: flex !important; }
}

/* En pantallas estrechas se ocultan «Tamaño» y «Modificado»: el tamaño pasa a
   subtítulo bajo el nombre (estilo Cx File Explorer). */
@media (max-width: 620px) {
    .file-list-table .col-mod, .file-list-table .col-tam { display: none; }
    .file-list-table th, .file-list-table td { padding: 0.6rem 0.4rem; }
    .subtitulo { display: block; }
    .tipo-icono svg { width: 2rem; height: 2rem; }
    .tipo-icono .miniatura { width: 2.5rem; height: 2.5rem; }
    .enlace-nombre { gap: 0.7rem; }
}

/* Comparativo de tarifas: resalta la columna del modo vigente. */
.col-vigente { background: color-mix(in srgb, var(--color-primary) 12%, transparent); }
.file-list-table th.col-vigente { color: var(--color-primary); }
.tabla-scroll { overflow-x: auto; }


/* ---- Panel de inicio (dashboard personal) ---- */
.panel-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 1rem; }
/* En móvil, cada recuadro de espacio a lo ancho (va DESPUÉS de la base para ganar). */
@media (max-width: 620px) { .panel-stats { grid-template-columns: 1fr; } }
.stat-card { padding: 1.1rem 1.25rem; }
.stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); font-weight: 600; }
.stat-valor { font-size: 1.9rem; font-weight: 700; line-height: 1.1; margin: 0.3rem 0 0.15rem; }
.stat-sub { font-size: 0.82rem; color: var(--color-text-muted); }
.donut-wrap { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.donut { width: 11rem; height: 11rem; flex: none; max-width: 100%; }
.donut svg { width: 100%; height: 100%; display: block; }
.leyenda { display: flex; flex-direction: column; gap: 0.45rem; min-width: 0; }
.leyenda-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
.leyenda-punto { width: 0.8rem; height: 0.8rem; border-radius: 50%; flex: none; }
.barras { display: flex; align-items: flex-end; gap: 0.4rem; height: 10rem; padding-top: 0.5rem; }
.barra-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.barra-valor { font-size: 0.75rem; color: var(--color-text-muted); margin-bottom: 0.2rem; height: 1rem; line-height: 1; }
.barra { width: 62%; max-width: 2.5rem; background: var(--color-primary); border-radius: var(--radius-sm) var(--radius-sm) 0 0; transition: height var(--transition); }
.barra-cero { background: var(--color-surface-2); }
.barra-dia { font-size: 0.68rem; color: var(--color-text-muted); margin-top: 0.35rem; white-space: nowrap; }
@keyframes girar { to { transform: rotate(360deg); } }
.girando svg { animation: girar 0.8s linear infinite; }


/* ---- Vista de galería ---- */
.vista-toggle { display: inline-flex; gap: 0.25rem; }
.vista-toggle svg { width: 1.15rem; height: 1.15rem; display: block; }
.galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.75rem; }
.galeria-item { position: relative; border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; background: var(--color-surface); }
.galeria-item.sel { border-color: var(--color-primary); box-shadow: 0 0 0 1px var(--color-primary); }
.galeria-thumb { aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; background: var(--color-surface-2); cursor: pointer; overflow: hidden; }
.galeria-img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform var(--transition); }
.galeria-thumb:hover .galeria-img { transform: scale(1.04); }
.galeria-icono svg { width: 3rem; height: 3rem; }
/* Preview apilado de carpeta con fotos (vista galería): pila inclinada estilo polaroid */
.galeria-pila { position: relative; width: 100%; aspect-ratio: 1 / 1; }
.galeria-pila-foto {
    position: absolute; width: 50%; height: 50%; object-fit: cover;
    border: 3px solid #fff; border-radius: 2px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
    background: var(--color-surface);
}
.galeria-pila-foto:nth-child(1) { top: 6%;  left: 7%;  transform: rotate(-7deg); z-index: 1; }
.galeria-pila-foto:nth-child(2) { top: 4%;  left: 43%; transform: rotate(6deg);  z-index: 2; }
.galeria-pila-foto:nth-child(3) { top: 45%; left: 5%;  transform: rotate(5deg);  z-index: 3; }
.galeria-pila-foto:nth-child(4) { top: 43%; left: 45%; transform: rotate(-6deg); z-index: 4; }
.galeria-thumb:hover .galeria-pila-foto { box-shadow: 0 2px 9px rgba(0, 0, 0, 0.45); }
.galeria-nombre { font-size: 0.8rem; padding: 0.4rem 0.5rem 0.15rem; display: flex; align-items: center; gap: 0.3rem; color: var(--color-text-2); }
.galeria-sub { font-size: 0.72rem; padding: 0 0.5rem 0.4rem; color: var(--color-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.galeria-check {
    position: absolute; top: 0.35rem; left: 0.35rem; z-index: 6;
    display: flex; align-items: center; justify-content: center;
    width: 2.1rem; height: 2.1rem; border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--color-surface) 72%, transparent); cursor: pointer;
}
.galeria-check input[type="checkbox"] { width: 1.35rem; height: 1.35rem; cursor: pointer; accent-color: var(--color-primary); }
/* Botón «No es esta persona» por foto (lente Por persona). */
.galeria-separar {
    position: absolute; top: 0.35rem; right: 0.35rem; z-index: 6;
    background: color-mix(in srgb, var(--color-surface) 82%, transparent);
}
.galeria-separar svg { width: 1.2rem; height: 1.2rem; }
/* Estrella de Favoritos (lista + galería) */
.btn-fav.activo { color: #f5b301; }
.galeria-fav { position: absolute; top: 0.35rem; right: 0.35rem; z-index: 6; width: 1.9rem; height: 1.9rem; border-radius: 50%; background: rgba(0, 0, 0, 0.4); color: #fff; }
.galeria-fav svg { width: 1.15rem; height: 1.15rem; }
.galeria-fav.activo { color: #f5b301; }
/* Distintivo de espacio (personal/compartida): icono pequeño a la izquierda del nombre */
.galeria-nombre-esp { flex: none; display: inline-flex; line-height: 0; }
.galeria-nombre-esp svg { width: 0.95rem; height: 0.95rem; }
.galeria-nombre-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.galeria-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; width: 2.75rem; height: 2.75rem; border: none; border-radius: 50%; background: rgba(0, 0, 0, 0.45); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.galeria-nav:hover { background: rgba(0, 0, 0, 0.65); }
.galeria-nav svg { width: 1.5rem; height: 1.5rem; }
.galeria-nav-prev { left: 0.75rem; }
.galeria-nav-next { right: 0.75rem; }
@media (max-width: 620px) {
    .galeria { grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: 0.5rem; }
    .galeria-nav { width: 2.25rem; height: 2.25rem; }
}

/* Modo "Por fecha": carpetas virtuales de año / mes ---------------------- */
.fecha-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.75rem; margin-top: 0.5rem; }
.fecha-card {
    display: flex; flex-direction: column; align-items: flex-start; gap: 0.3rem;
    padding: 1rem 1.1rem; border: 1px solid var(--color-border); border-radius: var(--radius-md);
    background: var(--color-surface); color: var(--color-text); cursor: pointer; text-align: left;
    transition: border-color 0.12s, background 0.12s, transform 0.12s;
}
.fecha-card:hover { border-color: var(--color-primary); background: var(--color-surface-2); transform: translateY(-1px); }
.fecha-card-icono svg { width: 1.6rem; height: 1.6rem; display: block; color: var(--color-primary); }
.fecha-card-num { font-size: 1.4rem; font-weight: 600; line-height: 1.1; }
.fecha-card-sub { font-size: 0.85rem; color: var(--color-text-muted); }
@media (max-width: 620px) {
    .fecha-cards { grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); gap: 0.5rem; }
    .fecha-card { padding: 0.8rem 0.9rem; }
    .fecha-card-num { font-size: 1.2rem; }
}

/* Lente «Por persona»: mosaicos con carita circular ---------------------- */
.persona-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: 0.9rem; margin-top: 0.5rem; }
.persona-card { position: relative; }
.persona-card-btn {
    width: 100%; display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
    padding: 0.9rem 0.6rem; border: 1px solid var(--color-border); border-radius: 0.7rem;
    background: var(--color-surface); color: var(--color-text); cursor: pointer; text-align: center;
}
.persona-card-btn:hover { border-color: var(--color-primary); background: var(--color-surface-2); transform: translateY(-1px); }
.persona-cara {
    width: 5rem; height: 5rem; border-radius: 50%; overflow: hidden; display: flex;
    align-items: center; justify-content: center; background: var(--color-surface-2); flex: 0 0 auto;
}
.persona-cara img { width: 100%; height: 100%; object-fit: cover; }
.persona-cara svg { width: 2.2rem; height: 2.2rem; color: var(--color-text-muted); }
.persona-nombre { font-size: 0.95rem; font-weight: 600; line-height: 1.15; word-break: break-word; }
.persona-nombre.sin-nombre { font-weight: 500; color: var(--color-text-muted); font-style: italic; }
.persona-sub { font-size: 0.8rem; color: var(--color-text-muted); }
.persona-editar { position: absolute; top: 0.35rem; right: 0.35rem; opacity: 0; transition: opacity 0.15s; }
.persona-fusionar { position: absolute; bottom: 0.35rem; left: 0.35rem; opacity: 0; transition: opacity 0.15s; }
.persona-eliminar { position: absolute; bottom: 0.35rem; right: 0.35rem; opacity: 0; transition: opacity 0.15s; }
.persona-card:hover .persona-editar, .persona-editar:focus,
.persona-card:hover .persona-fusionar, .persona-fusionar:focus,
.persona-card:hover .persona-eliminar, .persona-eliminar:focus { opacity: 1; }
/* Selección múltiple de personas (quitar falsos positivos en lote) */
.persona-check { position: absolute; top: 0.35rem; left: 0.35rem; z-index: 2; opacity: 0; transition: opacity 0.15s; line-height: 0; cursor: pointer; }
.persona-check input[type="checkbox"] { width: 1.15rem; height: 1.15rem; cursor: pointer; accent-color: var(--color-primary); }
.persona-card:hover .persona-check, .persona-check:focus-within, .persona-card.sel .persona-check { opacity: 1; }
.persona-card.sel .persona-card-btn { border-color: var(--color-primary); box-shadow: 0 0 0 1px var(--color-primary); }
.personas-sel-barra { display: flex; align-items: center; gap: 0.5rem; margin: 0.4rem 0 0.2rem; padding: 0.4rem 0.6rem; background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-md); font-size: 0.85rem; }
@media (max-width: 620px) {
    .persona-cards { grid-template-columns: repeat(auto-fill, minmax(6rem, 1fr)); gap: 0.6rem; }
    .persona-cara { width: 4rem; height: 4rem; }
    .persona-editar, .persona-fusionar, .persona-eliminar { opacity: 1; }
}

/* Buscador (cabecera) + resultados --------------------------------------- */
.busqueda-barra { order: 2; display: inline-flex; align-items: center; gap: 0.4rem; flex: 1 1 12rem; max-width: 24rem; min-width: 8rem; padding: 0.3rem 0.6rem; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-2); }
.busqueda-barra:focus-within { border-color: var(--color-primary); }
/* Buscador propio del picker (el navbar se oculta en modo picker). */
.picker-buscar { display: flex; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--color-border); background: var(--color-surface-2); }
.picker-buscar .busqueda-barra { flex: 1 1 auto; max-width: none; }
/* Indicador de carpeta segura (candado) junto al nombre. */
.candado-seguro { display: inline-flex; align-items: center; width: 0.85em; height: 0.85em; margin-left: 0.35rem; color: var(--color-primary); vertical-align: middle; }
.candado-seguro svg { width: 100%; height: 100%; }
.busqueda-icono svg { width: 1.05rem; height: 1.05rem; display: block; color: var(--color-text-muted); }
.busqueda-input { flex: 1; min-width: 0; border: none; background: transparent; color: var(--color-text); font-size: 0.9rem; outline: none; }
.resultados { display: flex; flex-direction: column; gap: 0.6rem; }
.resultado { padding: 0.7rem 0.9rem; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }
.resultado-acciones { display: flex; flex-wrap: wrap; gap: 0.2rem; margin-top: 0.5rem; }
.resultado-nombre { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 600; color: var(--color-text); }
.resultado-nombre:hover { color: var(--color-primary); }
.resultado-nombre .tipo-icono svg { width: 1.15rem; height: 1.15rem; }
.resultado-ruta { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.25rem; font-size: 0.82rem; }
.resultado-carpeta { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--color-text-muted); }
.resultado-carpeta svg { width: 0.9rem; height: 0.9rem; }
.resultado-carpeta:hover { color: var(--color-primary); }
.resultado-frag { margin: 0.4rem 0 0; font-size: 0.85rem; color: var(--color-text-muted); line-height: 1.4; }
@media (max-width: 620px) {
    .busqueda-barra { order: 4; flex-basis: 100%; max-width: none; }
}

/* Resumen con IA (modal) ------------------------------------------------- */
.resumen-caja { white-space: pre-wrap; word-break: break-word; max-height: 50vh; overflow-y: auto; padding: 0.9rem 1rem; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-2); font-size: 0.92rem; line-height: 1.5; margin: 0.5rem 0; }
.resumen-nota { font-size: 0.82rem; }

/* Q&A con IA (modal) ----------------------------------------------------- */
.qa-hilo { display: flex; flex-direction: column; gap: 0.75rem; max-height: 42vh; overflow-y: auto; margin: 0.5rem 0; }
.qa-turno { display: flex; flex-direction: column; gap: 0.35rem; }
.qa-pregunta { display: flex; align-items: flex-start; gap: 0.4rem; font-weight: 600; }
.qa-pregunta svg { width: 1rem; height: 1rem; flex: none; margin-top: 0.2rem; color: var(--color-primary); }
.qa-respuesta { white-space: pre-wrap; word-break: break-word; padding: 0.6rem 0.8rem; border-radius: var(--radius-md); background: var(--color-surface-2); border: 1px solid var(--color-border); font-size: 0.92rem; line-height: 1.5; }
.qa-error { color: var(--color-peligro, #e5484d); }
.qa-form { display: flex; gap: 0.5rem; margin: 0.5rem 0; }
.qa-form .input { flex: 1; }

/* Fichita de datos clave (IA) -------------------------------------------- */
.ficha-tipo { margin: 0.3rem 0 0.6rem; }
.ficha { display: flex; flex-direction: column; gap: 0.4rem; max-height: 46vh; overflow-y: auto; margin: 0.5rem 0; }
.ficha-fila { display: grid; grid-template-columns: minmax(7rem, 34%) 1fr; gap: 0.75rem; padding: 0.45rem 0.7rem; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-2); }
.ficha-campo { font-weight: 600; margin: 0; }
.ficha-valor { margin: 0; word-break: break-word; }
@media (max-width: 620px) { .ficha-fila { grid-template-columns: 1fr; gap: 0.15rem; } }

/* Menú de acciones de IA (modal) ----------------------------------------- */
.ia-opciones { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.6rem 0; }
.ia-opciones button { display: flex; align-items: center; gap: 0.6rem; width: 100%; text-align: left; padding: 0.7rem 0.9rem; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-2); color: var(--color-text); cursor: pointer; font-size: 0.95rem; font-weight: 600; transition: border-color 0.12s, background 0.12s; }
.ia-opciones button:hover { border-color: var(--color-primary); background: var(--color-surface); }
.ia-opciones button svg { width: 1.2rem; height: 1.2rem; flex: none; color: var(--color-primary); }

/* Contraseñas de aplicación (WebDAV) — perfil */
.app-token-box { background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 0.6rem 0.7rem; margin-bottom: 0.6rem; }
.app-token-fila { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.app-token { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.95rem; letter-spacing: 0.03em; word-break: break-all; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 0.4rem; padding: 0.35rem 0.5rem; }
.app-pwd-lista { display: flex; flex-direction: column; gap: 0.35rem; margin: 0.2rem 0 0.2rem; }
.app-pwd-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.55rem; border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.app-pwd-etq { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
