* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #0a0f1e;
    color: #e2e8f0;
    min-height: 100vh;
    overflow-x: hidden;
}

body.sidebar-open {
    overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
    width: 160px;
    height: 100vh;
    background: linear-gradient(160deg, #1a1f3a 0%, #0d1224 100%);
    position: fixed;
    top: 0;
    left: 0;
    padding: 20px 12px;
    border-right: 1px solid rgba(99, 102, 241, 0.2);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: width 0.25s ease, padding 0.25s ease;
    overflow: hidden;
}

/* Sidebar colapsado en escritorio */
body.sidebar-collapsed .sidebar {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    border-right: none;
}

/* Botón colapsar (desktop) */
.btn-collapse {
    position: fixed;
    top: 12px;
    left: 168px;
    z-index: 200;
    width: 26px;
    height: 26px;
    background: #1a1f3a;
    border: 1px solid rgba(99,102,241,0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: left 0.25s ease, background 0.2s;
    color: #818cf8;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
body.sidebar-collapsed .btn-collapse { left: 6px; }
.btn-collapse:hover { background: rgba(99,102,241,0.3); color: #c7d2fe; }

.sidebar h2 {
    font-size: 1rem;
    font-weight: 700;
    color: #818cf8;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.3);
    text-shadow: 0 0 20px rgba(129, 140, 248, 0.6);
    white-space: nowrap;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #94a3b8;
    padding: 12px 16px;
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.25s ease;
    border: 1px solid transparent;
}

.sidebar a:hover {
    background: rgba(99, 102, 241, 0.15);
    color: #c7d2fe;
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateX(4px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
}

/* ── MAIN ── */
.main {
    margin-left: 160px;
    padding: 36px 32px;
    min-height: 100vh;
    transition: margin-left 0.25s ease;
}

body.sidebar-collapsed .main {
    margin-left: 0;
}

.main h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 30px;
    color: #e2e8f0;
    letter-spacing: 0.5px;
    position: relative;
    padding-bottom: 14px;
}

.main h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 3px;
    background: linear-gradient(90deg, #6366f1, #818cf8);
    border-radius: 2px;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.6);
}

/* ── CARDS ── */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

/* Card base — tono operativo MAMEY (coral-naranja) */
.card {
    background: linear-gradient(155deg, #241410 0%, #150b08 100%);
    border-radius: 10px;
    border: 1px solid rgba(244, 132, 95, 0.28);
    box-shadow:
        0 4px 14px rgba(0, 0, 0, 0.4),
        0 1px 0 rgba(244, 132, 95, 0.06) inset;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Card tono cliente (azul) */
.card-cliente {
    background: linear-gradient(155deg, #0c1e2e 0%, #071320 100%);
    border-color: rgba(56, 189, 248, 0.28);
    box-shadow:
        0 4px 14px rgba(0, 0, 0, 0.4),
        0 1px 0 rgba(56, 189, 248, 0.06) inset;
}

.card::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -20%;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.card:hover {
    transform: translateY(-4px);
    border-color: rgba(244, 132, 95, 0.55);
    box-shadow: 0 12px 32px rgba(0,0,0,0.5), 0 0 20px rgba(244,132,95,0.18);
}

.card-cliente:hover {
    border-color: rgba(56, 189, 248, 0.55);
    box-shadow: 0 12px 32px rgba(0,0,0,0.5), 0 0 20px rgba(56,189,248,0.15);
}

/* Cabecera de la ficha */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: rgba(244, 132, 95, 0.07);
    border-bottom: 1px solid rgba(244, 132, 95, 0.12);
}

.card-cliente .card-header {
    background: rgba(56, 189, 248, 0.07);
    border-bottom-color: rgba(56, 189, 248, 0.12);
}

.card-orden {
    font-size: 0.6rem;
    font-weight: 700;
    color: #f4845f;
    letter-spacing: 1px;
    text-transform: uppercase;
    background: rgba(244, 132, 95, 0.12);
    padding: 1px 6px;
    border-radius: 20px;
    border: 1px solid rgba(244, 132, 95, 0.25);
}

.card-cliente .card-orden {
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.25);
}

.card-icono {
    font-size: 0.9rem;
}

/* Cuerpo */
.card-body {
    padding: 8px 10px 6px;
    flex: 1;
}

.card-body h3 {
    font-size: 0.85rem;
    font-weight: 700;
    color: #c7d2fe;
    margin-bottom: 2px;
    text-transform: capitalize;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-body p {
    font-size: 0.7rem;
    color: #64748b;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Link info */
.card-footer {
    padding: 4px 10px;
    border-top: 1px dashed rgba(99, 102, 241, 0.1);
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.card-link-label {
    font-size: 0.58rem;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.card-footer a {
    font-size: 0.65rem;
    color: #6366f1;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s;
}

.card-footer a:hover {
    color: #a5b4fc;
}

/* Botón acción */
.card-action {
    padding: 7px 10px;
}

.btn-abrir {
    display: block;
    text-align: center;
    background: linear-gradient(135deg, #c2523a, #f4845f);
    color: white !important;
    padding: 5px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: all 0.25s ease;
    box-shadow: 0 3px 10px rgba(194, 82, 58, 0.35);
}

.btn-abrir:hover {
    background: linear-gradient(135deg, #a8402a, #c2523a);
    box-shadow: 0 5px 16px rgba(194, 82, 58, 0.55);
    transform: translateY(-1px);
}

.btn-abrir-cliente {
    background: linear-gradient(135deg, #0284c7, #38bdf8);
    box-shadow: 0 3px 10px rgba(2, 132, 199, 0.35);
}

.btn-abrir-cliente:hover {
    background: linear-gradient(135deg, #0369a1, #0284c7);
    box-shadow: 0 5px 16px rgba(2, 132, 199, 0.55);
}

/* ── ALERT ── */
.alert {
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #a5b4fc;
    padding: 12px 18px;
    border-radius: 10px;
    margin-bottom: 24px;
    font-size: 0.9rem;
}

/* ── FORM CARD ── */
.form-card {
    background: linear-gradient(155deg, #1e2a4a 0%, #131c33 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 16px;
    padding: 28px;
    margin-bottom: 36px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.form-card h2 {
    font-size: 1rem;
    font-weight: 600;
    color: #818cf8;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-row {
    display: flex;
    gap: 20px;
}

.form-row .form-group {
    flex: 1;
}

.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.form-group input {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 8px;
    padding: 10px 14px;
    color: #e2e8f0;
    font-size: 0.9rem;
    transition: border-color 0.2s;
    outline: none;
}

.form-group input:focus {
    border-color: rgba(99, 102, 241, 0.6);
    background: rgba(15, 23, 42, 0.8);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: #94a3b8;
}

.form-check input {
    width: 16px;
    height: 16px;
    accent-color: #6366f1;
}

.form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-primary {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4338ca, #4f46e5);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.55);
    transform: translateY(-1px);
}

.btn-cancel {
    color: #64748b;
    text-decoration: none;
    font-size: 0.88rem;
    padding: 10px 16px;
    border-radius: 10px;
    transition: color 0.2s;
}

.btn-cancel:hover {
    color: #94a3b8;
}

/* ── BUSCADOR ── */
.search-bar {
    margin-bottom: 16px;
}

.search-bar input {
    width: 100%;
    max-width: 380px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 10px;
    padding: 10px 16px;
    color: #e2e8f0;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-bar input:focus {
    border-color: rgba(99, 102, 241, 0.5);
}

.search-bar input::placeholder {
    color: #475569;
}

/* ── TABLA ── */
.table-wrap {
    background: linear-gradient(155deg, #1e2a4a 0%, #131c33 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead tr {
    background: rgba(99, 102, 241, 0.1);
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
}

th {
    padding: 14px 16px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: left;
}

td {
    padding: 14px 16px;
    font-size: 0.88rem;
    color: #94a3b8;
    border-bottom: 1px solid rgba(99, 102, 241, 0.07);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

td a {
    color: #6366f1;
    text-decoration: none;
    font-size: 0.82rem;
}

td a:hover {
    color: #a5b4fc;
}

.td-actions {
    display: flex;
    gap: 8px;
}

.btn-edit {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8 !important;
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 0.78rem !important;
    font-weight: 600;
    border: 1px solid rgba(99, 102, 241, 0.25);
    transition: all 0.2s;
}

.btn-edit:hover {
    background: rgba(99, 102, 241, 0.3) !important;
    color: #c7d2fe !important;
}

.btn-delete {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171 !important;
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 0.78rem !important;
    font-weight: 600;
    border: 1px solid rgba(239, 68, 68, 0.2);
    transition: all 0.2s;
}

.btn-delete:hover {
    background: rgba(239, 68, 68, 0.25) !important;
    color: #fca5a5 !important;
}

.badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-on {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.badge-off {
    background: rgba(100, 116, 139, 0.15);
    color: #64748b;
    border: 1px solid rgba(100, 116, 139, 0.2);
}

.badge-admin {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge-sup {
    background: rgba(251, 191, 36, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.25);
}

.badge-op {
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.badge-inspector {
    background: rgba(251, 146, 60, 0.12);
    color: #fb923c;
    border: 1px solid rgba(251, 146, 60, 0.25);
}

.badge-invitado {
    background: rgba(148, 163, 184, 0.12);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.badge-oficina {
    background: rgba(168, 85, 247, 0.12);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.25);
}

/* ── SIDEBAR FOOTER ── */
.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgba(99, 102, 241, 0.2);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-user {
    font-size: 0.75rem;
    color: #94a3b8;
    word-break: break-word;
    font-weight: 600;
}

.sidebar-nivel {
    font-size: 0.68rem;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.btn-logout {
    display: block;
    text-align: center;
    background: rgba(239, 68, 68, 0.1);
    color: #f87171 !important;
    padding: 8px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid rgba(239, 68, 68, 0.2);
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* ── LOGIN ── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-wrap {
    width: 100%;
    max-width: 300px;
    padding: 12px;
}

.login-card {
    background: linear-gradient(155deg, #1e2a4a 0%, #131c33 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 14px;
    padding: 28px 22px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-card h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #818cf8;
    text-align: center;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 6px;
    text-shadow: 0 0 20px rgba(129,140,248,0.4);
}

.login-sub {
    text-align: center;
    color: #475569;
    font-size: 0.82rem;
    margin-bottom: 28px;
}

.login-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #f87171;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.83rem;
    margin-bottom: 18px;
}

@media (max-width: 480px) {
    .login-card {
        padding: 24px 18px;
        border-radius: 12px;
    }
    .login-wrap {
        padding: 12px;
    }
    .login-card h1 {
        font-size: 1.2rem;
    }
    .form-group input,
    .form-group select {
        width: 100%;
        font-size: 1rem;
        padding: 12px 14px;
    }
    .btn-primary {
        padding: 12px;
        font-size: 1rem;
    }
}

/* Ocultar btn-collapse en móvil */
@media (max-width: 768px) {
    .btn-collapse { display: none; }
}

/* ── HAMBURGER ── */
.btn-hamburger {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 300;
    background: rgba(30, 42, 74, 0.95);
    border: 1px solid rgba(99, 102, 241, 0.35);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    padding: 0;
}

.btn-hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: #818cf8;
    border-radius: 2px;
    transition: all 0.25s ease;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 150;
}

/* ── RESPONSIVE MÓVIL ── */
@media (max-width: 768px) {
    .btn-hamburger {
        display: flex;
    }

    /* Sidebar oculto por defecto en móvil */
    .sidebar {
        transform: translateX(-260px);
        transition: transform 0.3s ease;
        z-index: 500;
        width: 220px;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 6px 0 30px rgba(0,0,0,0.7);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.6);
        z-index: 400;
    }

    .sidebar-overlay.open {
        display: block;
    }

    /* Contenido ocupa toda la pantalla */
    .main {
        margin-left: 0 !important;
        padding: 16px;
        padding-top: 66px;
        width: 100%;
    }

    /* Cards */
    .cards {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }

    /* Formulario */
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    .form-card { padding: 14px; }
    .main h1 { font-size: 1.3rem; }

    /* Tabla con scroll horizontal */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Ocultar columnas secundarias */
    .col-cedula, .col-cliente, .col-sistemas { display: none; }

    /* Celdas compactas */
    th, td { padding: 7px 8px; font-size: 0.76rem; white-space: nowrap; }

    .td-actions { flex-direction: column; gap: 4px; }
    .btn-edit, .btn-delete { padding: 4px 8px; font-size: 0.7rem !important; }
    .select-cargo { font-size: 0.7rem; padding: 2px 4px; max-width: 90px; }
}

/* ── SECCIONES DASHBOARD ── */
.seccion {
    margin-bottom: 40px;
}

.seccion-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.seccion-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.seccion-count {
    background: rgba(255,255,255,0.07);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
    margin-left: auto;
}

/* Cliente — azul */
.seccion-cliente { color: #38bdf8; }
.seccion-cliente .seccion-dot { background: #38bdf8; box-shadow: 0 0 8px #38bdf8; }

/* Operativo — mamey (coral-naranja) */
.seccion-operativo { color: #f4845f; }
.seccion-operativo .seccion-dot { background: #f4845f; box-shadow: 0 0 8px #f4845f; }

/* ── SISTEMAS CHECK ── */
.btn-sel-all {
    background: rgba(99, 102, 241, 0.12);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 5px;
    padding: 2px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    margin-left: 10px;
    transition: all 0.2s;
}
.btn-sel-all:hover {
    background: rgba(99, 102, 241, 0.25);
    color: #c7d2fe;
}


.sistemas-check {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 8px;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 7px;
    background: rgba(99, 102, 241, 0.07);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 0.82rem;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
}

.check-item:hover {
    background: rgba(99, 102, 241, 0.15);
    color: #c7d2fe;
}

.check-item input[type="checkbox"] {
    accent-color: #6366f1;
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.check-cat {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.check-cat-cliente  { background: #38bdf8; }
.check-cat-operativo { background: #818cf8; }

.sistemas-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tag-sistema {
    background: rgba(99, 102, 241, 0.12);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 0.72rem;
    white-space: nowrap;
}

/* Select en formulario */
.form-group select {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 8px;
    padding: 10px 14px;
    color: #e2e8f0;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.form-group select:focus {
    border-color: rgba(99, 102, 241, 0.6);
}
