/* SGD — Design system vanguardista */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Syne:wght@600;700;800&display=swap');

:root {
    --font-display: 'Syne', system-ui, sans-serif;
    --font-body: 'DM Sans', system-ui, sans-serif;

    --bg-deep: #070b14;
    --bg-base: #0c1222;
    --bg-elevated: rgba(18, 26, 46, 0.72);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);

    --text: #eef2ff;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --accent: #22d3ee;
    --accent-2: #a78bfa;
    --accent-3: #34d399;
    --gradient-brand: linear-gradient(135deg, #22d3ee 0%, #6366f1 45%, #c084fc 100%);
    --gradient-card: linear-gradient(145deg, rgba(34, 211, 238, 0.12), rgba(167, 139, 250, 0.08));

    --border: rgba(148, 163, 184, 0.15);
    --border-focus: rgba(34, 211, 238, 0.55);
    --shadow-glow: 0 0 40px rgba(34, 211, 238, 0.12);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;

    --sidebar-w: 260px;
    --header-h: 64px;

    --error-bg: rgba(248, 113, 113, 0.12);
    --error-text: #fecaca;
    --ok-bg: rgba(52, 211, 153, 0.12);
    --ok-text: #a7f3d0;

    --gradient-cliente: linear-gradient(135deg, #34d399 0%, #22d3ee 50%, #6366f1 100%);
    --accent-cliente: #34d399;
}

* { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    color-scheme: dark;
}

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg-deep);
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s, opacity 0.2s;
}

a:hover { color: #67e8f9; }

/* Fondo ambiental */
.app-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    background: var(--bg-deep);
}

.app-bg::before,
.app-bg::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.45;
    animation: floatOrb 18s ease-in-out infinite alternate;
}

.app-bg::before {
    width: 520px;
    height: 520px;
    background: #6366f1;
    top: -120px;
    right: -80px;
}

.app-bg::after {
    width: 420px;
    height: 420px;
    background: #0891b2;
    bottom: -100px;
    left: -60px;
    animation-delay: -6s;
}

@keyframes floatOrb {
    to { transform: translate(30px, 40px) scale(1.08); }
}

/* Shell admin */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    padding: 1.25rem 1rem;
    background: var(--bg-elevated);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.sidebar__brand img,
.sidebar__brand svg {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.sidebar__brand-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.sidebar__brand-text small {
    display: block;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
}

/* Grupos colapsables del menú */
.nav-group {
    margin-bottom: 0.25rem;
}

.nav-group__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 0.35rem 0 0.15rem;
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font-body);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.nav-group__toggle:hover {
    background: var(--bg-glass-hover);
    color: var(--text-muted);
}

.nav-group__chevron {
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.25s ease;
    margin-top: -0.15rem;
}

.nav-group--open .nav-group__chevron {
    transform: rotate(-135deg);
    margin-top: 0.15rem;
}

.nav-group__items {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.28s ease;
}

.nav-group--open .nav-group__items {
    grid-template-rows: 1fr;
}

.nav-group__items-inner {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding-bottom: 0.35rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.92rem;
    border: 1px solid transparent;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.nav-link:hover {
    background: var(--bg-glass-hover);
    color: var(--text);
}

.nav-link--active {
    background: var(--gradient-card);
    border-color: var(--border);
    color: var(--text);
    box-shadow: var(--shadow-glow);
}

.nav-link__icon {
    width: 20px;
    text-align: center;
    opacity: 0.85;
}

.sidebar__foot {
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-dim);
}

.sidebar__user {
    color: var(--text);
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-header {
    height: var(--header-h);
    padding: 0 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: rgba(7, 11, 20, 0.6);
    backdrop-filter: blur(12px);
}

.page-title {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.03em;
}

.page-title span {
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.container {
    flex: 1;
    padding: 1.5rem 1.75rem 2.5rem;
    max-width: 1280px;
}

.muted { color: var(--text-muted); }

/* Alertas y mensajes del sistema */
.flash-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.container > .alert:not(.flash-stack .alert),
.form > .alert,
.form .alert {
    margin-bottom: 1rem;
}

.alert {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.95rem 1.1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    font-size: 0.9rem;
    box-shadow: var(--shadow-glow);
    overflow: hidden;
    animation: alertIn 0.35s ease-out;
}

.alert::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.alert--dismissible {
    padding-right: 2.75rem;
}

.alert__icon {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.alert__svg {
    width: 1.25rem;
    height: 1.25rem;
}

.alert__body {
    flex: 1;
    min-width: 0;
}

.alert__title {
    display: block;
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    margin-bottom: 0.2rem;
}

.alert__message {
    margin: 0;
    line-height: 1.45;
    color: var(--text);
}

.alert__close {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.alert__close:hover {
    background: var(--bg-glass-hover);
    color: var(--text);
}

.alert.is-dismissed {
    animation: alertOut 0.25s ease-in forwards;
}

.alert--error {
    border-color: rgba(248, 113, 113, 0.28);
}

.alert--error::before {
    background: linear-gradient(180deg, #f87171, #ef4444);
}

.alert--error .alert__icon {
    background: var(--error-bg);
    color: var(--error-text);
}

.alert--error .alert__title {
    color: var(--error-text);
}

.alert--success {
    border-color: rgba(52, 211, 153, 0.28);
}

.alert--success::before {
    background: linear-gradient(180deg, #34d399, #10b981);
}

.alert--success .alert__icon {
    background: var(--ok-bg);
    color: var(--ok-text);
}

.alert--success .alert__title {
    color: var(--ok-text);
}

.alert--warning {
    border-color: rgba(251, 191, 36, 0.3);
}

.alert--warning::before {
    background: linear-gradient(180deg, #fbbf24, #f59e0b);
}

.alert--warning .alert__icon {
    background: rgba(251, 191, 36, 0.12);
    color: #fde68a;
}

.alert--warning .alert__title {
    color: #fde68a;
}

.alert--info {
    border-color: rgba(34, 211, 238, 0.28);
}

.alert--info::before {
    background: var(--gradient-brand);
}

.alert--info .alert__icon {
    background: rgba(34, 211, 238, 0.12);
    color: #a5f3fc;
}

.alert--info .alert__title {
    color: #a5f3fc;
}

@keyframes alertIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes alertOut {
    to {
        opacity: 0;
        transform: translateY(-6px);
        max-height: 0;
        margin: 0;
        padding-top: 0;
        padding-bottom: 0;
    }
}

/* Modal confirmación */
.sgd-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.sgd-modal[hidden] {
    display: none;
}

.sgd-modal.is-open {
    display: flex;
}

.sgd-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 11, 20, 0.72);
    backdrop-filter: blur(6px);
}

.sgd-modal__panel {
    position: relative;
    width: min(420px, 100%);
    padding: 1.5rem 1.5rem 1.25rem;
    animation: alertIn 0.3s ease-out;
}

.sgd-modal__accent {
    position: absolute;
    top: 0;
    left: 1.25rem;
    right: 1.25rem;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: var(--gradient-brand);
}

.sgd-modal__title {
    margin: 0.35rem 0 0.75rem;
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
}

.sgd-modal__message {
    margin: 0 0 1.25rem;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text);
}

.sgd-modal__actions {
    margin-top: 0;
    justify-content: flex-end;
}

/* KPI cards */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.card {
    position: relative;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.35rem 1.25rem;
    overflow: hidden;
    transition: transform 0.25s, box-shadow 0.25s;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-brand);
    opacity: 0.85;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.card__label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.card__value {
    font-family: var(--font-display);
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
    margin-bottom: 0.75rem;
}

.card__link {
    font-size: 0.85rem;
    font-weight: 600;
}

/* Dashboard grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1.25rem;
}

@media (max-width: 900px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}

.panel {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.35rem;
}

.panel__title {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Gráfico barras CSS */
.chart-bars {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chart-bar__row {
    display: grid;
    grid-template-columns: 100px 1fr 36px;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.82rem;
}

.chart-bar__label {
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chart-bar__track {
    height: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 99px;
    overflow: hidden;
}

.chart-bar__fill {
    height: 100%;
    border-radius: 99px;
    background: var(--gradient-brand);
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.chart-bar__value {
    text-align: right;
    font-weight: 600;
    color: var(--accent);
}

/* Donut */
.donut-wrap {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.donut {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
}

.donut__hole {
    position: absolute;
    inset: 28%;
    background: var(--bg-base);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.5rem;
}

.donut-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.85rem;
}

.donut-legend li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    color: var(--text-muted);
}

.donut-legend__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Formularios */
.form label {
    display: block;
    margin-bottom: 0.85rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form input[type="text"],
.form input[type="password"],
.form input[type="email"],
.form input[type="search"],
.form input[type="file"],
.form select,
.form textarea {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form input:focus,
.form select:focus,
.form textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}

/* Listas desplegables: texto oscuro sobre fondo claro (legible en Windows/Chrome) */
.form select,
.toolbar select,
select {
    color-scheme: light dark;
    cursor: pointer;
}

.form select option,
.toolbar select option,
select option {
    background-color: #f1f5f9;
    color: #0f172a;
    font-weight: 500;
}

.form select option:checked,
.toolbar select option:checked,
select option:checked {
    background-color: #cbd5e1;
    color: #020617;
}

.form select option:hover,
.toolbar select option:hover,
select option:hover {
    background-color: #e2e8f0;
    color: #020617;
}

/* Placeholder / primera opción vacía */
.form select option[value=""],
.toolbar select option[value="0"] {
    color: #64748b;
}

.form--grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem 1.25rem;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.span-2 { grid-column: span 2; }

.checkbox {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
}

.checkbox input { width: auto; margin: 0; accent-color: var(--accent); }

.checkbox-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.35rem 1rem;
    max-height: 280px;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.checkbox-list__item {
    margin: 0 !important;
    font-size: 0.88rem;
    color: var(--text);
}

.panel--empresas {
    margin-top: 0.25rem;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge--admin {
    background: rgba(167, 139, 250, 0.25);
    color: #ddd6fe;
    border: 1px solid rgba(167, 139, 250, 0.35);
}

.badge--cliente {
    background: rgba(34, 211, 238, 0.15);
    color: #a5f3fc;
    border: 1px solid rgba(34, 211, 238, 0.3);
}

.form__actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-glass);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.btn:hover {
    background: var(--bg-glass-hover);
    color: var(--text);
}

.btn--primary {
    background: var(--gradient-brand);
    border: none;
    color: #0c1222;
    box-shadow: 0 4px 20px rgba(34, 211, 238, 0.25);
}

.btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 28px rgba(99, 102, 241, 0.35);
    color: #070b14;
}

.btn--ghost {
    background: transparent;
}

.btn--danger {
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.45);
    color: #fecaca;
}

.btn--danger:hover {
    background: rgba(248, 113, 113, 0.22);
    color: #fff;
}

.form__actions__danger {
    margin-left: auto;
}

/* Toolbar y tablas */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.toolbar__search,
.toolbar__filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.toolbar-checkbox {
    display: inline-flex !important;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.toolbar-checkbox input {
    width: auto;
    margin: 0;
}

.toolbar input,
.toolbar select {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    font-family: inherit;
}

.table-wrap {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
    font-weight: 600;
}

.table tbody tr {
    transition: background 0.15s;
}

.table tbody tr:hover {
    background: var(--bg-glass-hover);
}

.table tbody tr:last-child td { border-bottom: none; }

.table th.col-fecha,
.table td.col-fecha {
    white-space: nowrap;
    width: 1%;
}

.files a { font-size: 0.85rem; }

.file-actions { font-size: 0.85rem; display: inline-block; margin-bottom: 0.25rem; }

.file-actions a.is-preview-active {
    color: var(--accent-cyan);
    font-weight: 600;
}

.file-download {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.table tbody tr.is-preview-row {
    background: rgba(34, 211, 238, 0.08);
    outline: 1px solid rgba(34, 211, 238, 0.25);
}

.documentos-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    align-items: start;
}

.documentos-layout.is-preview-open {
    grid-template-columns: minmax(260px, 38%) minmax(320px, 1fr);
}

@media (max-width: 960px) {
    .documentos-layout.is-preview-open {
        grid-template-columns: 1fr;
    }
}

.doc-viewer {
    position: sticky;
    top: 0.75rem;
    max-height: calc(100vh - 6rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.doc-viewer__head {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--border);
}

.doc-viewer__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    word-break: break-word;
}

.doc-viewer__meta {
    margin: 0.35rem 0 0;
    font-size: 0.82rem;
}

.doc-viewer__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    flex-shrink: 0;
}

.doc-viewer__body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0.75rem 1rem 1rem;
}

.doc-preview-frame--inline {
    min-height: min(72vh, 640px);
}

.doc-viewer__excel {
    padding: 0;
    background: transparent;
    border: none;
}

.doc-preview-meta { margin-bottom: 1rem; }

.doc-preview-frame-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #1e293b;
    min-height: 70vh;
}

.doc-preview-frame {
    width: 100%;
    min-height: 70vh;
    border: none;
    display: block;
}

.doc-preview-excel { overflow-x: auto; }

.excel-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.excel-tab.is-active {
    background: var(--gradient-brand);
    color: #0c1222;
    border: none;
}

.excel-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: #fff;
    color: #0f172a;
}

.excel-content th,
.excel-content td {
    border: 1px solid #cbd5e1;
    padding: 0.35rem 0.5rem;
    text-align: left;
}

/* Login vanguardista */
.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

@media (max-width: 860px) {
    .login-page { grid-template-columns: 1fr; }
    .login-hero { min-height: 220px; }
}

.login-hero {
    position: relative;
    padding: 2.5rem 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    overflow: hidden;
}

.login-hero__logo {
    position: relative;
    width: 112px;
    height: 112px;
    margin-bottom: 1.25rem;
}

.login-hero__grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(34, 211, 238, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(34, 211, 238, 0.06) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: linear-gradient(to bottom, black 40%, transparent);
}

.login-hero h1 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 800;
    line-height: 1.05;
    margin: 0 0 1rem;
    letter-spacing: -0.04em;
    position: relative;
}

.login-hero h1 em {
    font-style: normal;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.login-hero p {
    position: relative;
    color: var(--text-muted);
    max-width: 480px;
    margin: 0 auto;
    font-size: 1.05rem;
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: rgba(12, 18, 34, 0.85);
    backdrop-filter: blur(24px);
    border-left: 1px solid var(--border);
}

.login-card {
    width: min(400px, 100%);
}

.login-card--centered {
    text-align: center;
}

.login-card--centered .form,
.login-card--centered .alert {
    text-align: left;
}

.login-card__badge {
    display: inline-block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.login-card__badge--access {
    background: rgba(34, 211, 238, 0.1);
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    border: 1px solid rgba(34, 211, 238, 0.28);
}

.sidebar__foot .badge {
    display: inline-block;
    margin: 0.4rem 0 0.5rem;
}

.app-header--cliente {
    flex-direction: column;
    align-items: stretch;
    height: auto;
    min-height: var(--header-h);
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
    gap: 0.65rem;
}

.app-header--cliente .app-header__top {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    min-width: 0;
}

.app-header--cliente .app-header__titles {
    flex: 1;
    min-width: 0;
}

.portal-cliente .sidebar,
.sidebar--cliente {
    border-right-color: rgba(52, 211, 153, 0.15);
}

.app-bg--cliente::after {
    background: #059669;
    opacity: 0.35;
}

.app-header__tools {
    width: 100%;
    max-width: none;
    display: flex;
    justify-content: flex-end;
    min-width: 0;
}

.empresa-chip {
    display: inline-flex;
    align-items: flex-start;
    gap: 0.45rem;
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(52, 211, 153, 0.35);
    background: rgba(52, 211, 153, 0.1);
    font-size: 0.82rem;
    color: #a7f3d0;
    max-width: 100%;
    white-space: normal;
    overflow: visible;
    word-break: break-word;
    line-height: 1.45;
    text-align: left;
}

.empresa-chip--wrap {
    flex: 1 1 auto;
    min-width: min(100%, 12rem);
}

.empresa-switch__name {
    flex: 1;
    min-width: 0;
}

.empresa-chip__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-cliente);
    box-shadow: 0 0 10px rgba(52, 211, 153, 0.6);
    flex-shrink: 0;
}

.empresa-switch {
    margin: 0;
    width: 100%;
    max-width: 100%;
}

.empresa-switch__wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: flex-end;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
}

.empresa-switch__control {
    position: relative;
    flex-shrink: 0;
    align-self: center;
    margin: 0;
}

.empresa-switch__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(52, 211, 153, 0.35);
    background: rgba(52, 211, 153, 0.08);
    color: #a7f3d0;
    font-size: 0.8rem;
    font-weight: 600;
    pointer-events: none;
}

.empresa-switch__select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    max-width: none;
}

.page-title--cliente span {
    background: var(--gradient-cliente);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.cliente-welcome {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
    background: var(--gradient-card);
    border-color: rgba(52, 211, 153, 0.2);
}

.cliente-welcome__eyebrow {
    margin: 0 0 0.25rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--accent-cliente);
    font-weight: 600;
}

.cliente-welcome__title {
    margin: 0 0 0.35rem;
    font-family: var(--font-display);
    font-size: 1.35rem;
}

.cards--cliente .card--cliente {
    border-color: rgba(52, 211, 153, 0.12);
}

.cards--cliente .card--cliente::before {
    background: var(--gradient-cliente);
    opacity: 0.85;
}

.card__value--sm {
    font-size: 1.35rem;
}

.panel--cliente {
    border-color: rgba(52, 211, 153, 0.1);
}

.panel__head-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.panel__head-row .panel__title {
    margin: 0;
}

.chart-bar__fill--cliente {
    background: var(--gradient-cliente);
}

.chart-bars--cliente .chart-bar__value {
    color: var(--accent-cliente);
}

.donut--cliente {
    box-shadow: 0 0 40px rgba(52, 211, 153, 0.15);
}

.btn--cliente.btn--primary {
    background: var(--gradient-cliente);
    border: none;
    color: #052e16;
    box-shadow: 0 4px 20px rgba(52, 211, 153, 0.25);
}

.btn--cliente.btn--primary:hover {
    color: #022c22;
    box-shadow: 0 8px 28px rgba(52, 211, 153, 0.35);
}

.btn--sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.cliente-cuenta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.detail-list {
    margin: 0.75rem 0 0;
}

.detail-list__row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 0.75rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
}

.detail-list__row:last-child {
    border-bottom: none;
}

.detail-list dt {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.detail-list dd {
    margin: 0;
    font-weight: 500;
}

.empresa-list {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.empresa-list__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-glass);
}

.empresa-list__item.is-active {
    border-color: rgba(52, 211, 153, 0.4);
    background: rgba(52, 211, 153, 0.08);
}

.empresa-list__badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6ee7b7;
    font-weight: 700;
}

.empresa-picker {
    border: none;
    padding: 0;
    margin: 1rem 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.empresa-picker__item {
    position: relative;
    margin: 0;
}

.empresa-picker__item input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.empresa-picker__card {
    display: block;
    padding: 1rem 1.1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-glass);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.empresa-picker__item input:focus-visible + .empresa-picker__card {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

.empresa-picker__item input:checked + .empresa-picker__card {
    border-color: rgba(52, 211, 153, 0.45);
    background: rgba(52, 211, 153, 0.08);
    box-shadow: 0 0 32px rgba(52, 211, 153, 0.12);
}

.login-card h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin: 0 0 0.35rem;
}

.login-card .btn--primary {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.75rem;
}

.login-card__credit {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

.login-card__credit p {
    margin: 0 0 0.35rem;
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--text-muted);
}

.login-card__credit p:last-child {
    margin-bottom: 0;
}

.login-card__credit a {
    color: var(--accent);
    font-weight: 600;
}

.login-card__credit a:hover {
    color: #67e8f9;
}

.login-card__undercloud-brand {
    display: block;
    width: auto;
    max-width: min(260px, 100%);
    height: auto;
    margin: 0.75rem auto 0;
}

.nav-link--secondary {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.table--auditoria .auditoria-detalle {
    font-size: 0.85rem;
    max-width: 420px;
    line-height: 1.45;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    margin-top: 1.25rem;
}

.pagination .btn.is-active {
    background: var(--gradient-brand);
    color: #0c1222;
    border: none;
}

.pagination__gap {
    color: var(--text-muted);
    padding: 0 0.25rem;
}

.doc-versiones {
    max-width: 100%;
}

.table tr.is-version-actual {
    background: rgba(52, 211, 153, 0.06);
}

.inline-form {
    display: inline;
    margin: 0;
}

.acerca-panel {
    max-width: 560px;
}

.acerca-panel__brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.acerca-panel__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.35rem;
}

.acerca-panel__app {
    margin: 0.25rem 0 0;
    font-size: 0.9rem;
}

.acerca-panel__text {
    margin: 0 0 1.5rem;
    line-height: 1.55;
    color: var(--text-muted);
}

.acerca-panel__vendor {
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.acerca-panel__label {
    margin: 0 0 0.35rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
}

.acerca-panel__company {
    margin: 0 0 0.5rem;
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.45;
}

.acerca-panel__link {
    font-weight: 600;
}

/* Mobile sidebar toggle */
.sidebar-toggle {
    display: none;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.4rem 0.65rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
}

@media (max-width: 768px) {
    .sidebar-toggle { display: inline-flex; }

    .sidebar {
        position: fixed;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.is-open { transform: translateX(0); }

    .app-shell { flex-direction: column; }

    .container { padding: 1rem; }

    .form--grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
}
