/* ==========================================================================
   HIPPO Control · Branding Grupo HYCSA
   Paleta:
     #FACD01  Amarillo HYCSA   (acento, énfasis — nunca texto largo)
     #292929  Negro Carbón     (títulos, fondos de portada)
     #54565A  Gris Grafito     (cuerpo de texto)
     #FFFFFF  Blanco           (fondo principal)
   Tipografía: Calibri (fallback Helvetica Neue, Helvetica, Arial)
   ========================================================================== */

:root {
    /* Marca */
    --brand-yellow:        #FACD01;
    --brand-yellow-hover:  #E8BE01;
    --brand-yellow-soft:   #FFF6CC;
    --brand-black:         #292929;
    --brand-black-hover:   #1a1a1a;
    --brand-gray:          #54565A;
    --brand-gray-soft:     #54565A99;

    /* Superficies */
    --bg:           #FFFFFF;
    --surface:      #FFFFFF;
    --surface-alt:  #FAFAF7;
    --border:       #E8E8E0;
    --border-strong:#D8D8D0;
    --card-bg:      #FFFFFF;

    /* Texto */
    --text:         #292929;
    --text-soft:    #54565A;
    --text-muted:   #54565A99;

    /* Estados */
    --danger:  #DC2626;
    --success: #16A34A;
    --warning: #D97706;
    --info:    #2563EB;

    /* Aliases (para código existente que usa los nombres viejos) */
    --primary:       #FACD01;
    --primary-hover: #E8BE01;
    --muted:         #54565A;

    /* UI */
    --shadow:
        0 1px 2px rgba(41, 41, 41, 0.04),
        0 1px 3px rgba(41, 41, 41, 0.06);
    --shadow-lg:
        0 10px 15px -3px rgba(41, 41, 41, 0.07),
        0 4px 6px -2px rgba(41, 41, 41, 0.04);
    --radius:    6px;
    --radius-lg: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Calibri", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-black); }
a:hover { color: var(--brand-black-hover); }

/* ==========================================================================
   Logo
   ========================================================================== */
.brand-logo {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none; color: inherit;
}
.brand-logo img {
    height: 36px;
    width: auto;
    display: block;
}
.brand-logo .brand-text-fallback {
    display: none;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.01em;
    color: var(--brand-black);
}
.brand-logo img.broken { display: none; }
.brand-logo img.broken + .brand-text-fallback { display: inline-block; }
.brand-logo .brand-text-fallback .accent { color: var(--brand-yellow); }

/* ==========================================================================
   Login
   ========================================================================== */
.login-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at 20% 0%, rgba(250, 205, 1, 0.08), transparent 40%),
        radial-gradient(circle at 80% 100%, rgba(41, 41, 41, 0.04), transparent 40%),
        var(--bg);
}

.login-card {
    background: var(--surface);
    padding: 36px 32px 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border);
    border-top: 3px solid var(--brand-yellow);
}

.login-card .login-logo {
    text-align: center;
    margin-bottom: 24px;
}
.login-card .login-logo img {
    height: 48px;
    width: auto;
}

.login-card h1 {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 700;
    color: var(--brand-black);
    text-align: center;
}

.login-card .sub {
    color: var(--text-soft);
    margin: 0 0 24px;
    font-size: 13px;
    text-align: center;
}

/* ==========================================================================
   Form controls
   ========================================================================== */
.field {
    display: block;
    margin-bottom: 14px;
}

.field label {
    display: block;
    margin-bottom: 4px;
    font-weight: 700;
    font-size: 12px;
    color: var(--brand-black);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 9px 11px;
    font-size: 14px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    transition: border 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--brand-yellow);
    box-shadow: 0 0 0 3px rgba(250, 205, 1, 0.25);
}

button, .btn {
    cursor: pointer;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    transition: background 0.15s, border 0.15s, transform 0.05s;
}

button:hover, .btn:hover { background: var(--surface-alt); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-sm {
    font-size: 12px;
    padding: 4px 10px;
}

.btn-primary {
    background: var(--brand-yellow);
    color: var(--brand-black);
    border-color: var(--brand-yellow);
    font-weight: 700;
}
.btn-primary:hover {
    background: var(--brand-yellow-hover);
    border-color: var(--brand-yellow-hover);
}

.btn-dark {
    background: var(--brand-black);
    color: #fff;
    border-color: var(--brand-black);
}
.btn-dark:hover {
    background: var(--brand-black-hover);
    border-color: var(--brand-black-hover);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-block { width: 100%; }

.alert {
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 14px;
}

.alert-error {
    background: #FEF2F2;
    color: var(--danger);
    border: 1px solid #FECACA;
}

/* ==========================================================================
   App shell
   ========================================================================== */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 0 var(--brand-yellow);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-header .brand {
    display: flex; align-items: center; gap: 10px;
}

.app-header .user-info {
    display: flex; align-items: center; gap: 12px;
    font-size: 13px;
    color: var(--text-soft);
}

.app-layout {
    display: flex;
    min-height: calc(100vh - 71px);
}

.app-nav {
    width: 230px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 0 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.app-nav .nav-section {
    padding: 16px 22px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--brand-yellow);
}

.app-nav hr {
    margin: 10px 22px;
    border: none;
    border-top: 1px solid var(--border);
}

.app-nav a {
    display: block;
    padding: 9px 22px;
    color: var(--text-soft);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.app-nav a:hover {
    background: var(--surface-alt);
    color: var(--brand-black);
}

.app-nav a.active {
    border-left-color: var(--brand-yellow);
    background: var(--surface-alt);
    color: var(--brand-black);
    font-weight: 700;
}

.app-content {
    flex: 1;
    padding: 28px;
    overflow-x: auto;
    background: var(--bg);
}

.app-content h2 {
    margin: 0 0 20px;
    font-size: 22px;
    font-weight: 700;
    color: var(--brand-black);
    letter-spacing: -0.01em;
    position: relative;
    padding-bottom: 10px;
}
.app-content h2::after {
    content: "";
    position: absolute;
    left: 0; bottom: 0;
    width: 38px; height: 3px;
    background: var(--brand-yellow);
    border-radius: 2px;
}

/* ==========================================================================
   Tablas
   ========================================================================== */
table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

table.data th, table.data td {
    padding: 10px 12px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

table.data th {
    background: var(--surface-alt);
    font-weight: 700;
    color: var(--brand-black);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 11px;
    border-bottom: 2px solid var(--border-strong);
    text-align: center;
}

table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fafaf3; }

table.data strong { color: var(--brand-black); font-weight: 700; }

.toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}

.toolbar .spacer { flex: 1; }

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-green  { background: #DCFCE7; color: #166534; }
.badge-red    { background: #FEE2E2; color: #991B1B; }
.badge-gray   { background: #E5E7EB; color: var(--brand-gray); }
.badge-yellow { background: var(--brand-yellow-soft); color: var(--brand-black); }
.badge-blue   { background: #DBEAFE; color: #1E40AF; }

/* ==========================================================================
   Filtros
   ========================================================================== */
.filters {
    background: var(--surface-alt);
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex; gap: 10px; align-items: end; flex-wrap: wrap;
    margin-bottom: 14px;
}
.filters .field { margin-bottom: 0; flex: 0 0 auto; }
.filters .field input, .filters .field select { min-width: 140px; }
.filters .field.search input { min-width: 240px; }

/* ==========================================================================
   Empty state, spinner
   ========================================================================== */
/* ── Domain Selector Cards ── */
.domain-card:hover {
    border-color: var(--brand-yellow) !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

/* ── Empty state ── */
.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 14px;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--brand-yellow);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Skeleton screen / loading placeholder
   ========================================================================== */
@keyframes shimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}
.skeleton {
    background: var(--surface-alt);
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
}
.skeleton::after {
    content: "";
    position: absolute; inset: 0;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255,255,255,0.25) 50%,
        transparent 100%);
    background-size: 800px 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}
.skeleton-table {
    display: flex; flex-direction: column; gap: 8px;
    padding: 16px;
}
.skeleton-row {
    display: flex; gap: 12px; align-items: center;
}
.skeleton-cell {
    height: 14px;
    background: var(--border);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}
.skeleton-cell::after {
    content: "";
    position: absolute; inset: 0;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255,255,255,0.3) 50%,
        transparent 100%);
    background-size: 800px 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}
.skeleton-cell:nth-child(1) { width: 8%; }
.skeleton-cell:nth-child(2) { width: 22%; }
.skeleton-cell:nth-child(3) { width: 15%; }
.skeleton-cell:nth-child(4) { width: 12%; }
.skeleton-cell:nth-child(5) { width: 18%; }
.skeleton-cell:nth-child(6) { width: 10%; }
.skeleton-header .skeleton-cell { height: 18px; background: var(--text-muted); }
.skeleton-card {
    height: 80px; margin-bottom: 12px;
    border-radius: var(--radius);
    position: relative; overflow: hidden;
    background: var(--surface-alt);
}
.skeleton-card::after {
    content: "";
    position: absolute; inset: 0;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255,255,255,0.25) 50%,
        transparent 100%);
    background-size: 800px 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}
.skeleton-title {
    height: 24px; width: 40%; margin-bottom: 16px;
    background: var(--border); border-radius: 4px;
    position: relative; overflow: hidden;
}
.skeleton-title::after {
    content: "";
    position: absolute; inset: 0;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255,255,255,0.3) 50%,
        transparent 100%);
    background-size: 800px 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

/* ==========================================================================
   Stats cards
   ========================================================================== */
.stats-bar {
    display: flex; gap: 12px; flex-wrap: wrap;
    margin-bottom: 16px;
}
.stat-card {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 18px;
    min-width: 120px;
    border-top: 2px solid var(--brand-yellow);
}
.stat-card .stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-soft);
    font-weight: 700;
}
.stat-card .stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--brand-black);
    margin-top: 2px;
    letter-spacing: -0.02em;
}

/* ==========================================================================
   Modal
   ========================================================================== */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(41, 41, 41, 0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 760px;
    max-height: 90vh;
    display: flex; flex-direction: column;
    border-top: 3px solid var(--brand-yellow);
}
.modal-header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 {
    margin: 0; font-size: 16px; font-weight: 700;
    color: var(--brand-black);
}
.modal-close {
    background: none; border: none; font-size: 24px; cursor: pointer;
    color: var(--text-soft); padding: 0 4px; line-height: 1;
}
.modal-close:hover { color: var(--brand-black); }
.modal-body {
    padding: 22px;
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    display: flex; gap: 8px; justify-content: flex-end;
    background: var(--surface-alt);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ==========================================================================
   Form grid
   ========================================================================== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px 16px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-section-title {
    grid-column: 1 / -1;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--brand-black);
    border-bottom: 2px solid var(--brand-yellow);
    padding-bottom: 4px;
    margin-top: 8px;
    font-weight: 700;
    width: max-content;
    min-width: 140px;
}
.field-inline {
    display: flex; align-items: center; gap: 8px;
    grid-column: 1 / -1;
}

/* ==========================================================================
   Toast
   ========================================================================== */
.toast-wrap {
    position: fixed; bottom: 20px; right: 20px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 2000;
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left-width: 4px;
    box-shadow: var(--shadow-lg);
    padding: 11px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    min-width: 260px;
    max-width: 420px;
    animation: slidein 0.2s ease-out;
    color: var(--brand-black);
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.info    { border-left-color: var(--brand-yellow); }
@keyframes slidein {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ==========================================================================
   Egresos / Categorías
   ========================================================================== */
.cat-chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.stack-bar {
    display: flex;
    width: 100%;
    height: 14px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--border);
    margin-bottom: 8px;
}
.stack-bar > div { transition: opacity 0.15s; }
.stack-bar > div:hover { opacity: 0.85; }
.stack-legend {
    display: flex; flex-wrap: wrap; gap: 12px;
    font-size: 12px; color: var(--text-soft);
    margin-bottom: 16px;
}
.stack-legend .legend-item {
    display: flex; align-items: center; gap: 6px;
}
.stack-legend .swatch {
    display: inline-block; width: 10px; height: 10px; border-radius: 2px;
}

/* ==========================================================================
   Reportes diarios — paro rows
   ========================================================================== */
.paro-row {
    display: flex; gap: 8px; align-items: center;
    margin-bottom: 6px;
}
.paro-row select { flex: 1; }

/* ==========================================================================
   Dashboard
   ========================================================================== */
.dash-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-top: 8px;
}
.dash-grid > .dash-card:nth-child(1) { grid-column: 1 / -1; }
.dash-grid > .dash-card:nth-child(2),
.dash-grid > .dash-card:nth-child(3) { grid-column: span 1; }
.dash-grid > .dash-card:nth-child(4),
.dash-grid > .dash-card:nth-child(5) { grid-column: span 1; }
/* OEE cards — ocupan todo el ancho */
.dash-grid > .dash-card:nth-child(6),
.dash-grid > .dash-card:nth-child(7) { grid-column: 1 / -1; }

@media (max-width: 900px) {
    .dash-grid { grid-template-columns: 1fr; }
}

.dash-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    border-top: 2px solid var(--brand-yellow);
}
.dash-card-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--brand-black);
    font-weight: 700;
    margin-bottom: 12px;
}
.dash-canvas-wrap {
    position: relative;
    height: 280px;
    width: 100%;
}

/* ==========================================================================
   Exports
   ========================================================================== */
.exp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.exp-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 2px solid var(--brand-yellow);
    border-radius: var(--radius);
    padding: 16px;
    display: flex; flex-direction: column; gap: 10px;
}
.exp-title {
    font-weight: 700; color: var(--brand-black);
    font-size: 14px;
}
.exp-url {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px; color: var(--text-soft);
    word-break: break-all;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.exp-actions { display: flex; gap: 6px; }
.exp-actions .btn-primary { padding: 7px 12px; font-size: 13px; text-decoration: none; }

.exp-help {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-left: 3px solid var(--brand-yellow);
    border-radius: var(--radius);
    padding: 16px 20px;
}
.exp-help h3 { margin: 0 0 10px; font-size: 15px; color: var(--brand-black); }
.exp-help ol { margin: 0; padding-left: 20px; line-height: 1.7; color: var(--text-soft); font-size: 13px; }
.exp-help code { background: var(--surface); padding: 1px 6px; border-radius: 3px; border: 1px solid var(--border); font-size: 12px; }

/* Score / Method badges */
.score-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.score-high { background: #05967015; color: #059669; }
.score-mid  { background: #d9770615; color: #d97706; }
.score-low  { background: #dc262615; color: #dc2626; }

.method-badge { font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 10px; }
.method-manual   { background: #6b728015; color: #6b7280; }
.method-promedio { background: #2563eb15; color: #2563eb; }
.method-ml       { background: #7c3aed15; color: #7c3aed; }

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
}
.tab {
    padding: 10px 24px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-soft);
    cursor: pointer;
    transition: all 0.15s;
}
.tab:hover { color: var(--brand-black); }
.tab.active {
    color: var(--brand-black);
    border-bottom-color: var(--brand-yellow);
}

/* ==========================================================================
   Resumen mensual (conciliaciones)
   ========================================================================== */
.rm-header {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}
.rm-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}
.rm-header-title h3 {
    margin: 0;
    font-size: 17px;
    color: var(--brand-black);
}
.rm-header-num {
    background: var(--brand-yellow);
    color: var(--brand-black);
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}
.rm-header-stats {
    display: flex;
    gap: 20px;
    align-items: center;
}
.rm-stat {
    text-align: center;
}
.rm-stat-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--brand-black);
    line-height: 1.2;
}
.rm-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-soft);
}
.rm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 12px;
}
.rm-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
    position: relative;
}
.rm-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}
.rm-card-bar {
    height: 4px;
    background: var(--rm-color, var(--border));
    width: 100%;
}
.rm-card-body {
    padding: 16px 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.rm-card-month {
    font-size: 15px;
    font-weight: 700;
    color: var(--brand-black);
    letter-spacing: -0.01em;
}
.rm-card-year {
    font-size: 11px;
    color: var(--text-soft);
    margin-top: -4px;
}
.rm-card-progress-wrap {
    display: flex;
    justify-content: center;
    margin: 4px 0 2px;
}
.rm-card-progress-wrap svg {
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.06));
}
.rm-card-count {
    text-align: center;
    font-size: 12px;
    color: var(--text-soft);
}
.rm-card-count-num {
    font-weight: 700;
    color: var(--brand-black);
    font-size: 14px;
}
.rm-card-total {
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--brand-black);
    background: var(--surface-alt);
    border-radius: 6px;
    padding: 4px 8px;
    margin-top: 2px;
}
.rm-card-faltantes {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}
.rm-card-faltantes-label {
    font-size: 11px;
    color: var(--text-soft);
    width: 100%;
}
.rm-card-faltante-chip {
    display: inline-block;
    background: #fef2f2;
    color: #dc2626;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
}
.rm-card-completo {
    text-align: center;
    font-size: 13px;
    color: #22c55e;
    font-weight: 600;
    margin-top: 4px;
    padding: 4px 0;
}
.rm-leyenda {
    font-size: 12px;
    color: var(--text-soft);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding: 10px 0 4px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

/* ==========================================================================
   CAT Telematics
   ========================================================================== */
.cat-header {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.cat-header-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-top: 2px solid var(--brand-yellow);
}
.cat-hc-icon {
    font-size: 22px;
}
.cat-hc-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-soft);
    font-weight: 600;
}
.cat-hc-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--brand-black);
}
.cat-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* Mapa CAT */
#cat-map {
    z-index: 1;
    background: var(--surface);
}
#cat-map .leaflet-popup-content {
    font-size: 13px;
    line-height: 1.5;
    min-width: 160px;
}
#cat-map .leaflet-popup-content button {
    background: var(--brand-yellow);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
}
#cat-map .leaflet-popup-content button:hover {
    background: var(--brand-yellow-hover);
}
#map-legend span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* ==========================================================================
   KPI Dashboard
   ========================================================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.kpi-value {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
}
.kpi-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--brand-black);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.kpi-subtitle {
    font-size: 11px;
    color: var(--text-soft);
}
.kpi-row-danger {
    background: #fef2f2 !important;
}
.kpi-row-warn {
    background: #fffbeb !important;
}
.kpi-row-danger:hover,
.kpi-row-warn:hover {
    filter: brightness(0.97);
}

/* ==========================================================================
   Warehouse Dashboard — Almacén
   ========================================================================== */

/* Alertas */
.wh-alerts { margin-bottom: 16px; }
.wh-alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 6px;
    border: 1px solid;
    font-weight: 500;
}
.wh-alert strong { font-weight: 700; }
.wh-alert-danger {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}
.wh-alert-warn {
    background: #fffbeb;
    color: #b45309;
    border-color: #fde68a;
}
.wh-alert-info {
    background: #f8fafc;
    color: #54565a;
    border-color: #e2e8f0;
}

/* KPIs */
.wh-kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 16px 14px;
    text-align: center;
    transition: transform 0.12s, box-shadow 0.12s;
    position: relative;
    overflow: hidden;
}
.wh-kpi::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}
.wh-kpi-neutral::before { background: var(--border); }
.wh-kpi-danger::before { background: #dc2626; }
.wh-kpi-accent::before { background: var(--brand-yellow); }
.wh-kpi:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}
.wh-kpi-value {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}
.wh-kpi-neutral .wh-kpi-value { color: var(--brand-black); }
.wh-kpi-danger .wh-kpi-value { color: #dc2626; }
.wh-kpi-accent .wh-kpi-value { color: var(--brand-black); }
.wh-kpi-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-soft);
}

/* Caja de stock crítico */
.wh-critbox {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #dc2626;
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 20px;
}
.wh-critbox-title {
    font-weight: 700;
    color: #dc2626;
    font-size: 13px;
    margin-bottom: 10px;
}
.wh-critbox-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.wh-critbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #fecaca;
    font-size: 12px;
}
.wh-critbox-sku {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 11px;
    color: var(--text-soft);
    min-width: 100px;
}
.wh-critbox-name { flex: 1; font-weight: 600; color: var(--brand-black); }
.wh-critbox-stock {
    display: flex; gap: 8px; align-items: center;
}
.wh-stock-badge {
    background: #fef2f2;
    color: #dc2626;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 11px;
}
.wh-min-badge {
    background: #f3f4f6;
    color: #6b7280;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 11px;
}

/* Secciones del dashboard */
.wh-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}
.wh-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    border-top: 3px solid var(--brand-yellow);
}
.wh-section-wide { grid-column: 1 / -1; }
.wh-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--brand-black);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.wh-section .data { margin-bottom: 0; }
.wh-section .data th {
    font-size: 10px;
    padding: 7px 10px;
}
.wh-section .data td {
    padding: 8px 10px;
    font-size: 12px;
}

/* Gráfica de consumo */
.wh-chart-wrap {
    margin-top: 8px;
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-top: 3px solid var(--brand-yellow);
}
.wh-chart-wrap .wh-section-title { margin-bottom: 4px; }
.wh-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 120px;
    padding: 12px 0 4px;
    border-bottom: 1px solid var(--border);
    margin-top: 12px;
}
.wh-bar {
    flex: 1;
    min-width: 6px;
    background: linear-gradient(180deg, #facc15 0%, #eab308 100%);
    border-radius: 3px 3px 0 0;
    transition: opacity 0.15s;
    cursor: help;
}
.wh-bar:hover { opacity: 0.8; }
.wh-chart-legend {
    display: flex;
    gap: 16px;
    font-size: 11px;
    color: var(--text-soft);
    margin-top: 8px;
    padding: 8px 4px;
}
.wh-chart-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.wh-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: linear-gradient(180deg, #facc15 0%, #eab308 100%);
    border-radius: 2px;
}

/* Responsive */
@media (max-width: 800px) {
    .wh-sections { grid-template-columns: 1fr; }
}

/* ==========================================================================
   ============================================================================
   HIPPO DESIGN SYSTEM  ·  v1  (prefijo `ds-`)
   ----------------------------------------------------------------------------
   Lenguaje visual estándar. Marca HYCSA (amarillo #FACD01 + Calibri) sobre la
   estructura del rediseño: lienzo en capas, tarjetas, chips, micro-animaciones.
   Opt-in: las clases `ds-*` no tocan el CSS existente. Toda pantalla nueva o
   modificada debe construirse con este sistema + `js/ds.js`.
   Documentación y reglas: ver frontend/DESIGN.md
   ============================================================================
   ========================================================================== */

:root {
    /* Lienzo en capas (HYCSA neutro) */
    --ds-bg:        #F7F7F2;   /* canvas (detrás de las tarjetas)            */
    --ds-panel:     #FFFFFF;   /* superficie de tarjeta                      */
    --ds-panel-2:   #FAFAF5;   /* superficie hundida (chips, thead, tiles)   */
    --ds-line:      #E8E8E0;   /* borde hairline                             */
    --ds-line-2:    #D8D8D0;   /* borde fuerte                               */

    /* Tinta (escala de grises de marca) */
    --ds-ink:   #292929;   /* títulos / números grandes   (brand-black) */
    --ds-ink-2: #3F4146;   /* cuerpo enfatizado                          */
    --ds-ink-3: #6B6D72;   /* texto secundario / labels                  */
    --ds-ink-4: #9A9CA1;   /* texto terciario / ejes                     */

    /* Acento de marca */
    --ds-accent:        #FACD01;   /* = --brand-yellow */
    --ds-accent-hover:  #E8BE01;
    --ds-accent-soft:   #FFF6CC;
    --ds-accent-ink:    #6E5A00;   /* texto sobre soft amarillo (contraste) */

    /* Estados (alineados con la app) */
    --ds-good:      #16A34A;  --ds-good-soft: #E6F6EC;
    --ds-bad:       #DC2626;  --ds-bad-soft:  #FCE9E7;
    --ds-warn:      #D97706;  --ds-warn-soft: #FCEFD6;
    --ds-info:      #2563EB;  --ds-info-soft: #E4ECFD;

    /* Forma y elevación */
    --ds-r-sm: 8px;
    --ds-r:    12px;
    --ds-r-lg: 14px;
    --ds-shadow:    0 1px 2px rgba(41,41,41,.05), 0 1px 3px rgba(41,41,41,.06);
    --ds-shadow-lg: 0 8px 24px -12px rgba(41,41,41,.22);
    --ds-ease: cubic-bezier(.2,.7,.2,1);
}

/* Tema oscuro — variables listas (sin toggle aún; activar con
   <html data-theme="dark"> o body.ds-dark cuando se decida). */
[data-theme="dark"], .ds-dark {
    --ds-bg:        #0E0F12;
    --ds-panel:     #16181D;
    --ds-panel-2:   #1B1E24;
    --ds-line:      #262A32;
    --ds-line-2:    #313641;
    --ds-ink:       #ECEDF1;
    --ds-ink-2:     #C2C5CD;
    --ds-ink-3:     #8C909B;
    --ds-ink-4:     #5E626E;
    --ds-accent:      #F7C948;
    --ds-accent-hover:#F0B429;
    --ds-accent-soft: #2A2410;
    --ds-accent-ink:  #F7C948;
    --ds-good: #34D399; --ds-good-soft: #102A20;
    --ds-bad:  #F87171; --ds-bad-soft:  #2C1416;
    --ds-warn: #F59E0B; --ds-warn-soft: #2A1F0A;
    --ds-info: #60A5FA; --ds-info-soft: #122036;
}

/* ── Tipografía utilitaria ────────────────────────────────────────────────── */
/* Calibri con figuras tabulares para métricas alineadas. */
.ds-num {
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

/* ── Lienzo de pantalla ───────────────────────────────────────────────────── */
.ds-screen {
    background: var(--ds-bg);
    min-height: 100%;
    margin: -28px;            /* sangra el padding de .app-content */
    color: var(--ds-ink);
}
.ds-screen-body {
    padding: 24px 28px 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── Encabezado de pantalla ───────────────────────────────────────────────── */
.ds-screen-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--ds-bg);
    border-bottom: 1px solid var(--ds-line);
    padding: 22px 28px 16px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
}
.ds-sh-titles { flex: 1 1 240px; }
.ds-sh-icon {
    width: 38px; height: 38px;
    border-radius: var(--ds-r-sm);
    display: flex; align-items: center; justify-content: center;
    background: var(--ds-ink);
    color: #FFF;
    flex-shrink: 0;
    font-size: 18px;
}
.ds-sh-titles { min-width: 0; }
.ds-sh-titlerow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ds-sh-title {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--ds-ink);
    line-height: 1.1;
}
.ds-sh-sub {
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--ds-ink-3);
}
.ds-sh-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── Tarjeta ──────────────────────────────────────────────────────────────── */
.ds-card {
    background: var(--ds-panel);
    border: 1px solid var(--ds-line);
    border-radius: var(--ds-r-lg);
    padding: 16px;
}
.ds-card-hairline {
    background: var(--ds-panel);
    border: 1px solid var(--ds-line);
    border-radius: var(--ds-r);
}
.ds-lift { transition: transform .25s var(--ds-ease), box-shadow .25s, border-color .25s; }
.ds-lift:hover { transform: translateY(-2px); box-shadow: var(--ds-shadow-lg); }

/* ── Rejillas ─────────────────────────────────────────────────────────────── */
.ds-grid { display: grid; gap: 14px; }
.ds-grid-2 { grid-template-columns: repeat(2, 1fr); }
.ds-grid-3 { grid-template-columns: repeat(3, 1fr); }
.ds-grid-4 { grid-template-columns: repeat(4, 1fr); }
.ds-grid-5 { grid-template-columns: repeat(5, 1fr); }
.ds-col-2 { grid-column: span 2; }
@media (max-width: 1100px) {
    .ds-grid-4, .ds-grid-5 { grid-template-columns: repeat(2, 1fr); }
    .ds-grid-3 { grid-template-columns: 1fr; }
    .ds-col-2 { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
    .ds-grid-2, .ds-grid-4, .ds-grid-5 { grid-template-columns: 1fr; }
}

/* ── KPI hero card ────────────────────────────────────────────────────────── */
.ds-kpi { position: relative; overflow: hidden; }
.ds-kpi-top { display: flex; align-items: flex-start; justify-content: space-between; }
.ds-kpi-icon {
    width: 28px; height: 28px;
    border-radius: var(--ds-r-sm);
    display: flex; align-items: center; justify-content: center;
    background: var(--ds-panel-2);
    border: 1px solid var(--ds-line);
}
.ds-kpi-label {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ds-ink-3);
}
.ds-kpi-valuerow { margin-top: 12px; display: flex; align-items: baseline; gap: 6px; white-space: nowrap; overflow: hidden; }
.ds-kpi-value { font-size: 30px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.ds-kpi-suffix { font-size: 14px; font-weight: 600; opacity: .82; }
.ds-kpi-foot { margin-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 20px; font-size: 12px; color: var(--ds-ink-3); }
.ds-trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; margin-right: 8px; }
.ds-trend-up { color: var(--ds-good); }
.ds-trend-down { color: var(--ds-bad); }

/* ── Stat tile ────────────────────────────────────────────────────────────── */
.ds-stat { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.ds-stat-icon {
    width: 28px; height: 28px; flex-shrink: 0;
    border-radius: var(--ds-r-sm);
    display: flex; align-items: center; justify-content: center;
    background: var(--ds-panel-2);
    border: 1px solid var(--ds-line);
}
.ds-stat-label { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ds-ink-3); }
.ds-stat-value { font-size: 16px; font-weight: 800; line-height: 1.2; color: var(--ds-ink); }

/* ── Metric card ──────────────────────────────────────────────────────────── */
.ds-metric-top { display: flex; align-items: center; justify-content: space-between; }
.ds-metric-body { margin-top: 12px; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.ds-metric-value { font-size: 26px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.ds-metric-sub { font-size: 11.5px; margin-top: 6px; color: var(--ds-ink-3); }

/* ── Chips ────────────────────────────────────────────────────────────────── */
.ds-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
}
.ds-chip-good    { background: var(--ds-good-soft); color: var(--ds-good); }
.ds-chip-bad     { background: var(--ds-bad-soft);  color: var(--ds-bad); }
.ds-chip-warn    { background: var(--ds-warn-soft); color: var(--ds-warn); }
.ds-chip-info    { background: var(--ds-info-soft); color: var(--ds-info); }
.ds-chip-hippo   { background: var(--ds-accent-soft); color: var(--ds-accent-ink); }
.ds-chip-neutral { background: var(--ds-panel-2); color: var(--ds-ink-3); border: 1px solid var(--ds-line); }
.ds-dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }

/* ── Botón ghost (complementa los .btn-* de marca existentes) ─────────────── */
.btn-ghost {
    background: var(--ds-panel);
    color: var(--ds-ink-2);
    border-color: var(--ds-line-2);
}
.btn-ghost:hover { background: var(--ds-panel-2); border-color: var(--ds-line-2); }
.btn .ds-i, .btn-ghost .ds-i { display: inline-flex; vertical-align: -2px; margin-right: 6px; }

/* ── Tabs con subrayado animado ───────────────────────────────────────────── */
.ds-tabs { position: relative; display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--ds-line); }
.ds-tab {
    position: relative;
    padding: 10px 14px;
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 13.5px; font-weight: 700;
    color: var(--ds-ink-3);
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: color .15s;
}
.ds-tab:hover { background: transparent; color: var(--ds-ink-2); }
.ds-tab.active { color: var(--ds-ink); }
.ds-tab-count { font-size: 10.5px; font-weight: 800; padding: 1px 6px; border-radius: 6px; background: var(--ds-line); color: var(--ds-ink-3); }
.ds-tab.active .ds-tab-count { background: var(--ds-ink); color: #FFF; }
.ds-tab-ink { position: absolute; bottom: -1px; height: 2px; background: var(--ds-ink); transition: transform .35s var(--ds-ease), width .35s var(--ds-ease); }

/* ── Barra de cobertura segmentada ────────────────────────────────────────── */
.ds-cov { width: 100%; display: flex; border-radius: 999px; overflow: hidden; background: var(--ds-line); }
.ds-cov-seg { height: 100%; }

/* ── Barra de progreso (top offenders, presupuesto, etc.) ─────────────────── */
.ds-bar-track { height: 4px; border-radius: 999px; overflow: hidden; background: var(--ds-line); }
.ds-bar-fill { height: 100%; border-radius: 999px; transform-origin: left; }

/* ── Heat strip (cobertura por día) ───────────────────────────────────────── */
.ds-heat { display: flex; align-items: flex-end; gap: 3px; }
.ds-heat-cell { width: 16px; height: 38px; border-radius: 3px; cursor: default; transition: transform .15s; }
.ds-heat-cell:hover { transform: scaleY(1.08); }

/* ── Divisor ──────────────────────────────────────────────────────────────── */
.ds-divider { height: 1px; background: var(--ds-line); border: 0; margin: 0; }

/* ── Animaciones ──────────────────────────────────────────────────────────── */
@keyframes dsRise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.ds-rise { animation: dsRise .55s var(--ds-ease) both; }

@keyframes dsDrawLine { to { stroke-dashoffset: 0; } }
.ds-draw-line { stroke-dasharray: 600; stroke-dashoffset: 600; animation: dsDrawLine 1.4s var(--ds-ease) .15s forwards; }

@keyframes dsFillArea { from { opacity: 0; } to { opacity: 1; } }
.ds-fill-area { opacity: 0; animation: dsFillArea .7s ease .9s forwards; }

@keyframes dsGrowBar { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.ds-grow-bar { transform-origin: bottom; animation: dsGrowBar .8s var(--ds-ease) both; }

@keyframes dsGrowX { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@keyframes dsPulse {
    0%   { box-shadow: 0 0 0 0 rgba(22,163,74,.5); }
    70%  { box-shadow: 0 0 0 9px rgba(22,163,74,0); }
    100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); }
}
.ds-pulse { animation: dsPulse 1.8s infinite; }
@keyframes dsPulseRed {
    0%   { box-shadow: 0 0 0 0 rgba(220,38,38,.5); }
    70%  { box-shadow: 0 0 0 9px rgba(220,38,38,0); }
    100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); }
}
.ds-pulse-red { animation: dsPulseRed 1.6s infinite; }

/* ── Andon badge (parpadeo crítico para reportes pendientes) ──────────── */
.nav-andon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #DC2626;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    margin-left: auto;
    animation: andonBlink 1.2s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.6);
    transition: none;
}
@keyframes andonBlink {
    0%   { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(220,38,38,.6); }
    50%  { opacity: .3; transform: scale(.85); box-shadow: 0 0 0 6px rgba(220,38,38,0); }
    100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(220,38,38,.6); }
}
.nav-andon.off {
    animation: none;
    opacity: .6;
}
.app-nav.collapsed .nav-andon {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 8px;
    height: 8px;
    padding: 0;
    font-size: 0;
    border-radius: 50%;
}

/* Andon en botones (Cumplimiento) */
.cumpl-andon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: #DC2626;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    line-height: 1;
    margin-left: 4px;
    animation: andonBlink 1.2s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.6);
    vertical-align: middle;
    position: relative;
    top: -1px;
}

@keyframes dsSpin { to { transform: rotate(360deg); } }
.ds-spin { animation: dsSpin 6s linear infinite; transform-origin: center; }

@media (prefers-reduced-motion: reduce) {
    .ds-rise, .ds-draw-line, .ds-fill-area, .ds-grow-bar,
    .ds-pulse, .ds-pulse-red, .ds-spin { animation: none !important; }
    .ds-draw-line { stroke-dashoffset: 0; }
    .ds-fill-area { opacity: 1; }
}

/* ==========================================================================
   Sidebar colapsable ("slide del menú")
   ========================================================================== */
.app-nav {
    transition: width .22s var(--ds-ease, ease);
    overflow: hidden;
}
.app-nav .nav-links {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Toggle */
.nav-toggle {
    position: relative;
    align-self: flex-end;
    margin: 0 14px 10px;
    width: 28px; height: 28px;
    padding: 0;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-soft);
    flex-shrink: 0;
}
.nav-toggle:hover { background: var(--surface-alt); color: var(--brand-black); }
.nav-toggle svg { transition: transform .22s var(--ds-ease, ease); transform: rotate(180deg); }
.app-nav.collapsed .nav-toggle { align-self: center; margin-right: 0; margin-left: 0; }
.app-nav.collapsed .nav-toggle svg { transform: rotate(0deg); }

/* Links: icono + label */
.app-nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 20px;
    white-space: nowrap;
}
.app-nav .nav-ico {
    flex-shrink: 0;
    width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-soft);
}
.app-nav a.active .nav-ico { color: var(--brand-black); }
.app-nav .nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 1;
    transition: opacity .15s ease;
}

/* Domain switch */
.domain-switch-container {
    padding: 8px;
    border-top: 1px solid var(--border);
    margin-top: auto;
    flex-shrink: 0;
}
.nav-switch {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    justify-content: flex-start;
}
.nav-switch .nav-ico { width: 16px; height: 16px; }

/* ── Estado colapsado ── */
.app-nav.collapsed { width: 64px; }
.app-nav.collapsed .nav-label { opacity: 0; width: 0; }
.app-nav.collapsed a,
.app-nav.collapsed .nav-switch {
    justify-content: center;
    gap: 0;
    padding-left: 0; padding-right: 0;
}
.app-nav.collapsed .nav-section {
    height: 1px; padding: 0; margin: 12px 18px;
    overflow: hidden; color: transparent;
    background: var(--border);
}
.app-nav.collapsed hr { margin: 10px 18px; }
.app-nav.collapsed .domain-switch-container { padding: 8px 0; }

/* Tooltip (solo colapsado) */
.app-nav.collapsed [data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--brand-black);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 9px;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 60;
    box-shadow: 0 6px 20px -8px rgba(0,0,0,.45);
    pointer-events: none;
}