/*
 * Paleta de marca NeoRed — variables CSS usadas en todo el panel a partir de la Fase 3.
 * --nr-orange-500 y --nr-blue-600 son los hex EXACTOS extraídos de neored-logo-color.svg
 * (fill:#e57222 y fill:#037ac3). El resto de tonos navy son de soporte (fondo/hero),
 * aproximados a partir de neored.com.
 */
:root {
    --nr-navy-950: #071022;
    --nr-navy-900: #0b1a33;
    --nr-navy-800: #0f2547;
    --nr-blue-700: #0a5a94;
    --nr-blue-600: #037ac3;
    --nr-blue-500: #2e93d6;

    --nr-orange-500: #e57222;
    --nr-orange-600: #c75e15;

    --nr-text-onDark: #eef4fb;
    --nr-text-muted-onDark: #a9c0dd;
    --nr-text-body: #1c2b3a;

    --nr-surface: #ffffff;
    --nr-surface-alt: #f4f7fb;
    --nr-border: #dde5ef;

    --nr-success: #1f9d55;
    --nr-danger: #d64545;
    --nr-warning: #e0a716;

    --nr-radius: 0.75rem;
    --nr-gradient-hero: linear-gradient(135deg, var(--nr-navy-950) 0%, var(--nr-blue-600) 100%);
}

body {
    background-color: var(--nr-surface-alt);
    color: var(--nr-text-body);
}

.nr-navbar {
    background: var(--nr-navy-900);
}

.nr-hero {
    background: var(--nr-gradient-hero);
    color: var(--nr-text-onDark);
}

.btn-nr-primary {
    background-color: var(--nr-orange-500);
    border-color: var(--nr-orange-500);
    color: #fff;
}

.btn-nr-primary:hover,
.btn-nr-primary:focus {
    background-color: var(--nr-orange-600);
    border-color: var(--nr-orange-600);
    color: #fff;
}

.nr-card {
    background: var(--nr-surface);
    border: 1px solid var(--nr-border);
    border-radius: var(--nr-radius);
    color: var(--nr-text-body);
}

/* ==========================================================================
   Estructura del panel (v3): barra lateral agrupada + barra superior.
   ========================================================================== */
:root {
    --nr-muted: #5b6b7d;
    --nr-sidebar-w: 252px;
    --nr-shadow: 0 1px 2px rgba(11, 26, 51, .06), 0 1px 3px rgba(11, 26, 51, .05);
    --nr-shadow-hover: 0 6px 18px rgba(11, 26, 51, .10);
}

.nr-card { box-shadow: var(--nr-shadow); overflow-x: auto; }

.nr-i { width: 1.15rem; height: 1.15rem; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.nr-shell { display: flex; min-height: 100vh; }

/* --- barra lateral --- */
.nr-sidebar { width: 0; flex: 0 0 auto; }
.nr-sidebar .offcanvas-lg { --bs-offcanvas-width: 288px; --bs-offcanvas-bg: var(--nr-navy-900); --bs-offcanvas-color: var(--nr-text-onDark); }
.nr-sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.1rem .75rem; }
.nr-brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .2px; }
.nr-sidebar-body { padding: .5rem .85rem 1rem; display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.nr-nav-section { margin: 1.1rem .65rem .35rem; font-size: .68rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--nr-text-muted-onDark); opacity: .75; }
.nr-nav-link { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; margin: .1rem 0; border-radius: 9px; color: #c9d8ec; text-decoration: none; font-size: .93rem; position: relative; }
.nr-nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nr-nav-link.active { background: rgba(3, 122, 195, .28); color: #fff; font-weight: 600; }
.nr-nav-link.active::before { content: ""; position: absolute; left: -.85rem; top: 22%; bottom: 22%; width: 4px; border-radius: 0 4px 4px 0; background: var(--nr-orange-500); }
.nr-sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid rgba(255, 255, 255, .08); }

@media (min-width: 992px) {
    .nr-sidebar { width: var(--nr-sidebar-w); background: var(--nr-navy-900); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
    .nr-sidebar .offcanvas-lg { display: flex; flex-direction: column; height: 100%; color: var(--nr-text-onDark); }
}

/* --- zona principal --- */
.nr-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.nr-topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; height: 60px; padding: 0 1.25rem; background: var(--nr-surface); border-bottom: 1px solid var(--nr-border); }
.nr-content { width: 100%; max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.25rem 3.5rem; }
.nr-impersonation { background: var(--nr-orange-500); color: #fff; text-align: center; padding: .45rem 1rem; font-size: .88rem; }

.nr-icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 9px; background: transparent; color: inherit; }
.nr-icon-btn:hover { background: rgba(127, 140, 160, .15); }
.nr-topbar .nr-icon-btn { color: var(--nr-text-body); }

.nr-search { display: flex; align-items: center; gap: .5rem; flex: 1 1 auto; max-width: 420px; padding: 0 .75rem; height: 38px; border: 1px solid var(--nr-border); border-radius: 10px; background: var(--nr-surface-alt); color: var(--nr-muted); }
.nr-search:focus-within { border-color: var(--nr-blue-500); box-shadow: 0 0 0 3px rgba(46, 147, 214, .18); background: #fff; }
.nr-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: .9rem; color: var(--nr-text-body); }

.nr-company { display: inline-flex; align-items: center; gap: .45rem; max-width: 220px; padding: .3rem .7rem; border-radius: 999px; background: var(--nr-surface-alt); border: 1px solid var(--nr-border); color: var(--nr-text-body); text-decoration: none; font-size: .85rem; }
.nr-company span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nr-user { display: inline-flex; align-items: center; gap: .5rem; border: 0; background: transparent; padding: .2rem .4rem; border-radius: 999px; color: var(--nr-text-body); font-size: .9rem; }
.nr-user:hover { background: var(--nr-surface-alt); }
.nr-avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--nr-blue-600); color: #fff; font-weight: 700; font-size: .85rem; }

/* --- componentes de página --- */
.nr-content h1.h4, .nr-page-title { font-size: 1.45rem; font-weight: 700; letter-spacing: -.01em; }
.nr-page-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: .75rem 1rem; margin-bottom: 1.25rem; }
.nr-page-title { margin: 0; }
.nr-page-sub { margin: .2rem 0 0; color: var(--nr-muted); font-size: .93rem; max-width: 62ch; }

.nr-kpi { height: 100%; padding: 1rem 1.1rem; }
.nr-kpi .nr-kpi-label { color: var(--nr-muted); font-size: .8rem; }
.nr-kpi .nr-kpi-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; }
.nr-kpi .nr-kpi-hint { color: var(--nr-muted); font-size: .78rem; }

.nr-action { display: flex; gap: 1rem; align-items: flex-start; height: 100%; padding: 1.15rem 1.25rem; color: inherit; text-decoration: none; transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease; }
.nr-action:hover { box-shadow: var(--nr-shadow-hover); transform: translateY(-2px); border-color: var(--nr-blue-500); color: inherit; }
.nr-action .nr-bubble { display: grid; place-items: center; flex: 0 0 auto; width: 46px; height: 46px; border-radius: 12px; background: rgba(229, 114, 34, .12); color: var(--nr-orange-600); }
.nr-action.alt .nr-bubble { background: rgba(3, 122, 195, .12); color: var(--nr-blue-600); }
.nr-action .nr-bubble .nr-i { width: 1.4rem; height: 1.4rem; }
.nr-action h2 { font-size: 1.05rem; margin: 0 0 .15rem; }
.nr-action p { margin: 0; color: var(--nr-muted); font-size: .88rem; }

.nr-rate { display: flex; align-items: center; gap: .6rem; min-width: 150px; }
.nr-rate .progress { flex: 1 1 auto; height: 8px; background: var(--nr-border); }
.nr-rate .progress-bar { background: var(--nr-blue-600); }
.nr-rate .nr-rate-num { font-weight: 600; font-size: .85rem; min-width: 3ch; text-align: right; }

.nr-empty { text-align: center; padding: 2.25rem 1rem; color: var(--nr-muted); }
.nr-empty .nr-bubble { display: inline-grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: var(--nr-surface-alt); color: var(--nr-blue-600); margin-bottom: .75rem; }
.nr-empty .nr-bubble .nr-i { width: 1.5rem; height: 1.5rem; }
.nr-empty h2 { font-size: 1.05rem; color: var(--nr-text-body); }

.nr-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .6rem; border-radius: 999px; background: var(--nr-surface-alt); border: 1px solid var(--nr-border); color: var(--nr-muted); font-size: .78rem; }

.table > :not(caption) > * > * { padding-top: .6rem; padding-bottom: .6rem; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--nr-muted); font-weight: 700; white-space: nowrap; }

@media (max-width: 575.98px) {
    .nr-content { padding: 1rem .85rem 3rem; }
    .nr-topbar { padding: 0 .75rem; }
    .nr-search { max-width: none; }
    .nr-company span { display: none; }
}

@media (prefers-reduced-motion: reduce) { .nr-action { transition: none; } .nr-action:hover { transform: none; } }

/* ==========================================================================
   Sistema de componentes (v4): formularios, tablas, estados, alertas, auth.
   ========================================================================== */

/* --- tipografía y formularios --- */
.form-label { font-size: .85rem; font-weight: 600; color: var(--nr-text-body); margin-bottom: .3rem; }
.form-control, .form-select { border-color: #cdd8e6; border-radius: 9px; padding: .55rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--nr-blue-500); box-shadow: 0 0 0 3px rgba(46, 147, 214, .18); }
.form-control-sm, .form-select-sm { padding: .35rem .6rem; border-radius: 8px; }
.form-text { color: var(--nr-muted); font-size: .8rem; }
.input-group-text { background: var(--nr-surface-alt); border-color: #cdd8e6; color: var(--nr-muted); font-size: .9rem; }
.input-group > .form-control:not(:first-child), .input-group > .input-group-text:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group > .input-group-text:not(:last-child) { border-top-left-radius: 9px; border-bottom-left-radius: 9px; }
.btn { border-radius: 9px; font-weight: 600; }
.btn-sm { border-radius: 8px; }
.btn-outline-secondary { --bs-btn-color: #44566c; --bs-btn-border-color: #cdd8e6; --bs-btn-hover-bg: var(--nr-surface-alt); --bs-btn-hover-color: var(--nr-text-body); --bs-btn-hover-border-color: #b7c5d8; }
.btn-nr-primary { box-shadow: 0 1px 2px rgba(199, 94, 21, .35); }
a { color: var(--nr-blue-600); }
a:hover { color: var(--nr-blue-700); }

.nr-form { max-width: 760px; }
.nr-form-section { padding: 1.25rem 1.4rem; border-bottom: 1px solid var(--nr-border); }
.nr-form-section:last-of-type { border-bottom: 0; }
.nr-form-section h2 { font-size: .95rem; margin: 0 0 .15rem; }
.nr-form-section .nr-section-hint { margin: 0 0 1rem; color: var(--nr-muted); font-size: .85rem; }
.nr-form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: 1rem 1.4rem; background: var(--nr-surface-alt); border-top: 1px solid var(--nr-border); border-radius: 0 0 var(--nr-radius) var(--nr-radius); }
.nr-card.nr-form { padding: 0; overflow: hidden; }
.nr-details { border: 1px dashed #c3d0e2; border-radius: 10px; padding: .15rem .9rem; }
.nr-details > summary { cursor: pointer; padding: .55rem 0; font-weight: 600; font-size: .88rem; color: var(--nr-blue-700); list-style: none; display: flex; align-items: center; gap: .4rem; }
.nr-details > summary::-webkit-details-marker { display: none; }
.nr-details > summary::before { content: "＋"; font-weight: 700; }
.nr-details[open] > summary::before { content: "−"; }
.nr-details > div { padding: .25rem 0 .9rem; }
.nr-checklist { max-height: 200px; overflow-y: auto; border: 1px solid #cdd8e6; border-radius: 9px; padding: .5rem .75rem; background: #fff; }

/* --- alertas --- */
.alert { border-radius: 10px; border-width: 1px; font-size: .9rem; }
.nr-alert { display: flex; gap: .65rem; align-items: flex-start; padding: .75rem .95rem; margin-bottom: 1rem; border-radius: 10px; border: 1px solid; font-size: .9rem; }
.nr-alert .nr-i { margin-top: .12rem; }
.nr-alert.success { background: #ecf8f1; border-color: #bfe6cf; color: #166a3c; }
.nr-alert.danger { background: #fdeeee; border-color: #f4c3c3; color: #9b2c2c; }
.nr-alert.warning { background: #fff7e3; border-color: #f1d98c; color: #8a6200; }
.nr-alert.info { background: #eaf4fc; border-color: #b6d9f1; color: #0b4f7c; }
.nr-alert a { color: inherit; font-weight: 600; }

/* --- estados (pills) --- */
.nr-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .18rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.nr-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.nr-pill.ok { background: #e6f6ed; color: #17703f; }
.nr-pill.off { background: #edf1f6; color: #4c5d72; }
.nr-pill.warn { background: #fff3d6; color: #8a5b00; }
.nr-pill.bad { background: #fde8e8; color: #a02727; }
.nr-pill.info { background: #e3f1fb; color: #0b5d94; }

/* --- tablas --- */
.nr-table-card { padding: 0; }
.nr-table-card > .table { margin: 0; }
.nr-table-card .table > :not(caption) > * > * { padding: .75rem 1rem; }
.nr-table-card .table thead th { background: var(--nr-surface-alt); border-bottom: 1px solid var(--nr-border); }
.nr-table-card .table tbody tr:hover { background: #fafcff; }
.nr-table-card .table > tbody > tr:last-child > td { border-bottom: 0; }
.nr-cell-main { font-weight: 600; }
.nr-cell-sub { color: var(--nr-muted); font-size: .8rem; }
.nr-user-cell { display: flex; align-items: center; gap: .7rem; }
.nr-user-cell .nr-avatar { width: 34px; height: 34px; font-size: .8rem; flex: 0 0 auto; }
.nr-kebab { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid #cdd8e6; border-radius: 8px; background: #fff; color: #44566c; }
.nr-kebab:hover, .nr-kebab.show { background: var(--nr-surface-alt); }
.nr-row-actions { display: inline-flex; align-items: center; gap: .4rem; justify-content: flex-end; }
.dropdown-menu { border-color: var(--nr-border); border-radius: 12px; padding: .4rem; box-shadow: 0 10px 30px rgba(11, 26, 51, .14); font-size: .9rem; }
.dropdown-item { border-radius: 8px; padding: .45rem .7rem; }
.dropdown-item form { margin: 0; }
.dropdown-item.text-danger:hover { background: #fde8e8; }
.dropdown-header { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--nr-muted); }

/* --- filtros y barras de herramientas --- */
.nr-toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.nr-toolbar .form-control, .nr-toolbar .form-select { width: auto; min-width: 150px; }
.nr-toolbar .nr-grow { flex: 1 1 220px; }
.nr-segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--nr-surface-alt); border: 1px solid var(--nr-border); }
.nr-segmented a { padding: .28rem .8rem; border-radius: 8px; color: var(--nr-muted); text-decoration: none; font-size: .85rem; font-weight: 600; }
.nr-segmented a.active { background: #fff; color: var(--nr-text-body); box-shadow: var(--nr-shadow); }
.pagination { --bs-pagination-border-radius: 8px; --bs-pagination-active-bg: var(--nr-blue-600); --bs-pagination-active-border-color: var(--nr-blue-600); --bs-pagination-color: var(--nr-blue-700); gap: .2rem; }
.page-link { border-radius: 8px !important; }

/* --- desgloses con barras --- */
.nr-bars { list-style: none; margin: 0; padding: 0; }
.nr-bars li { padding: .35rem 0; }
.nr-bars .nr-bar-row { display: flex; justify-content: space-between; gap: .75rem; font-size: .86rem; }
.nr-bars .nr-bar-track { height: 6px; border-radius: 999px; background: var(--nr-border); margin-top: .25rem; overflow: hidden; }
.nr-bars .nr-bar-fill { height: 100%; border-radius: 999px; background: var(--nr-blue-500); }
.nr-card-title { font-size: .95rem; font-weight: 700; margin: 0 0 .6rem; }
.nr-delta { font-weight: 700; font-size: .78rem; padding: .1rem .45rem; border-radius: 999px; }
.nr-delta.up { background: #e6f6ed; color: #17703f; }
.nr-delta.down { background: #fde8e8; color: #a02727; }
.nr-delta.flat { background: #edf1f6; color: #4c5d72; }

.nr-copybox { display: inline-flex; align-items: center; gap: .5rem; padding: .3rem .4rem .3rem .8rem; border: 1px solid var(--nr-border); border-radius: 10px; background: var(--nr-surface-alt); max-width: 100%; }
.nr-copybox code { background: none; padding: 0; color: var(--nr-text-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- páginas de acceso y públicas (auth, 404, etc.) --- */
.nr-auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.nr-auth-side { display: none; background: var(--nr-gradient-hero); color: var(--nr-text-onDark); padding: 3rem; position: relative; overflow: hidden; }
.nr-auth-side::after { content: ""; position: absolute; right: -140px; bottom: -140px; width: 420px; height: 420px; border-radius: 50%; background: rgba(229, 114, 34, .18); }
.nr-auth-side h2 { font-size: 2rem; line-height: 1.2; font-weight: 800; max-width: 16ch; margin: 2.5rem 0 1rem; }
.nr-auth-side p { color: var(--nr-text-muted-onDark); max-width: 38ch; }
.nr-auth-points { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: .9rem; position: relative; z-index: 1; }
.nr-auth-points li { display: flex; gap: .7rem; align-items: flex-start; color: #dbe8f7; font-size: .95rem; }
.nr-auth-points .nr-i { margin-top: .15rem; color: #ffb27c; }
.nr-auth-main { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; background: var(--nr-surface-alt); }
.nr-auth-card { width: 100%; max-width: 410px; }
.nr-auth-card .nr-card { padding: 2rem 1.75rem; box-shadow: 0 10px 30px rgba(11, 26, 51, .08); }
.nr-auth-card h1 { font-size: 1.4rem; font-weight: 800; margin: 0 0 .25rem; }
.nr-auth-card .nr-auth-sub { color: var(--nr-muted); font-size: .92rem; margin-bottom: 1.25rem; }
.nr-auth-logo { margin-bottom: 1.5rem; }
@media (min-width: 992px) { .nr-auth { grid-template-columns: 1.05fr 1fr; } .nr-auth-side { display: flex; flex-direction: column; } }

.nr-public { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1.25rem; background: var(--nr-gradient-hero); color: var(--nr-text-onDark); text-align: center; }
.nr-public .nr-code { display: inline-block; max-width: 100%; padding: .35rem .9rem; border-radius: 999px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .25); color: #cfe0f4; font-size: .9rem; word-break: break-all; margin-bottom: 1.5rem; }
.nr-public .nr-big { font-size: clamp(3.5rem, 12vw, 6rem); font-weight: 800; line-height: 1; letter-spacing: -.04em; color: rgba(255, 255, 255, .92); }
.nr-public h1 { font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 800; margin: .5rem 0 .75rem; }
.nr-public p { color: var(--nr-text-muted-onDark); max-width: 44ch; margin-left: auto; margin-right: auto; }
.nr-public .btn-light { color: var(--nr-navy-900); }

.nr-public img { display: block; margin-left: auto; margin-right: auto; }
.nr-public .nr-code { margin-bottom: 1.25rem; }
.nr-public br { display: none; }

/* Evitar desbordes en pantallas angostas */
.nr-search { min-width: 0; }
.nr-search input { width: 100%; }
.nr-alert > div { min-width: 0; }
.nr-copybox { min-width: 0; }
.nr-copybox code { min-width: 0; }
.nr-copybox code.user-select-all { white-space: normal; word-break: break-all; }
.nr-topbar > * { min-width: 0; }

/* Código en línea con la identidad (en lugar del rosa por defecto) */
.nr-content code, .nr-auth code { color: var(--nr-blue-700); background: var(--nr-surface-alt); padding: .1em .4em; border-radius: 6px; font-size: .86em; }
.nr-content a > code { color: inherit; background: rgba(3, 122, 195, .08); }
.nr-content pre code { color: inherit; background: none; padding: 0; font-size: inherit; }
.nr-page-title code { font-size: .8em; }
