:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-2: #eef3f8;
    --text: #142033;
    --muted: #66758b;
    --line: #dbe3ec;
    --primary: #0a7c6b;
    --primary-strong: #075f52;
    --danger: #c83d4d;
    --warning: #a86a00;
    --sidebar: #101b2d;
    --sidebar-text: #cdd7e5;
    --shadow: 0 18px 50px rgba(22, 37, 61, .08);
    --radius: 16px;
}
html[data-theme="dark"] {
    --bg: #0d1420;
    --surface: #131e2e;
    --surface-2: #19263a;
    --text: #edf4ff;
    --muted: #9cafc5;
    --line: #26364b;
    --primary: #36b8a5;
    --primary-strong: #229d8c;
    --danger: #ef6574;
    --warning: #efb44b;
    --sidebar: #09101b;
    --sidebar-text: #c8d5e6;
    --shadow: 0 18px 50px rgba(0, 0, 0, .25);
}
* { box-sizing: border-box; }
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button, .button-link { min-height: 42px; border-radius: 10px; padding: 9px 14px; border: 1px solid transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary), transparent 65%); outline-offset: 2px; }
.primary { background: var(--primary); color: white; border-color: var(--primary); }
.primary:hover { background: var(--primary-strong); text-decoration: none; }
.secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.ghost { background: transparent; color: inherit; border-color: transparent; }
.danger { background: var(--danger); color: white; }
.danger-link { background: transparent; color: var(--danger); border: 0; padding-inline: 8px; }
.mini { min-height: 34px; padding: 6px 10px; font-size: .86rem; }
.full { width: 100%; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 14px; background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; z-index: 20; }
.brand { color: white; font-weight: 800; letter-spacing: -.02em; display: flex; gap: 10px; align-items: center; padding: 0 8px 24px; }
.brand:hover { text-decoration: none; }
.brand-logo {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: block;
    object-fit: contain;
}
.brand-logo-large {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
}
.brand-mark { width: 36px; height: 36px; border-radius: 12px; display: inline-grid; place-items: center; background: linear-gradient(135deg, #2bc1aa, #418cff); color: white; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { padding: 11px 12px; border-radius: 10px; color: var(--sidebar-text); display: flex; gap: 10px; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; color: white; }
.sidebar-footer { margin-top: auto; display: grid; gap: 6px; }
.main-area { min-width: 0; }
.navbar { height: 70px; padding: 0 28px; background: color-mix(in srgb, var(--surface), transparent 6%); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 15; backdrop-filter: blur(18px); }
.navbar > div:first-of-type { display: grid; }
.top-subtitle { font-size: .76rem; }
.navbar-actions, .actions { display: flex; gap: 8px; align-items: center; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); color: var(--text); display: grid; place-items: center; font-weight: 700; }
.icon-button { width: 40px; min-height: 40px; padding: 0; border-radius: 10px; border-color: var(--line); background: var(--surface); color: var(--text); }
.content { padding: 28px; max-width: 1600px; margin: 0 auto; }
.page-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-header h1 { margin: 2px 0 0; font-size: clamp(1.7rem, 3vw, 2.4rem); letter-spacing: -.035em; }
.page-header p { margin: 5px 0 0; color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; color: var(--primary); font-size: .75rem; font-weight: 800; }
.muted, small { color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.panel h2 { margin: 0 0 16px; font-size: 1.05rem; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-heading h2 { margin: 0; }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin-top: 20px; }
.stack { display: grid; gap: 15px; }
.narrow { max-width: 720px; }
label { display: grid; gap: 7px; font-weight: 650; font-size: .9rem; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); padding: 10px 12px; min-height: 42px; }
textarea { resize: vertical; }
.checkbox-row { display: flex; align-items: center; gap: 9px; font-weight: 500; }
.checkbox-row input { width: 18px; min-height: 18px; }
.inline-form { display: flex; gap: 9px; align-items: end; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.toolbar input { flex: 1; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
td small { display: block; margin-top: 2px; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 4px 9px; font-size: .75rem; }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; border: 1px solid var(--line); }
.alert.success { background: color-mix(in srgb, var(--primary), transparent 90%); border-color: color-mix(in srgb, var(--primary), transparent 65%); }
.alert.warning { background: color-mix(in srgb, var(--warning), transparent 90%); border-color: color-mix(in srgb, var(--warning), transparent 60%); }
.status-good { color: var(--primary); font-weight: 700; }
.empty-state { min-height: 120px; display: flex; flex-direction: column; gap: 4px; justify-content: center; align-items: center; color: var(--muted); text-align: center; padding: 20px; }
.empty-state.good { color: var(--primary); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.folder-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.folder-card > div:first-child { display: flex; gap: 10px; align-items: center; }
.folder-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); }
.session-list { display: grid; }
.session-row { display: flex; gap: 12px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); }
.session-row > div { flex: 1; display: grid; }
.toast-region { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 100; }
.toast { min-width: 250px; max-width: 420px; padding: 12px 14px; border-radius: 11px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); transform: translateY(10px); opacity: 0; transition: .2s ease; }
.toast.show { transform: none; opacity: 1; }
.toast.error { border-color: var(--danger); }
.modal { border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 28px)); background: transparent; color: var(--text); }
.modal::backdrop { background: rgba(5, 12, 22, .62); backdrop-filter: blur(4px); }
.modal-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; display: grid; gap: 15px; box-shadow: var(--shadow); }
.modal-heading, .modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-heading h2 { margin: 0; }
.modal-actions { justify-content: end; margin-top: 4px; }
.popover { position: fixed; right: 24px; top: 62px; width: min(380px, calc(100vw - 30px)); max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 8px; z-index: 40; }
.notification-item { width: 100%; display: grid; text-align: left; background: transparent; color: var(--text); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.notification-item span, .notification-item small { display: block; }
.notification-item.read { opacity: .6; }
.hidden { display: none !important; }
.mobile-only { display: none; }
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.error-card { max-width: 560px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 42px; box-shadow: var(--shadow); }
.error-code { font-size: 4rem; font-weight: 900; color: var(--primary); }

@media (max-width: 950px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; transform: translateX(-101%); transition: transform .2s ease; width: 260px; }
    .sidebar.open { transform: none; }
    .mobile-only { display: inline-flex; }
    .navbar { padding: 0 16px; }
    .content { padding: 20px 16px; }
    .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 650px) {
    .page-header { align-items: stretch; flex-direction: column; }
    .page-header .actions { flex-wrap: wrap; }
    .toolbar, .inline-form { align-items: stretch; flex-direction: column; }
    .content { padding-inline: 12px; }
    .panel { padding: 15px; }
    .navbar .top-subtitle { display: none; }
}


/* === SoyVault UX patch 2026-09 === */
button:disabled,
button.is-busy {
    cursor: wait;
    opacity: .72;
}

.form-status {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: .88rem;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text);
}

.form-status.info {
    border-color: var(--line);
}

.form-status.success {
    color: var(--primary-strong);
    border-color: color-mix(in srgb, var(--primary), transparent 55%);
    background: color-mix(in srgb, var(--primary), transparent 92%);
}

.form-status.warning {
    color: var(--warning);
    border-color: color-mix(in srgb, var(--warning), transparent 55%);
    background: color-mix(in srgb, var(--warning), transparent 92%);
}

.form-status.error {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger), transparent 50%);
    background: color-mix(in srgb, var(--danger), transparent 94%);
}

.password-rules {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 12px;
    margin-top: -7px;
    font-size: .78rem;
    color: var(--muted);
}

.password-rules span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.password-rules span::before {
    content: '○';
    font-weight: 800;
}

.password-rules span.valid {
    color: var(--primary);
}

.password-rules span.valid::before {
    content: '✓';
}

.password-rules span.invalid::before {
    content: '○';
}

.setup-result,
.import-help {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
}

.import-help code {
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: .78rem;
}

.toast.warning {
    border-color: var(--warning);
}

/* Folder cards: content and actions never compete for the same horizontal space. */
.folder-grid {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    align-items: start;
}

.folder-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    min-width: 0;
    align-items: stretch;
}

.folder-main {
    display: grid !important;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 12px !important;
    align-items: center;
    min-width: 0;
}

.folder-name {
    min-width: 0;
    line-height: 1.25;
    overflow-wrap: anywhere;
    word-break: normal;
}

.folder-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding-left: 52px;
}

.folder-actions .danger-link {
    min-height: 34px;
}

@media (max-width: 620px) {
    .folder-grid {
        grid-template-columns: 1fr;
    }

    .folder-actions {
        padding-left: 0;
    }

    .password-rules {
        grid-template-columns: 1fr;
    }
}


/* SoyVault: account administration */
.account-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
}
.account-meta span {
    color: var(--muted);
    font-size: .84rem;
}

/* =========================================================
   SOYVAULT - LOGO DEL HEADER / SIDEBAR
   Muestra la imagen completa. No hace zoom ni recorta.
   ========================================================= */

.sidebar-soyvault-brand {
    display: flex !important;
    align-items: center;
    justify-content: center;

    width: 100%;
    height: 76px;

    margin: 0 0 20px;
    padding: 4px 2px;

    overflow: visible !important;

    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;

    text-decoration: none !important;
}

.sidebar-soyvault-brand:hover {
    text-decoration: none !important;
}

.sidebar-soyvault-logo {
    display: block !important;

    width: 205px !important;
    height: 68px !important;

    max-width: 100% !important;
    max-height: 68px !important;

    object-fit: contain !important;
    object-position: center !important;

    transform: none !important;
    scale: 1 !important;

    margin: 0 auto !important;
    padding: 0 !important;

    overflow: visible !important;

    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

/* Neutraliza reglas viejas si el navegador conserva alguna clase. */
.sidebar-soyvault-window,
.sidebar-soyvault-window img {
    transform: none !important;
    scale: 1 !important;
    overflow: visible !important;
    background: transparent !important;
    box-shadow: none !important;
}

@media (max-width: 900px) {
    .sidebar-soyvault-brand {
        height: 76px;
    }

    .sidebar-soyvault-logo {
        width: 205px !important;
        height: 68px !important;
    }
}


/* =========================================================
   SOYVAULT - SIDEBAR / HEADER SIN MARCO
   Fondo claro para que el wordmark navy se vea.
   ========================================================= */

/* Sidebar completo */
.sidebar {
    background:
        linear-gradient(
            180deg,
            #C7DDF0 0%,
            #AFCBE4 100%
        ) !important;

    color: #10233F !important;
}

/* Navegación */
.sidebar nav a {
    color: #10233F !important;
}

.sidebar nav a:hover {
    background: rgba(16, 35, 63, .08) !important;
    color: #071A30 !important;
}

.sidebar nav a.active {
    background: rgba(255,255,255,.42) !important;
    color: #071A30 !important;
    box-shadow:
        inset 0 0 0 1px rgba(16,35,63,.08) !important;
}

/* Iconos */
.sidebar nav a > :first-child,
.nav-symbol {
    color: #087F8C !important;
}

/* Footer */
.sidebar-footer {
    border-top-color: rgba(16,35,63,.12) !important;
}

.sidebar-footer .ghost,
.sidebar-footer button {
    color: #10233F !important;
}

.sidebar-footer .ghost:hover,
.sidebar-footer button:hover {
    background: rgba(16,35,63,.07) !important;
}

/* LOGO: completamente libre, sin caja */
.sidebar-soyvault-brand {
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
}

.sidebar-soyvault-logo {
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    object-fit: contain !important;
}

/* Header superior */
.navbar {
    background: #F7FAFD !important;
    border-bottom-color: #D7E3EE !important;
}


/* =========================================================
   SOYVAULT - SIDEBAR POR SECCIONES / ACORDEÓN
   ========================================================= */

/* Texto oscuro y legible sobre el fondo azul claro */
.sidebar {
    color: #0B172A !important;
}

.sidebar-nav {
    display: grid !important;
    gap: 7px !important;
}

/* Enlaces y botones principales */
.sidebar-main-link,
.sidebar-section-toggle {
    position: relative;

    width: 100%;

    min-height: 46px;

    display: flex !important;
    align-items: center;
    justify-content: space-between;

    gap: 10px;

    padding: 10px 12px !important;

    border: 1px solid transparent !important;
    border-radius: 11px !important;

    background: transparent !important;

    color: #0B172A !important;

    font-size: .95rem;
    font-weight: 700;

    text-align: left;

    text-decoration: none !important;

    transition:
        background .18s ease,
        border-color .18s ease,
        color .18s ease,
        transform .18s ease;
}

.sidebar-main-link:hover,
.sidebar-section-toggle:hover {
    background: rgba(255, 255, 255, .36) !important;

    border-color: rgba(11, 23, 42, .09) !important;

    color: #07111F !important;

    text-decoration: none !important;
}

/* Dashboard activo */
.sidebar-main-link.active {
    background: #FFFFFF !important;

    border-color: rgba(11, 23, 42, .10) !important;

    color: #111827 !important;

    box-shadow:
        0 5px 14px rgba(40, 74, 105, .08);
}

.sidebar-main-link.active::before {
    content: '';

    position: absolute;

    left: 0;
    top: 9px;
    bottom: 9px;

    width: 3px;

    border-radius: 999px;

    background:
        linear-gradient(
            180deg,
            #3B82F6,
            #6D4BD1
        );
}

/* Cabecera de cada sección */
.sidebar-section {
    display: grid;

    gap: 4px;
}

.sidebar-section-left {
    display: flex;
    align-items: center;

    gap: 10px;

    min-width: 0;
}

.sidebar-section-toggle.is-open {
    color: #111827 !important;

    background: rgba(255, 255, 255, .20) !important;
}

.sidebar-menu-icon {
    width: 20px;

    flex: 0 0 20px;

    display: inline-grid;
    place-items: center;

    color: #0E7490 !important;

    font-weight: 900;
}

.sidebar-chevron {
    width: 20px;
    height: 20px;

    display: inline-grid;
    place-items: center;

    flex: 0 0 20px;

    color: #334155;

    font-size: 1.35rem;
    line-height: 1;

    transition:
        transform .18s ease;
}

.sidebar-section-toggle[aria-expanded="true"]
.sidebar-chevron {
    transform: rotate(90deg);
}

/* Panel desplegable */
.sidebar-section-panel {
    display: grid;

    gap: 3px;

    margin:
        1px 0
        4px
        10px;

    padding:
        2px 0
        2px 15px;

    border-left:
        1px solid
        rgba(11, 23, 42, .14);
}

.sidebar-section-panel[hidden] {
    display: none !important;
}

/* Enlaces secundarios */
.sidebar-section-panel a {
    position: relative;

    min-height: 39px;

    display: flex !important;
    align-items: center;

    gap: 9px;

    padding:
        8px 10px !important;

    border-radius: 9px !important;

    color: #172033 !important;

    font-size: .89rem;
    font-weight: 600;

    text-decoration: none !important;

    transition:
        background .17s ease,
        color .17s ease,
        transform .17s ease;
}

.sidebar-section-panel a:hover {
    background:
        rgba(255, 255, 255, .42) !important;

    color: #020617 !important;

    text-decoration: none !important;

    transform: translateX(1px);
}

.sidebar-section-panel a.active {
    background: #FFFFFF !important;

    color: #111827 !important;

    font-weight: 800;

    box-shadow:
        0 4px 12px
        rgba(43, 75, 103, .07);
}

.sidebar-child-dot {
    width: 6px;
    height: 6px;

    flex: 0 0 6px;

    border-radius: 50%;

    background: #64748B;
}

.sidebar-section-panel a.active
.sidebar-child-dot {
    background: #4F46E5;

    box-shadow:
        0 0 0 4px
        rgba(79, 70, 229, .10);
}

/* Pie del menú */
.sidebar-footer {
    gap: 7px !important;

    padding-top: 14px;

    border-top:
        1px solid
        rgba(11, 23, 42, .12) !important;
}

.sidebar-footer-button {
    min-height: 42px !important;

    justify-content: flex-start !important;

    padding:
        9px 12px !important;

    border-radius: 10px !important;

    color: #0B172A !important;

    font-weight: 700;
}

.sidebar-footer-button:hover {
    background:
        rgba(255, 255, 255, .36) !important;

    color: #020617 !important;
}

.sidebar-logout {
    color: #B42332 !important;
}

/* El header superior también con texto oscuro */
.navbar,
.navbar strong,
.navbar-title {
    color: #0B172A !important;
}

.top-subtitle {
    color: #58677B !important;
}

/* Móvil */
@media (max-width: 900px) {

    .sidebar-main-link,
    .sidebar-section-toggle {
        min-height: 48px;
    }

    .sidebar-section-panel a {
        min-height: 42px;
    }
}


/* =========================================================
   SOYVAULT - USUARIO AUTENTICADO EN EL HEADER
   ========================================================= */

.navbar-user {
    display: flex;
    align-items: center;
    gap: 10px;

    min-width: 0;

    padding: 6px 10px 6px 6px;

    border: 1px solid rgba(11, 23, 42, .10);
    border-radius: 999px;

    background: rgba(255, 255, 255, .58);

    color: #0B172A;

    text-decoration: none;

    transition:
        background .18s ease,
        border-color .18s ease,
        box-shadow .18s ease,
        transform .18s ease;
}

.navbar-user:hover {
    background: #FFFFFF;

    border-color: rgba(11, 23, 42, .15);

    color: #0B172A;

    text-decoration: none;

    transform: translateY(-1px);

    box-shadow:
        0 7px 18px rgba(31, 58, 87, .09);
}

.navbar-user-avatar {
    width: 38px;
    height: 38px;

    flex: 0 0 38px;

    display: inline-grid;
    place-items: center;

    border-radius: 50%;

    background:
        linear-gradient(
            145deg,
            #6D4BD1 0%,
            #B34FAF 52%,
            #E24D86 100%
        );

    color: #FFFFFF;

    font-size: .92rem;
    font-weight: 900;

    box-shadow:
        0 5px 12px rgba(101, 67, 178, .18);
}

.navbar-user-info {
    min-width: 0;

    display: grid;
    gap: 1px;

    text-align: left;
}

.navbar-user-info strong {
    max-width: 180px;

    overflow: hidden;

    color: #0B172A !important;

    font-size: .86rem;
    font-weight: 800;

    line-height: 1.2;

    white-space: nowrap;
    text-overflow: ellipsis;
}

.navbar-user-info small {
    max-width: 180px;

    overflow: hidden;

    color: #5B687B;

    font-size: .69rem;
    font-weight: 700;

    line-height: 1.2;

    white-space: nowrap;
    text-overflow: ellipsis;
}

/* En pantallas pequeñas dejamos solo la inicial */
@media (max-width: 760px) {
    .navbar-user {
        padding: 5px;

        border-radius: 50%;
    }

    .navbar-user-info {
        display: none;
    }

    .navbar-user-avatar {
        width: 36px;
        height: 36px;

        flex-basis: 36px;
    }
}
