/* =============================================
   Captcha
   ============================================= */
.captcha-chars {
    background: linear-gradient(135deg, #eef2ff, #f0f4ff);
    border: 2px solid #c5d0e6;
    border-radius: 8px;
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    user-select: none;
    cursor: default;
}
.captcha-chars span {
    display: inline-block;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    line-height: 1.3;
}

/* =============================================
   Base
   ============================================= */
:root {
    --ip-blue: #00a0e3;
    --ip-blue-dark: #0082bb;
    --ip-blue-light: #d9f1fb;
    --ip-bg: #f5f8fa;
    --ip-surface: #ffffff;
    --ip-border: #e1e8ed;
    --ip-hover: #edf5fb;
    --ip-text: #1a2332;
    --ip-text-muted: #5a6a7a;
    --ip-folder: #f59e0b;
    --ip-folder-hover: #d97706;
    --ip-navbar-h: 48px;
}

html { font-size: 14px; }
@media (min-width: 768px) { html { font-size: 16px; } }

body {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--ip-text);
    background: var(--ip-bg);
    margin: 0;
}

/* =============================================
   Landing page
   ============================================= */
.landing-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #00304a 0%, #005580 35%, #0082bb 70%, #00a0e3 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.landing-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: rgba(0, 160, 227, 0.15);
    top: -150px;
    right: -150px;
    pointer-events: none;
}

.landing-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: rgba(0, 160, 227, 0.1);
    bottom: -100px;
    left: -100px;
    pointer-events: none;
}

.landing-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 2rem;
}

.landing-footer-logo {
    height: 18px;
    width: auto;
    opacity: 0.55;
    mix-blend-mode: screen;
    vertical-align: middle;
    margin-right: 0.4rem;
}

.landing-title {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.5px;
    margin-bottom: 1rem;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
}

.landing-title-version {
    font-size: 0.45em;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.65);
    vertical-align: super;
    letter-spacing: 0;
}

.landing-subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: 2.5rem;
    font-weight: 400;
}

.landing-btn {
    display: inline-flex;
    align-items: center;
    background: var(--ip-blue);
    color: #fff;
    text-decoration: none;
    padding: 0.8rem 2.5rem;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 4px 20px rgba(0, 160, 227, 0.45);
}

.landing-btn:hover {
    background: var(--ip-blue-dark);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 160, 227, 0.55);
}

.landing-footer {
    position: absolute;
    bottom: 1.5rem;
    z-index: 1;
}

.landing-footer-link {
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.8rem;
    text-decoration: none;
    transition: opacity 0.2s;
}
.landing-footer-link:hover {
    color: rgba(255, 255, 255, 0.7);
    opacity: 0.85;
}

.landing-login-card {
    background: var(--ip-surface);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 2rem 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
    margin: 0 auto;
}

/* =============================================
   Login page
   ============================================= */
.login-page {
    min-height: 100vh;
    background: var(--ip-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    background: var(--ip-surface);
    border: 1px solid var(--ip-border);
    border-radius: 8px;
    padding: 2.5rem 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.07);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo-img {
    height: 40px;
    width: auto;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ip-text);
    margin-bottom: 0.25rem;
}

.login-subtitle {
    font-size: 0.875rem;
    color: var(--ip-text-muted);
    margin: 0;
}

.login-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--ip-text);
}

.login-input-icon {
    background: var(--ip-hover);
    border-color: var(--ip-border);
    color: var(--ip-text-muted);
}

.login-input {
    border-color: var(--ip-border);
}

.login-input:focus {
    border-color: var(--ip-blue);
    box-shadow: 0 0 0 3px var(--ip-blue-light);
}

.login-submit-btn {
    background: var(--ip-blue);
    color: #fff;
    border: none;
    font-weight: 600;
    padding: 0.65rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.login-submit-btn:hover {
    background: var(--ip-blue-dark);
    color: #fff;
}

/* =============================================
   Browse navbar
   ============================================= */
.browse-body {
    background: #e8edf1;
    margin: 0;
    overflow-x: hidden;
}

.browse-navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--ip-surface);
    border-bottom: 1px solid var(--ip-border);
    height: var(--ip-navbar-h);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.browse-navbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.25rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.browse-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--ip-text);
}

.browse-logo-img {
    height: 26px;
    width: auto;
}

.browse-logo-sep {
    width: 1px;
    height: 18px;
    background: var(--ip-border);
    flex-shrink: 0;
}

.browse-logo-text {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--ip-text-muted);
    letter-spacing: -0.2px;
}

.browse-logo-version {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--ip-blue);
    vertical-align: super;
    letter-spacing: 0;
}

.browse-navbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.browse-user-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    color: var(--ip-text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.browse-user-btn:hover { background: var(--ip-hover); }

.browse-user-avatar {
    width: 28px;
    height: 28px;
    background: var(--ip-blue);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.browse-username { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.browse-dropdown { border: 1px solid var(--ip-border); box-shadow: 0 4px 16px rgba(0,0,0,0.1); border-radius: 6px; min-width: 200px; }
.browse-dropdown .dropdown-item { font-size: 0.875rem; padding: 0.5rem 1rem; }
.browse-dropdown .dropdown-item:hover { background: var(--ip-hover); }

/* =============================================
   Browse main & shell
   ============================================= */
.browse-main {
    display: flex;
    flex-direction: column;
}

/* Páginas normales (search, change-pwd, historial) usan browse-container */
.browse-container {
    padding: 1.5rem 1.5rem 3rem;
    width: 100%;
    height: 100%;
    overflow-y: auto;
}

/* =============================================
   Split layout: árbol + contenido
   ============================================= */
.browse-shell {
    display: flex;
    min-height: calc(100vh - var(--ip-navbar-h));
    background: #e8edf1;
}

/* ---- Panel árbol (izquierda) ---- */
.tree-panel {
    position: sticky;
    top: var(--ip-navbar-h);
    align-self: flex-start;
    height: calc(100vh - var(--ip-navbar-h));
    width: 260px;
    min-width: 260px;
    border-right: 1px solid var(--ip-border);
    background: var(--ip-surface);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.2s, min-width 0.2s;
}

.browse-shell.tree-collapsed .tree-panel {
    width: 0;
    min-width: 0;
    border-right: none;
}

.tree-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 0.85rem 0.5rem;
    border-bottom: 1px solid var(--ip-border);
    flex-shrink: 0;
}

.tree-header-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--ip-text-muted);
}

.tree-collapse-btn {
    background: none;
    border: none;
    color: var(--ip-text-muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}
.tree-collapse-btn:hover { background: var(--ip-hover); color: var(--ip-blue); }

.tree-search-wrap {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--ip-border);
    flex-shrink: 0;
}
.tree-search-icon { color: var(--ip-text-muted); font-size: 0.8rem; margin-right: 0.4rem; }
.tree-search-input {
    border: none;
    outline: none;
    font-size: 0.8rem;
    color: var(--ip-text);
    width: 100%;
    background: transparent;
}
.tree-search-input::placeholder { color: var(--ip-text-muted); }

.tree-root {
    overflow-y: auto;
    flex: 1;
    padding: 0.4rem 0;
}

.tree-loading, .tree-empty {
    font-size: 0.8rem;
    color: var(--ip-text-muted);
    padding: 0.75rem 1rem;
}

/* ---- Nodos del árbol ---- */
.tn { }

.tn-row {
    display: flex;
    align-items: center;
    padding: 0.22rem 0.6rem 0.22rem 0;
    border-radius: 4px;
    margin: 1px 4px;
    transition: background 0.1s;
    text-decoration: none;
    color: var(--ip-text);
    font-size: 0.82rem;
    gap: 0.35rem;
    overflow: hidden;
    cursor: pointer;
}
.tn-row:hover { background: var(--ip-hover); color: var(--ip-blue); }
.tn-row.tn-active { background: var(--ip-blue-light); }
.tn-row.tn-active .tn-folder-icon { color: var(--ip-blue); }
.tn-row.tn-active .tn-label { color: var(--ip-blue); font-weight: 600; }

.tn-toggle {
    width: 20px;
    min-width: 20px;
    text-align: center;
    cursor: pointer;
    color: var(--ip-text-muted);
    font-size: 0.65rem;
    padding: 4px 2px;
}
.tn-toggle i { transition: transform 0.15s; display: inline-block; }
.tn-toggle i.tn-rotated { transform: rotate(90deg); }
.tn-toggle-leaf { visibility: hidden; pointer-events: none; }

.tn-folder-icon { color: var(--ip-folder); font-size: 0.9rem; flex-shrink: 0; }
.tn-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }

.tn-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    flex-shrink: 0;
    line-height: 1;
}
.tn-badge-nov  { background: #dc3545; color: #fff; }
.tn-badge-pend { background: #6c757d; color: #fff; }

.tn-children { padding-left: 16px; }

/* ---- Panel de contenido (derecha) ---- */
.content-panel {
    flex: 1;
    min-width: 0;
    padding: 1.25rem 1.5rem 3rem;
    background: #e8edf1;
}

/* =============================================
   Cabecera de contenido y toolbar
   ============================================= */
.content-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.content-title-wrap { flex: 1; min-width: 0; }

.content-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-left: auto;
    flex-shrink: 0;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.35rem 0.7rem;
    border-radius: 4px;
    border: 1px solid var(--ip-border);
    background: var(--ip-surface);
    color: var(--ip-text);
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}
.toolbar-btn:hover { background: var(--ip-hover); color: var(--ip-blue); border-color: var(--ip-blue); }
.toolbar-btn-active {
    background: var(--ip-blue-light);
    border-color: var(--ip-blue);
    color: var(--ip-blue);
    font-weight: 600;
}

.toolbar-filter-form { display: flex; }
.toolbar-filter-wrap {
    display: flex;
    align-items: center;
    background: var(--ip-surface);
    border: 1px solid var(--ip-border);
    border-radius: 4px;
    overflow: hidden;
    transition: border-color 0.2s;
}
.toolbar-filter-wrap:focus-within { border-color: var(--ip-blue); }
.toolbar-filter-icon { padding: 0 0.4rem 0 0.65rem; color: var(--ip-text-muted); font-size: 0.8rem; }
.toolbar-filter-input {
    border: none; outline: none; font-size: 0.82rem;
    padding: 0.35rem 0.4rem; color: var(--ip-text); width: 180px; background: transparent;
}
.toolbar-filter-input::placeholder { color: var(--ip-text-muted); }
.toolbar-filter-clear {
    padding: 0.35rem 0.5rem; color: var(--ip-text-muted);
    text-decoration: none; font-size: 0.9rem;
    transition: color 0.15s;
}
.toolbar-filter-clear:hover { color: var(--ip-text); }

/* =============================================
   Cabecera lista documentos + ZIP
   ============================================= */
.docs-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.zip-btn {
    display: inline-flex;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.3rem 0.75rem;
    border-radius: 4px;
    border: 1px solid var(--ip-blue);
    background: var(--ip-surface);
    color: var(--ip-blue);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.zip-btn:not(:disabled):hover { background: var(--ip-blue); color: #fff; }
.zip-btn:disabled { opacity: 0.45; cursor: not-allowed; border-color: var(--ip-border); color: var(--ip-text-muted); }
.zip-btn-folder { border-color: var(--ip-folder); color: #7d5a00; background: #fffbf0; }
.zip-btn-folder:hover { background: var(--ip-folder); color: #fff; }

/* =============================================
   Cabecera y columnas de tabla de documentos
   ============================================= */
/* ── Tabla de documentos ── */
.doc-table {
    display: table;
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    border: 1px solid var(--ip-border);
    border-radius: 6px;
    overflow: hidden;
}

.doc-list-thead,
.browse-item-doc {
    display: table-row;
}

.doc-list-thead { background: var(--ip-hover); }
.browse-item-doc { background: var(--ip-surface); transition: background 0.1s; }
.browse-item-doc:hover { background: var(--ip-hover); }

.doc-list-thead > div,
.browse-item-doc > div {
    display: table-cell;
    vertical-align: middle;
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid var(--ip-border);
    white-space: nowrap;
}
.browse-item-doc:last-child > div { border-bottom: none; }

.doc-list-thead > div {
    font-size: 0.73rem;
    font-weight: 700;
    color: var(--ip-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

/* Columnas */
.doc-col-check  { width: 36px;  text-align: center; }
.doc-col-icon   { width: 38px;  text-align: center; }
.doc-col-name   { width: auto;  overflow: hidden; text-overflow: ellipsis; }
.doc-col-folder { width: 220px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-col-ext    { width: 54px;  text-align: center; }
.doc-col-fecha  { width: 135px; min-width: 135px; text-align: center; font-size: 0.78rem; white-space: nowrap; }
.doc-col-action { width: 190px; text-align: right; }

.fecha-pendiente      { color: #dc3545; font-weight: 600; }
.fecha-no-descargado  { color: #999; font-style: italic; }
.fecha-descargado     { color: var(--ip-text-muted); }

.sort-link {
    color: var(--ip-text-muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}
.sort-link:hover { color: var(--ip-blue); }
.sort-active { color: var(--ip-text); }


.doc-folder-link {
    color: var(--ip-text-muted);
    font-size: 0.78rem;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}
.doc-folder-link:hover { color: var(--ip-blue); }

/* Spin animation for loading */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin 1s linear infinite; }

.browse-breadcrumb-nav {
    margin-bottom: 1.5rem;
    background: rgba(0, 160, 227, 0.06);
    border: 1px solid var(--ip-border);
    border-radius: 6px;
    padding: 0.55rem 0.9rem;
}

.browse-breadcrumb {
    background: none;
    padding: 0;
    font-size: 0.9rem;
    font-weight: 500;
    margin: 0;
}

.browse-breadcrumb .breadcrumb-item a {
    color: var(--ip-blue);
    text-decoration: none;
    font-weight: 600;
}

.browse-breadcrumb .breadcrumb-item a:hover { text-decoration: underline; }
.browse-breadcrumb .breadcrumb-item.active { color: var(--ip-text); font-weight: 500; }

.browse-section-header { margin-bottom: 1.5rem; }

.browse-section-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--ip-text);
    margin: 0;
    display: flex;
    align-items: center;
}

.browse-section-desc {
    color: var(--ip-text-muted);
    font-size: 0.875rem;
    margin: 0.3rem 0 0 0;
}

.browse-folder-icon-lg { color: var(--ip-folder); font-size: 1.2rem; }

/* =============================================
   Browse group
   ============================================= */
.browse-group { }

.browse-group-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--ip-text-muted);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.browse-count-badge {
    background: var(--ip-hover);
    color: var(--ip-text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    text-transform: none;
    letter-spacing: 0;
}

/* =============================================
   Folder grid – estilo Explorador de Windows
   ============================================= */
.browse-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 130px));
    gap: 0.35rem;
}

.browse-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.35rem;
    padding: 0.75rem 0.5rem 0.6rem;
    border-radius: 6px;
    text-decoration: none;
    color: var(--ip-text);
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s;
    cursor: pointer;
}

.browse-item:hover {
    background: var(--ip-hover);
    border-color: var(--ip-border);
    color: var(--ip-text);
    text-decoration: none;
}

.browse-item-folder .browse-item-icon { flex-shrink: 0; }
.browse-folder-icon { font-size: 2.4rem; color: var(--ip-folder); }
.browse-item-folder:hover .browse-folder-icon { color: var(--ip-folder-hover); }

.browse-item-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.browse-item-name {
    font-size: 0.78rem;
    font-weight: 500;
    word-break: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
}

.browse-item-desc {
    font-size: 0.75rem;
    color: var(--ip-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.browse-item-arrow { display: none; }

/* =============================================
   Document list
   ============================================= */
.browse-list { display: flex; flex-direction: column; }

.browse-doc-icon { font-size: 1.5rem; flex-shrink: 0; }

.browse-item-ext {
    font-size: 0.7rem;
    color: var(--ip-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.doc-action-wrap {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
}

.browse-preview-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--ip-border);
    color: var(--ip-text-muted);
    width: 28px;
    height: 28px;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
    padding: 0;
}
.browse-preview-btn:hover {
    background: var(--ip-hover);
    color: var(--ip-blue);
    border-color: var(--ip-blue);
}

.browse-download-btn {
    display: inline-flex;
    align-items: center;
    background: var(--ip-blue);
    color: #fff;
    text-decoration: none;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s;
}

.browse-download-btn:hover {
    background: var(--ip-blue-dark);
    color: #fff;
}

.browse-sign-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--ip-border);
    color: var(--ip-text-muted);
    width: 28px;
    height: 28px;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
    padding: 0;
}
.browse-sign-btn:hover {
    background: #fff3cd;
    color: #856404;
    border-color: #ffc107;
}

/* ── Modal firma: canvas ──────────────────────────── */
.sign-canvas-wrap {
    position: relative;
    width: 100%;
    height: 140px;
    border: 2px dashed var(--ip-border);
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
    cursor: crosshair;
}
[data-theme="dark"] .sign-canvas-wrap { background: #1e1e2e; }

#signatureCanvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

.sign-canvas-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #aaa;
    font-size: 0.85rem;
    pointer-events: none;
    user-select: none;
}

/* ── Modal firma: grid de posición ───────────────── */
.sign-pos-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 4px;
    width: 100%;
    max-width: 180px;
}

.sign-pos-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid var(--ip-border);
    border-radius: 4px;
    background: var(--ip-surface);
    color: var(--ip-text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    padding: 0;
}
.sign-pos-btn:hover {
    background: var(--ip-hover);
    color: var(--ip-blue);
    border-color: var(--ip-blue);
}
.sign-pos-btn.active {
    background: var(--ip-blue);
    color: #fff;
    border-color: var(--ip-blue);
}
.sign-pos-custom-btn { font-size: 0.85rem; }

/* ── Modal firma: layout dos columnas ────────── */
.sign-modal-dialog {
    max-width: min(92vw, 1300px);
}

.sign-modal-body {
    height: 75vh;
    overflow: hidden;
}

.sign-pdf-panel {
    flex: 1 1 0;
    min-width: 0;
    background: #525659;
    border-right: 1px solid var(--ip-border);
    overflow: auto;
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 16px;
}

#signPdfWrap {
    position: relative;
    display: inline-block;
    line-height: 0;
    flex-shrink: 0;
}

#signPdfCanvas {
    display: block;
    box-shadow: 0 2px 16px rgba(0,0,0,.6);
}

#signOverlay {
    position: absolute;
    border: 2px dashed rgba(220,53,69,.9);
    background: rgba(220,53,69,.12);
    cursor: move;
    box-sizing: border-box;
    touch-action: none;
    user-select: none;
    min-width: 30px;
    min-height: 15px;
}

#signOverlay::before {
    content: 'Firma';
    position: absolute;
    top: 3px;
    left: 5px;
    font-size: 10px;
    font-weight: 700;
    color: rgba(180,30,30,.95);
    pointer-events: none;
    white-space: nowrap;
    line-height: 1;
}

#signOverlayResize {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    background: rgba(220,53,69,.75);
    cursor: se-resize;
    border-top-left-radius: 3px;
}

#signPdfSpinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.35);
}

.sign-controls-panel {
    flex: 0 0 400px;
    overflow-y: auto;
    padding: 1rem;
}

@media (max-width: 768px) {
    .sign-modal-body    { flex-direction: column; height: auto; }
    .sign-pdf-panel     { flex: none; height: 40vh; border-right: none; border-bottom: 1px solid var(--ip-border); }
    .sign-controls-panel { flex: none; }
}

/* =============================================
   Pagination
   ============================================= */
.browse-pagination .page-link {
    color: var(--ip-blue);
    border-color: var(--ip-border);
    font-size: 0.875rem;
}

.browse-pagination .page-item.active .page-link {
    background: var(--ip-blue);
    border-color: var(--ip-blue);
    color: #ffffff;
}

.browse-pagination .page-link:focus { box-shadow: 0 0 0 3px var(--ip-blue-light); }

/* =============================================
   Empty state
   ============================================= */
.browse-empty {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--ip-text-muted);
}

.browse-empty-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
    opacity: 0.3;
}

/* =============================================
   Change password page
   ============================================= */
.change-password-page {
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
}

.change-password-card {
    background: var(--ip-surface);
    border: 1px solid var(--ip-border);
    border-radius: 8px;
    padding: 2rem;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}

.change-password-header { margin-bottom: 1.5rem; }

.back-link {
    font-size: 0.875rem;
    color: var(--ip-blue);
    text-decoration: none;
}

.back-link:hover { text-decoration: underline; }

/* =============================================
   Search bar (navbar)
   ============================================= */
.browse-search-form {
    flex: 1;
    max-width: 480px;
    margin: 0 1.5rem;
}

.browse-search-wrap {
    display: flex;
    align-items: center;
    background: var(--ip-hover);
    border: 1px solid var(--ip-border);
    border-radius: 4px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.browse-search-wrap:focus-within {
    border-color: var(--ip-blue);
    box-shadow: 0 0 0 3px var(--ip-blue-light);
    background: #fff;
}

.browse-search-icon {
    padding: 0 0.5rem 0 0.75rem;
    color: var(--ip-text-muted);
    font-size: 0.875rem;
    pointer-events: none;
}

.browse-search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.45rem 0.5rem;
    font-size: 0.875rem;
    color: var(--ip-text);
    outline: none;
}

.browse-search-input::placeholder { color: var(--ip-text-muted); }

.browse-search-clear {
    background: none;
    border: none;
    color: var(--ip-text-muted);
    cursor: pointer;
    padding: 0 0.4rem;
    font-size: 0.78rem;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}
.browse-search-clear:hover { color: var(--ip-text); }

.browse-search-btn {
    background: var(--ip-blue);
    color: #fff;
    border: none;
    padding: 0.45rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.browse-search-btn:hover { background: var(--ip-blue-dark); }

/* =============================================
   Search results
   ============================================= */
.search-header { margin-bottom: 1.5rem; }

.search-query-text {
    color: var(--ip-blue);
    font-style: normal;
    font-weight: 600;
}

.browse-folder-link-btn {
    display: inline-flex;
    align-items: center;
    color: var(--ip-text-muted);
    padding: 0.35rem 0.6rem;
    border-radius: 4px;
    border: 1px solid var(--ip-border);
    font-size: 0.85rem;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.browse-folder-link-btn:hover {
    background: var(--ip-hover);
    color: var(--ip-blue);
}

/* =============================================
   Toggle vista lista / cuadrícula
   ============================================= */
.toolbar-view-toggle {
    display: flex;
    border: 1px solid var(--ip-border);
    border-radius: 4px;
    overflow: hidden;
}

.toolbar-view-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: var(--ip-surface);
    border: none;
    color: var(--ip-text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.toolbar-view-btn + .toolbar-view-btn {
    border-left: 1px solid var(--ip-border);
}
.toolbar-view-btn:hover { background: var(--ip-hover); color: var(--ip-blue); }
.toolbar-view-btn-active { background: var(--ip-blue-light); color: var(--ip-blue); }

/* =============================================
   Vista cuadrícula de documentos
   ============================================= */
.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.doc-card {
    background: var(--ip-surface);
    border: 1px solid var(--ip-border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    padding: 1rem 0.85rem 0.75rem;
    transition: box-shadow 0.15s, border-color 0.15s;
    position: relative;
}
.doc-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.09);
    border-color: var(--ip-blue);
}
.doc-card-nueva {
    border-left: 3px solid #dc3545;
}

.doc-card-icon {
    position: relative;
    font-size: 2.4rem;
    margin-bottom: 0.6rem;
    line-height: 1;
}

.doc-card-badge-nov {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #dc3545;
    color: #fff;
    font-size: 0.55rem;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.doc-card-badge-pend {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 8px;
    background: #6c757d;
    border-radius: 50%;
}

.doc-card-body { flex: 1; min-width: 0; overflow: hidden; }

.doc-card-name {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--ip-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.doc-card-folder {
    font-size: 0.72rem;
    color: var(--ip-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.2rem;
}

.doc-card-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.3rem;
    flex-wrap: wrap;
}

.doc-card-fecha { font-size: 0.72rem; }

.doc-card-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    margin-top: 0.6rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--ip-border);
}

/* =============================================
   Novedades toolbar button
   ============================================= */
.toolbar-btn-nov {
    background: #fff8e1;
    border-color: #f59e0b;
    color: #92400e;
}
.toolbar-btn-nov:hover {
    background: #f59e0b;
    color: #fff;
    border-color: #f59e0b;
}

/* =============================================
   Historial page
   ============================================= */
.historial-header { margin-bottom: 0.5rem; }


/* =============================================
   Simulación de usuario (solo admins)
   ============================================= */

/* Input en la navbar para introducir el email */
.sim-form { position: relative; display: flex; flex-direction: column; align-items: flex-end; }
.sim-wrap {
    display: flex;
    align-items: center;
    background: var(--ip-hover);
    border: 1px solid var(--ip-border);
    border-radius: 20px;
    padding: 0 0.4rem 0 0.75rem;
    gap: 0.3rem;
    transition: border-color 0.15s, background 0.15s;
}
.sim-wrap:focus-within {
    background: #fff;
    border-color: var(--ip-blue);
    box-shadow: 0 0 0 2px var(--ip-blue-light);
}
.sim-wrap-icon { color: var(--ip-text-muted); font-size: 0.9rem; flex-shrink: 0; }
.sim-input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--ip-text);
    font-size: 0.8rem;
    width: 160px;
    min-width: 0;
}
.sim-input::placeholder { color: var(--ip-text-muted); }
.sim-btn {
    background: transparent;
    border: none;
    color: var(--ip-text-muted);
    padding: 0.2rem 0.3rem;
    cursor: pointer;
    border-radius: 50%;
    font-size: 0.85rem;
    transition: color 0.15s, background 0.15s;
}
.sim-btn:hover { color: var(--ip-blue); background: var(--ip-blue-light); }
.sim-error {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: #dc3545;
    color: #fff;
    font-size: 0.72rem;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
}

/* Pill "simulando X" en la navbar */
.sim-pill {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: #f59e0b;
    color: #1a1a1a;
    border-radius: 20px;
    padding: 0.2rem 0.5rem 0.2rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    max-width: 220px;
}
.sim-pill-icon { font-size: 0.85rem; flex-shrink: 0; }
.sim-pill-email {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.sim-pill-stop {
    background: transparent;
    border: none;
    padding: 0.1rem 0.25rem;
    cursor: pointer;
    color: #1a1a1a;
    border-radius: 50%;
    font-size: 0.75rem;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.15s;
}
.sim-pill-stop:hover { opacity: 1; }

/* Banner de simulación activa (debajo de la navbar) */
.sim-banner {
    background: #f59e0b;
    color: #1a1a1a;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.35rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    z-index: 900;
}
.sim-banner-stop {
    background: rgba(0,0,0,0.12);
    border: 1px solid rgba(0,0,0,0.2);
    border-radius: 4px;
    padding: 0.1rem 0.6rem;
    font-size: 0.78rem;
    cursor: pointer;
    color: #1a1a1a;
    font-weight: 600;
    transition: background 0.15s;
}
.sim-banner-stop:hover { background: rgba(0,0,0,0.22); }

/* Ajuste de la posición sticky del árbol cuando hay banner de simulación */
.sim-active-body .tree-panel {
    top: calc(var(--ip-navbar-h) + 34px);
    height: calc(100vh - var(--ip-navbar-h) - 34px);
}
.sim-active-body .browse-shell {
    min-height: calc(100vh - var(--ip-navbar-h) - 34px);
}

/* =============================================
   Misc
   ============================================= */
.text-purple { color: #7719aa !important; }

/* =============================================
   Modo oscuro
   ============================================= */
html[data-theme="dark"] {
    --ip-blue:        #29b6f6;
    --ip-blue-dark:   #0288d1;
    --ip-blue-light:  #0d2a3d;
    --ip-bg:          #0f1117;
    --ip-surface:     #1a1d27;
    --ip-border:      #2c3044;
    --ip-hover:       #1e2233;
    --ip-text:        #e2e8f0;
    --ip-text-muted:  #8892a4;
    --ip-folder:      #f59e0b;
    --ip-folder-hover:#d97706;
}

html[data-theme="dark"] body {
    background: var(--ip-bg);
    color: var(--ip-text);
}

/* Panel de contenido, shell y body en dark mode (color hardcoded) */
html[data-theme="dark"] .content-panel,
html[data-theme="dark"] .browse-shell,
html[data-theme="dark"] .browse-body {
    background: #12151e;
}
html[data-theme="dark"] .doc-table-stacked .browse-item-doc {
    border-bottom-color: rgba(255,255,255,0.15) !important;
}
/* Cards Bootstrap en dark mode */
html[data-theme="dark"] .card {
    --bs-card-bg: var(--ip-surface);
    --bs-card-border-color: var(--ip-border);
    --bs-card-color: var(--ip-text);
    background-color: var(--ip-surface);
    border-color: var(--ip-border);
    color: var(--ip-text);
}
html[data-theme="dark"] .card-header {
    background-color: var(--ip-hover);
    border-color: var(--ip-border);
    color: var(--ip-text);
}
/* Labels de formularios en dark mode */
html[data-theme="dark"] .form-label,
html[data-theme="dark"] .form-text,
html[data-theme="dark"] .form-check-label {
    color: var(--ip-text);
}

/* Barra de búsqueda (fondo hardcoded al enfocar) */
html[data-theme="dark"] .browse-search-wrap:focus-within,
html[data-theme="dark"] .sim-wrap:focus-within {
    background: var(--ip-surface);
}

/* Navbar móvil en dark mode */
html[data-theme="dark"] .browse-navbar.nav-search-open .browse-search-form {
    background: var(--ip-surface);
}
html[data-theme="dark"] .browse-mobile-btn { color: var(--ip-text-muted); }
html[data-theme="dark"] .browse-mobile-btn:hover { background: var(--ip-hover); }

/* Breadcrumb */
html[data-theme="dark"] .browse-breadcrumb-nav {
    background: rgba(41, 182, 246, 0.06);
    border-color: var(--ip-border);
}
html[data-theme="dark"] .browse-breadcrumb .breadcrumb-item.active {
    color: var(--ip-text-muted);
}
html[data-theme="dark"] .breadcrumb-item + .breadcrumb-item::before {
    color: var(--ip-text-muted);
}

/* Inputs Bootstrap */
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
    background-color: #222536;
    border-color: var(--ip-border);
    color: var(--ip-text);
}
html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus {
    background-color: #222536;
    color: var(--ip-text);
    border-color: var(--ip-blue);
    box-shadow: 0 0 0 3px rgba(41, 182, 246, 0.18);
}
html[data-theme="dark"] .form-control::placeholder { color: var(--ip-text-muted); }
html[data-theme="dark"] .form-check-input {
    background-color: #222536;
    border-color: var(--ip-border);
}
html[data-theme="dark"] .form-check-input:checked {
    background-color: var(--ip-blue);
    border-color: var(--ip-blue);
}

/* Input group */
html[data-theme="dark"] .input-group-text {
    background-color: #1e2233;
    border-color: var(--ip-border);
    color: var(--ip-text-muted);
}

/* Botones Bootstrap outline/secondary */
html[data-theme="dark"] .btn-outline-secondary {
    color: var(--ip-text-muted);
    border-color: var(--ip-border);
}
html[data-theme="dark"] .btn-outline-secondary:hover {
    background-color: var(--ip-hover);
    color: var(--ip-text);
    border-color: var(--ip-border);
}

/* Modales */
html[data-theme="dark"] .modal-content {
    background-color: var(--ip-surface);
    border-color: var(--ip-border);
    color: var(--ip-text);
}
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer {
    border-color: var(--ip-border);
}
html[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1); }

/* Dropdown */
html[data-theme="dark"] .dropdown-menu {
    background-color: var(--ip-surface);
    border-color: var(--ip-border);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
html[data-theme="dark"] .dropdown-item { color: var(--ip-text); }
html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus {
    background-color: var(--ip-hover);
    color: var(--ip-blue);
}
html[data-theme="dark"] .dropdown-divider { border-color: var(--ip-border); }

/* Progress */
html[data-theme="dark"] .progress { background-color: #2a2d3a; }

/* Alerts */
html[data-theme="dark"] .alert-danger {
    background-color: #2d1515;
    border-color: #5a2020;
    color: #f08080;
}
html[data-theme="dark"] .alert-success {
    background-color: #0d2d1a;
    border-color: #1a5c38;
    color: #6fcf97;
}

/* Paginación */
html[data-theme="dark"] .page-link {
    background-color: var(--ip-surface);
    border-color: var(--ip-border);
    color: var(--ip-blue);
}
html[data-theme="dark"] .page-item.active .page-link {
    background-color: var(--ip-blue);
    border-color: var(--ip-blue);
    color: #fff;
}
html[data-theme="dark"] .page-item.disabled .page-link {
    background-color: var(--ip-surface);
    border-color: var(--ip-border);
    color: var(--ip-text-muted);
}

/* Botón ZIP carpeta (color hardcoded) */
html[data-theme="dark"] .zip-btn-folder {
    background: #1e1a0a;
    border-color: #7d5a00;
    color: #f0b429;
}
html[data-theme="dark"] .zip-btn-folder:hover {
    background: var(--ip-folder);
    color: #fff;
}

/* Toolbar novedades activo (color hardcoded) */
html[data-theme="dark"] .toolbar-btn-nov {
    background: #1f1800;
    border-color: #f59e0b;
    color: #f0b429;
}
html[data-theme="dark"] .toolbar-btn-nov:hover {
    background: #f59e0b;
    color: #fff;
}

/* Doc card nueva (borde izquierdo rojo, se mantiene igual) */
html[data-theme="dark"] .doc-card-nueva { border-left-color: #e55; }

/* Iframe de preview (ya tiene fondo oscuro, sin cambios) */

/* =============================================
   Pestaña lateral para reabrir árbol colapsado
   ============================================= */
.browse-shell { position: relative; }

.tree-tab-btn {
    position: absolute;
    left: 0;
    top: 1rem;
    width: 20px;
    height: 52px;
    background: var(--ip-blue);
    border: none;
    border-radius: 0 6px 6px 0;
    color: #fff;
    cursor: pointer;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.18);
    transition: width 0.15s, background 0.15s;
    padding: 0;
    gap: 5px;
}
.browse-shell.tree-collapsed .tree-tab-btn { display: flex; }
.tree-tab-btn:hover { width: 28px; background: var(--ip-blue-dark); }
.tree-tab-btn .tree-tab-icon { font-size: 0.8rem; }
.tree-tab-btn .tree-tab-label { display: none; }

/* Checkbox en vista cuadrícula */
.doc-card-check {
    position: static;
    align-self: flex-start;
    margin-bottom: 0.2rem;
    z-index: 2;
}

/* =============================================
   Cookie consent banner (estilo Google)
   ============================================= */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #202124;
    color: #e8eaed;
    z-index: 9999;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    box-shadow: 0 -2px 16px rgba(0,0,0,0.3);
    font-size: 0.875rem;
    line-height: 1.5;
}
.cookie-banner-text { flex: 1; min-width: 200px; }
.cookie-banner-text a { color: #8ab4f8; text-decoration: underline; }
.cookie-banner-actions { display: flex; gap: 0.75rem; flex-shrink: 0; flex-wrap: wrap; align-items: center; }
.cookie-banner-btn {
    background: #8ab4f8;
    color: #202124;
    border: none;
    padding: 0.55rem 1.4rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.cookie-banner-btn:hover { background: #aac4f0; }

/* =============================================
   Nombre documento como enlace de descarga
   ============================================= */
.doc-name-link {
    color: var(--ip-text);
    text-decoration: none;
    font-weight: 500;
}
.doc-name-link:hover {
    color: var(--ip-blue);
    text-decoration: underline;
}
.doc-card-name-link {
    display: block;
    color: var(--ip-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}
.doc-card-name-link:hover { color: var(--ip-blue); text-decoration: underline; }

/* =============================================
   Vista lista compacta (simple)
   ============================================= */
.doc-simple-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--ip-border);
    border-radius: 6px;
    overflow: hidden;
}
.doc-simple-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.75rem;
    background: var(--ip-surface);
    border-bottom: 1px solid var(--ip-border);
    transition: background 0.1s;
    min-width: 0;
}
.doc-simple-row:last-child { border-bottom: none; }
.doc-simple-row:hover { background: var(--ip-hover); }
.doc-simple-icon { font-size: 1.05rem; flex-shrink: 0; color: var(--ip-text-muted); }
.doc-simple-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.82rem;
}
.doc-simple-folder {
    font-size: 0.75rem;
    color: var(--ip-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.doc-simple-ext {
    font-size: 0.7rem;
    color: var(--ip-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
    min-width: 36px;
}
.doc-simple-nova { font-size: 0.7rem; color: #dc3545; flex-shrink: 0; }
.doc-simple-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }

/* =============================================
   Panel progreso ZIP (fijo, no modal)
   ============================================= */
.zip-progress-panel {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    width: 340px;
    background: var(--ip-surface);
    border: 1px solid var(--ip-border);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    z-index: 1050;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.zip-progress-panel.zpp-visible { display: flex; }
.zpp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1rem 0.5rem;
    border-bottom: 1px solid var(--ip-border);
    font-size: 0.875rem;
    font-weight: 600;
}
.zpp-body { padding: 0.75rem 1rem; font-size: 0.82rem; color: var(--ip-text-muted); }
.zpp-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--ip-text-muted);
    font-size: 1rem;
    padding: 0;
    line-height: 1;
    transition: color 0.15s;
}
.zpp-close:hover { color: var(--ip-text); }

/* =============================================
   Suprimir ojo nativo del browser en passwords
   ============================================= */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear { display: none; }

/* Ocultar X nativa de Chrome/Edge en input[type=search] para usar la personalizada */
input[type="search"]::-webkit-search-cancel-button { display: none; }
input[type="search"]::-ms-clear { display: none; }

/* =============================================
   Modo oscuro - nuevos elementos
   ============================================= */
html[data-theme="dark"] .zip-progress-panel { box-shadow: 0 4px 24px rgba(0,0,0,0.4); }
html[data-theme="dark"] .cookie-banner { background: #18191b; }
html[data-theme="dark"] .doc-name-link,
html[data-theme="dark"] .doc-card-name-link { color: var(--ip-text); }
html[data-theme="dark"] .doc-name-link:hover,
html[data-theme="dark"] .doc-card-name-link:hover { color: var(--ip-blue); }

/* Botón icono móvil: oculto en escritorio (se activa dentro del @media ≤960px) */
.browse-mobile-btn { display: none; }

/* =============================================
   Responsive – ventana estrecha (≤ 960 px)
   ============================================= */
@media (max-width: 960px) {

    /* ── Navbar: esconder texto del logo ── */
    .browse-logo-sep,
    .browse-logo-text { display: none; }

    /* ── Navbar: ocultar barra de búsqueda (reemplazada por icono toggle) ── */
    .browse-search-form { display: none; }

    /* ── Navbar: cuando la búsqueda está abierta → barra full-width sobre la navbar ── */
    .browse-navbar { position: relative; }
    .browse-navbar.nav-search-open .browse-search-form {
        display: flex;
        position: absolute;
        inset: 0;
        z-index: 20;
        background: var(--ip-surface);
        padding: 0 0.5rem;
        align-items: center;
        gap: 0.4rem;
        margin: 0;
        max-width: none;
        flex: none;
    }
    .browse-navbar.nav-search-open .browse-search-wrap { flex: 1; min-width: 0; }
    .browse-navbar.nav-search-open .browse-logo,
    .browse-navbar.nav-search-open .browse-navbar-right { display: none; }

    /* ── Botón cierre búsqueda móvil (flecha ←): visible solo cuando search está abierta ── */
    .browse-mobile-search-close { display: none; }
    .browse-navbar.nav-search-open .browse-mobile-search-close { display: flex; }

    /* ── Botón icono móvil genérico ── */
    .browse-mobile-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--ip-text-muted);
        font-size: 1.05rem;
        width: 34px;
        height: 34px;
        border-radius: 50%;
        cursor: pointer;
        flex-shrink: 0;
        padding: 0;
        transition: background 0.15s;
    }
    .browse-mobile-btn:hover { background: var(--ip-hover); }

    /* ── Ocultar nombre de usuario → solo avatar ── */
    .browse-username { display: none; }
    .browse-user-btn { padding: 0.25rem; }

    /* ── Simular usuario: colapsar a solo icono, expandir con clase JS ── */
    .sim-wrap { border: none; background: transparent; padding: 0; gap: 0; }
    .sim-wrap-icon { cursor: pointer; font-size: 1.05rem; padding: 0.4rem; color: var(--ip-text-muted); }
    .sim-input {
        width: 0;
        max-width: 0;
        opacity: 0;
        padding: 0;
        pointer-events: none;
        overflow: hidden;
        transition: max-width 0.2s ease, opacity 0.15s, padding 0.2s;
    }
    .sim-btn { display: none; }
    .sim-wrap.sim-mobile-open .sim-input {
        width: auto;
        max-width: 150px;
        opacity: 1;
        padding: 0.3rem 0.5rem;
        pointer-events: auto;
        background: var(--ip-hover);
        border: 1px solid var(--ip-border);
        border-radius: 4px;
        font-size: 0.8rem;
    }
    .sim-wrap.sim-mobile-open { border: 1px solid var(--ip-border); background: var(--ip-surface); padding: 0.2rem 0.4rem; border-radius: 4px; gap: 0.3rem; }
    .sim-wrap.sim-mobile-open .sim-btn { display: inline-flex; }
    .sim-error { font-size: 0.75rem; }

    /* ── Sim pill: ocultar email en móvil, solo icono + botón stop ── */
    .sim-pill-email { display: none; }
    .sim-pill { padding: 0.2rem 0.3rem; gap: 0.2rem; max-width: none; }

    /* ── Toolbar: evitar desbordamiento horizontal ── */
    .content-toolbar { flex-wrap: wrap; gap: 0.4rem; }
    .toolbar-filter-form { flex: 1 1 100%; min-width: 0; }
    .toolbar-filter-wrap { flex: 1; min-width: 0; }
    .toolbar-filter-input { width: auto; flex: 1; min-width: 0; }

    /* ── Panel de contenido ── */
    .content-panel { padding: 0.75rem 0.65rem 3rem; }

    /* ── Ocultar el toggle lista/cuadrícula (siempre cuadrícula en ventana estrecha) ── */
    .toolbar-view-toggle { display: none; }

    /* ── Cabecera lista documentos: apilar ZIP buttons ── */
    .docs-list-header { flex-direction: column; align-items: stretch; gap: 0.5rem; }
    .docs-list-header > .d-flex { flex-direction: column; gap: 0.4rem; }
    .zip-btn { justify-content: center; }

    /* ── Vista cuadrícula: una columna ── */
    .doc-grid { grid-template-columns: 1fr !important; gap: 0.3rem; }

    /* ── Card horizontal (estilo OneDrive): icono | info apilada | acciones ── */
    .doc-card {
        flex-direction: row;
        align-items: center;
        padding: 0.55rem 0.7rem;
        gap: 0.6rem;
        border-radius: 6px;
        min-width: 0;
    }
    .doc-card-icon {
        font-size: 1.7rem;
        margin-bottom: 0;
        flex-shrink: 0;
        width: 2rem;
        text-align: center;
    }
    .doc-card-body { flex: 1; min-width: 0; overflow: hidden; }
    .doc-card-fecha { display: none; }
    .doc-card-meta { margin-top: 0.1rem; }
    .doc-card-actions {
        flex-shrink: 0;
        flex-direction: column;
        align-items: center;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        gap: 0.25rem;
    }
    .doc-card-check {
        position: static !important;
        flex-shrink: 0;
        margin: 0;
        order: -1;
    }
    /* Botones de acción: solo icono, compactos */
    .browse-download-btn .dl-text { display: none; }
    .browse-download-btn { padding: 0.3rem 0.45rem; }
    .browse-preview-btn { width: 28px; height: 28px; font-size: 0.8rem; }
    /* Botón descarga en tabla */
    .doc-col-dl .browse-download-btn { padding: 0.3rem 0.45rem; }
    .doc-col-dl .dl-text { display: none; }

    /* ── Tabla de documentos: convertir filas en tarjetas flex ── */
    .doc-table { display: block; }
    .doc-list-thead { display: none !important; }
    .browse-item-doc {
        display: flex !important;
        flex-direction: row;
        align-items: center;
        gap: 0.6rem;
        padding: 0.55rem 0.7rem;
        min-width: 0;
    }
    .browse-item-doc > div {
        display: block !important;
        padding: 0 !important;
        white-space: normal !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
    }
    /* Icono */
    .doc-col-icon { flex-shrink: 0; width: 2rem !important; font-size: 1.4rem; text-align: center; }
    /* Nombre: ocupa el espacio disponible */
    .doc-col-name { flex: 1; min-width: 0; overflow: hidden; }
    .doc-col-name .browse-item-name,
    .doc-col-name .doc-name-link { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    /* Ocultar columnas secundarias */
    .doc-col-ext    { display: none !important; }
    .doc-col-folder { display: none !important; }
    .doc-col-check  { display: none !important; }
    /* Fecha */
    .doc-col-fecha { flex-shrink: 0; text-align: right; font-size: 0.72rem; white-space: nowrap; width: auto !important; min-width: 0 !important; }
    /* Acción */
    .doc-col-action { flex-shrink: 0; width: auto !important; text-align: right; }
    /* Auditoría: usuario / email / badge */
    .doc-col-user  { flex: 1; min-width: 0; overflow: hidden; }
    .doc-col-user .d-block,
    .doc-col-user .browse-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
    .doc-col-email { display: none !important; }
    .doc-col-badge { flex-shrink: 0; }

    /* ── Variante apilada (Auditoría): todos los campos en columna ── */
    .doc-table-stacked .browse-item-doc {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 0.1rem 0.4rem;
        padding: 0.6rem 0.75rem;
        border-bottom: 1px solid rgba(0,0,0,0.18) !important;
    }
    .doc-table-stacked .browse-item-doc:last-child { border-bottom: none !important; }
    /* Por defecto todos los hijos ocupan la línea completa */
    .doc-table-stacked .browse-item-doc > div { width: 100% !important; min-width: 0 !important; }
    .doc-table-stacked .doc-col-icon  { display: none !important; }
    /* Extensión + nombre comparten la primera línea */
    .doc-table-stacked .browse-item-doc > .doc-col-ext {
        display: block !important;
        width: auto !important;
        flex-shrink: 0;
        order: 1;
        font-size: 0.73rem;
        align-self: center;
    }
    .doc-table-stacked .browse-item-doc > .doc-col-name {
        flex: 1;
        min-width: 0;
        width: auto !important;
        order: 2;
        font-weight: 700;
        font-size: 0.9rem;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .doc-table-stacked .doc-col-name .browse-item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
    /* El resto ocupa líneas propias por orden */
    .doc-table-stacked .doc-col-folder { display: block !important; order: 3; font-size: 0.78rem; }
    .doc-table-stacked .doc-col-user  { order: 4; font-size: 0.82rem; flex: none; }
    .doc-table-stacked .doc-col-email { display: block !important; order: 5; font-size: 0.75rem; }
    .doc-table-stacked .doc-col-fecha { order: 6; text-align: left; font-size: 0.75rem; white-space: nowrap; }
    .doc-table-stacked .doc-col-badge { order: 7; font-size: 0.82rem; text-align: left !important; }
}
