:root {
    --primary: #7460a7;
    --primary-dark: #5f4d8f;
    --secondary: #8dcab2;
    --dark: #3f3f46;
    --light: #f6f7fb;
}

body {
    background: linear-gradient(180deg, #fbfbfd 0%, #f4f5f9 100%);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    color: #2c2c34;
}

/* ---------- Shell ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 1.4rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand-block { margin-bottom: 1.4rem; padding: 0 .3rem; }
.brand-logo { max-width: 170px; margin-bottom: .5rem; }
.brand-title { font-size: 1.1rem; font-weight: 800; }
.brand-subtitle { font-size: .76rem; opacity: .82; }

.nav-sections { flex: 1; }
.nav-section-title {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 700;
    opacity: .65;
    margin: 1rem .3rem .3rem;
}
.app-sidebar .nav-link {
    color: rgba(255,255,255,.92) !important;
    border-radius: 10px;
    padding: .5rem .65rem;
    font-weight: 600;
    font-size: .89rem;
    display: flex;
    align-items: center;
    gap: .55rem;
}
.app-sidebar .nav-link:hover { background: rgba(255,255,255,.1); }
.app-sidebar .nav-link.active { background: rgba(255,255,255,.18); }
.app-sidebar .nav-link.disabled {
    opacity: .55;
    cursor: default;
    justify-content: space-between;
}
.soon-badge {
    font-size: .62rem;
    background: rgba(255,255,255,.18);
    border-radius: 999px;
    padding: .12rem .5rem;
    font-weight: 700;
    letter-spacing: .02em;
}

.sidebar-footer { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.18); }
.user-name { font-weight: 700; font-size: .92rem; }
.user-role { font-size: .78rem; opacity: .8; margin-bottom: .6rem; }
.btn-logout {
    background: rgba(255,255,255,.12);
    color: white;
    border: 1px solid rgba(255,255,255,.3);
}
.btn-logout:hover { background: rgba(255,255,255,.22); color: white; }

.app-main {
    flex: 1;
    padding: 1.6rem 2rem 3rem;
    max-width: 1500px;
}

.flash-stack { margin-bottom: 1rem; }

/* ---------- Componentes ---------- */
.hero {
    background: linear-gradient(120deg, var(--primary), #5e4a8e 70%, #4b3d73);
    color: white;
    border-radius: 22px;
    padding: 1.35rem 1.6rem;
    box-shadow: 0 14px 35px rgba(72,55,115,.20);
    margin-bottom: 1.1rem;
}
.hero h1 { margin: 0; font-size: 1.7rem; font-weight: 800; }
.hero p { margin: .25rem 0 0; opacity: .9; }

.soft-card {
    background: white;
    border: 1px solid #ececf2;
    border-radius: 18px;
    padding: 1.1rem 1.25rem;
    box-shadow: 0 8px 26px rgba(30,31,45,.06);
    margin-bottom: 1rem;
}

.section-title { font-size: 1rem; font-weight: 750; margin-bottom: .7rem; color: #30303a; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .85rem;
    margin-bottom: 1rem;
}
.kpi-card {
    background: white;
    border: 1px solid #ececf2;
    border-radius: 17px;
    padding: .95rem 1.1rem;
    box-shadow: 0 7px 22px rgba(30,31,45,.055);
}
.kpi-card-warn { border-color: rgba(239,68,68,.35); background: linear-gradient(135deg, rgba(239,68,68,.05), white); }
.kpi-label { color: #666675; font-weight: 650; font-size: .8rem; margin-bottom: .3rem; }
.kpi-value { color: var(--primary); font-weight: 800; font-size: 1.5rem; letter-spacing: -.02em; }
.kpi-delta { font-size: .75rem; color: #94a3b8; margin-top: .2rem; }

.period-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .6rem; }
.period-label { font-weight: 650; color: #47475a; font-size: .9rem; }

.insight-list { margin: 0; padding-left: 1.1rem; }
.insight-list li { margin-bottom: .35rem; color: #3f3f4a; }

.chart-card canvas { max-height: 320px; }
.empty-hint { color: #8a8a99; font-size: .9rem; margin: 0; }

.code-block {
    background: #f4f2f9;
    border: 1px solid #e5e1f0;
    border-radius: 10px;
    padding: .8rem 1rem;
    font-size: .78rem;
    color: #3f3f4a;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 260px;
    overflow-y: auto;
    margin: 0;
}

.status-pill {
    display: inline-block;
    padding: .22rem .6rem;
    border-radius: 999px;
    background: #fdecea;
    color: #b3261e;
    font-size: .74rem;
    font-weight: 700;
}
.status-pill-ok { background: #edf8f4; color: #286957; }

/* ---------- Sub-navegación de módulo (Catálogo / Crear / Historial...) ---------- */
.module-subnav .nav-link {
    color: #57576a;
    font-weight: 650;
    font-size: .88rem;
    border-radius: 999px;
    padding: .4rem 1rem;
    margin-right: .35rem;
}
.module-subnav .nav-link.active {
    background: var(--primary);
    color: white;
}
.module-subnav .nav-link:hover:not(.active) { background: #f1eef8; }

.search-bar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.search-bar .form-control { max-width: 340px; }

/* ---------- Botones de marca ---------- */
.btn-brand {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    font-weight: 650;
    border-radius: 12px;
}
.btn-brand:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: white; }
.btn-outline-brand {
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 650;
    border-radius: 12px;
}
.btn-outline-brand:hover { background: var(--primary); color: white; }

/* ---------- Login / auth ---------- */
.auth-body {
    background: linear-gradient(180deg, #fbfbfd 0%, #f4f5f9 100%);
    min-height: 100vh;
}
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}
.flash-stack-auth { max-width: 460px; margin: 1rem auto 0; }
.auth-card {
    width: 100%;
    max-width: 440px;
    background: white;
    padding: 2.2rem 2rem;
    border-radius: 24px;
    box-shadow: 0 25px 60px rgba(34,34,50,.14);
    border: 1px solid #eeeef5;
}
.auth-title { text-align: center; color: var(--primary); font-weight: 800; margin-bottom: .2rem; }
.auth-title-sm { text-align: center; color: var(--primary); font-weight: 800; font-size: 1.25rem; margin-bottom: .2rem; }
.auth-subtitle { text-align: center; color: #6d6d79; margin-bottom: 1.4rem; }
.auth-hint { text-align: center; color: #8a8a99; font-size: .82rem; margin-top: 1.1rem; margin-bottom: 0; }

@media (max-width: 900px) {
    .app-sidebar { position: static; height: auto; width: 100%; }
    .app-shell { flex-direction: column; }
    .app-main { padding: 1.2rem 1rem 2rem; }
}
