:root {
    --primary:       #3a8fd1;   /* azul E-Tech */
    --primary-dark:  #2a72b0;   /* azul oscuro hover */
    --primary-light: #e8f4fc;   /* azul muy claro fondos */
    --accent:        #4caf50;   /* verde E-Tech */
    --accent-dark:   #388e3c;
    --accent-light:  #e8f5e9;
    --success:       #4caf50;
    --warning:       #f59e0b;
    --danger:        #e53935;
    --white:         #ffffff;
    --gray-50:       #f8fafc;
    --gray-100:      #f1f5f9;
    --gray-200:      #e2e8f0;
    --gray-400:      #94a3b8;
    --gray-600:      #475569;
    --gray-800:      #1e293b;
    --black:         #0f172a;
    --sidebar-bg:    #1e293b;   /* sidebar oscuro */
    --sidebar-w:     240px;
    --topbar-h:      60px;
    --radius:        8px;
    --shadow:        0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ============================================================
   LOGIN
   ============================================================ */
#loginContainer {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1f2937;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.login-logo { width: 240px; height: 80px; text-align: center; margin: 0 auto 12px; display: block; }
.login-card h1 { text-align: center; font-size: 20px; color: var(--primary); margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--gray-400); margin-bottom: 28px; font-size: 13px; }

.input-group { margin-bottom: 16px; }
.input-group label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--gray-600); font-size: 13px; }
.input-group input {
    width: 100%; padding: 10px 14px;
    border: 1.5px solid var(--gray-200); border-radius: var(--radius);
    transition: border-color .2s;
}
.input-group input:focus { outline: none; border-color: var(--primary); }

.btn-login {
    width: 100%; padding: 12px;
    background: var(--primary); color: white;
    border: none; border-radius: var(--radius);
    font-size: 15px; font-weight: 600;
    transition: background .2s, transform .05s;
    margin-top: 4px;
    display: inline-flex; align-items: center; justify-content: center;
    gap: 10px;
    min-height: 46px;
}
.btn-login:hover { background: var(--primary-dark); }
.btn-login:active { transform: translateY(1px); }
.btn-login:disabled,
.btn-login[aria-busy="true"] {
    opacity: .75;
    cursor: not-allowed;
    background: var(--primary-dark);
}
.btn-login__spinner {
    display: none;
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btnLoginSpin .7s linear infinite;
}
.btn-login[aria-busy="true"] .btn-login__spinner { display: inline-block; }
@keyframes btnLoginSpin { to { transform: rotate(360deg); } }

/* Wrapper de contraseña con botón mostrar/ocultar */
.login-password-wrap { position: relative; }
.login-password-wrap > input { padding-right: 42px; width: 100%; }
.login-password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent;
    border: none;
    color: var(--gray-400);
    border-radius: 6px;
    transition: color .15s, background .15s;
}
.login-password-toggle:hover { color: var(--primary); background: var(--primary-light); }
.login-password-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

/* Hint de Caps Lock — oculto por defecto, se muestra solo con .is-on */
.login-caps-hint {
    display: none;
    margin-top: 6px;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--warning);
    background: #fef3c7;
    padding: 4px 8px;
    border-radius: 6px;
}
.login-caps-hint.is-on { display: inline-flex; }

/* Alerta de login — oculta por defecto y solo visible con .is-visible y contenido */
.login-alert {
    display: none;
    margin-top: 14px;
    padding: 11px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    background: #fee2e2;
    color: var(--danger);
    border: 1px solid #fecaca;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.4;
    animation: loginAlertIn .18s ease;
}
.login-alert.is-visible:not(:empty) { display: flex; }
.login-alert::before {
    content: "\f071"; /* fa-triangle-exclamation */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    line-height: 1.4;
}

/* Hard-stop: si tienen el atributo hidden, no se muestran nunca,
   independientemente de otras reglas con display. */
.login-caps-hint[hidden],
.login-alert[hidden] { display: none !important; }
@keyframes loginAlertIn {
    from { transform: translateY(-4px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* Estado de error en input */
.input-group input.is-invalid {
    border-color: var(--danger);
    background: #fef2f2;
}
.input-group input.is-invalid:focus { border-color: var(--danger); }

/* ============================================================
   PERMISSIONS EDITOR (módulo + acciones)
   ============================================================ */
.permissions-editor {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 18px 18px 14px;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}
.permissions-editor__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 14px;
}
.permissions-editor__title {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 700;
    color: var(--gray-800);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.permissions-editor__title i { color: var(--primary); }
.permissions-editor__hint {
    margin: 0;
    font-size: 12px;
    color: var(--gray-600);
    line-height: 1.5;
    max-width: 540px;
}
.permissions-editor__bulk {
    display: inline-flex; gap: 14px; flex-shrink: 0;
}
.permissions-editor__bulk .btn-link {
    background: none; border: none; padding: 0;
    color: var(--primary); font-size: 12px; font-weight: 600;
    cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
}
.permissions-editor__bulk .btn-link:hover { text-decoration: underline; }

.permissions-editor__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.permissions-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-left: 4px solid var(--mod-color, var(--primary));
    border-radius: 12px;
    padding: 14px 14px 12px;
    transition: border-color .15s, box-shadow .15s, transform .05s;
    display: flex; flex-direction: column; gap: 12px;
    min-height: 0;
}
.permissions-card:hover { box-shadow: 0 2px 8px rgba(15, 23, 42, .07); }
.permissions-card--active { border-color: var(--mod-color, var(--primary)); }

.permissions-card__head {
    display: flex; align-items: flex-start; gap: 12px;
}
.permissions-card__title {
    flex: 1; min-width: 0;
    display: flex; gap: 10px; align-items: flex-start;
}
.permissions-card__icon {
    color: var(--mod-color, var(--primary));
    font-size: 18px;
    margin-top: 2px;
}
.permissions-card__name {
    font-size: 14px; font-weight: 700; color: var(--gray-800);
    line-height: 1.2;
}
.permissions-card__desc {
    font-size: 12px; color: var(--gray-600); line-height: 1.45;
    margin-top: 2px;
}

/* Switch (toggle) */
.permissions-card__toggle { position: relative; display: inline-block; cursor: pointer; flex-shrink: 0; }
.permissions-card__switch {
    position: absolute; opacity: 0; width: 0; height: 0;
}
.permissions-card__switch-track {
    display: inline-block; width: 38px; height: 22px;
    background: #cbd5e1;
    border-radius: 999px; position: relative;
    transition: background .2s;
}
.permissions-card__switch-knob {
    position: absolute; top: 2px; left: 2px;
    width: 18px; height: 18px;
    background: white; border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    transition: transform .2s;
}
.permissions-card__switch:checked + .permissions-card__switch-track {
    background: var(--mod-color, var(--primary));
}
.permissions-card__switch:checked + .permissions-card__switch-track .permissions-card__switch-knob {
    transform: translateX(16px);
}
.permissions-card__switch:focus-visible + .permissions-card__switch-track {
    outline: 2px solid var(--mod-color, var(--primary));
    outline-offset: 2px;
}

/* Sub-acciones */
.permissions-card__actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 8px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height .25s ease, opacity .2s ease, margin .2s ease;
}
.permissions-card--active .permissions-card__actions {
    max-height: 240px;
    opacity: 1;
}
.permissions-action {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 10px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 12px; font-weight: 600; color: var(--gray-600);
    cursor: pointer;
    transition: all .15s;
    user-select: none;
}
.permissions-action:hover { border-color: var(--mod-color, var(--primary)); color: var(--mod-color, var(--primary)); }
.permissions-action__checkbox { display: none; }
.permissions-action__icon { font-size: 12px; }
.permissions-action__label { white-space: nowrap; }
.permissions-action:has(.permissions-action__checkbox:checked) {
    background: color-mix(in srgb, var(--mod-color, var(--primary)) 12%, white);
    border-color: var(--mod-color, var(--primary));
    color: var(--mod-color, var(--primary));
}

.permissions-editor__summary {
    margin-top: 14px;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 12px;
    color: var(--gray-600);
    background: #eef2ff;
    border: 1px solid #e0e7ff;
    display: flex; align-items: flex-start; gap: 8px;
    line-height: 1.5;
}
.permissions-editor__summary i { color: var(--primary); margin-top: 2px; }
.permissions-editor__summary--warn {
    background: #fef3c7;
    border-color: #fde68a;
    color: #92400e;
}
.permissions-editor__summary--warn i { color: #d97706; }

/* ============================================================
   PASSWORD METER + INPUTS DE CONTRASEÑA (modal usuario)
   ============================================================ */
.password-input-wrap {
    position: relative;
    display: block;
}
.password-input-wrap > input {
    padding-right: 42px;
    width: 100%;
}
.password-input-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent;
    border: none;
    color: var(--gray-400);
    border-radius: 6px;
    transition: color .15s, background .15s;
    cursor: pointer;
}
.password-input-toggle:hover { color: var(--primary); background: var(--primary-light); }
.password-input-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.password-meter {
    margin-top: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
}
.password-meter:empty {
    display: none;
}
.password-meter__head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.password-meter__bar {
    flex: 1;
    height: 6px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}
.password-meter__bar-fill {
    height: 100%;
    width: 0%;
    background: var(--gray-400);
    border-radius: 999px;
    transition: width .25s ease, background .25s ease;
}
.password-meter__level {
    font-size: 12px;
    font-weight: 700;
    min-width: 90px;
    text-align: right;
    color: var(--gray-500);
}
.password-meter__reqs {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 4px 14px;
}
.password-meter__reqs li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--gray-500);
    line-height: 1.45;
    transition: color .15s;
}
.password-meter__reqs li i {
    font-size: 12px;
    flex-shrink: 0;
}
.password-meter__reqs li.is-pending { color: var(--gray-500); }
.password-meter__reqs li.is-pending i { color: #cbd5e1; }
.password-meter__reqs li.is-ok { color: #15803d; }
.password-meter__reqs li.is-ok i { color: #16a34a; }

.password-meter__match {
    margin-top: 10px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.password-meter__match[hidden] { display: none; }
.password-meter__match[data-state="match"] {
    background: #ecfdf5;
    color: #15803d;
    border: 1px solid #bbf7d0;
}
.password-meter__match[data-state="mismatch"] {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.login-brand {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 25px;
    border-top: 1px solid var(--gray-200);
}
.login-brand__label {
    font-size: 8px;
    color: var(--gray-400);
    font-weight: 500;
    letter-spacing: .6px;
    text-transform: uppercase;
    white-space: nowrap;
}
.login-brand__logo {
    height: 80px;
    width: auto;
    object-fit: contain;
    opacity: 1;
    transition: opacity .2s;
}
.login-brand:hover .login-brand__logo {
    opacity: .8;
}

.login-demo { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--gray-200); }
.login-demo p { text-align: center; color: var(--gray-400); font-size: 12px; margin-bottom: 10px; }
.demo-users { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.demo-users span {
    padding: 5px 10px; background: var(--primary-light); color: var(--primary);
    border-radius: 20px; font-size: 12px; cursor: pointer; transition: background .2s;
}
.demo-users span:hover { background: var(--primary); color: var(--white); }

/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */
#app { width: 100%; overflow-x: hidden; }
#mainContainer {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    overflow: hidden;
}

/* SIDEBAR */
#sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .3s ease;
    transform: translateX(0);
}

/* En desktop: al hacer toggle se oculta */
@media (min-width: 901px) {
    #sidebar.open {
        transform: translateX(-100%);
    }
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    height: var(--topbar-h); /* misma altura que el topbar = 60px */
    min-height: var(--topbar-h);
    border-bottom: 1px solid rgba(255,255,255,.1);
    flex-shrink: 0;
}
.sidebar-logo { font-size: 24px; }
.sidebar-logo-img {
    height: 40px;
    max-height: 44px;
    width: auto;
    object-fit: contain;
    flex: 1;
    min-width: 0;
}
.sidebar-toggle {
    background: none;
    border: none;
    color: rgba(255,255,255,.7);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 5px;
    transition: background .2s, color .2s;
    flex-shrink: 0;
}
.sidebar-toggle:hover {
    background: rgba(255,255,255,.1);
    color: white;
}

.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--primary); display: flex; align-items: center;
    justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0;
    color: var(--white);
}
.user-details { display: flex; flex-direction: column; overflow: hidden; }
.user-details span:first-child { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rol-badge {
    font-size: 10px; padding: 2px 8px; border-radius: 10px;
    background: rgba(255,255,255,.15); width: fit-content; margin-top: 2px;
    text-transform: uppercase; letter-spacing: .5px;
}

#sidebarNav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; color: rgba(255,255,255,.75);
    border: none; background: none; width: 100%;
    text-align: left; font-size: 14px; border-radius: 0;
    transition: all .2s; cursor: pointer;
}
.nav-item:hover { background: rgba(58,143,209,.2); color: var(--white); }
.nav-item.active { background: var(--primary); color: var(--white); }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }

.btn-logout {
    margin: 12px; padding: 10px;
    background: rgba(224,36,36,.15); color: #fc8181;
    border: 1px solid rgba(224,36,36,.3); border-radius: var(--radius);
    font-size: 13px; transition: all .2s;
}
.btn-logout:hover { background: var(--danger); color: white; }

/* PAGE CONTENT */
#pageContent {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: calc(100% - var(--sidebar-w));
    min-width: 0;
    background: var(--gray-100);
    transition: margin-left .3s ease, width .3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Cuando el sidebar está colapsado en desktop */
#pageContent.sidebar-collapsed {
    margin-left: 0;
    width: 100%;
}

/* TOP BAR */
#topBar {
    height: var(--topbar-h);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center;
    padding: 0 24px; gap: 16px;
    position: sticky;
    top: 0;
    z-index: 300;
    flex-shrink: 0;
    box-shadow: var(--shadow);
}
#topBar h2 { font-size: 18px; flex: 1; }
.menu-toggle {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--gray-600);
    padding: 4px 8px;
    border-radius: 5px;
    transition: background .2s;
    display: none; /* oculto en desktop por defecto (sidebar visible) */
}
.menu-toggle:hover { background: var(--gray-100); }

/* En móvil siempre visible */
@media (max-width: 900px) {
    .menu-toggle { display: block !important; }
}

/* En desktop aparece solo cuando sidebar está colapsado */
.sidebar-collapsed .menu-toggle-show,
body.sidebar-hidden #menuToggle { display: block; }
.topbar-logo {
    height: 36px;
    width: auto;
    object-fit: contain;
}
.topbar-right { color: var(--gray-600); font-size: 13px; }

/* MAIN CONTENT */
#mainContent { padding: 24px; flex: 1; min-height: 0; }

/* ============================================================
   VISTAS
   ============================================================ */
.view { display: none; }
.view.active { display: block; }

.view-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.view-header h2 { font-size: 20px; }
.view-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}
.stat-card.green  { border-color: var(--accent); }
.stat-card.orange { border-color: var(--warning); }
.stat-card.red    { border-color: var(--danger); }

.stat-label { font-size: 12px; color: #1f2937; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 700; color: #000000; }
.stat-sub { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.chart-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.chart-card h3 { font-size: 14px; color: var(--gray-600); margin-bottom: 16px; }

.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-item { display: flex; align-items: center; gap: 10px; }
.bar-label { font-size: 12px; color: var(--gray-600); width: 120px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; background: var(--gray-100); border-radius: 4px; height: 20px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width .5s; display: flex; align-items: center; padding-left: 6px; }
.bar-fill span { font-size: 11px; color: white; font-weight: 600; }

/* ============================================================
   ÓRDENES
   ============================================================ */
.ordenes-table { width: 100%; border-collapse: collapse; background: white; }
.ordenes-table th {
    background: #f8fafc;
    color: #475569;
    padding: 12px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}
.ordenes-table td { padding: 14px 16px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; font-size: 14px; color: #334155; }
.ordenes-table tbody tr:last-child td { border-bottom: none; }
.ordenes-table tbody tr:hover td { background: #f8fafc; }

.estado-badge {
    display: inline-block; padding: 3px 10px;
    border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.estado-pendiente  { background: #fff3cd; color: #856404; }
.estado-asignada   { background: #d4edda; color: #155724; }
.estado-cerrada    { background: #f8d7da; color: #721c24; }

.btn-icon { padding: 5px 8px; border: none; border-radius: 5px; font-size: 13px; transition: opacity .2s; }
.btn-icon:hover { opacity: .8; }
.btn-pdf { background: #fee2e2; color: var(--danger); }
.btn-excel { background: #d1fae5; color: var(--success); }
.btn-edit { background: #dbeafe; color: var(--primary); }
.btn-estado-sel { padding: 4px 8px; border: 1px solid var(--gray-200); border-radius: 5px; font-size: 12px; background: white; }

/* ============================================================
   FORMULARIO ORDEN
   ============================================================ */
.form-orden { max-width: 1000px; margin: 0 auto; }

.form-card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.form-card-title {
    font-size: 15px; font-weight: 700;
    color: var(--primary); margin-bottom: 18px;
    padding-bottom: 10px; border-bottom: 2px solid var(--primary-light);
}

/* Estado vacío estándar (listados / tablas) */
.table-empty-state {
    margin: 0;
}
.table-empty-state__card {
    text-align: center;
    padding: 48px 28px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--gray-200, #e2e8f0);
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(15, 23, 42, 0.06));
}
.table-empty-state__icon {
    font-size: 4.25rem;
    color: #94a3b8;
    margin: 0 auto 1.1rem;
    display: block;
    line-height: 1;
    opacity: 0.92;
}
.table-empty-state__message {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    color: #64748b;
    line-height: 1.55;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}
.table-empty-state__hint {
    margin: 0.55rem auto 0;
    font-size: 0.875rem;
    color: #94a3b8;
    line-height: 1.45;
    max-width: 440px;
}
.table-empty-state--compact .table-empty-state__card {
    padding: 36px 20px;
}
.table-empty-state--compact .table-empty-state__icon {
    font-size: 3rem;
    margin-bottom: 0.85rem;
}
.table-empty-state-row .table-empty-state-cell {
    padding: 12px 8px 16px;
    border: none;
    background: transparent;
    vertical-align: middle;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--gray-600); }
.form-group input, .form-group select, .form-group textarea {
    padding: 9px 12px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    transition: border-color .2s;
    background: white;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary);
}
.form-group textarea { resize: vertical; min-height: 80px; }

.checks-row { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 14px; }
.check-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.check-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }

/* Repuestos */
.repuesto-row {
    display: grid;
    grid-template-columns: 120px 1fr 70px 1fr 36px;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}
.repuesto-row input {
    padding: 8px 10px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    width: 100%;
    box-sizing: border-box;
}
.repuesto-row input:focus { outline: none; border-color: var(--primary); }
.btn-remove-rep {
    background: var(--danger); color: white;
    border: none; border-radius: var(--radius);
    width: 32px; height: 32px; font-size: 14px;
}
.btn-add-rep {
    background: var(--primary-light); color: var(--primary);
    border: 1.5px dashed var(--primary); border-radius: var(--radius);
    padding: 8px 16px; font-size: 13px; font-weight: 600;
    margin-top: 4px; transition: all .2s;
}
.btn-add-rep:hover { background: var(--primary); color: var(--white); }

/* Firmas */
.firmas-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 16px; }
.firma-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: var(--radius);
}
.firma-box label { font-size: 12px; font-weight: 600; color: var(--gray-600); align-self: center; text-align: center; }
.firma-canvas {
    border: 2px solid var(--gray-200); border-radius: var(--radius);
    cursor: crosshair; background: white; width: 100%; max-width: 360px;
    touch-action: none;
    display: block;
    margin: 0 auto;
}
.firma-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.firma-actions button {
    padding: 5px 12px; background: var(--gray-100);
    border: 1px solid var(--gray-200); border-radius: 5px;
    font-size: 12px; color: var(--gray-600);
}

.form-footer {
    display: flex; justify-content: flex-end; gap: 12px;
    padding-top: 8px;
}

/* ============================================================
   EQUIPOS Y USUARIOS (CARDS)
   ============================================================ */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.item-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--primary);
    transition: box-shadow .2s;
}
.item-card:hover { box-shadow: var(--shadow-md); }
.item-card h3 { font-size: 15px; margin-bottom: 10px; color: var(--gray-800); }
.item-card p { font-size: 13px; color: var(--gray-600); margin-bottom: 4px; }
.item-card p strong { color: var(--gray-800); }
.card-actions { display: flex; gap: 8px; margin-top: 14px; }

/* ============================================================
   FACTURACIÓN
   ============================================================ */
.info-badge {
    background: #fef3c7; color: #92400e;
    padding: 6px 14px; border-radius: 20px;
    font-size: 12px; font-weight: 600;
}

/* ============================================================
   MODALES
   ============================================================ */
.modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: 20px 40px;
}
.modal-content {
    background: white;
    border-radius: 16px;
    width: 100%; max-width: 600px;
    max-height: 90vh;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.modal-body {
    overflow-y: auto;
    flex: 1;
}

/* Ajustes de cuenta: mismo look redondeado que otros módulos */
#modalAjustes .modal-content {
    max-width: 480px;
    border: 1px solid var(--gray-200);
}
.modal-header h3 { font-size: 16px; }
.modal-header button { background: none; border: none; font-size: 18px; color: var(--gray-400); }
.modal-content .form-grid { padding: 20px 24px; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
}

/* ============================================================
   BOTONES
   ============================================================ */
.btn-primary {
    padding: 9px 20px; 
    background: var(--primary); 
    color: white;
    border: none; 
    border-radius: var(--radius);
    font-size: 14px; 
    font-weight: 600; 
    transition: background .2s;
}
.btn-primary-dashed {
    border: 1px var(--primary) dashed!important;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    padding: 9px 20px; background: white; color: var(--gray-600);
    border: 1.5px solid var(--gray-200); border-radius: var(--radius);
    font-size: 14px; font-weight: 600; transition: all .2s;
}
.btn-secondary:hover { border-color: var(--gray-400); }

.btn-export {
    padding: 8px 16px; background: var(--accent-light); color: var(--accent-dark);
    border: 1.5px solid var(--accent); border-radius: var(--radius);
    font-size: 13px; font-weight: 600; transition: all .2s;
}
.btn-export:hover { background: var(--accent); color: var(--white); }

/* ============================================================
   INPUTS BÚSQUEDA Y FILTRO
   ============================================================ */
.input {
    padding: 10px 12px;
}
.input-search, .input-select {
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 13px; background: white;
}
.input-search:focus, .input-select:focus { outline: none; border-color: var(--primary); }

/* ------------------------------------------------------------
   Buscador con ícono (lupa)
   Wrapper reutilizable: <div class="search-input"> + <i> + input
   El ícono queda absoluto a la izquierda; el input le hace hueco
   con padding-left. Cambia de color al enfocar gracias a
   :focus-within (sin necesidad de JS).
   ------------------------------------------------------------ */
.search-input {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.search-input > i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 13px;
    pointer-events: none;
    transition: color .15s ease;
}
.search-input > .input-search,
.search-input > .input {
    width: 100%;
    padding-left: 36px;
}
.search-input:focus-within > i { color: var(--primary); }
@media (max-width: 768px) {
    .search-input { width: 100%; min-width: 0 !important; }
}

/* ============================================================
   ALERTAS Y TOAST
   ============================================================ */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-top: 10px; }
.alert-error { background: #fee2e2; color: var(--danger); }
.alert-success { background: #d1fae5; color: var(--success); }

.toast {
    position: fixed; bottom: 24px; right: 24px;
    padding: 12px 20px; border-radius: var(--radius);
    background: var(--sidebar-bg); color: var(--white);
    font-size: 14px; z-index: 999;
    box-shadow: var(--shadow-md);
    animation: slideIn .3s ease;
}
.toast.success { background: var(--accent); }
.toast.error   { background: var(--danger); }

@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ============================================================
   RESPONSIVE — SIDEBAR HAMBURGUESA
   Desktop: sidebar visible, .open lo OCULTA (toggle)
   Móvil/tablet: sidebar oculto, .open lo MUESTRA
   ============================================================ */
@media (max-width: 900px) {
    #sidebar {
        transform: translateX(-100%);
        position: fixed;
        top: 0; left: 0; bottom: 0;
        z-index: 280;
        box-shadow: 4px 0 24px rgba(0,0,0,.35);
        transition: transform .3s ease;
    }
    #sidebar.is-open,
    #sidebar.open {
        transform: translateX(0);
    }

    #topBar {
        z-index: 300;
        position: sticky;
    }

    #pageContent {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100vw;
    }

    #mainContainer {
        width: 100%;
        overflow-x: hidden;
    }

    .repuesto-row { grid-template-columns: 1fr 1fr; }
    .firmas-grid  { grid-template-columns: 1fr; }
    .charts-grid  { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    #mainContent  { padding: 12px; }
    #topBar       { padding: 0 14px; }

    .view-header  { flex-direction: column; align-items: flex-start; }
    .view-actions { width: 100%; flex-direction: column; }
    .input-search, .input-select, .btn-export { width: 100%; }

    .form-grid    { grid-template-columns: 1fr; }
    .stats-grid   { grid-template-columns: 1fr 1fr; }
    .cards-grid   { grid-template-columns: 1fr; }

    .ordenes-table            { font-size: 12px; }
    .ordenes-table th,
    .ordenes-table td         { padding: 8px; }

    .repuesto-row  { grid-template-columns: 1fr; }
    .modal-content { max-height: 95vh; }
    .login-card    { padding: 24px; }
}

/* Overlay oscuro detrás del sidebar abierto */
#sidebarOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 270;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
}
#sidebarOverlay.show { display: block; }

/* ============================================================
   DETALLE DE ORDEN
   ============================================================ */
.detalle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}
.detalle-grid .form-card p {
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--gray-600);
    line-height: 1.5;
}
.detalle-grid .form-card p strong {
    color: var(--gray-800);
}

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