/* ============================================================
   Sistema de Mantenimiento Predictivo - Estilos (UI moderna)
   ============================================================ */

:root {
    /* Moderno limpio: azul tecnológico, grises neutros, blancos */
    --primary:        #2563eb;
    --primary-dark:   #1d4ed8;
    --primary-light:  #3b82f6;
    --primary-soft:   #eff6ff;
    --primary-ghost:  #dbeafe;
    --accent:         #f97316;

    --bg:             #f7f8fa;
    --surface:        #ffffff;
    --surface-2:      #f9fafb;
    --surface-3:      #f3f4f6;

    --text:           #111827;
    --text-2:         #374151;
    --muted:          #6b7280;
    --muted-2:        #9ca3af;
    --border:         #e5e7eb;
    --border-strong:  #d1d5db;
    --border-light:   #f3f4f6;

    --normal:         #059669;
    --normal-bg:      #d1fae5;
    --normal-ghost:   #ecfdf5;
    --alert:          #d97706;
    --alert-bg:       #fef3c7;
    --alert-ghost:    #fffbeb;
    --critical:       #dc2626;
    --critical-bg:    #fee2e2;
    --critical-ghost: #fef2f2;

    --sidebar-w:      250px;
    --topbar-h:       60px;
    --radius:         12px;
    --radius-sm:      8px;
    --radius-lg:      16px;

    --shadow-xs:      0 1px 2px rgba(16,24,40,.06);
    --shadow:         0 2px 8px rgba(16,24,40,.06);
    --shadow-md:      0 6px 16px rgba(16,24,40,.08);
    --shadow-lg:      0 12px 24px rgba(16,24,40,.10);
    --shadow-xl:      0 20px 40px rgba(16,24,40,.14);

    --grad-primary:   linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    --grad-header:    linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);

    --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 13.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface-3); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border: 2px solid var(--surface-3); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

::selection { background: var(--accent); color: #fffaf0; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: var(--bg);
}

.login-wrapper {
    width: 100%; max-width: 400px;
    animation: pop .35s ease;
}

@keyframes pop {
    from { opacity:0; transform: translateY(10px); }
    to   { opacity:1; transform: none; }
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 32px;
    box-shadow: var(--shadow);
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
}
.login-brand .brand-icon {
    display: inline-grid;
    width: 54px; height: 54px;
    place-items: center;
    border: 1px solid var(--border);
    background: var(--primary);
    color: var(--surface);
    border-radius: 50%;
    margin-bottom: 14px;
    box-shadow: var(--shadow-md);
}
.login-kicker {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .2em;
    color: var(--muted);
    margin-bottom: 6px;
}
.login-brand h1 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -.03em;
    color: var(--text);
}
.login-brand p {
    color: var(--muted);
    font-size: 13px;
    margin-top: 6px;
}
@media (max-width: 520px) {
    .login-kicker { font-size: 9px; }
}

.login-form { display: flex; flex-direction: column; gap: 18px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-2);
    letter-spacing: .02em;
}
.form-group input {
    padding: 12px 14px;
    font-size: 14px;
    font-family: var(--font-mono);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    transition: all .15s;
    width: 100%;
}
.form-group input::placeholder { color: var(--muted-2); }
.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ghost);
}

.btn-block {
    width: 100%; justify-content: center;
    padding: 12px;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-top: 4px;
}

.login-footer {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px dashed var(--border);
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    font-size: 12px;
    color: var(--muted);
    flex-wrap: wrap;
}
.demo-hint {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
}

.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    border: 2px solid var(--critical);
    background: var(--critical-ghost);
    color: var(--critical);
}
.alert-success {
    border-color: var(--normal);
    background: var(--normal-ghost);
    color: var(--normal);
}

.lang-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.lang-toggle a {
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
    transition: background .15s, color .15s;
}
.lang-toggle a:hover { background: var(--surface-2); }
.lang-toggle a.active { background: var(--text); color: var(--surface); }

@media (max-width: 520px) {
    .login-page { padding: 16px; }
    .login-card { padding: 28px 22px; border-width: 1px; }
    .login-brand h1 { font-size: 22px; }
}

/* ============================================================
   LAYOUT (Sidebar + Main)
   ============================================================ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    color: var(--text);
    display: flex; flex-direction: column;
    position: fixed; inset: 0 auto 0 0; z-index: 50;
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}
.brand-icon-sm {
    width: 36px; height: 36px; display: grid; place-items: center;
    background: var(--primary); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--surface);
    box-shadow: var(--shadow);
}
.brand-text { font-weight: 800; font-size: 17px; line-height: 1.1; color: var(--text); }
.brand-text small {
    display: block; font-family: var(--font-mono); font-size: 9px; font-weight: 700;
    color: var(--muted); letter-spacing: .18em; text-transform: uppercase; margin-top: 2px;
}

.sidebar-nav {
    flex: 1; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px;
    overflow-y: auto;
}
.nav-section {
    font-family: var(--font-mono);
    font-size: 10px; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .14em;
    padding: 16px 0 6px; margin-top: 6px;
}
.nav-section:first-child { margin-top: 0; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 0;
    color: var(--text-2); text-decoration: none; font-size: 13px; font-weight: 600;
    transition: all .15s;
    border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--surface-2); color: var(--primary); border-left-color: var(--primary); }
.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary-dark);
    border-left-color: var(--primary);
    font-weight: 700;
}
.nav-item .nav-badge {
    margin-left: auto; background: var(--critical); color: var(--surface);
    border: 1px solid var(--border);
    font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 99px; min-width: 18px; text-align: center;
}
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}
.nav-item.logout { color: var(--muted); }
.nav-item.logout:hover { background: var(--critical-ghost); color: var(--critical); border-left-color: var(--critical); }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

/* Topbar */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px; height: var(--topbar-h);
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 40;
    box-shadow: var(--shadow-xs);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-left h2 { font-size: 17px; font-weight: 800; color: var(--text); letter-spacing: -.02em; }
.topbar-sub { font-size: 11px; color: var(--muted); font-weight: 700; font-family: var(--font-mono); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.hamburger {
    display: none; background: var(--surface); border: 1px solid var(--border);
    cursor: pointer; color: var(--text); padding: 6px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xs);
}

.topbar-divider { width: 1px; height: 24px; background: var(--border); }

.user-chip { display: flex; align-items: center; gap: 10px; cursor: default; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary); color: var(--surface);
    display: grid; place-items: center; font-weight: 700; font-size: 13px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta strong { font-size: 13px; font-weight: 700; color: var(--text); }
.user-meta small { font-size: 11px; color: var(--muted); font-weight: 400; }

.content { padding: 22px 24px; display: flex; flex-direction: column; gap: 18px; }

.page-header {
    display: flex; align-items: flex-end; justify-content: space-between;
    padding-bottom: 4px; gap: 16px;
}
.page-header h1 { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -.03em; }
.page-header p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-family: var(--font-mono); }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb span.sep { color: var(--muted-2); }

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
}
.kpi-card {
    position: relative;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px;
    display: flex; align-items: center; gap: 14px;
    box-shadow: var(--shadow); transition: transform .15s;
    overflow: hidden;
}
.kpi-card::before {
    content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 4px;
}
.kpi-card.kpi-blue::before   { background: var(--primary); }
.kpi-card.kpi-green::before  { background: var(--normal); }
.kpi-card.kpi-amber::before  { background: var(--alert); }
.kpi-card.kpi-red::before    { background: var(--critical); }
.kpi-card.kpi-purple::before { background: #6b4c9a; }
.kpi-card:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-md); }
.kpi-icon {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    display: grid; place-items: center; flex-shrink: 0;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
}
.kpi-icon.blue   { background: var(--primary-ghost); color: var(--primary); }
.kpi-icon.green  { background: var(--normal-ghost); color: var(--normal); }
.kpi-icon.amber  { background: var(--alert-ghost); color: var(--alert); }
.kpi-icon.red    { background: var(--critical-ghost); color: var(--critical); }
.kpi-icon.purple { background: #ede2ff; color: #6b4c9a; }
.kpi-data { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; color: var(--text); line-height: 1.1; font-feature-settings: "tnum"; }
.kpi-label {
    font-size: 10px; color: var(--muted); font-weight: 700;
    text-transform: uppercase; letter-spacing: .08em; font-family: var(--font-mono);
}

/* ============================================================
   PANELS / CHART
   ============================================================ */
.panel-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.panel-head {
    padding: 14px 18px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    background: var(--surface-2); min-height: 52px;
}
.panel-head h3 {
    font-size: 13px; font-weight: 800; color: var(--text);
    letter-spacing: -.01em;
    display: flex; align-items: center; gap: 10px;
}
.panel-head h3::before {
    content: ""; width: 8px; height: 8px; background: var(--primary); border: 1px solid var(--border);
}
.panel-body { padding: 20px; }

.chart-body { display: flex; align-items: center; gap: 36px; flex-wrap: wrap; justify-content: center; padding: 8px 0; }
.donut {
    --deg-n: calc(var(--normal) / var(--total) * 360deg);
    --deg-a: calc((var(--normal) + var(--alert)) / var(--total) * 360deg);
    width: 150px; height: 150px; border-radius: 50%;
    background: conic-gradient(
        var(--normal, #2f6f5e) 0 var(--deg-n),
        var(--alert, #b86b2f) var(--deg-n) var(--deg-a),
        var(--critical, #a9463b) var(--deg-a) 360deg
    );
    position: relative; flex-shrink: 0;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}
.donut::after {
    content: ""; position: absolute; inset: 22px; background: var(--surface); border-radius: 50%;
    border: 1px solid var(--border);
}
.donut-center {
    position: absolute; inset: 0; display: grid; place-items: center; text-align: center; z-index: 1;
}
.donut-center strong { font-size: 28px; font-weight: 800; color: var(--text); font-feature-settings: "tnum"; }
.donut-center small { font-size: 10px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-family: var(--font-mono); }

.legend { list-style: none; display: flex; flex-direction: column; gap: 10px; min-width: 180px; }
.legend li {
    display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2);
    padding: 5px 10px; border: 1px solid transparent; border-radius: 0;
    transition: all .15s;
}
.legend li:hover { background: var(--surface-2); border-color: var(--text); box-shadow: var(--shadow-xs); }
.legend b { margin-left: auto; font-weight: 800; color: var(--text); font-feature-settings: "tnum"; }
.dot { width: 10px; height: 10px; border-radius: 0; border: 1px solid var(--border); flex-shrink: 0; }
.dot.green { background: var(--normal); }
.dot.amber { background: var(--alert); }
.dot.red   { background: var(--critical); }

.health-panel .panel-body { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 24px 20px; }
.gauge {
    width: 130px; height: 130px; border-radius: 50%;
    display: grid; place-items: center;
    background: conic-gradient(currentColor calc(var(--p,0) * 1%), var(--border) 0);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}
.gauge.good { color: var(--normal); }
.gauge.warn { color: var(--alert); }
.gauge.bad  { color: var(--critical); }
.gauge-value {
    width: 96px; height: 96px; background: var(--surface); border-radius: 50%;
    display: grid; place-items: center; font-size: 26px; font-weight: 800; color: var(--text);
    border: 1px solid var(--border); font-feature-settings: "tnum";
}
.health-bar { width: 100%; height: 8px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.health-fill { height: 100%; background: linear-gradient(90deg, var(--critical), var(--alert), var(--normal)); transition: width .4s ease; }
.health-status {
    font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
    padding: 4px 12px; border: 1px solid var(--border);
    font-family: var(--font-mono);
}
.health-status.good { background: var(--normal-ghost); color: var(--normal); }
.health-status.warn { background: var(--alert-ghost); color: var(--alert); }
.health-status.bad  { background: var(--critical-ghost); color: var(--critical); }

/* ============================================================
   FILTROS
   ============================================================ */
.table-head { flex-wrap: wrap; gap: 12px; }
.filters {
    padding: 12px 18px; display: flex; align-items: center; gap: 10px;
    border-bottom: 2px dashed var(--border); flex-wrap: wrap;
    background: var(--surface-2);
}
.search-box { position: relative; flex: 1; min-width: 220px; max-width: 360px; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box input {
    width: 100%; padding: 8px 12px 8px 34px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 13px; background: var(--surface); color: var(--text); font-family: var(--font-mono);
    transition: all .15s;
}
.search-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ghost); }
#filter-condition {
    padding: 8px 30px 8px 10px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 13px; background: var(--surface); cursor: pointer;
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23716a5d' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 8px center;
    color: var(--text); font-family: var(--font-mono);
}
#filter-condition:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ghost); }
.result-info {
    font-size: 11px; color: var(--muted); margin-left: auto;
    font-weight: 700; font-family: var(--font-mono);
    background: var(--surface); padding: 5px 10px; border: 1px solid var(--border);
}

.badge-count {
    background: var(--surface); color: var(--text); border-radius: 99px;
    padding: 1px 7px; font-size: 10px; font-weight: 800; min-width: 18px; text-align: center;
    border: 1px solid var(--border);
}
.btn-primary .badge-count {
    background: var(--surface); color: var(--text); border-color: var(--text);
}
.btn-secondary .badge-count {
    background: var(--surface); color: var(--text); border-color: var(--text);
}

/* ============================================================
   TABLA
   ============================================================ */
.table-wrapper { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }

table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; min-width: 1150px; }

thead th {
    background: var(--surface-2); padding: 10px 12px; text-align: left;
    font-weight: 800; font-size: 10px; color: var(--text);
    border-bottom: 1px solid var(--border); white-space: nowrap;
    position: sticky; top: 0; z-index: 5;
    text-transform: uppercase; letter-spacing: .08em; font-family: var(--font-mono);
}

tbody td {
    padding: 10px 12px; border-bottom: 1px solid var(--border);
    vertical-align: middle; white-space: nowrap; color: var(--text-2);
}
tbody tr { transition: background .1s ease; }
tbody tr:nth-child(even) td { background: rgba(239,230,211,.35); }
tbody tr:hover td { background: var(--primary-soft); }
tbody tr.selected td { background: var(--primary-ghost) !important; }
.empty-row td { text-align: center; padding: 56px 20px; color: var(--muted); font-size: 13px; background: var(--surface) !important; }

.cell-tag {
    font-weight: 700; font-family: var(--font-mono);
    font-size: 12px; color: var(--text);
    background: var(--surface-2); padding: 2px 6px;
    border: 1px solid var(--border); display: inline-block;
}
.cell-text { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

/* Borde izquierdo de color por condicion */
tr.status-normal   td:first-child { box-shadow: inset 4px 0 0 var(--normal); }
tr.status-alert    td:first-child { box-shadow: inset 4px 0 0 var(--alert); }
tr.status-critical td:first-child { box-shadow: inset 4px 0 0 var(--critical); }

/* Pills de condicion */
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 9px 3px 7px; border-radius: 99px;
    font-size: 10px; font-weight: 800; letter-spacing: .04em;
    text-transform: uppercase; font-family: var(--font-mono);
    border: 1px solid var(--border);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--text); flex-shrink: 0; }
.pill-normal   { background: var(--normal);   color: var(--surface); }
.pill-alert    { background: var(--alert);     color: var(--surface); }
.pill-critical { background: var(--critical);  color: var(--surface); }

/* Inputs en tabla */
input[type="text"], input[type="date"] {
    padding: 6px 9px; font-size: 12.5px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); width: 100%; min-width: 110px;
    transition: all .15s; background: var(--surface);
    font-family: var(--font-mono); color: var(--text);
}
input[type="text"]:focus, input[type="date"]:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ghost);
}
input.ot-input:disabled {
    background: var(--surface-3); cursor: not-allowed; color: var(--muted-2);
    border-style: dashed; border-color: var(--border-strong);
}
input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }
.col-check { width: 44px; text-align: center; }
.col-ot { min-width: 140px; }
.col-actions { width: 90px; text-align: center; }

/* Botones de accion por fila */
.row-actions { display: flex; gap: 6px; justify-content: center; }
.icon-btn {
    width: 28px; height: 28px; display: grid; place-items: center;
    border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm);
    cursor: pointer; color: var(--muted); transition: all .15s;
}
.icon-btn:hover { color: var(--surface); transform: translate(-1px, -1px); box-shadow: var(--shadow-xs); }
.btn-edit:hover   { background: var(--primary); border-color: var(--text); }
.btn-delete:hover { background: var(--critical); border-color: var(--text); }

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; font-size: 12px; font-weight: 800;
    border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
    transition: all .15s; font-family: inherit;
    line-height: 1.4; white-space: nowrap;
    text-transform: uppercase; letter-spacing: .04em;
    font-family: var(--font-mono);
}
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--primary); color: var(--surface);
    box-shadow: var(--shadow);
}
.btn-primary:hover { background: var(--primary-dark); transform: translate(-1px, -1px); box-shadow: var(--shadow-md); }
.btn-secondary {
    background: var(--surface); color: var(--text-2);
    box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--surface-2); transform: translate(-1px, -1px); box-shadow: var(--shadow); }
.btn-success {
    background: var(--normal); color: var(--surface);
    box-shadow: var(--shadow-xs);
}
.btn-success:hover { background: var(--primary-dark); transform: translate(-1px, -1px); box-shadow: var(--shadow); }
.btn-danger {
    background: var(--critical); color: var(--surface);
    box-shadow: var(--shadow-xs);
}
.btn-danger:hover { background: #8f3a31; transform: translate(-1px, -1px); box-shadow: var(--shadow); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-sm { padding: 6px 10px; font-size: 11px; }

/* ============================================================
   TOAST
   ============================================================ */
#toast-container {
    position: fixed; top: 18px; right: 18px; z-index: 1000;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 11px 16px; border-radius: var(--radius-sm); color: var(--text); font-size: 13px; font-weight: 700;
    box-shadow: var(--shadow-lg); animation: slideIn .3s ease; max-width: 320px;
    display: flex; align-items: center; gap: 10px;
    border: 1px solid var(--border); background: var(--surface);
}
.toast.success { background: var(--normal); color: var(--surface); }
.toast.error   { background: var(--critical); color: var(--surface); }
.toast.info    { background: var(--accent); color: var(--surface); }
@keyframes slideIn { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(36,32,26,.45);
    display: none; justify-content: center; align-items: center; z-index: 200; padding: 20px;
}
.modal-overlay.active { display: flex; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); width: 520px; max-width: 100%; max-height: 88vh;
    overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-xl);
    animation: pop .3s cubic-bezier(.16,1,.3,1);
}
.modal-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    font-weight: 800; font-size: 14px;
    display: flex; align-items: center; justify-content: space-between; color: var(--text);
    background: var(--surface-2);
}
.modal-close {
    background: var(--surface); border: 1px solid var(--border);
    font-size: 18px; line-height: 1;
    color: var(--text); cursor: pointer; padding: 0;
    width: 28px; height: 28px; display: grid; place-items: center;
    border-radius: var(--radius-sm); transition: all .15s;
    box-shadow: var(--shadow-xs);
}
.modal-close:hover { background: var(--critical); color: var(--surface); }
.modal-body { padding: 18px 20px; overflow-y: auto; font-size: 13px; line-height: 1.55; color: var(--text-2); }
.modal-body p { margin-bottom: 4px; }
.modal-body ul { list-style: none; padding: 0; margin-top: 10px; }
.modal-body li {
    padding: 10px 12px; margin-bottom: 6px; border-radius: 0;
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    border: 1px solid var(--border); font-size: 12.5px;
}
.modal-footer {
    padding: 14px 20px; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 10px;
    background: var(--surface-2);
}
.modal-lg { width: 680px; }

/* Acciones de cabecera de tabla */
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Formulario nuevo registro */
.form-section {
    font-size: 11px; font-weight: 800; color: var(--text);
    margin: 4px 0 14px; padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase; letter-spacing: .1em;
    font-family: var(--font-mono);
}
.form-section:not(:first-child) { margin-top: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 14px; }
.form-grid .form-group label {
    font-size: 11px; font-weight: 800; color: var(--text-2);
    text-transform: uppercase; letter-spacing: .04em; font-family: var(--font-mono);
}
.form-grid .form-group label small { font-weight: 400; color: var(--muted); text-transform: none; letter-spacing: 0; font-family: var(--font); }
.form-grid input, .form-grid select {
    padding: 9px 12px; font-size: 13px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); width: 100%; background: var(--surface);
    font-family: var(--font-mono); color: var(--text); transition: all .15s;
}
.form-grid input::placeholder { color: var(--muted-2); }
.form-grid input:focus, .form-grid select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ghost);
}
.form-grid input.invalid, .form-grid select.invalid {
    border-color: var(--critical);
    box-shadow: 0 0 0 3px var(--critical-bg);
}
.form-grid input.locked {
    background: var(--surface-3); color: var(--muted);
    cursor: not-allowed; border-style: dashed;
}
.form-col-2 { grid-column: 1 / -1; }

/* ============================================================
   SPINNER
   ============================================================ */
.spinner {
    display: inline-block; width: 14px; height: 14px;
    border: 2px solid var(--surface); border-radius: 50%;
    border-top-color: var(--text); animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   MODULO AVERIAS
   ============================================================ */

/* KPI grid de 6 + KPI como link */
.kpi-grid.kpi-grid-6 { grid-template-columns: repeat(6, 1fr); }
.kpi-link {
    text-decoration: none; color: inherit; cursor: pointer;
}
.kpi-link::after {
    content: ""; position: absolute; right: 12px; top: 12px;
    width: 8px; height: 8px;
    border-top: 1px solid var(--border); border-right: 1px solid var(--border);
    transform: rotate(45deg); opacity: .55;
}

/* Hint pequeno en panel-head */
.panel-hint {
    font-size: 11px; color: var(--muted);
    font-family: var(--font-mono); font-weight: 600;
    text-align: right;
}

/* ---- Recordatorios ---- */
.reminders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}
.reminder-card {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: relative;
}
.reminder-card::before {
    content: ""; position: absolute; top: 0; left: 0; bottom: 0; width: 5px;
}
.reminder-card.reminder-recurrent::before { background: var(--alert); }
.reminder-card.reminder-down::before      { background: var(--critical); }
.reminder-card.reminder-area::before      { background: var(--primary); }
.reminder-card.reminder-good::before      { background: var(--normal); }
.reminder-ico {
    width: 36px; height: 36px; flex-shrink: 0;
    display: grid; place-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xs);
}
.reminder-recurrent .reminder-ico { color: var(--alert); }
.reminder-down      .reminder-ico { color: var(--critical); }
.reminder-area      .reminder-ico { color: var(--primary); }
.reminder-good      .reminder-ico { color: var(--normal); }
.reminder-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.reminder-body strong { font-size: 13.5px; color: var(--text); font-weight: 800; letter-spacing: -.01em; }
.reminder-body small  { font-size: 11px; color: var(--muted); font-family: var(--font-mono); }
.reminder-body p      { font-size: 12.5px; color: var(--text-2); margin-top: 4px; line-height: 1.45; }

/* ---- Empty state ---- */
.empty-state {
    padding: 28px 20px; text-align: center;
    background: var(--surface-2);
    border: 2px dashed var(--border-strong);
    color: var(--muted);
    font-size: 13px; font-weight: 600;
}
.empty-state.success {
    background: var(--normal-ghost);
    border-color: var(--normal);
    color: var(--normal);
}

/* ---- Pills de estado de averia ---- */
.pill-status.pill-fuera-de-servicio { background: var(--critical); color: var(--surface); }
.pill-status.pill-en-reparacion     { background: var(--alert);    color: var(--surface); }
.pill-status.pill-operativo         { background: var(--normal);   color: var(--surface); }

/* ---- Pills de impacto ---- */
.pill-impact {
    background: var(--surface);
    color: var(--text);
}
.pill-impact::before { display: none; }
.pill-impact.pill-impact-bajo    { background: var(--normal-ghost);   color: var(--normal); }
.pill-impact.pill-impact-medio   { background: var(--surface-2);      color: var(--text-2); }
.pill-impact.pill-impact-alto    { background: var(--alert-ghost);    color: var(--alert); }
.pill-impact.pill-impact-critico { background: var(--critical-ghost); color: var(--critical); }

/* ---- Equipos en averia (weak points) ---- */
.weak-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.weak-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.weak-item.is-down { box-shadow: var(--shadow); border-color: var(--critical); }
.weak-head {
    width: 100%;
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px;
    background: transparent;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    color: var(--text);
    transition: background .15s;
}
.weak-head:hover { background: var(--surface-2); }
.weak-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.weak-tag-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.weak-meta {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    font-size: 12px; color: var(--muted-2);
}
.weak-meta strong { color: var(--text-2); font-weight: 700; }
.weak-sep { color: var(--border-strong); }
.weak-counter {
    display: flex; flex-direction: column; align-items: center;
    min-width: 64px;
    padding: 4px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
}
.weak-num { font-size: 22px; font-weight: 800; color: var(--text); line-height: 1; }
.weak-counter small { font-size: 9px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin-top: 2px; }
.weak-chevron {
    display: grid; place-items: center;
    width: 32px; height: 32px;
    color: var(--muted);
    transition: transform .2s;
}
.weak-head.open .weak-chevron { transform: rotate(180deg); color: var(--primary); }

/* Detalle expandible */
.weak-detail {
    border-top: 2px dashed var(--border-strong);
    padding: 14px 18px 18px;
    background: var(--surface-2);
}
.failure-timeline {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column; gap: 12px;
}
.failure-timeline li {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    box-shadow: var(--shadow-xs);
}
.ft-date {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    font-family: var(--font-mono);
}
.ft-date strong { font-size: 13px; color: var(--text); }
.ft-desc {
    margin: 8px 0 4px;
    font-size: 13px; color: var(--text-2); line-height: 1.5;
}
.ft-desc em { color: var(--muted-2); font-style: normal; }
.ft-obs {
    margin-top: 6px; padding: 8px 10px;
    background: var(--alert-ghost);
    border-left: 3px solid var(--alert);
    font-size: 12.5px; color: var(--text-2); line-height: 1.45;
}
.ft-obs strong { color: var(--alert); }
.ft-foot {
    margin-top: 8px;
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    font-size: 11.5px; color: var(--muted);
    font-family: var(--font-mono);
}
.ft-foot strong { color: var(--text); }

/* Botones tipo link en timeline */
.link-btn {
    background: none; border: 0; padding: 0; margin-left: auto;
    font-family: var(--font-mono);
    font-size: 11px; font-weight: 700;
    color: var(--primary); text-transform: uppercase; letter-spacing: .06em;
    cursor: pointer;
    border-bottom: 1px dashed var(--primary);
}
.link-btn:hover { color: var(--primary-dark); }
.link-btn.link-danger { color: var(--critical); border-bottom-color: var(--critical); margin-left: 0; }
.link-btn.link-danger:hover { color: #8f3a31; }

/* ---- Toggle de periodo ---- */
.period-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    background: var(--surface);
    flex-wrap: wrap;
}
.period-btn {
    background: var(--surface);
    border: 0;
    padding: 8px 14px;
    font-family: var(--font-mono);
    font-size: 11px; font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase; letter-spacing: .06em;
    cursor: pointer;
    border-right: 1px solid var(--border);
    transition: all .15s;
}
.period-btn:last-child { border-right: 0; }
.period-btn:hover { background: var(--surface-2); }
.period-btn.active { background: var(--primary); color: var(--surface); }

/* ---- Acumulados (matriz periodo x dimension) ---- */
.acc-subtitle {
    font-family: var(--font-mono);
    font-size: 11px; font-weight: 800;
    color: var(--text-2);
    text-transform: uppercase; letter-spacing: .12em;
    margin: 8px 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.acc-subtitle:not(:first-child) { margin-top: 22px; }
.acc-wrapper { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 4px; box-shadow: var(--shadow-xs); }
table.acc-table { min-width: auto; }
.acc-table thead th {
    background: var(--text);
    color: var(--surface);
    border-bottom-color: var(--text);
    text-align: center;
    font-size: 10px;
}
.acc-table thead th:first-child { text-align: left; }
.acc-table tbody td {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 12.5px;
    border-bottom-color: var(--border);
}
.acc-table tbody td:first-child {
    text-align: left;
    font-family: var(--font);
    color: var(--text);
}
.acc-cell.has-v {
    background: var(--alert-ghost);
    color: var(--alert);
    font-weight: 800;
}
.acc-cell .muted { color: var(--muted-2); font-weight: 400; }
.acc-table .acc-total {
    background: var(--surface-2);
    color: var(--text);
    font-weight: 800;
    border-left: 2px solid var(--text);
}

/* ---- Maquinas paradas (out of service) ---- */
.down-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
}
.down-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow-md);
    display: flex; flex-direction: column; gap: 10px;
    position: relative;
}
.down-card.pill-status-bg-fuera-de-servicio { box-shadow: var(--shadow-md); border-color: var(--critical); }
.down-card.pill-status-bg-en-reparacion     { box-shadow: var(--shadow-md); border-color: var(--alert); }
.down-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.down-head > div:first-child { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.down-days {
    text-align: center;
    padding: 4px 12px;
    background: var(--critical);
    color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    box-shadow: var(--shadow-xs);
    line-height: 1;
}
.down-days strong { font-size: 22px; font-weight: 800; display: block; }
.down-days small { font-size: 8.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.down-meta {
    display: flex; flex-wrap: wrap; gap: 8px 14px;
    font-size: 12px; color: var(--text-2);
    padding: 8px 10px;
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
}
.down-meta strong { color: var(--muted); font-family: var(--font-mono); font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; }
.down-meta .pill { padding: 2px 8px; }
.down-desc {
    font-size: 12.5px; color: var(--text-2); line-height: 1.5;
    padding: 8px 10px;
    border-left: 3px solid var(--primary);
    background: var(--primary-soft);
}
.down-obs-label {
    font-size: 11px; font-weight: 800;
    color: var(--alert);
    font-family: var(--font-mono);
    text-transform: uppercase; letter-spacing: .06em;
}
.down-obs {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.5;
    resize: vertical;
    min-height: 56px;
    transition: all .15s;
}
.down-obs:focus {
    outline: none;
    border-color: var(--alert);
    box-shadow: 0 0 0 3px var(--alert-bg);
}
.down-actions {
    display: flex; gap: 8px; flex-wrap: wrap;
    border-top: 1px dashed var(--border);
    padding-top: 10px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
.sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(36,32,26,.45); z-index: 45;
}

@media (max-width: 1280px) {
    .kpi-grid { grid-template-columns: repeat(5, 1fr); gap: 12px; }
    .kpi-grid.kpi-grid-6 { grid-template-columns: repeat(3, 1fr); }
    .kpi-card { padding: 14px; }
    .kpi-value { font-size: 22px; }
}

@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(3, 1fr); }
    .kpi-grid.kpi-grid-6 { grid-template-columns: repeat(3, 1fr); }
    .panel-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.show { display: block; }
    .main { margin-left: 0; }
    .hamburger { display: inline-flex; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .kpi-grid.kpi-grid-6 { grid-template-columns: repeat(2, 1fr); }
    .content { padding: 14px; gap: 12px; }
    .topbar { padding: 0 16px; }
    .user-meta { display: none; }
    .result-info { width: 100%; margin-left: 0; }
    .form-grid { grid-template-columns: 1fr; }
    .chart-body { flex-direction: column; gap: 24px; }
    .reminders-grid { grid-template-columns: 1fr; }
    .down-grid { grid-template-columns: 1fr; }
    .panel-hint { text-align: left; flex-basis: 100%; }
    .weak-counter { min-width: 56px; padding: 4px 8px; }
    .weak-num { font-size: 18px; }
}

@media (max-width: 520px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .kpi-grid.kpi-grid-6 { grid-template-columns: 1fr; }
    .lang-toggle { display: none; }
    .head-actions .btn { padding: 7px 10px; font-size: 11px; }
    .head-actions .btn span:not(.badge-count) { display: none; }
    .panel-head { padding: 12px 14px; flex-wrap: wrap; }
    .panel-head h3 { font-size: 12px; }
    .filters { padding: 12px 14px; }
    .search-box { max-width: none; width: 100%; }
    .topbar-left h2 { font-size: 14px; }
    .topbar-sub { display: none; }
    .weak-head { flex-wrap: wrap; padding: 12px; }
    .weak-info { flex: 1 1 100%; }
    .weak-meta { font-size: 11px; }
    .down-card { padding: 12px; }
    .down-meta { gap: 6px 10px; font-size: 11.5px; }
    .down-actions .btn { flex: 1; justify-content: center; min-width: 0; }
    .period-btn { padding: 7px 10px; font-size: 10px; }
}

/* ============================================================
   DASHBOARD REDISEÑO (estilo moderno, limpio y amigable)
   ============================================================ */
.dash-content {
    gap: 18px;
    padding: 22px 26px;
    background: #f7f8fa;
    min-height: calc(100vh - 70px);
}

/* ---- Filtros tipo chip (modernos y suaves) ---- */
.filter-bar {
    display: flex; flex-wrap: wrap;
    align-items: center;
    gap: 14px 18px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(16, 24, 40, .06);
    padding: 14px 18px;
}
.filter-group {
    display: flex; align-items: center; gap: 10px;
    padding-right: 14px;
    border-right: 1px solid #e5e7eb;
}
.filter-group:last-of-type { border-right: 0; }
.filter-label {
    font: 600 10px var(--font);
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #6b7280;
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    color: #4b5563;
    font: 500 12px var(--font);
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: all .18s ease;
    user-select: none;
}
.chip:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
    color: #374151;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,.06);
}
.chip.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
    box-shadow: 0 3px 8px rgba(37, 99, 235, .22);
    font-weight: 600;
}
.btn-clear-filters {
    margin-left: auto;
    display: inline-flex; align-items: center; gap: 6px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    color: #6b7280;
    font: 500 12px var(--font);
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: all .18s ease;
}
.btn-clear-filters:hover {
    background: #fee2e2;
    border-color: #fecaca;
    color: #dc2626;
    box-shadow: 0 2px 6px rgba(220, 38, 38, .08);
}

/* ---- Grid principal: 3 columnas ---- */
.dash-grid {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr) minmax(0, 270px);
    gap: 18px;
    align-items: start;
    overflow: visible;
}
.dash-grid > * { min-width: 0; }

/* ---- Columna izquierda: KPIs verticales con mini barras ---- */
.dash-left { display: flex; flex-direction: column; gap: 14px; }
.kpi-tall {
    position: relative;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(16, 24, 40, .06);
    padding: 16px;
    overflow: hidden;
    min-height: 120px;
    display: flex; flex-direction: column; justify-content: space-between;
    transition: transform .18s ease, box-shadow .18s ease;
}
.kpi-tall:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(16, 24, 40, .10);
}
.kpi-tall::before {
    content: ""; position: absolute; left: 0; top: 0; width: 5px; height: 100%;
    border-radius: 14px 0 0 14px;
}
.kpi-tall header { display: flex; flex-direction: column; gap: 4px; padding-left: 2px; }
.kpi-tall h4 {
    font: 600 11px var(--font);
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #6b7280;
    line-height: 1.3;
}
.kpi-tall .kt-num {
    font-size: 32px; font-weight: 700; line-height: 1; color: #111827;
    font-feature-settings: "tnum"; margin-top: 4px;
    letter-spacing: -.02em;
}
.kpi-tall .kt-pct {
    font: 600 11px var(--font);
    color: #9ca3af;
    letter-spacing: -.01em;
}
.kpi-tall.kt-purple::before { background: linear-gradient(180deg, #8b5cf6, #7c3aed); }
.kpi-tall.kt-purple .kt-num { color: #6d28d9; }
.kpi-tall.kt-coral::before  { background: linear-gradient(180deg, #f97316, #ea580c); }
.kpi-tall.kt-coral .kt-num  { color: #c2410c; }
.kpi-tall.kt-pink::before   { background: linear-gradient(180deg, #ec4899, #db2777); }
.kpi-tall.kt-pink .kt-num   { color: #be185d; }
.kpi-tall.kt-sky::before    { background: linear-gradient(180deg, #0ea5e9, #0284c7); }
.kpi-tall.kt-sky .kt-num    { color: #0369a1; }
.kpi-tall.kt-green::before  { background: linear-gradient(180deg, #10b981, #059669); }
.kpi-tall.kt-green .kt-num  { color: #047857; }

/* Mini barras (12 meses) */
.mini-bars {
    display: flex; align-items: flex-end; justify-content: space-between;
    height: 44px; gap: 3px; margin-top: 12px; padding-left: 2px;
}
.mini-bar {
    flex: 1; min-width: 6px;
    background: currentColor;
    opacity: .22;
    border-radius: 3px 3px 0 0;
    position: relative;
    transition: opacity .18s, transform .18s;
}
.mini-bar i {
    position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
    background: #111827; color: #ffffff;
    font: 600 9px var(--font); padding: 2px 5px;
    border-radius: 4px;
    margin-bottom: 4px; white-space: nowrap;
    opacity: 0; pointer-events: none; transition: opacity .18s;
    box-shadow: 0 2px 6px rgba(0,0,0,.18);
}
.mini-bar:hover { opacity: 1; transform: scaleY(1.05); }
.mini-bar:hover i { opacity: 1; }
.kpi-tall.kt-purple .mini-bar { color: #8b5cf6; }
.kpi-tall.kt-coral  .mini-bar { color: #f97316; }
.kpi-tall.kt-pink   .mini-bar { color: #ec4899; }
.kpi-tall.kt-sky    .mini-bar { color: #0ea5e9; }
.kpi-tall.kt-green  .mini-bar { color: #10b981; }

/* ---- Columna centro ---- */
.dash-center { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* KPIs centrales con icono (fila) */
.ikpi-row {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px;
}
.ikpi {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(16, 24, 40, .06);
    padding: 14px 16px;
    display: flex;
    align-items: center; gap: 12px;
    transition: all .18s ease;
}
.ikpi:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 22px rgba(16, 24, 40, .10);
    border-color: #d1d5db;
}
.ikpi-icon {
    flex-shrink: 0;
    width: 44px; height: 44px; display: grid; place-items: center;
    border-radius: 12px;
    transition: transform .18s ease;
}
.ikpi:hover .ikpi-icon { transform: scale(1.08); }
.ikpi-content { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ikpi-label {
    font: 500 11px var(--font);
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6b7280;
    line-height: 1.2;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ikpi-val {
    font-size: 24px; font-weight: 700; line-height: 1; color: #111827;
    font-feature-settings: "tnum";
    letter-spacing: -.02em;
}
.ikpi.ikpi-blue   .ikpi-icon { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #2563eb; }
.ikpi.ikpi-mint   .ikpi-icon { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #059669; }
.ikpi.ikpi-red    .ikpi-icon { background: linear-gradient(135deg, #fee2e2, #fecaca); color: #dc2626; }
.ikpi.ikpi-amber  .ikpi-icon { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #d97706; }
.ikpi.ikpi-violet .ikpi-icon { background: linear-gradient(135deg, #ede9fe, #ddd6fe); color: #7c3aed; }

/* Grid de graficos */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
.chart-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(16, 24, 40, .06);
    padding: 16px 18px;
    display: flex; flex-direction: column; gap: 10px;
    min-height: 250px;
    transition: transform .18s ease, box-shadow .18s ease;
}
.chart-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(16, 24, 40, .09);
}
.chart-card-wide { grid-column: span 3; min-height: 230px; }
.chart-head h3 {
    font-size: 13px; font-weight: 600; color: #374151;
    letter-spacing: 0;
    display: flex; align-items: center; gap: 8px;
}
.chart-head h3::before {
    content: ""; width: 8px; height: 8px;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    border-radius: 50%;
}
.chart-canvas-wrap {
    flex: 1; min-height: 190px;
    position: relative;
}
.chart-canvas-wrap canvas { max-width: 100%; }

/* ---- Columna derecha: tarjeta de ultima falla + salud mini ---- */
.dash-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* Widget de falla reciente: ventana flotante arrastrable */
.recent-card {
    position: fixed;
    right: 26px;
    top: 120px;
    width: 260px;
    z-index: 100;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, .14);
    padding: 16px;
    display: flex; flex-direction: column; gap: 10px;
    overflow: hidden;
    transition: box-shadow .18s ease;
    user-select: none;
}
.recent-card:hover {
    box-shadow: 0 12px 32px rgba(16, 24, 40, .18);
}
.recent-card::before {
    content: ""; position: absolute; left: 0; top: 0; right: 0; height: 4px;
    background: linear-gradient(90deg, #f59e0b, #ef4444);
}
.recent-handle {
    cursor: move;
    display: flex; align-items: center; gap: 10px;
    position: relative;
}
.recent-handle::after {
    content: "⋮⋮";
    margin-left: auto;
    font-size: 12px;
    color: #9ca3af;
    letter-spacing: 1px;
}
.recent-card.is-fresh { background: linear-gradient(180deg, #fff7ed, #ffffff 55%); }
.recent-card.is-fresh::before { background: linear-gradient(90deg, #ef4444, #f97316); }
.recent-card.is-stale { background: linear-gradient(180deg, #fefce8, #ffffff 55%); }
.recent-card.is-stale::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.recent-card.is-empty { background: #ffffff; }
.recent-card.is-empty::before { background: #d1d5db; }
.recent-card header { display: flex; align-items: center; gap: 10px; position: relative; }
.recent-card h4 {
    font: 600 11px var(--font);
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #6b7280;
}
.recent-icon {
    width: 34px; height: 34px; display: grid; place-items: center;
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #dc2626;
    border-radius: 10px;
}
.recent-card.is-empty .recent-icon { background: #f3f4f6; color: #9ca3af; }
.recent-body { display: flex; flex-direction: column; gap: 6px; position: relative; min-width: 0; }
.recent-date {
    font: 600 13px var(--font);
    color: #374151;
    letter-spacing: 0;
    word-break: break-word;
}
.recent-ago {
    font-size: 22px; font-weight: 700; line-height: 1.15;
    color: #dc2626; letter-spacing: -.02em;
    word-break: break-word;
}
.recent-card.is-stale .recent-ago { color: #d97706; }
.recent-card.is-empty .recent-ago { color: #9ca3af; font-size: 17px; font-weight: 600; }
.recent-link {
    margin-top: auto;
    font: 600 12px var(--font);
    color: #2563eb; text-decoration: none;
    border-top: 1px solid #e5e7eb; padding-top: 12px;
    display: inline-flex; align-items: center; gap: 6px;
    transition: color .18s;
}
.recent-link:hover { color: #1d4ed8; }
.recent-link::after { content: "→"; transition: transform .18s; }
.recent-link:hover::after { transform: translateX(3px); }

/* Salud mini */
.health-mini {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(16, 24, 40, .06);
    padding: 18px;
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    transition: transform .18s ease, box-shadow .18s ease;
}
.health-mini:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 26px rgba(16, 24, 40, .10);
}
.health-mini h4 {
    font: 600 11px var(--font);
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #6b7280;
}
.health-mini .gauge-wrap { display: grid; place-items: center; padding: 4px 0; }
.health-mini .gauge {
    width: 120px; height: 120px;
    border: none;
    box-shadow: 0 4px 14px rgba(16, 24, 40, .12);
}
.health-mini .gauge-value {
    width: 88px; height: 88px; font-size: 22px;
    background: #ffffff; border: none; color: #111827;
    box-shadow: inset 0 0 0 1px #f3f4f6;
}
.health-mini .health-status {
    font: 600 11px var(--font); padding: 5px 14px;
    text-transform: uppercase; letter-spacing: .06em;
    border-radius: 20px;
    border: none;
}
.health-mini .health-status.good { background: #d1fae5; color: #047857; }
.health-mini .health-status.warn { background: #fef3c7; color: #b45309; }
.health-mini .health-status.bad  { background: #fee2e2; color: #b91c1c; }

/* ---- Panel detalle (tabla colapsable) ---- */
.detail-panel.collapsed .filters,
.detail-panel.collapsed .table-wrapper { display: none; }
/* Filtro chip: oculta filas sin pelearse con app.js (que toca display inline) */
#data-table tbody tr.data-row.chip-hidden { display: none !important; }
.detail-panel .panel-head h3 { cursor: pointer; user-select: none; }
.detail-panel .panel-head h3::after {
    content: "▾"; margin-left: 8px;
    transition: transform .2s;
    color: #9ca3af;
    font-size: 14px;
}
.detail-panel.collapsed .panel-head h3::after { transform: rotate(-90deg); display: inline-block; }

/* ============================================================
   RESPONSIVE DASHBOARD
   ============================================================ */
@media (max-width: 1400px) {
    .dash-grid { grid-template-columns: 210px minmax(0, 1fr) 240px; }
    .ikpi-row { grid-template-columns: repeat(5, 1fr); }
    .ikpi-val { font-size: 20px; }
    .ikpi-label { font-size: 10px; }
}
@media (max-width: 1180px) {
    .dash-grid { grid-template-columns: 1fr; }
    .dash-left {
        display: grid; grid-template-columns: repeat(5, 1fr);
    }
    .kpi-tall { min-height: 140px; }
    .dash-right {
        display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
    }
    .charts-grid { grid-template-columns: repeat(2, 1fr); }
    .chart-card-wide { grid-column: span 2; }
}
@media (max-width: 860px) {
    .dash-left { grid-template-columns: repeat(2, 1fr); }
    .ikpi-row { grid-template-columns: repeat(2, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }
    .chart-card-wide { grid-column: span 1; }
    .filter-group { border-right: 0; padding-right: 0; }
}
@media (max-width: 520px) {
    .dash-content { padding: 14px; }
    .dash-left { grid-template-columns: 1fr; }
    .dash-right { grid-template-columns: 1fr; }
    .ikpi-row { grid-template-columns: 1fr; }
    .filter-bar { padding: 12px; }
    .btn-clear-filters { margin-left: 0; width: 100%; justify-content: center; }
    .recent-card {
        width: calc(100vw - 28px);
        right: 14px;
        left: 14px;
        top: auto;
        bottom: 14px;
    }
}

/* ============================================================
   SAP MODULE (enterprise, clean, non-overlapping)
   ============================================================ */

/* Badge SAP en el menu lateral */
.nav-item .nav-badge.sap-badge {
    background: #eef2ff;
    color: #4f46e5;
    border: 1px solid #c7d2fe;
    font-weight: 700;
    font-size: 10px;
}

/* --- Banner SAP en el dashboard --- */
.sap-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 18px 22px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .04);
    text-decoration: none;
    color: inherit;
    transition: box-shadow .2s ease, border-color .2s ease, transform .2s ease;
}
.sap-banner:hover {
    border-color: #cbd5e1;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .08);
    transform: translateY(-1px);
}
.sap-banner-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}
.sap-banner-icon {
    width: 48px; height: 48px;
    display: grid; place-items: center;
    background: #f1f5f9;
    color: #475569;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}
.sap-banner-head {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sap-banner-title {
    font: 800 15px var(--font);
    color: #0f172a;
    letter-spacing: .04em;
}
.sap-banner-subtitle {
    font: 500 12px var(--font);
    color: #64748b;
}
.sap-banner-metrics {
    display: flex;
    align-items: center;
    gap: 40px;
    flex: 1;
    justify-content: center;
    padding: 0 20px;
}
.sap-banner-metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
}
.sap-banner-metric-wide {
    flex: 1;
    max-width: 320px;
}
.sap-banner-metric-label {
    font: 600 11px var(--font);
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.sap-banner-metric-value {
    font: 700 22px var(--font);
    color: #0f172a;
    line-height: 1.1;
    letter-spacing: -.02em;
    font-feature-settings: "tnum";
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sap-banner-metric-value small {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    margin-left: 6px;
}
.sap-banner-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    font: 600 13px var(--font);
    color: #2563eb;
    padding: 9px 16px;
    border: 1px solid #dbeafe;
    border-radius: 10px;
    background: #eff6ff;
    transition: all .2s ease;
    white-space: nowrap;
}
.sap-banner:hover .sap-banner-cta {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

/* --- Pagina sap.php: barra de filtros --- */
.sap-filterbar {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px 18px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
    flex-wrap: wrap;
}
.sap-filterbar-search {
    position: relative;
    flex: 1;
    min-width: 240px;
    max-width: 360px;
}
.sap-filterbar-search svg {
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}
.sap-filterbar-search input {
    width: 100%;
    padding: 10px 12px 10px 38px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font: 500 13px var(--font);
    color: #0f172a;
    transition: all .15s ease;
}
.sap-filterbar-search input:focus {
    outline: none;
    background: #ffffff;
    border-color: #94a3b8;
    box-shadow: 0 0 0 3px rgba(148, 163, 184, .12);
}
.sap-filterbar-divider {
    width: 1px;
    height: 32px;
    background: #e2e8f0;
    flex-shrink: 0;
}
.sap-filterbar-group {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex: 1;
    flex-wrap: wrap;
}
.sap-filterbar-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 110px;
    flex: 1;
}
.sap-filterbar-field label {
    font: 600 10px var(--font);
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.sap-filterbar-field select {
    width: 100%;
    padding: 8px 28px 8px 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font: 500 13px var(--font);
    color: #0f172a;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    cursor: pointer;
    transition: all .15s ease;
}
.sap-filterbar-field select:focus {
    outline: none;
    background-color: #ffffff;
    border-color: #94a3b8;
    box-shadow: 0 0 0 3px rgba(148, 163, 184, .12);
}
.sap-filterbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}
.btn-ghost {
    background: #ffffff;
    color: #64748b;
    border: 1px solid #e2e8f0;
    padding: 9px 14px;
    border-radius: 8px;
    font: 600 13px var(--font);
    text-decoration: none;
    transition: all .15s ease;
}
.btn-ghost:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
}

/* --- KPIs SAP --- */
.sap-kpi-row {
    display: grid;
    grid-template-columns: 1.25fr 1fr 1fr 1fr;
    gap: 16px;
}
.sap-kpi {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    transition: box-shadow .2s ease, border-color .2s ease;
    min-height: 120px;
}
.sap-kpi:hover {
    box-shadow: 0 8px 20px rgba(15, 23, 42, .06);
    border-color: #cbd5e1;
}
.sap-kpi-main { display: flex; flex-direction: column; gap: 6px; }
.sap-kpi-body {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
}
.sap-kpi-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}
.sap-kpi-icon {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    border-radius: 10px;
    background: #f1f5f9;
    color: #475569;
    flex-shrink: 0;
}
.sap-kpi-label {
    font: 600 11px var(--font);
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sap-kpi-val {
    font: 700 24px var(--font);
    color: #0f172a;
    line-height: 1;
    letter-spacing: -.02em;
    font-feature-settings: "tnum";
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sap-kpi.kpi-total .sap-kpi-val { font-size: 30px; }
.sap-kpi-footer {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid #f1f5f9;
}
.sap-kpi-chip {
    font: 600 11px var(--font);
    padding: 4px 10px;
    border-radius: 20px;
}
.sap-kpi-chip.chip-mint { background: #f0fdf4; color: #15803d; }
.sap-kpi-chip.chip-amber { background: #fffbeb; color: #b45309; }
.sap-kpi.kpi-total { border-top: 3px solid #3b82f6; }
.sap-kpi.kpi-real  { border-top: 3px solid #10b981; }
.sap-kpi.kpi-plan  { border-top: 3px solid #8b5cf6; }
.sap-kpi.kpi-estim { border-top: 3px solid #f59e0b; }

/* --- Charts SAP --- */
.sap-charts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.sap-charts-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.sap-charts .chart-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 280px;
}
.sap-charts .chart-card-wide {
    grid-column: 1 / -1;
    min-height: 260px;
}
.sap-charts .chart-head h3 {
    font: 600 14px var(--font);
    color: #334155;
    letter-spacing: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sap-charts .chart-head h3::before {
    content: "";
    width: 8px; height: 8px;
    background: #3b82f6;
    border-radius: 50%;
}
.sap-charts .chart-canvas-wrap {
    flex: 1;
    min-height: 200px;
    position: relative;
}

/* --- Tabla SAP --- */
.sap-table-panel {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
    overflow: hidden;
}
.sap-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    background: #ffffff;
}
.sap-table-title {
    display: flex;
    align-items: center;
    gap: 10px;
}
.sap-table-title svg {
    color: #64748b;
}
.sap-table-title h3 {
    font: 600 15px var(--font);
    color: #0f172a;
}
.sap-count {
    font: 500 12px var(--font);
    color: #64748b;
    background: #f1f5f9;
    padding: 3px 10px;
    border-radius: 20px;
    margin-left: 4px;
}
.sap-table-wrap {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 600px;
}
.sap-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    color: #334155;
    min-width: 1100px;
}
.sap-table thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 2;
    padding: 12px 16px;
    text-align: left;
    font: 600 11px var(--font);
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}
.sap-table thead th.text-right { text-align: right; }
.sap-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid #f8fafc;
    vertical-align: middle;
}
.sap-table tbody tr:nth-child(even) { background: #fafafa; }
.sap-table tbody tr:hover { background: #f1f5f9; }
.sap-table tbody td.text-right { text-align: right; }
.sap-table tbody td.mono { font-feature-settings: "tnum"; color: #475569; }
.sap-table tbody td.strong { font-weight: 700; color: #0f172a; }
.sap-table .sap-texto {
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sap-table .sap-ubi strong {
    font-weight: 600;
    color: #0f172a;
}
.sap-table .sap-ubi-den {
    color: #64748b;
    font-size: 12px;
    max-width: 240px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sap-empty-row {
    text-align: center;
    padding: 40px 16px !important;
    color: #94a3b8;
    background: #ffffff !important;
}

/* --- Chips de prioridad --- */
.sap-prio {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 9px;
    border-radius: 6px;
    font: 700 12px var(--font);
}
.sap-prio.prio-1 { background: #fef2f2; color: #b91c1c; }
.sap-prio.prio-2 { background: #fff7ed; color: #c2410c; }
.sap-prio.prio-3 { background: #fefce8; color: #a16207; }
.sap-prio.prio-4 { background: #f0fdf4; color: #15803d; }
.sap-prio.prio-n { background: #f8fafc; color: #64748b; }

/* --- Paginador --- */
.sap-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-top: 1px solid #f1f5f9;
    background: #ffffff;
    flex-wrap: wrap;
    gap: 12px;
}
.sap-pager-info {
    font: 500 13px var(--font);
    color: #64748b;
}
.sap-pager-nav {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.sap-pager-nav .btn {
    padding: 7px 13px;
    font: 600 13px var(--font);
    border-radius: 8px;
    min-width: 36px;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* --- Sin datos SAP --- */
.sap-empty {
    background: #ffffff;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    padding: 48px 24px;
    text-align: center;
    color: #64748b;
}
.sap-empty h3 {
    color: #0f172a;
    font: 600 18px var(--font);
    margin-bottom: 8px;
}

/* --- Responsive SAP --- */
@media (max-width: 1300px) {
    .sap-kpi-row { grid-template-columns: 1.25fr 1fr 1fr; }
    .sap-kpi.kpi-estim { grid-column: 1 / -1; }
    .sap-banner-metrics { gap: 28px; padding: 0 10px; }
}
@media (max-width: 1100px) {
    .sap-banner { flex-wrap: wrap; }
    .sap-banner-metrics {
        order: 3;
        width: 100%;
        justify-content: flex-start;
        padding: 12px 0 0;
        border-top: 1px solid #f1f5f9;
    }
    .sap-banner-cta { order: 2; }
    .sap-filterbar { gap: 12px; }
    .sap-filterbar-divider { display: none; }
    .sap-filterbar-group { width: 100%; }
    .sap-filterbar-actions { margin-left: 0; }
}
@media (max-width: 900px) {
    .sap-kpi-row { grid-template-columns: repeat(2, 1fr); }
    .sap-kpi.kpi-estim { grid-column: auto; }
    .sap-charts { grid-template-columns: 1fr; }
    .sap-charts-row { grid-template-columns: 1fr; grid-column: auto; }
    .sap-charts .chart-card-wide { grid-column: auto; }
}
@media (max-width: 640px) {
    .sap-kpi-row { grid-template-columns: 1fr; }
    .sap-banner-brand { width: 100%; }
    .sap-banner-metrics { flex-direction: column; gap: 14px; align-items: stretch; }
    .sap-banner-cta { width: 100%; justify-content: center; }
    .sap-filterbar-search { max-width: 100%; }
    .sap-filterbar-field { min-width: 100%; }
    .sap-filterbar-actions { width: 100%; }
    .sap-filterbar-actions .btn { flex: 1; text-align: center; justify-content: center; }
    .sap-pager { flex-direction: column; align-items: stretch; }
}

/* --- Wizard de importacion SAP --- */
.import-form { max-width: 720px; }
.file-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 48px 24px;
    border: 2px dashed #cbd5e1;
    border-radius: 14px;
    background: #f8fafc;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}
.file-dropzone:hover { border-color: #2563eb; background: #eff6ff; }
.file-dropzone input[type="file"] { display: none; }
.dropzone-text {
    color: #475569;
    font: 500 15px var(--font);
    text-align: center;
}
.import-instructions { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px 24px; }
.import-instructions h3 { margin: 0 0 12px; font: 600 16px var(--font); color: #0f172a; }
.import-instructions ul { margin: 0; padding-left: 20px; color: #475569; }
.import-instructions li { margin-bottom: 6px; }
.mapping-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
    margin: 16px 0 24px;
}
.mapping-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #f1f5f9;
    font-size: 13px;
}
.mapping-row.mapped { background: #ecfdf5; }
.mapping-row.unmapped { background: #fef2f2; }
.mapping-field { font-weight: 600; color: #0f172a; }
.mapping-arrow { color: #94a3b8; }
.mapping-col { color: #334155; }
.mapping-row.unmapped .mapping-col { color: #ef4444; }
.preview-table { font-size: 13px; }
.preview-table th,
.preview-table td { white-space: nowrap; }
