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

:root {
    /* Retro limpio: crema, tinta, verde terminal y coral */
    --primary:        #2f6f5e;
    --primary-dark:   #214f43;
    --primary-light:  #4f9b84;
    --primary-soft:   #e6f1ec;
    --primary-ghost:  #d7ebe4;
    --accent:         #d97745;

    --bg:             #f4efe3;
    --surface:        #fffaf0;
    --surface-2:      #fbf4e6;
    --surface-3:      #efe6d3;

    --text:           #24201a;
    --text-2:         #3d372e;
    --muted:          #716a5d;
    --muted-2:        #9a9180;
    --border:         #d8cbb7;
    --border-strong:  #b9aa91;
    --border-light:   #eadfcb;

    --normal:         #2f6f5e;
    --normal-bg:      #d7ebe4;
    --normal-ghost:   #edf7f3;
    --alert:          #b86b2f;
    --alert-bg:       #f6dfc9;
    --alert-ghost:    #fff4e9;
    --critical:       #a9463b;
    --critical-bg:    #f2d1cc;
    --critical-ghost: #fff0ed;

    --sidebar-w:      250px;
    --topbar-h:       60px;
    --radius:         4px;
    --radius-sm:      3px;
    --radius-lg:      6px;

    --shadow-xs:      2px 2px 0 rgba(36,32,26,.10);
    --shadow:         3px 3px 0 rgba(36,32,26,.14);
    --shadow-md:      5px 5px 0 rgba(36,32,26,.16);
    --shadow-lg:      8px 8px 0 rgba(36,32,26,.18);
    --shadow-xl:      10px 10px 0 rgba(36,32,26,.22);

    --grad-primary:   linear-gradient(135deg, #2f6f5e 0%, #4f9b84 100%);
    --grad-header:    linear-gradient(180deg, #fffaf0 0%, #fbf4e6 100%);

    --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'Courier New', 'SF Mono', Consolas, monospace;
}

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

html, body { height: 100%; }

body {
    font-family: var(--font);
    background:
        linear-gradient(rgba(36,32,26,.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(36,32,26,.035) 1px, transparent 1px),
        var(--bg);
    background-size: 28px 28px;
    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: 2px solid var(--text);
    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: 2px solid var(--text);
    background: var(--primary);
    color: var(--surface);
    border-radius: 50%;
    margin-bottom: 14px;
    box-shadow: 4px 4px 0 var(--text);
}
.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: 2px 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: 3px 3px 0 var(--primary);
    transform: translate(-1px, -1px);
}

.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: 2px solid var(--text); 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: 2px solid var(--text);
    box-shadow: 6px 0 0 rgba(36,32,26,.08);
}

.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 20px;
    border-bottom: 2px solid var(--text);
}
.brand-icon-sm {
    width: 36px; height: 36px; display: grid; place-items: center;
    background: var(--primary); border: 2px solid var(--text);
    border-radius: var(--radius); color: var(--surface);
    box-shadow: 3px 3px 0 var(--text);
}
.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: 2px solid var(--text);
    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: 2px solid var(--text);
    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: 2px solid var(--text);
    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: 2px solid var(--text);
    cursor: pointer; color: var(--text); padding: 6px;
    border-radius: var(--radius-sm);
    box-shadow: 2px 2px 0 var(--text);
}

.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: 2px solid var(--text);
    box-shadow: 2px 2px 0 var(--text);
}
.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: 2px solid var(--text);
    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: 2px solid var(--text);
    box-shadow: 2px 2px 0 var(--text);
}
.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: 2px solid var(--text);
    border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.panel-head {
    padding: 14px 18px; border-bottom: 2px solid var(--text);
    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: 2px solid var(--text);
}
.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: 2px solid var(--text);
    box-shadow: 4px 4px 0 var(--text);
}
.donut::after {
    content: ""; position: absolute; inset: 22px; background: var(--surface); border-radius: 50%;
    border: 2px solid var(--text);
}
.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: 2px solid var(--text); 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: 2px solid var(--text);
    box-shadow: 4px 4px 0 var(--text);
}
.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: 2px solid var(--text); font-feature-settings: "tnum";
}
.health-bar { width: 100%; height: 8px; background: var(--surface-3); border: 1px solid var(--text); 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: 2px solid var(--text);
    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: 2px 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: 3px 3px 0 var(--primary); transform: translate(-1px, -1px); }
#filter-condition {
    padding: 8px 30px 8px 10px; border: 2px 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: 3px 3px 0 var(--primary); transform: translate(-1px, -1px); }
.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: 2px 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: 2px solid var(--text);
}
.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: 2px solid var(--text); 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: 2px solid var(--text); 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: 2px solid var(--text);
}
.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: 2px 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: 3px 3px 0 var(--primary); transform: translate(-1px, -1px);
}
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: 2px 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: 2px 2px 0 var(--text); }
.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: 2px solid var(--text); 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: 3px 3px 0 var(--text);
}
.btn-primary:hover { background: var(--primary-dark); transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--text); }
.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: 2px solid var(--text); 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: 2px solid var(--text);
    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: 2px solid var(--text);
    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: 2px solid var(--text);
    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: 2px 2px 0 var(--text);
}
.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: 2px solid var(--border); font-size: 12.5px;
}
.modal-footer {
    padding: 14px 20px; border-top: 2px solid var(--text);
    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: 2px solid var(--text);
    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: 2px 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: 3px 3px 0 var(--primary); transform: translate(-1px, -1px);
}
.form-grid input.invalid, .form-grid select.invalid {
    border-color: var(--critical);
    box-shadow: 3px 3px 0 var(--critical);
}
.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); } }

/* ============================================================
   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-card { padding: 14px; }
    .kpi-value { font-size: 22px; }
}

@media (max-width: 1100px) {
    .kpi-grid { 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); }
    .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; }
}

@media (max-width: 520px) {
    .kpi-grid { 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; }
    .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; }
}
