:root {
    color-scheme: light;
    --navy-950: #252324;
    --navy-900: #373435;
    --navy-800: #484345;
    --blue-600: #c51f27;
    --cyan-400: #e8d445;
    --cyan-100: #fff7cc;
    --slate-700: #494345;
    --slate-500: #71696c;
    --slate-300: #d8d1d2;
    --slate-200: #eae5e6;
    --slate-100: #f7f5f4;
    --white: #ffffff;
    --danger: #a62935;
    --danger-bg: #fff0f1;
    --shadow: 0 18px 45px rgba(55, 52, 53, 0.09);
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
    margin: 0;
    min-width: 320px;
    color: var(--navy-950);
    background: var(--slate-100);
    font-family: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.5;
}

button, input, select { font: inherit; }

a { color: inherit; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: .7rem;
    color: var(--navy-950);
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: .18em;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 2.25rem;
    height: 2.25rem;
    place-items: center;
    color: var(--navy-950);
    background: var(--cyan-400);
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: 0;
    clip-path: polygon(50% 0, 100% 100%, 73% 100%, 62% 74%, 38% 74%, 27% 100%, 0 100%);
}

.brand-lockup-light { color: var(--white); }

.eyebrow {
    display: block;
    margin-bottom: .45rem;
    color: var(--blue-600);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.button {
    display: inline-flex;
    min-height: 2.85rem;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .7rem 1.15rem;
    border: 1px solid transparent;
    border-radius: .55rem;
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
    transition: transform .15s ease, background-color .15s ease, border-color .15s ease;
}

.button:hover { transform: translateY(-1px); }
.button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
    outline: 3px solid rgba(237, 50, 55, .42);
    outline-offset: 2px;
}

.button-primary {
    color: var(--white);
    background: var(--blue-600);
    box-shadow: 0 8px 20px rgba(197, 31, 39, .2);
}

.button-primary:hover { background: #a71921; }

.button-download {
    color: var(--navy-950);
    background: var(--cyan-100);
    border-color: #e4ce65;
}

.button-download:hover { background: #f4e58b; }

.button-quiet {
    min-height: 2.4rem;
    color: #f5eeee;
    background: rgba(255, 255, 255, .06);
    border-color: rgba(255, 255, 255, .16);
}

.login-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: minmax(320px, 42rem) 1fr;
    background: var(--white);
}

.login-panel {
    display: flex;
    width: 100%;
    max-width: 34rem;
    min-height: 100vh;
    flex-direction: column;
    justify-content: center;
    padding: clamp(2rem, 7vw, 5.5rem);
    margin: 0 auto;
}

.login-copy { margin: clamp(3.5rem, 9vh, 6rem) 0 2rem; }

.login-copy h1, .page-heading h1 {
    margin: 0;
    color: var(--navy-950);
    font-size: clamp(2rem, 4vw, 3.15rem);
    line-height: 1.05;
    letter-spacing: -.045em;
}

.login-copy p {
    max-width: 28rem;
    margin: 1rem 0 0;
    color: var(--slate-500);
    font-size: 1.05rem;
}

.login-form { display: grid; gap: .55rem; }

.login-form label, .field-group label {
    color: var(--slate-700);
    font-size: .88rem;
    font-weight: 700;
}

.login-form input, .field-group input, .field-group select {
    width: 100%;
    min-height: 3rem;
    margin-bottom: .55rem;
    padding: .65rem .85rem;
    color: var(--navy-950);
    background: var(--white);
    border: 1px solid var(--slate-300);
    border-radius: .5rem;
}

.login-form .button { margin-top: .65rem; }

.form-error, .field-error {
    color: var(--danger);
    font-size: .85rem;
}

.form-error:empty, .field-error:empty { display: none; }
.form-error ul { padding-left: 1.25rem; margin: 0 0 .6rem; }

.security-note {
    margin: 2rem 0 0;
    color: var(--slate-500);
    font-size: .82rem;
}

.security-note span { margin-right: .35rem; color: #24a46d; }

.login-accent {
    position: relative;
    display: flex;
    min-height: 100vh;
    align-items: flex-end;
    overflow: hidden;
    padding: clamp(3rem, 7vw, 7rem);
    color: var(--white);
    background:
        radial-gradient(circle at 78% 20%, rgba(237, 50, 55, .25), transparent 22rem),
        linear-gradient(145deg, var(--navy-800), var(--navy-950) 68%);
}

.accent-grid {
    position: absolute;
    inset: 0;
    opacity: .24;
    background-image:
        linear-gradient(rgba(255,255,255,.13) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.13) 1px, transparent 1px);
    background-size: 64px 64px;
    transform: perspective(650px) rotateX(55deg) scale(1.4) translateY(-8%);
    transform-origin: bottom;
}

.accent-copy { position: relative; z-index: 1; }
.accent-copy span {
    display: block;
    margin-bottom: 1rem;
    color: var(--cyan-400);
    font-size: .82rem;
    font-weight: 900;
    letter-spacing: .24em;
}
.accent-copy strong {
    font-size: clamp(2rem, 4vw, 4.6rem);
    font-weight: 700;
    line-height: 1.02;
    letter-spacing: -.05em;
}

.app-shell { min-height: 100vh; }

.topbar {
    display: flex;
    min-height: 4.5rem;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .85rem clamp(1rem, 4vw, 3.25rem);
    color: var(--white);
    background: var(--navy-950);
    border-bottom: 3px solid var(--cyan-400);
}

.topbar-actions { display: flex; align-items: center; gap: 1rem; }
.topbar-actions form { margin: 0; }
.user-chip { color: #e3dada; font-size: .88rem; }
.user-chip span { color: #2fd69c; }

.main-nav { display: flex; align-items: center; gap: .25rem; }
.main-nav a {
    padding: .55rem .85rem;
    color: #cfc5c7;
    border-radius: .45rem;
    font-size: .9rem;
    font-weight: 700;
    text-decoration: none;
}
.main-nav a:hover, .main-nav a.active { color: var(--white); background: rgba(255,255,255,.1); }

.workspace {
    width: min(100%, 96rem);
    margin: 0 auto;
    padding: clamp(1.5rem, 4vw, 3.25rem);
}

.page-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 1.75rem;
}

.page-heading h1 { font-size: clamp(2.1rem, 4vw, 3.4rem); }

.record-count { display: flex; align-items: baseline; gap: .65rem; }
.record-count strong { font-size: 1.55rem; }
.record-count span { color: var(--slate-500); font-size: .88rem; }

.filter-card, .table-card {
    background: var(--white);
    border: 1px solid var(--slate-200);
    border-radius: .75rem;
    box-shadow: var(--shadow);
}

.filter-card { padding: 1.15rem; margin-bottom: 1.25rem; }
.filter-form {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) 7rem auto auto;
    align-items: end;
    gap: .85rem;
}
.field-group { display: grid; gap: .35rem; }
.field-group input, .field-group select { margin: 0; }

.notice {
    padding: 1rem 1.15rem;
    margin-bottom: 1rem;
    border-radius: .6rem;
}
.notice-error { color: var(--danger); background: var(--danger-bg); border: 1px solid #f4c7cc; }
.notice-success { color: #116044; background: #eafaf3; border: 1px solid #b8ead4; }

.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

th, td {
    padding: .85rem .9rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--slate-200);
}

th {
    color: #f1e8ea;
    background: var(--navy-800);
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: .045em;
    text-transform: uppercase;
    white-space: nowrap;
}

tbody tr:hover { background: #fff9ef; }
.numeric { text-align: right; }
.nowrap { white-space: nowrap; }
.amount { color: var(--navy-800); font-weight: 800; }
.primary-cell, .secondary-cell { display: block; min-width: 8rem; }
.primary-cell { color: var(--navy-950); font-weight: 650; }
.secondary-cell { margin-top: .15rem; color: var(--slate-500); font-size: .78rem; }
.tag {
    display: inline-flex;
    padding: .2rem .5rem;
    color: #6c4f0b;
    background: var(--cyan-100);
    border-radius: 99px;
    font-size: .75rem;
    font-weight: 800;
}

.table-footer {
    display: flex;
    min-height: 4.2rem;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .85rem 1rem;
    color: var(--slate-500);
    font-size: .85rem;
}

.pagination { display: flex; align-items: center; gap: .85rem; }
.pagination a {
    padding: .45rem .7rem;
    color: var(--blue-600);
    background: #fff1ed;
    border-radius: .4rem;
    font-weight: 700;
    text-decoration: none;
}

.empty-state {
    display: grid;
    min-height: 20rem;
    place-items: center;
    align-content: center;
    text-align: center;
}
.empty-icon {
    display: grid;
    width: 3.5rem;
    height: 3.5rem;
    place-items: center;
    color: var(--slate-500);
    background: var(--white);
    border: 1px solid var(--slate-200);
    border-radius: 50%;
    font-weight: 800;
}
.empty-state h2 { margin: 1rem 0 .25rem; font-size: 1.2rem; }
.empty-state p { margin: 0; color: var(--slate-500); }

.dashboard-workspace { display: grid; gap: 1.25rem; }
.dashboard-heading { margin-bottom: .25rem; }
.period-form { display: flex; align-items: end; gap: .65rem; }
.period-form label { display: grid; gap: .25rem; color: var(--slate-500); font-size: .76rem; font-weight: 800; text-transform: uppercase; }
.period-form input {
    min-height: 2.75rem;
    padding: .55rem .7rem;
    color: var(--navy-950);
    background: var(--white);
    border: 1px solid var(--slate-300);
    border-radius: .5rem;
}
.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .85rem; }
.kpi-card {
    display: flex;
    min-height: 9.2rem;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.1rem;
    background: var(--white);
    border: 1px solid var(--slate-200);
    border-radius: .7rem;
    box-shadow: 0 10px 28px rgba(55,52,53,.06);
}
.kpi-primary { color: var(--white); background: linear-gradient(145deg, var(--navy-800), var(--navy-950)); border-color: var(--navy-800); }
.kpi-label { color: var(--slate-500); font-size: .76rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.kpi-primary .kpi-label, .kpi-primary .kpi-meta { color: #d5cacc; }
.kpi-card strong { display: block; font-size: clamp(1.25rem, 2vw, 1.75rem); line-height: 1.15; letter-spacing: -.035em; }
.kpi-meta, .kpi-trend { color: var(--slate-500); font-size: .75rem; }
.kpi-trend.positive { color: #5be2ae; }
.kpi-trend.negative { color: #ff9ba5; }
.analytics-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(17rem, .8fr); gap: 1rem; }
.analysis-card { padding: 1.15rem; background: var(--white); border: 1px solid var(--slate-200); border-radius: .75rem; box-shadow: 0 10px 28px rgba(55,52,53,.05); }
.card-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.card-kicker { color: var(--blue-600); font-size: .7rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.card-heading h2 { margin: .15rem 0 0; font-size: 1.15rem; }
.date-range { color: var(--slate-500); font-size: .8rem; }
.line-chart { height: 14rem; padding-top: .5rem; }
.line-chart svg { width: 100%; height: 100%; overflow: visible; }
.chart-grid { stroke: var(--slate-200); stroke-width: .5; stroke-dasharray: 2 2; }
.chart-axis { stroke: var(--slate-300); stroke-width: .6; }
.trend-area { fill: rgba(237, 50, 55, .12); stroke: none; }
.trend-line { fill: none; stroke: var(--cyan-400); stroke-width: 2.1; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.trend-point { fill: var(--white); stroke: var(--blue-600); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.chart-caption { display: flex; justify-content: space-between; color: var(--slate-500); font-size: .75rem; }
.chart-empty { display: grid; min-height: 13rem; place-items: center; color: var(--slate-500); background: var(--slate-100); border-radius: .55rem; }
.chart-empty.compact { min-height: 8rem; }
.stats-list { display: grid; gap: .75rem; margin: 0; }
.stats-list div { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding-bottom: .7rem; border-bottom: 1px solid var(--slate-200); }
.stats-list div:last-child { padding-bottom: 0; border-bottom: 0; }
.stats-list dt { color: var(--slate-500); font-size: .82rem; }
.stats-list dd { margin: 0; color: var(--navy-950); font-weight: 800; }
.ranking-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.ranking-list { display: grid; gap: .85rem; padding: 0; margin: 0; list-style: none; }
.ranking-list li { display: grid; grid-template-columns: 1.55rem 1fr; align-items: start; gap: .65rem; }
.rank-number { display: grid; width: 1.45rem; height: 1.45rem; place-items: center; color: var(--slate-500); background: var(--slate-100); border-radius: .3rem; font-size: .72rem; font-weight: 900; }
.rank-body { min-width: 0; }
.rank-label { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; font-size: .82rem; }
.rank-label span { overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.rank-label strong { flex: 0 0 auto; font-size: .78rem; }
.rank-body progress { width: 100%; height: .38rem; margin: .38rem 0 .15rem; border: 0; border-radius: 99px; overflow: hidden; background: var(--slate-200); }
.rank-body progress::-webkit-progress-bar { background: var(--slate-200); }
.rank-body progress::-webkit-progress-value { background: linear-gradient(90deg, var(--blue-600), var(--cyan-400)); }
.rank-body progress::-moz-progress-bar { background: var(--blue-600); }
.rank-body small { display: block; color: var(--slate-500); font-size: .68rem; }

.users-workspace { display: grid; gap: 1.25rem; }
.users-heading { margin-bottom: 0; }
.users-grid { display: grid; grid-template-columns: minmax(22rem, .9fr) minmax(27rem, 1.1fr); gap: 1rem; align-items: start; }
.user-form { display: grid; gap: .85rem; }
.form-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.module-fieldset { padding: 0; margin: .2rem 0; border: 0; }
.module-fieldset legend { margin-bottom: .45rem; color: var(--slate-700); font-size: .88rem; font-weight: 700; }
.module-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.module-option { display: flex; gap: .55rem; padding: .7rem; background: var(--slate-100); border: 1px solid var(--slate-200); border-radius: .5rem; cursor: pointer; }
.module-option input { flex: 0 0 auto; width: 1rem; height: 1rem; margin-top: .18rem; accent-color: var(--blue-600); }
.module-option span, .module-option strong, .module-option small { display: block; }
.module-option strong { font-size: .82rem; }
.module-option small { margin-top: .12rem; color: var(--slate-500); font-size: .7rem; }
.module-option em { display: inline-flex; margin-top: .3rem; padding: .08rem .35rem; color: var(--slate-500); background: var(--white); border-radius: 99px; font-size: .64rem; font-style: normal; font-weight: 800; text-transform: uppercase; }
.module-disabled { opacity: .65; cursor: not-allowed; }
.user-list { display: grid; }
.user-row { display: grid; grid-template-columns: 2.6rem 1fr auto; align-items: center; gap: .8rem; padding: .95rem 0; border-bottom: 1px solid var(--slate-200); }
.user-row:last-child { border-bottom: 0; }
.user-avatar { display: grid; width: 2.6rem; height: 2.6rem; place-items: center; color: var(--navy-800); background: var(--cyan-100); border-radius: .65rem; font-weight: 900; }
.user-info { min-width: 0; }
.user-name-line { display: flex; align-items: center; gap: .45rem; }
.user-info > span, .user-info small { display: block; color: var(--slate-500); font-size: .75rem; }
.user-info small { margin-top: .16rem; }
.status-pill { padding: .12rem .4rem; border-radius: 99px; font-size: .65rem; font-weight: 800; }
.status-pill.active { color: #116044; background: #daf5e9; }
.status-pill.inactive { color: var(--danger); background: var(--danger-bg); }
.button-small { min-height: 2rem; padding: .35rem .6rem; font-size: .72rem; }
.button-secondary { color: var(--blue-600); background: #fff1ed; border-color: #f1c6c8; }
.button-danger { color: var(--danger); background: var(--danger-bg); border-color: #f4c7cc; }
.button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: .6; transform: none; }
.access-editor { grid-column: 2 / -1; padding-top: .35rem; }
.access-editor summary { width: max-content; color: var(--blue-600); cursor: pointer; font-size: .75rem; font-weight: 800; }
.access-editor form { display: flex; align-items: end; gap: .75rem; padding: .75rem; margin-top: .55rem; background: var(--slate-100); border-radius: .55rem; }
.access-editor form > label { display: grid; gap: .25rem; color: var(--slate-500); font-size: .72rem; font-weight: 800; }
.access-editor select { min-height: 2.2rem; padding: .35rem .5rem; background: var(--white); border: 1px solid var(--slate-300); border-radius: .4rem; }
.access-editor fieldset { padding: 0; margin: 0; border: 0; }
.access-editor legend { margin-bottom: .25rem; color: var(--slate-500); font-size: .72rem; font-weight: 800; }
.access-checks { display: flex; flex-wrap: wrap; gap: .55rem; }
.access-checks label { display: flex; align-items: center; gap: .25rem; color: var(--slate-700); font-size: .75rem; }
.access-checks input { accent-color: var(--blue-600); }

@media (max-width: 980px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-accent { display: none; }
    .filter-form { grid-template-columns: 1fr 1fr 7rem; }
    .filter-form .button { width: 100%; }
    .filter-form .button-primary { grid-column: 1 / 2; }
    .filter-form .button-download { grid-column: 2 / 4; }
    .topbar { flex-wrap: wrap; }
    .main-nav { order: 3; width: 100%; }
    .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .analytics-grid { grid-template-columns: 1fr; }
    .users-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .brand-lockup { letter-spacing: .1em; }
    .topbar { align-items: flex-start; }
    .user-chip { display: none; }
    .page-heading { align-items: flex-start; flex-direction: column; gap: .8rem; }
    .record-count { flex-direction: column; gap: 0; }
    .filter-form { grid-template-columns: 1fr 1fr; }
    .field-group-small { grid-column: 1 / -1; }
    .filter-form .button-primary, .filter-form .button-download { grid-column: auto; }
    .table-footer { align-items: flex-start; flex-direction: column; }
    .pagination { width: 100%; flex-wrap: wrap; justify-content: space-between; }
    .period-form { width: 100%; flex-wrap: wrap; }
    .period-form label { flex: 1 1 8rem; }
    .period-form .button { flex: 1 1 100%; }
    .kpi-grid, .ranking-grid { grid-template-columns: 1fr; }
    .form-columns, .module-options { grid-template-columns: 1fr; }
    .user-row { grid-template-columns: 2.6rem 1fr; }
    .user-row form { grid-column: 2; }
    .access-editor { grid-column: 1 / -1; }
    .access-editor form { align-items: stretch; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

/* Identidad REBI: rojo #ed3237, amarillo #e8d445 y gris #373435. */
body { display: flex; flex-direction: column; min-height: 100vh; }
.app-shell, .login-shell { flex: 1 0 auto; min-height: calc(100vh - 6.25rem); }
.login-panel, .login-accent { min-height: calc(100vh - 6.25rem); }
.brand-mark { background: #ed3237; color: #ffffff; }
.topbar { border-bottom-color: #ed3237; }
.main-nav a.active { background: #c51f27; }
.trend-line { stroke: #ed3237; }
.rank-body progress::-webkit-progress-value { background: linear-gradient(90deg, #c51f27, #ed3237); }
.rank-body progress::-moz-progress-bar { background: #ed3237; }
.site-footer {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: .65rem 1.5rem; padding: 1.2rem clamp(1rem, 4vw, 3.25rem);
    color: #51484b; background: #ffffff; border-top: 3px solid #e8d445;
    font-size: .82rem; line-height: 1.65;
}
.site-footer-brand { font-weight: 700; color: #373435; }
.site-footer-credit a { color: #b21b23; font-weight: 700; text-underline-offset: .18em; }
.site-footer-contact { color: #b21b23; font-weight: 700; text-decoration: none; }
.site-footer-contact:hover, .site-footer-credit a:hover { color: #86141b; text-decoration: underline; }
@media (max-width: 640px) {
    .site-footer { flex-direction: column; align-items: flex-start; gap: .4rem; }
    .login-panel { min-height: calc(100vh - 9rem); }
}
