:root {
    --navy: #071426;
    --navy-soft: #10243e;
    --blue: #1d7cff;
    --blue-dark: #0e5ed1;
    --surface: #ffffff;
    --page: #f3f7fb;
    --text: #142033;
    --muted: #6d7a8b;
    --line: #dce5ef;
    --danger: #c83232;
    --success: #16834c;
    --warning: #a56800;
    --shadow: 0 18px 48px rgba(7, 20, 38, .10);
}

* { box-sizing: border-box; }
html { color-scheme: light; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--page);
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.topbar {
    min-height: 74px;
    padding: 12px clamp(18px, 4vw, 44px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: var(--navy);
    color: white;
    box-shadow: 0 8px 24px rgba(7, 20, 38, .18);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: linear-gradient(145deg, var(--blue), #68a8ff);
    font-weight: 900;
    font-size: 1.2rem;
}

.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: #9fb4cc; font-size: .76rem; }

.topnav { display: flex; gap: 8px; }
.topnav a { padding: 10px 13px; border-radius: 10px; color: #dbe7f5; }
.topnav a:hover { background: rgba(255,255,255,.08); }

.page {
    width: min(1180px, calc(100% - 28px));
    margin: 0 auto;
    padding: 34px 0 60px;
}

.hero {
    padding: clamp(24px, 5vw, 48px);
    border-radius: 26px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    color: white;
    background:
        radial-gradient(circle at 90% 0%, rgba(83,155,255,.5), transparent 32%),
        linear-gradient(135deg, #071426, #123660);
    box-shadow: var(--shadow);
}

.hero--compact { padding: 28px 34px; }
.hero h1, .viewer-header h1 { margin: 4px 0 8px; font-size: clamp(1.8rem, 5vw, 3.4rem); line-height: 1.05; }
.hero p { margin: 0; color: #cbd9e9; }
.eyebrow { text-transform: uppercase; letter-spacing: .13em; font-weight: 800; font-size: .74rem; color: #82b7ff !important; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 10px; }

.button {
    border: 0;
    border-radius: 12px;
    padding: 12px 17px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 750;
}

.button--primary { background: var(--blue); color: white; }
.button--primary:hover { background: var(--blue-dark); }
.button--secondary { background: #e8f1fb; color: #173354; }
.hero .button--secondary { background: rgba(255,255,255,.12); color: white; border: 1px solid rgba(255,255,255,.18); }
.button--danger { background: #ffe8e8; color: var(--danger); }
.button--small { padding: 8px 11px; font-size: .82rem; }

.breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 24px 2px 12px;
    color: var(--muted);
    font-size: 1.08rem;
    font-weight: 750;
    color: #263b54;
}

.breadcrumbs a:hover { color: var(--blue); }
.back-link { display: inline-block; margin: 0 0 14px; color: var(--blue-dark); font-weight: 700; }

.file-list, .user-list { display: grid; gap: 12px; }
.user-list { margin-top: 22px; }

.file-card, .user-card {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    box-shadow: 0 6px 22px rgba(7,20,38,.04);
}

.file-card:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(7,20,38,.08); }

.file-card__main {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 14px;
}

.file-card__icon {
    width: 46px;
    height: 46px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: #edf4fb;
    font-size: 1.45rem;
    flex: none;
}

.file-card__main span:last-child { min-width: 0; }
.file-card__main strong { display: block; overflow-wrap: anywhere; }
.file-card__main small { display: block; margin-top: 4px; color: var(--muted); }

.file-card__actions, .user-card__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
}

.file-card__actions form, .user-card__actions form { margin: 0; }

.icon-button {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: #edf3f9;
    cursor: pointer;
}

.icon-button:hover { background: #dfeaf5; }
.icon-button--danger { color: var(--danger); }
.icon-button--muted { color: #a8b2bd; cursor: default; }

.empty-state { padding: 62px 20px; text-align: center; color: var(--muted); }
.empty-state div { font-size: 3rem; }
.empty-state h2 { color: var(--text); }

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    padding: 18px;
    display: grid;
    place-items: center;
    background: rgba(2,10,20,.68);
    backdrop-filter: blur(5px);
}

.modal[hidden] { display: none; }
.modal__card {
    width: min(470px, 100%);
    max-height: calc(100vh - 36px);
    overflow: auto;
    padding: 28px;
    border-radius: 22px;
    background: white;
    box-shadow: var(--shadow);
    position: relative;
}

.modal__card--wide { width: min(620px, 100%); }
.modal__card h2 { margin-top: 0; }
.modal__close { position: absolute; top: 12px; right: 14px; border: 0; background: none; font-size: 1.7rem; cursor: pointer; }

.form-stack { display: grid; gap: 16px; }
.form-stack label { display: grid; gap: 7px; font-weight: 700; font-size: .9rem; }
.form-stack input, .form-stack select {
    width: 100%;
    border: 1px solid #cbd7e4;
    border-radius: 12px;
    padding: 12px 13px;
    background: white;
    color: var(--text);
}

.form-stack input:focus, .form-stack select:focus {
    outline: 3px solid rgba(29,124,255,.17);
    border-color: var(--blue);
}

.drop-zone { padding: 26px; text-align: center; border: 2px dashed #aec4da; border-radius: 17px; background: #f7fbff; }
.drop-zone input { margin-top: 10px; }

.alert { margin-bottom: 18px; padding: 13px 15px; border-radius: 12px; border: 1px solid; }
.alert--success { color: var(--success); background: #e8f8ef; border-color: #b9e6cd; }
.alert--error { color: var(--danger); background: #fff0f0; border-color: #f1c0c0; }
.alert--warning { color: var(--warning); background: #fff7e3; border-color: #eed496; }

.auth-shell { min-height: calc(100vh - 145px); display: grid; place-items: center; }
.auth-card { width: min(440px, 100%); padding: 34px; border-radius: 24px; background: white; box-shadow: var(--shadow); }
.auth-card h1 { margin-bottom: 7px; }
.auth-card > p { color: var(--muted); }
.auth-card__icon { font-size: 2.5rem; }

.viewer-header {
    margin-bottom: 18px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
}

.viewer-header h1 { font-size: clamp(1.45rem, 4vw, 2.5rem); overflow-wrap: anywhere; }
.viewer {
    min-height: 66vh;
    padding: 16px;
    border-radius: 20px;
    background: var(--navy);
    box-shadow: var(--shadow);
    display: grid;
    place-items: center;
    overflow: auto;
}

.viewer iframe { width: 100%; height: 76vh; border: 0; border-radius: 12px; background: white; }
.viewer img { display: block; max-width: 100%; max-height: 76vh; border-radius: 12px; }
.viewer video { width: min(100%, 980px); max-height: 76vh; }
.viewer pre { width: 100%; min-height: 60vh; margin: 0; padding: 20px; overflow: auto; border-radius: 12px; background: white; color: #1a2636; white-space: pre-wrap; }

.table-wrap { width: 100%; max-height: 72vh; overflow: auto; border-radius: 12px; background: white; }
.csv-table { width: 100%; border-collapse: collapse; }
.csv-table td { padding: 10px 12px; border: 1px solid var(--line); white-space: nowrap; }

.user-card { padding: 16px; }
.avatar {
    width: 48px;
    height: 48px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    flex: none;
    color: white;
    background: var(--navy-soft);
    font-weight: 900;
}

.user-card__info { min-width: 0; flex: 1; }
.user-card__info strong, .user-card__info span, .user-card__info small { display: block; }
.user-card__info span, .user-card__info small { color: var(--muted); margin-top: 3px; }

@media (max-width: 720px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .topnav { width: 100%; overflow-x: auto; }
    .hero, .viewer-header { align-items: stretch; flex-direction: column; }
    .hero__actions .button { flex: 1; }
    .file-card { align-items: flex-start; }
    .file-card__actions { flex-direction: column; }
    .user-card { align-items: flex-start; flex-wrap: wrap; }
    .user-card__actions { width: 100%; padding-left: 62px; }
    .user-card__actions .button, .user-card__actions form { flex: 1; }
    .user-card__actions form .button { width: 100%; }
    .auth-card { padding: 25px; }
}


/* Ruta de carpetas más visible */
.breadcrumbs a { font-weight: 800; color: #173d6b; }
.breadcrumbs span { font-weight: 800; color: #6c7e91; }

/* Visor PDF especial para móviles */
.viewer--pdf-mobile { display: block; padding: 10px; background: #071426; }
.pdf-mobile-pages { display: grid; gap: 14px; width: 100%; }
.pdf-mobile-page { margin: 0; padding: 0; background: white; border-radius: 10px; overflow: hidden; }
.pdf-mobile-page img { width: 100%; max-width: none; max-height: none; border-radius: 0; }
.pdf-mobile-page figcaption { padding: 8px 12px; text-align: center; color: #506176; background: #f2f5f8; font-size: .85rem; }
.pdf-mobile-error { padding: 24px; border-radius: 12px; background: white; color: #142033; }

@media (max-width: 720px) {
    .breadcrumbs { font-size: 1.18rem; line-height: 1.45; margin-bottom: 16px; }
}