/* =========================================================
   Lolipop Collections · Moda juvenil
   Tema basado en el rosado del logo.
   ========================================================= */
:root {
    --bg: #fbf6f9;
    --panel: #ffffff;
    --panel2: #fff7fb;
    --line: #f1dde7;
    --line-strong: #e7c6d7;
    --text: #2d1f27;
    --muted: #8b7280;
    --brand: #c2417f;        /* rosa intenso: botones, títulos (contraste AA con blanco) */
    --brand-dark: #a8336b;
    --brand2: #eb99c2;       /* rosa del logo */
    --brand-soft: #fde9f2;
    --brand-soft2: #fbd6e7;
    --lila: #8e6bbf;
    --lila-soft: #f1ebfa;
    --green: #1f9d63;
    --green-soft: #e6f6ee;
    --amber: #c27c0e;
    --amber-soft: #fff3dc;
    --red: #d0415a;
    --red-soft: #fdeaee;
    --blue: #3867c9;
    --blue-soft: #eaf0fc;
    --shadow: 0 18px 48px rgba(194, 65, 127, .08);
    --shadow-sm: 0 6px 18px rgba(45, 31, 39, .06);
    --focus: 0 0 0 3px rgba(194, 65, 127, .16);
}

* { box-sizing: border-box; }

/* El atributo hidden siempre gana, aunque la clase del elemento defina display. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

.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;
}

body {
    margin: 0;
    font-family: 'Nunito', 'Segoe UI', Arial, sans-serif;
    color: var(--text);
    background: radial-gradient(circle at top right, rgba(235, 153, 194, .18), transparent 28%),
                radial-gradient(circle at bottom left, rgba(142, 107, 191, .08), transparent 24%),
                var(--bg);
    background-attachment: fixed;
    font-size: 0.95rem;
    line-height: 1.45;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

h1, h2, h3, h4 { font-weight: 900; }

img { max-width: 100%; }

/* ===== LAYOUT ===== */
.app-layout {
    display: grid;
    grid-template-columns: 272px minmax(0, 1fr);
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    background: linear-gradient(180deg, #ffffff 0%, #fff1f7 100%);
    border-right: 1px solid var(--line);
    padding: 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 6px 4px 16px;
    border-bottom: 1px solid var(--line);
    text-align: center;
}

.sidebar-brand img {
    width: 100%;
    max-width: 210px;
    height: auto;
    display: block;
}

.sidebar-brand small {
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 800;
}

.nav-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 16px 0 4px;
    padding: 12px 14px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--brand), #de6aa2);
    color: #fff;
    font-weight: 900;
    font-size: 0.95rem;
    box-shadow: 0 10px 24px rgba(194, 65, 127, .25);
    transition: 0.18s ease;
}

.nav-cta:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(194, 65, 127, .32);
}

.nav-cta.active { box-shadow: 0 0 0 3px var(--brand-soft2), 0 10px 24px rgba(194, 65, 127, .25); }

.nav-title {
    margin: 18px 8px 10px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--muted);
    font-weight: 800;
}

.nav-btn {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    padding: 11px 14px;
    border-radius: 14px;
    text-align: left;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 5px;
    transition: 0.18s ease;
    font-size: 0.92rem;
}

.nav-btn:hover, .nav-btn.active {
    background: #fff;
    border-color: var(--line);
    box-shadow: var(--shadow-sm);
    color: var(--brand);
}

.nav-btn .icon { font-size: 1.05rem; width: 1.3em; text-align: center; }

.nav-group { margin-bottom: 5px; }
.nav-group summary { list-style: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group-toggle { justify-content: flex-start; }

.nav-group-toggle::after {
    content: '\25BE';
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--muted);
}

.nav-group:not([open]) .nav-group-toggle::after { content: '\25B8'; }

.nav-submenu {
    margin-top: 4px;
    padding-left: 12px;
    border-left: 2px solid var(--brand-soft);
    margin-left: 14px;
}

.nav-subbtn {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    padding: 9px 12px;
    border-radius: 12px;
    text-align: left;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 3px;
    transition: 0.18s ease;
    font-size: 0.88rem;
}

.nav-subbtn:hover, .nav-subbtn.active {
    background: #fff;
    border-color: var(--line);
    box-shadow: var(--shadow-sm);
    color: var(--brand);
}

.nav-subbtn .icon { font-size: 0.98rem; width: 1.3em; text-align: center; }

.sidebar-footer {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    font-size: 0.74rem;
    color: var(--muted);
    text-align: center;
}

/* ===== MAIN ===== */
.main-content {
    padding: 22px;
    min-width: 0;
}

/* ===== TOPBAR ===== */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.topbar-left h2 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--brand);
}

.topbar-left p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 7px 10px 7px 8px;
}

.user-chip-name { font-weight: 800; font-size: 0.88rem; }
.user-chip-role { font-size: 0.76rem; color: var(--muted); }

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--brand), var(--brand2));
    color: #fff;
    font-weight: 900;
    font-size: 0.82rem;
    flex-shrink: 0;
}

/* ===== CARDS ===== */
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 18px;
    box-shadow: var(--shadow);
    min-width: 0;
}

.card + .card { margin-top: 16px; }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.card-header h3 {
    margin: 0;
    color: var(--brand);
    font-size: 1.1rem;
}

.card-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.section-title {
    margin: 18px 0 10px;
    font-size: 0.8rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
}

/* ===== KPI ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.kpi-card {
    background: linear-gradient(180deg, #fff 0%, #fff7fb 100%);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
    box-shadow: var(--shadow);
    min-width: 0;
}

.kpi-card .label {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 800;
    margin-bottom: 6px;
}

.kpi-card .value {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--brand);
    overflow-wrap: anywhere;
}

.kpi-card .tag {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 900;
    margin-top: 6px;
}

.kpi-card .tag.up { background: var(--green-soft); color: var(--green); }
.kpi-card .tag.down { background: var(--red-soft); color: var(--red); }
.kpi-card .tag.neutral { background: var(--brand-soft); color: var(--brand); }

/* ===== HERO (dashboard) ===== */
.hero {
    background: linear-gradient(135deg, #c2417f 0%, #de6aa2 55%, #eb99c2 100%);
    color: #fff;
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 18px 48px rgba(194, 65, 127, .22);
    margin-bottom: 16px;
}

.hero h2 { margin: 0 0 6px; font-size: 1.55rem; }
.hero p { margin: 0; color: rgba(255, 255, 255, .9); font-size: 0.92rem; }

.hero-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.hero-mini {
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 14px;
    padding: 12px;
    min-width: 0;
}

.hero-mini .label { color: #ffe6f1; font-size: 0.78rem; font-weight: 800; }
.hero-mini .value { font-size: 1.3rem; font-weight: 900; margin-top: 4px; overflow-wrap: anywhere; }

/* ===== TABLES ===== */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 11px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: 0.9rem;
    vertical-align: middle;
}

th {
    background: var(--panel2);
    color: var(--brand);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 900;
    white-space: nowrap;
}

tbody tr:hover td { background: rgba(253, 233, 242, .45); }

th.num, td.num { text-align: right; white-space: nowrap; }
th.center, td.center { text-align: center; }
td.actions { white-space: nowrap; }

tr.row-muted td { color: var(--muted); }
tr.row-muted td strong { color: var(--muted); }

tfoot td {
    font-weight: 900;
    background: var(--panel2);
    border-top: 2px solid var(--line-strong);
}

.cell-sub { color: var(--muted); font-size: 0.8rem; }

/* ===== STATUS / BADGES ===== */
.status, .badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 900;
    white-space: nowrap;
}

.status.ok { background: var(--green-soft); color: var(--green); }
.status.warn { background: var(--amber-soft); color: var(--amber); }
.status.bad { background: var(--red-soft); color: var(--red); }
.status.neutral { background: #f3edf0; color: var(--muted); }
.status.info { background: var(--blue-soft); color: var(--blue); }
.status.pink { background: var(--brand-soft); color: var(--brand); }
.status.lila { background: var(--lila-soft); color: var(--lila); }

.badge-pink { background: var(--brand-soft); color: var(--brand); }
.badge-lila { background: var(--lila-soft); color: var(--lila); }
.badge-gray { background: #f3edf0; color: var(--muted); }

/* ===== BUTTONS ===== */
.btn {
    border: none;
    border-radius: 14px;
    padding: 10px 16px;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    transition: 0.18s ease;
    font-size: 0.88rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; transform: none; pointer-events: none; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }

.btn-outline { background: #fff; border: 1px solid var(--line-strong); color: var(--text); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }

.btn-soft { background: var(--brand-soft); color: var(--brand); }
.btn-soft:hover { background: var(--brand-soft2); color: var(--brand-dark); }

.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #18804f; color: #fff; }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b23349; color: #fff; }

.btn-danger-outline { background: #fff; border: 1px solid #f0bcc6; color: var(--red); }
.btn-danger-outline:hover { background: var(--red-soft); color: var(--red); }

.btn-sm { padding: 7px 12px; font-size: 0.8rem; border-radius: 10px; }
.btn-lg { padding: 14px 22px; font-size: 1rem; border-radius: 16px; }
.btn-block { width: 100%; }

/* ===== TOOLBAR / FILTROS ===== */
.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    align-items: center;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.filters .form-group {
    margin: 0;
    flex: 1 1 170px;
    min-width: 150px;
}

.filters .form-group.grow { flex: 2 1 260px; }
.filters .form-group.narrow { flex: 0 1 150px; }

.filters .filter-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 14px; min-width: 0; }

.form-group label, .form-label {
    display: block;
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 6px;
    font-weight: 800;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    font-size: 0.92rem;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: 0.18s ease;
    min-height: 42px;
}

.form-control:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--focus);
}

.form-control[readonly], .form-control:disabled {
    background: var(--panel2);
    color: var(--muted);
}

textarea.form-control { min-height: 84px; resize: vertical; }
select.form-control { appearance: auto; }

.form-hint { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.form-check label { margin: 0; font-size: 0.9rem; color: var(--text); font-weight: 700; }

input[type="checkbox"], input[type="radio"] {
    accent-color: var(--brand);
    width: 18px;
    height: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 14px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0 14px;
}

.form-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0 14px;
}

.form-grid .span-2, .form-grid-3 .span-2, .form-grid-4 .span-2 { grid-column: span 2; }
.form-grid-3 .span-3, .form-grid-4 .span-4 { grid-column: 1 / -1; }

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-top: 16px;
}

.card-form { max-width: 760px; }

/* ===== SELECT CON BUSCADOR ===== */
.searchable-select {
    position: relative;
    width: 100%;
}

.searchable-select-native { display: none; }

.searchable-select-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(45, 31, 39, .14);
    max-height: 280px;
    overflow-y: auto;
    z-index: 1200;
    display: none;
}

.searchable-select.open { z-index: 1300; }

.searchable-select.invalid .searchable-select-input {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(208, 65, 90, .14);
}
.searchable-select.open .searchable-select-menu { display: block; }

.searchable-select-option,
.searchable-select-empty {
    padding: 10px 14px;
    font-size: 0.9rem;
}

.searchable-select-option {
    cursor: pointer;
    border-bottom: 1px solid rgba(241, 221, 231, .8);
}

.searchable-select-option:last-child { border-bottom: none; }

.searchable-select-option:hover,
.searchable-select-option.active {
    background: var(--brand-soft);
    color: var(--brand);
}

.searchable-select-option.placeholder,
.searchable-select-empty {
    color: var(--muted);
    font-style: italic;
}

/* Tablas con selects con buscador: el menú no se debe recortar. */
.table-wrapper.overflow-visible { overflow: visible; }
.table-wrapper.overflow-visible td { overflow: visible; }

/* ===== RESUMEN / TOTALES ===== */
.summary-box {
    background: var(--panel2);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px 16px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.summary-row span:first-child { color: var(--muted); font-weight: 700; }

.summary-row.total {
    border-top: 1px dashed var(--line-strong);
    margin-top: 6px;
    padding-top: 10px;
    font-size: 1.3rem;
    font-weight: 900;
    color: var(--brand);
}

.summary-row.total span:first-child { color: var(--brand); }

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.info-item .info-label { color: var(--muted); font-size: 0.8rem; font-weight: 800; }
.info-item .info-value { font-weight: 800; overflow-wrap: anywhere; }

/* ===== GRIDS ===== */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: 16px; }
.grid-2 > .card + .card, .grid-3 > .card + .card, .grid-4 > .card + .card, .workspace > .card + .card { margin-top: 0; }

/* ===== MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(45, 31, 39, .5);
    backdrop-filter: blur(4px);
    z-index: 1500;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.show { display: flex; }

.modal-box {
    background: #fff;
    border-radius: 24px;
    padding: 24px;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 24px 64px rgba(45, 31, 39, .22);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

.modal-box h3 { margin: 0 0 12px; color: var(--brand); }

/* ===== ALERTS ===== */
.alert {
    padding: 12px 16px;
    border-radius: 14px;
    margin-bottom: 14px;
    font-size: 0.9rem;
    font-weight: 700;
}

.alert ul { margin: 0; padding-left: 18px; }
.alert-success { background: var(--green-soft); color: var(--green); border: 1px solid #bfe6d1; }
.alert-error { background: var(--red-soft); color: var(--red); border: 1px solid #f3c2cb; }
.alert-warning { background: var(--amber-soft); color: var(--amber); border: 1px solid #f0d89b; }
.alert-info { background: var(--brand-soft); color: var(--brand); border: 1px solid var(--brand-soft2); }

/* ===== LOGIN ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: radial-gradient(circle at top right, rgba(235, 153, 194, .35), transparent 34%),
                radial-gradient(circle at bottom left, rgba(142, 107, 191, .14), transparent 30%),
                var(--bg);
}

.login-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 28px;
    padding: 34px 32px;
    width: 100%;
    max-width: 430px;
    box-shadow: 0 24px 64px rgba(194, 65, 127, .14);
    text-align: center;
}

.login-logo {
    display: block;
    width: 100%;
    max-width: 290px;
    height: auto;
    margin: 0 auto 14px;
}

.login-card h2 { margin: 6px 0 4px; color: var(--brand); }

.login-card .subtitle {
    color: var(--muted);
    margin: 0 0 22px;
    font-size: 0.9rem;
}

.login-card .form-group, .login-card .form-check { text-align: left; }

.login-card .btn-primary {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
}

/* ===== LISTAS ===== */
.activity-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.activity-item:last-child { border-bottom: none; }

.activity-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.activity-info .title { font-weight: 800; font-size: 0.9rem; overflow-wrap: anywhere; }
.activity-info .meta { color: var(--muted); font-size: 0.8rem; }

.empty-state {
    text-align: center;
    padding: 30px 12px;
    color: var(--muted);
}

.empty-state .icon { font-size: 2.2rem; margin-bottom: 6px; }
.empty-state p { margin: 4px 0 12px; }

/* Barras horizontales simples (rankings del dashboard / reportes) */
.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-item .bar-label { display: flex; justify-content: space-between; gap: 10px; font-size: 0.86rem; font-weight: 700; }
.bar-item .bar-track { height: 8px; border-radius: 999px; background: var(--brand-soft); overflow: hidden; margin-top: 4px; }
.bar-item .bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand2)); }

/* ===== PAGINACIÓN ===== */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.pagination-info { color: var(--muted); font-size: 0.84rem; font-weight: 700; }

.pagination-links { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.page-link {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--line-strong);
    background: #fff;
    color: var(--text);
    font-weight: 800;
    font-size: 0.86rem;
}

.page-link:hover { border-color: var(--brand); color: var(--brand); }
.page-link.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.page-link.disabled { opacity: .45; pointer-events: none; }
.page-gap { color: var(--muted); padding: 0 2px; }

/* ===== MENÚ MÓVIL ===== */
.menu-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1100;
    width: 54px;
    height: 54px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), var(--brand2));
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(194, 65, 127, .35);
    align-items: center;
    justify-content: center;
    transition: 0.2s ease;
}

.menu-toggle:hover { transform: scale(1.06); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(45, 31, 39, .45);
    backdrop-filter: blur(3px);
    z-index: 999;
}

/* ===== VALIDACIÓN ===== */
.field-validation-error {
    display: block;
    color: var(--red);
    font-size: 0.8rem;
    margin-top: 4px;
    font-weight: 700;
}

.field-validation-valid { display: none; }
.input-validation-error { border-color: var(--red) !important; }
.validation-summary-valid { display: none; }

/* ===== OVERLAY DE CARGA ===== */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(45, 31, 39, .42);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.loading-overlay.show { display: flex; }

.loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    z-index: 2001;
    overflow: hidden;
    background: rgba(194, 65, 127, .15);
}

.loading-bar .bar {
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, var(--brand), var(--brand2), var(--brand));
    border-radius: 4px;
    animation: loadingSlide 1.2s ease-in-out infinite;
}

@keyframes loadingSlide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

.loading-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 28px 36px;
    box-shadow: 0 24px 64px rgba(45, 31, 39, .2);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.loading-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--line);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-card .loading-text { font-weight: 900; color: var(--brand); font-size: 1rem; }
.loading-card .loading-sub { color: var(--muted); font-size: 0.85rem; }

/* ===== UTILIDADES ===== */
.text-muted { color: var(--muted); }
.text-brand { color: var(--brand); }
.text-success { color: var(--green); }
.text-danger { color: var(--red); }
.text-warning { color: var(--amber); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-small { font-size: 0.82rem; }
.fw-bold { font-weight: 900; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 16px; }
.gap-sm { gap: 8px; }
.d-flex { display: flex; }
.d-inline { display: inline; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hero-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
    .app-layout { grid-template-columns: minmax(0, 1fr); }

    .sidebar {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 285px;
        z-index: 1000;
        box-shadow: 8px 0 32px rgba(45, 31, 39, .2);
    }

    .sidebar.open { display: block; }
    .sidebar-overlay.open { display: block; }
    .menu-toggle { display: flex; }

    .workspace, .grid-3 { grid-template-columns: minmax(0, 1fr); }
    .form-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .topbar { flex-wrap: wrap; }
}

@media (max-width: 720px) {
    .main-content { padding: 16px; }
    .kpi-grid, .hero-grid, .grid-2, .grid-4 { grid-template-columns: minmax(0, 1fr); }
    .form-grid, .form-grid-3, .form-grid-4 { grid-template-columns: minmax(0, 1fr); }
    .form-grid .span-2, .form-grid-3 .span-2, .form-grid-4 .span-2 { grid-column: auto; }
    .topbar-right { width: 100%; }
    .user-chip { width: 100%; }
    .user-chip form { margin-left: auto !important; }
    .form-actions .btn { flex: 1 1 auto; }
    .card { padding: 14px; border-radius: 16px; }
    .login-card { padding: 26px 20px; }
}

/* ===== IMPRESIÓN ===== */
@media print {
    .sidebar, .menu-toggle, .sidebar-overlay, .topbar-right, .toolbar, .filters, .form-actions, .btn, .pagination { display: none !important; }
    .app-layout { display: block; }
    .main-content { padding: 0; }
    body { background: #fff; }
    .card, .kpi-card { box-shadow: none; }
}
