/* ==========================================================================
   Gestor de Archivos — Sistema de diseño
   Estilo corporativo moderno: índigo/azul, superficies limpias, sombras suaves
   ========================================================================== */

:root {
    /* Paleta */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --primary-tint: #e0e7ff;
    --accent: #0ea5e9;
    --success: #10b981;
    --danger: #e11d48;
    --danger-soft: #fff1f2;
    --warning: #f59e0b;

    /* Neutros */
    --ink: #0f172a;
    --ink-soft: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --line-soft: #eef2f7;
    --surface: #ffffff;
    --surface-soft: #f8fafc;

    /* Sidebar */
    --sidebar-top: #101a3d;
    --sidebar-mid: #172554;
    --sidebar-bottom: #1e1b4b;

    /* Formas y sombras */
    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 22px;
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
    --shadow: 0 16px 40px -20px rgba(15, 23, 42, 0.35);
    --shadow-lg: 0 32px 70px -28px rgba(15, 23, 42, 0.45);
    --ring: 0 0 0 4px rgba(79, 70, 229, 0.16);
    --ease: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

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

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink-soft);
    background: linear-gradient(135deg, #f7f9fc 0%, #eef2ff 55%, #f0f9ff 100%);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    margin: 0;
    color: var(--ink);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

h1 { font-size: 26px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }

p { margin: 0 0 10px; }

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--ease);
}

a:hover { color: var(--primary-hover); }

strong { color: var(--ink); font-weight: 650; }

::selection {
    background: var(--primary-tint);
    color: var(--primary-hover);
}

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

/* Botón de menú y fondo del cajón lateral (sólo móvil) */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1520;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--primary);
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform var(--ease), background var(--ease);
}

.mobile-menu-toggle:hover { background: var(--primary-soft); }
.mobile-menu-toggle:active { transform: scale(0.94); }
.mobile-menu-toggle[hidden] { display: none; }

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1505;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-backdrop[hidden] { display: none; }
.sidebar-backdrop.is-visible { opacity: 1; }

/* --------------------------------------------------------------------------
   Botones — componente estrella del rediseño
   -------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: 11px;
    font: inherit;
    font-size: 13.5px;
    font-weight: 650;
    letter-spacing: 0.005em;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: transform var(--ease), box-shadow var(--ease), background var(--ease),
                border-color var(--ease), color var(--ease);
    user-select: none;
}

.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(0.98); }

.btn .ico {
    font-size: 15px;
    line-height: 1;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.08));
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 55%, #4338ca 100%);
    box-shadow: 0 8px 18px -8px rgba(79, 70, 229, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-primary:hover {
    color: #fff;
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    box-shadow: 0 12px 24px -10px rgba(79, 70, 229, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-secondary {
    color: var(--primary-hover);
    background: #fff;
    border-color: #d8dcf5;
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 10px 20px -10px rgba(79, 70, 229, 0.7);
}

.btn-soft {
    color: var(--primary-hover);
    background: var(--primary-soft);
}

.btn-soft:hover {
    color: #fff;
    background: var(--primary);
    box-shadow: 0 10px 20px -10px rgba(79, 70, 229, 0.6);
}

.btn-ghost {
    color: var(--muted);
    background: transparent;
}

.btn-ghost:hover {
    color: var(--primary);
    background: var(--primary-soft);
    transform: none;
}

.btn-danger {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: #ffe4e6;
}

.btn-danger:hover {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
    box-shadow: 0 10px 20px -10px rgba(225, 29, 72, 0.6);
}

.btn-sm {
    padding: 8px 11px;
    font-size: 12px;
    border-radius: 9px;
    gap: 5px;
}

.btn-sm .ico { font-size: 13px; }

.btn-block { width: 100%; }

.btn-lg {
    padding: 14px 22px;
    font-size: 15px;
    border-radius: 13px;
}

/* Botones de solo icono: compactos, con etiqueta accesible y tooltip */
.btn-icon {
    position: relative;
    width: 38px;
    height: 38px;
    min-width: 38px;
    padding: 0;
    border-radius: 11px;
    font-size: 16px;
}

.btn-icon.btn-sm {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 9px;
    font-size: 14px;
}

.btn-icon.btn-lg {
    width: 52px;
    height: 52px;
    min-width: 52px;
    border-radius: 14px;
    font-size: 20px;
}

.btn-icon.btn-block { width: 100%; }

.auth-actions .btn-icon { justify-self: center; }

.btn-icon .ico,
.btn-icon > span[aria-hidden] {
    font-size: inherit;
    filter: none;
}

.btn-icon[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    z-index: 60;
    padding: 6px 9px;
    border-radius: 8px;
    color: #fff;
    background: var(--ink);
    font-size: 11px;
    font-weight: 650;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 4px);
    transition: opacity var(--ease), transform var(--ease);
    box-shadow: 0 6px 16px -8px rgba(15, 23, 42, 0.7);
}

.btn-icon[data-tooltip]:hover::after,
.btn-icon[data-tooltip]:focus-visible::after {
    opacity: 1;
    transform: translate(-50%, 0);
}

.btn[disabled],
.btn.disabled,
.btn.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
    transform: none;
    box-shadow: none;
}

/* Enlaces que parecen botones (compatibilidad con plantillas antiguas) */
.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--primary);
    font-weight: 650;
    font-size: 13px;
    padding: 5px 2px;
}

.btn-link:hover { color: var(--primary-hover); }
.btn-link.danger { color: var(--danger); }
.btn-link.danger:hover { color: #be123c; }

/* --------------------------------------------------------------------------
   Estructura de la aplicación
   -------------------------------------------------------------------------- */

.app-shell {
    display: grid;
    grid-template-columns: 268px minmax(0, 1fr);
    min-height: 100vh;
}

.app-sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 26px;
    height: 100vh;
    padding: 26px 18px 20px;
    overflow: hidden;
    color: #e2e8f0;
    background: linear-gradient(165deg, var(--sidebar-top) 0%, var(--sidebar-mid) 55%, var(--sidebar-bottom) 100%);
}

.app-sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 12% 2%, rgba(99, 102, 241, 0.4), transparent 42%),
        radial-gradient(circle at 100% 96%, rgba(14, 165, 233, 0.22), transparent 46%);
    pointer-events: none;
}

.app-sidebar > * {
    position: relative;
    z-index: 1;
}

.side-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 6px 2px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex: none;
    border-radius: 13px;
    color: #fff;
    font-size: 20px;
    background: linear-gradient(135deg, #818cf8, #4f46e5 60%, #2563eb);
    box-shadow: 0 10px 22px -8px rgba(99, 102, 241, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transition: transform var(--ease);
}

.brand-mark:hover { transform: rotate(-6deg) scale(1.06); }

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { color: #fff; font-size: 17px; letter-spacing: -0.02em; }
.brand-text span { color: #a5b4fc; font-size: 10px; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }

.side-section-title {
    padding: 0 10px;
    margin: -10px 0 -12px;
    color: #64748b;
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.13em;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.side-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border-radius: 11px;
    color: #cbd5e1;
    font-weight: 600;
    font-size: 13.5px;
    transition: background var(--ease), color var(--ease), transform var(--ease);
}

.side-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.09);
    transform: translateX(3px);
}

.side-link.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.85), rgba(79, 70, 229, 0.45));
    box-shadow: 0 8px 20px -10px rgba(99, 102, 241, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.side-link.active::before {
    content: '';
    position: absolute;
    left: -18px;
    top: 50%;
    width: 4px;
    height: 26px;
    border-radius: 0 4px 4px 0;
    background: #a5b4fc;
    transform: translateY(-50%);
}

.side-ico {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    flex: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 14px;
}

.side-link.active .side-ico { background: rgba(255, 255, 255, 0.2); }
.side-link.logout { margin-top: auto; color: #fda4af; }
.side-link.logout:hover { background: rgba(225, 29, 72, 0.16); color: #fff; }

.side-foot {
    margin-top: auto;
    padding: 14px 12px 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 11px;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    background: linear-gradient(135deg, #38bdf8, #6366f1);
    box-shadow: 0 6px 14px -6px rgba(56, 189, 248, 0.8);
}

.user-chip > div { display: flex; flex-direction: column; min-width: 0; }
.user-chip strong { color: #fff; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.user-chip span { color: #94a3b8; font-size: 11px; }

.app-main {
    min-width: 0;
    padding: 26px 30px 42px;
}

/* --------------------------------------------------------------------------
   Barra superior /面包屑 / encabezados
   -------------------------------------------------------------------------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 18px 20px;
    margin-bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.topbar-title { min-width: 0; }

.page-eyebrow {
    margin-bottom: 2px;
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.topbar h3,
.topbar h1 { margin-top: 2px; }

.page-actions,
.repo-actions {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}

.breadcrumbs,
.path-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12.5px;
}

.path-bar {
    padding: 7px 11px;
    margin-bottom: 9px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
    font-size: 12px;
    color: var(--muted);
}

.path-root {
    font-family: inherit;
    font-weight: 700;
    color: var(--primary);
}

.path-bar a {
    color: var(--primary);
    padding: 2px 5px;
    border-radius: 6px;
    font-family: inherit;
}

.path-bar a:hover { background: var(--primary-tint); }
.path-sep { color: #cbd5e1; }
.path-current { color: var(--ink); font-weight: 650; }

.breadcrumbs .current { color: var(--muted); font-weight: 600; }

/* --------------------------------------------------------------------------
   Tarjetas, listas y tablas
   -------------------------------------------------------------------------- */

.content-card,
.list-table {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.content-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line-soft);
}

.content-head h3 { display: flex; align-items: center; gap: 8px; }

.file-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 9px;
}

.file-row,
.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 13px;
    border-radius: 11px;
    transition: background var(--ease), box-shadow var(--ease), transform var(--ease);
}

.file-row:hover {
    background: var(--surface-soft);
    box-shadow: inset 3px 0 0 var(--primary);
}

.file-row.head,
.list-row.header {
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-radius: 0;
    padding: 11px 17px;
}

.file-main,
.entry-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
    color: var(--ink);
    text-decoration: none;
}

.file-main:hover strong,
.entry-main:hover strong { color: var(--primary); }

.file-ico,
.entry-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex: none;
    border-radius: 12px;
    font-size: 19px;
    background: var(--primary-soft);
    box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.08);
}

.file-ico.folder { background: #fff7ed; box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.14); }
.file-ico.parent { background: #f1f5f9; box-shadow: none; }

.file-meta,
.muted {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.file-actions,
.list-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
}

.entry-size {
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-hover);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.badge.role-admin { background: #ede9fe; color: #6d28d9; }
.badge.role-manager { background: #e0f2fe; color: #0369a1; }
.badge.role-employee { background: #dcfce7; color: #15803d; }
.badge.role-guest { background: #f1f5f9; color: #475569; }

.empty,
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 38px 20px;
    color: var(--muted);
    font-size: 13.5px;
    text-align: center;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: var(--primary-soft);
    font-size: 26px;
    color: var(--primary);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
    gap: 16px;
}

.card {
    padding: 18px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--primary);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform var(--ease), box-shadow var(--ease);
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.card .list-actions { margin-top: 12px; }

/* --------------------------------------------------------------------------
   Explorador tipo Windows: navegación, columnas y paginación
   -------------------------------------------------------------------------- */

.explorer-topbar { align-items: flex-start; }

.explorer-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.explorer-nav .path-bar { margin-bottom: 0; }
.explorer-search input { width: 200px; }

.sort-bar {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    padding: 9px 16px;
    border-bottom: 1px solid var(--line-soft);
    background: var(--surface-soft);
}

.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    transition: var(--ease);
}

.sort-link:hover,
.sort-link.active {
    color: var(--primary);
    background: var(--primary-soft);
}

.sort-hint {
    margin-left: auto;
    color: #94a3b8;
    font-size: 11px;
}

.file-col {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.file-col.size { width: 80px; text-align: right; }
.file-col.date { width: 110px; }

.status-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 11px 16px;
    border-top: 1px solid var(--line-soft);
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 12px;
}

.status-count { color: var(--ink); font-weight: 700; }

.perpage-form {
    display: flex;
    align-items: center;
    gap: 7px;
}

.perpage-form select {
    width: auto;
    padding: 6px 28px 6px 9px;
    margin: 0;
    font-size: 12px;
}

.pager {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-left: auto;
}

.pager-btn {
    display: grid;
    place-items: center;
    min-width: 30px;
    height: 30px;
    padding: 0 7px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 700;
    transition: var(--ease);
}

.pager-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.pager-btn.active {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

/* --------------------------------------------------------------------------
   Panel de administración
   -------------------------------------------------------------------------- */

.module-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
}

.module-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 14px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
    white-space: nowrap;
    transition: var(--ease);
}

.module-tab:hover {
    color: var(--primary);
    background: var(--primary-soft);
}

.module-tab.active {
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    box-shadow: 0 6px 14px -7px rgba(79, 70, 229, 0.8);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow-sm);
    color: var(--ink);
    transition: transform var(--ease), box-shadow var(--ease);
}

.stat-card::after {
    content: '';
    position: absolute;
    right: -24px;
    top: -24px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: var(--primary-soft);
    opacity: 0.7;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.stat-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    flex: none;
    border-radius: 14px;
    font-size: 21px;
    background: linear-gradient(135deg, #e0e7ff, #eef2ff);
    box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.1);
}

.stat-icon.green { background: linear-gradient(135deg, #d1fae5, #ecfdf5); }
.stat-icon.amber { background: linear-gradient(135deg, #fef3c7, #fffbeb); }
.stat-icon.sky { background: linear-gradient(135deg, #e0f2fe, #f0f9ff); }

.stat-copy { display: flex; flex-direction: column; position: relative; z-index: 1; }
.stat-value { color: var(--ink); font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; }

.module-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.module-header h3 { display: flex; align-items: center; gap: 9px; }

.search-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-form input { width: 240px; margin: 0; }
.search-form .btn { margin: 0; }

.list-table .list-row.cols-users {
    display: grid;
    grid-template-columns: minmax(160px, 1.2fr) minmax(90px, 0.7fr) minmax(250px, 1.8fr) minmax(85px, 0.55fr);
}

.list-table .list-row.cols-folders {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(250px, 2fr);
}

.list-table .list-row.cols-files {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) minmax(200px, 1.6fr) minmax(90px, 0.5fr);
}

.module-hint {
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.list-table .list-row:not(.header) {
    border-bottom: 1px solid var(--line-soft);
    border-radius: 0;
}

.list-table .list-row:last-child { border-bottom: 0; }
.list-table .list-row:not(.header):hover { background: var(--surface-soft); }

.list-cell { min-width: 0; }

/* --------------------------------------------------------------------------
   Formularios
   -------------------------------------------------------------------------- */

.form-page {
    max-width: 760px;
    margin: 40px auto;
    padding: 0 20px 30px;
}

.form-page.compact { max-width: 560px; }
.form-page.wide { max-width: 860px; }

.form-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 22px 26px;
    background: linear-gradient(135deg, #f8fafc, #eef2ff);
    border-bottom: 1px solid var(--line);
}

.card-head h2 { display: flex; align-items: center; gap: 10px; }

.card-head-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: none;
    border-radius: 12px;
    font-size: 18px;
    color: #fff;
    background: linear-gradient(135deg, #818cf8, #4f46e5);
    box-shadow: 0 8px 16px -8px rgba(79, 70, 229, 0.8);
}

.card-body { padding: 24px 26px; }

.card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 16px 26px;
    background: var(--surface-soft);
    border-top: 1px solid var(--line-soft);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 4px 16px;
}

.form-field { margin-bottom: 16px; }

.form-field label,
.field-label {
    display: block;
    margin-bottom: 6px;
    color: var(--ink);
    font-size: 12.5px;
    font-weight: 700;
}

.form-field label.required::after,
.field-label.required::after {
    content: ' *';
    color: var(--danger);
}

input[type='text'],
input[type='password'],
input[type='email'],
input[type='search'],
input[type='number'],
input[type='date'],
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}

input::placeholder,
textarea::placeholder { color: #94a3b8; }

input:hover,
select:hover,
textarea:hover { border-color: #cbd5e1; }

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: var(--ring);
}

select {
    appearance: none;
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

input[type='checkbox'],
input[type='radio'] {
    width: 16px;
    height: 16px;
    flex: none;
    margin: 0;
    padding: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

input[type='file'] {
    width: 100%;
    padding: 12px;
    border: 1px dashed #c7d2fe;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--ink-soft);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

input[type='file']::file-selector-button {
    padding: 8px 12px;
    margin-right: 12px;
    border: 0;
    border-radius: 8px;
    color: #fff;
    background: var(--primary);
    font: inherit;
    font-size: 12px;
    font-weight: 650;
    cursor: pointer;
}

.form-check .check-label {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    cursor: pointer;
}

.form-check .check-label span { font-weight: 600; }

.field-help,
.form-field .helptext {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 11.5px;
}

.field-error,
.form-field .errorlist li {
    display: block;
    margin: 6px 0 0;
    color: var(--danger);
    font-size: 12px;
    font-weight: 650;
}

.form-field .errorlist {
    margin: 0;
    padding: 0;
    list-style: none;
}

.has-error input,
.has-error select,
.has-error textarea {
    border-color: #fb7185;
    background: #fff5f6;
}

.form-errors {
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid #fecdd3;
    border-left: 3px solid var(--danger);
    border-radius: 11px;
    background: var(--danger-soft);
}

.form-error { margin: 0; color: var(--danger); font-weight: 650; }

.inline-form {
    display: flex;
    align-items: center;
    gap: 6px;
}

.inline-form input,
.inline-form select {
    width: auto;
    min-width: 120px;
    padding: 9px 10px;
    font-size: 12.5px;
}

.inline-form .btn { margin: 0; }

.form-divider {
    height: 1px;
    margin: 22px 0;
    background: var(--line-soft);
}

/* Permisos */
.permission-panel { display: flex; flex-direction: column; gap: 12px; }

.perm-card {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: linear-gradient(135deg, #fff, #f8faff);
    box-shadow: var(--shadow-sm);
}

.perm-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.perm-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-weight: 750;
    text-transform: capitalize;
}

.perm-title .perm-ico {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--primary-soft);
    font-size: 13px;
}

.perm-hint { color: var(--muted); font-size: 11.5px; }

.group-list { display: flex; flex-wrap: wrap; gap: 8px; }

.group-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--ink-soft);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--ease);
}

.group-chip:hover {
    border-color: #c7d2fe;
    background: var(--primary-soft);
    color: var(--primary-hover);
}

.group-chip:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-hover);
    box-shadow: 0 4px 10px -6px rgba(79, 70, 229, 0.7);
}

/* Subida de archivos */
.file-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 22px;
    text-align: center;
    border: 2px dashed #c7d2fe;
    border-radius: 14px;
    background: linear-gradient(135deg, #f8faff, #eef2ff);
    transition: var(--ease);
}

.file-drop:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.file-drop .ico { font-size: 28px; }
.file-drop input[type='file'] { max-width: 330px; }

.upload-progress {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
}

.progress-bar {
    width: 100%;
    height: 9px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.progress-fill {
    width: 0;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #6366f1, #0ea5e9);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.5);
    transition: width 0.2s ease;
}

.progress-text {
    margin-top: 7px;
    color: var(--muted);
    font-size: 11.5px;
}

.upload-speed { color: var(--primary); font-weight: 700; }

/* --------------------------------------------------------------------------
   Acceso (login / registro)
   -------------------------------------------------------------------------- */

.auth-shell {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 28px;
    overflow: hidden;
    background:
        radial-gradient(circle at 12% 18%, rgba(99, 102, 241, 0.18), transparent 40%),
        radial-gradient(circle at 88% 82%, rgba(14, 165, 233, 0.16), transparent 42%),
        linear-gradient(135deg, #f8fafc 0%, #eef2ff 50%, #f0f9ff 100%);
}

.auth-shell::before,
.auth-shell::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(2px);
    pointer-events: none;
}

.auth-shell::before {
    width: 420px;
    height: 420px;
    top: -160px;
    left: -120px;
    background: radial-gradient(circle, rgba(129, 140, 248, 0.22), transparent 70%);
}

.auth-shell::after {
    width: 500px;
    height: 500px;
    right: -180px;
    bottom: -220px;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.2), transparent 70%);
}

.auth-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 450px;
    padding: 36px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.93);
    backdrop-filter: blur(16px);
    box-shadow: 0 32px 70px -28px rgba(49, 46, 129, 0.45), inset 0 1px 0 #fff;
}

.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    text-align: center;
}

.auth-mark {
    display: grid;
    place-items: center;
    width: 60px;
    height: 60px;
    border-radius: 18px;
    color: #fff;
    font-size: 27px;
    font-weight: 800;
    background: linear-gradient(135deg, #818cf8, #4f46e5 60%, #2563eb);
    box-shadow: 0 16px 30px -12px rgba(79, 70, 229, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    transform: rotate(-4deg);
}

.auth-title { font-size: 23px; }
.auth-sub { color: var(--muted); font-size: 13px; }

.auth-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 20px 0 16px;
    color: #94a3b8;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
}

.auth-footer {
    margin-top: 20px;
    text-align: center;
    color: var(--muted);
    font-size: 12.5px;
}

/* --------------------------------------------------------------------------
   Avisos flotantes (messages)
   -------------------------------------------------------------------------- */

.toast-stack {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(370px, calc(100vw - 32px));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 14px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--primary);
    border-radius: 13px;
    background: #fff;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toast-in 0.35s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.toast.is-leaving {
    animation: toast-out 0.3s ease forwards;
}

.toast-icon {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    flex: none;
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    background: var(--primary);
}

.toast-text { flex: 1; color: var(--ink); font-size: 13px; font-weight: 600; }

.toast-close {
    padding: 0;
    margin: -4px -4px 0 0;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: var(--ease);
}

.toast-close:hover { background: var(--line-soft); color: var(--ink); }

.toast-success { border-left-color: var(--success); }
.toast-success .toast-icon { background: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-error .toast-icon { background: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-warning .toast-icon { background: var(--warning); }
.toast-info { border-left-color: var(--accent); }
.toast-info .toast-icon { background: var(--accent); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(24px) scale(0.96); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateX(24px) scale(0.96); }
}

/* --------------------------------------------------------------------------
   Menú contextual y modal de renombrado
   -------------------------------------------------------------------------- */

.ctx-menu {
    position: fixed;
    z-index: 1800;
    min-width: 210px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: #fff;
    box-shadow: var(--shadow-lg);
    animation: ctx-in 0.14s ease-out both;
}

.ctx-menu[hidden] { display: none; }

@keyframes ctx-in {
    from { opacity: 0; transform: scale(0.96) translateY(-4px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.ctx-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 9px 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ctx-head-icon {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 7px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12px;
}

.ctx-name {
    overflow: hidden;
    max-width: 150px;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-transform: none;
    letter-spacing: 0;
    color: var(--ink);
    font-size: 12px;
}

.ctx-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--ink-soft);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: var(--ease);
}

.ctx-item:hover {
    background: var(--primary-soft);
    color: var(--primary-hover);
}

.ctx-item-icon {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 7px;
    background: var(--surface-soft);
    font-size: 13px;
}

.ctx-separator {
    height: 1px;
    margin: 5px 6px;
    background: var(--line-soft);
}

.ctx-item[hidden],
.ctx-separator[hidden] { display: none; }

.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: var(--danger-soft); color: var(--danger); }
.ctx-item.danger .ctx-item-icon { background: var(--danger-soft); }

.file-row[tabindex],
.list-row[tabindex] { cursor: default; }

.file-row:focus-visible,
.list-row:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.ctx-item kbd {
    margin-left: auto;
    padding: 2px 5px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface-soft);
    color: var(--muted);
    font: inherit;
    font-size: 10px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1900;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    animation: fade-in 0.18s ease both;
}

.modal-backdrop[hidden] { display: none; }

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    width: 100%;
    max-width: 420px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: 0 40px 80px -30px rgba(15, 23, 42, 0.6);
    animation: modal-in 0.22s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(14px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
    display: flex;
    align-items: center;
    gap: 13px;
    margin-bottom: 20px;
}

.modal-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex: none;
    border-radius: 13px;
    color: #fff;
    font-size: 18px;
    background: linear-gradient(135deg, #818cf8, #4f46e5);
    box-shadow: 0 8px 18px -8px rgba(79, 70, 229, 0.8);
}

.modal-head .muted {
    overflow-wrap: anywhere;
    max-width: 300px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 20px;
}

/* --------------------------------------------------------------------------
   Compatibilidad con clases antiguas (no romper vistas sin migrar)
   -------------------------------------------------------------------------- */

.container {
    max-width: 1320px;
    margin: 32px auto;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.nav-links { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav-links a { font-weight: 650; font-size: 13px; }

.github-shell {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 28px;
    overflow: hidden;
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 50%, #f0f9ff 100%);
}

.form-box {
    max-width: 560px;
    margin: 40px auto;
    padding: 26px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.github-card { max-width: 450px; padding: 36px; }

.github-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 16px;
    border: 0;
    border-radius: 11px;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    font-weight: 700;
    cursor: pointer;
    transition: var(--ease);
}

.github-btn:hover { box-shadow: 0 10px 20px -10px rgba(79, 70, 229, 0.8); transform: translateY(-2px); }
.github-btn.secondary { background: #fff; color: var(--primary); border: 1px solid #d8dcf5; }

.github-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 11px;
    font-size: 14px;
}

.message {
    padding: 11px 14px;
    margin-bottom: 12px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary-hover);
    font-weight: 600;
}

.message.error { background: var(--danger-soft); color: var(--danger); }
.message.success { background: #ecfdf5; color: #059669; }
.message.info { background: #f0f9ff; color: #0369a1; }

.nextcloud-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 15px;
    border-radius: 11px;
    font-weight: 650;
    font-size: 13px;
    border: 1px solid var(--line);
}

.nextcloud-btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.nextcloud-btn.secondary { background: #fff; color: var(--primary-hover); }
.nextcloud-btn.disabled { opacity: 0.5; pointer-events: none; }

.admin-shell {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.admin-sidebar {
    padding: 16px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.admin-nav { display: flex; flex-direction: column; gap: 5px; }
.admin-nav a { padding: 10px 12px; border-radius: 10px; font-weight: 650; }
.admin-nav a.active,
.admin-nav a:hover { background: var(--primary-soft); color: var(--primary); }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
    .app-shell { grid-template-columns: 224px minmax(0, 1fr); }
    .app-main { padding: 20px; }
}

@media (max-width: 900px) {
    .file-col.date,
    .sort-hint { display: none; }
    .explorer-search input { width: 150px; }
}

@media (max-width: 800px) {
    .app-shell { grid-template-columns: 1fr; }

    .mobile-menu-toggle { display: grid; }
    .app-main { padding-top: 66px; }

    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1510;
        width: min(290px, 84vw);
        height: 100vh;
        padding: 24px 18px 20px;
        gap: 24px;
        transform: translateX(-105%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 12px 0 40px rgba(15, 23, 42, 0.35);
    }

    .app-shell.sidebar-open .app-sidebar { transform: translateX(0); }

    .app-sidebar::before { display: none; }
    .side-nav { flex-direction: column; }
    .side-link { padding: 11px 13px; }
    .side-link.active::before { display: none; }
    .side-link.logout { margin-top: auto; }
    .side-foot { margin-top: 0; padding-top: 12px; }
    .admin-shell { grid-template-columns: 1fr; }
    .admin-nav { flex-direction: row; flex-wrap: wrap; }
    .module-tabs { overflow-x: auto; flex-wrap: nowrap; }
}

@media (max-width: 600px) {
    .app-main { padding: 14px; padding-top: 66px; }
    .topbar { padding: 14px; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1; }
    .file-row,
    .list-row,
    .list-table .list-row.cols-users,
    .list-table .list-row.cols-folders,
    .list-table .list-row.cols-files {
        display: flex;
        align-items: flex-start;
        flex-direction: column;
    }
    .list-table .list-row.header { display: none; }
    .file-col.size { display: none; }
    .pager { width: 100%; margin-left: 0; }
    .file-actions { width: 100%; justify-content: flex-start; }
    .file-ico { width: 36px; height: 36px; font-size: 16px; }
    .search-form input { width: 100%; }
    .search-form { width: 100%; }
    .auth-card { padding: 24px; }
    .card-body, .card-head, .card-foot { padding-left: 18px; padding-right: 18px; }
    .toast-stack { bottom: 12px; right: 12px; left: 12px; width: auto; }
}
