*{
    box-sizing:border-box;
}

body{
    margin:0;
    font-family:Inter,Arial,sans-serif;
    background:#f4f6f8;
    color:#1f2937;
}

.app-shell{
    display:flex;
    min-height:100vh;
}

/* =========================================================
   SIDEBAR
   ========================================================= */

.sidebar{
    width:240px;
    background:#111827;
    color:#fff;
    padding:24px 16px;
    position:fixed;
    inset:0 auto 0 0;
}

/* =========================================================
   LOGO / MARCA TECNIMEX
   ========================================================= */

.brand{
    display:block;
    width:100%;
    max-width:208px;
    margin-bottom:28px;
    overflow:hidden;
}

.brand-logo{
    display:block !important;
    width:180px !important;
    max-width:100% !important;
    height:auto !important;
    object-fit:contain;
}

.brand span{
    display:block;
    margin-top:7px;
    font-size:13px;
    font-weight:500;
    color:#cbd5e1;
}

/* =========================================================
   NAVEGACIÓN
   ========================================================= */

.sidebar nav{
    display:grid;
    gap:6px;
}

.sidebar a{
    color:#e5e7eb;
    text-decoration:none;
    padding:10px 12px;
    border-radius:8px;
}

.sidebar a:hover{
    background:#1f2937;
}

.sidebar a.active{
    background:#243041;
    color:#fff;
}

/* =========================================================
   ÁREA PRINCIPAL
   ========================================================= */

.main{
    margin-left:240px;
    width:calc(100% - 240px);
}

.topbar{
    height:64px;
    background:white;
    border-bottom:1px solid #e5e7eb;
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:0 24px;
    position:sticky;
    top:0;
    z-index:4;
}

.userbox{
    font-size:13px;
    color:#6b7280;
}

.userbox a{
    color:#111827;
}

.content{
    padding:24px;
}

/* =========================================================
   GRIDS
   ========================================================= */

.grid{
    display:grid;
    gap:16px;
}

.kpis{
    grid-template-columns:repeat(4,minmax(0,1fr));
    margin-bottom:20px;
}

.two-col{
    grid-template-columns:2fr 1fr;
}

/* =========================================================
   CARDS
   ========================================================= */

.card{
    background:#fff;
    border:1px solid #e5e7eb;
    border-radius:12px;
    padding:18px;
    box-shadow:0 1px 2px rgba(0,0,0,.03);
}

.kpi .label{
    font-size:12px;
    text-transform:uppercase;
    color:#6b7280;
    font-weight:700;
}

.kpi .value{
    font-size:28px;
    font-weight:800;
    margin-top:8px;
}

.section-title{
    margin:0 0 14px;
}

/* =========================================================
   TOOLBAR
   ========================================================= */

.toolbar{
    display:flex;
    gap:10px;
    justify-content:space-between;
    align-items:center;
    margin-bottom:16px;
    flex-wrap:wrap;
}

/* =========================================================
   BOTONES
   ========================================================= */

.btn{
    display:inline-block;
    background:#111827;
    color:white;
    text-decoration:none;
    border:0;
    border-radius:8px;
    padding:10px 14px;
    cursor:pointer;
}

.btn.secondary{
    background:white;
    color:#111827;
    border:1px solid #d1d5db;
}

.btn.danger{
    background:#991b1b;
}

.btn.mini{
    padding:6px 9px;
    font-size:12px;
}

/* =========================================================
   TABLAS
   ========================================================= */

.table{
    width:100%;
    border-collapse:collapse;
    background:white;
}

.table th,
.table td{
    padding:11px;
    border-bottom:1px solid #e5e7eb;
    text-align:left;
    font-size:14px;
}

.table th{
    font-size:12px;
    text-transform:uppercase;
    color:#6b7280;
    background:#f9fafb;
}

.table-card{
    padding:0;
    overflow:auto;
}

/* =========================================================
   FORMULARIOS
   ========================================================= */

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

.field label{
    display:block;
    font-size:13px;
    font-weight:700;
    margin-bottom:6px;
}

.field input,
.field select,
.field textarea{
    width:100%;
    border:1px solid #d1d5db;
    border-radius:8px;
    padding:10px;
    background:white;
}

.field textarea{
    min-height:100px;
}

.full{
    grid-column:1/-1;
}

/* =========================================================
   AVISOS
   ========================================================= */

.notice{
    padding:12px 14px;
    border-radius:8px;
    background:#eff6ff;
    border:1px solid #bfdbfe;
    margin-bottom:16px;
}

.notice.success{
    background:#ecfdf5;
    border-color:#a7f3d0;
}

.error{
    background:#fef2f2;
    border-color:#fecaca;
}

/* =========================================================
   ESTADOS
   ========================================================= */

.status{
    display:inline-block;
    border-radius:999px;
    background:#eef2ff;
    padding:4px 8px;
    font-size:12px;
    font-weight:700;
}

.status.ok{
    background:#dcfce7;
    color:#166534;
}

.status.off{
    background:#fee2e2;
    color:#991b1b;
}

.status.warn{
    background:#fef3c7;
    color:#92400e;
}

.pill{
    font-size:11px;
    border-radius:999px;
    padding:4px 8px;
    background:#f3f4f6;
}

/* =========================================================
   GRÁFICOS / BARRAS
   ========================================================= */

.bars{
    display:grid;
    gap:10px;
}

.bar-row{
    display:grid;
    grid-template-columns:46px 1fr 120px;
    gap:10px;
    align-items:center;
    font-size:13px;
}

.bar-track{
    height:12px;
    background:#e5e7eb;
    border-radius:99px;
    overflow:hidden;
}

.bar-fill{
    height:100%;
    background:#374151;
    border-radius:99px;
}

/* =========================================================
   LOGIN
   ========================================================= */

.login-body{
    min-height:100vh;
    display:grid;
    place-items:center;
    background:#f3f4f6;
}

.login-card{
    width:min(420px,92vw);
    background:white;
    padding:28px;
    border-radius:14px;
    border:1px solid #e5e7eb;
}

.login-card h1{
    margin-top:0;
}

.muted{
    color:#6b7280;
    font-size:13px;
}

/* =========================================================
   ADMINISTRACIÓN
   ========================================================= */

.admin-grid{
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:16px;
}

.admin-card{
    display:flex;
    gap:14px;
    align-items:flex-start;
    background:#fff;
    border:1px solid #e5e7eb;
    border-radius:12px;
    padding:18px;
    text-decoration:none;
    color:#1f2937;
    box-shadow:0 1px 2px rgba(0,0,0,.03);
}

.admin-card:hover{
    border-color:#9ca3af;
    transform:translateY(-1px);
}

.admin-card strong{
    display:block;
    font-size:16px;
    margin-bottom:4px;
}

.admin-card small{
    display:block;
    color:#6b7280;
    line-height:1.4;
}

.admin-icon{
    width:38px;
    height:38px;
    border-radius:10px;
    background:#111827;
    color:#fff;
    display:grid;
    place-items:center;
    font-weight:800;
    flex:0 0 38px;
}

.back-link{
    display:inline-block;
    margin-bottom:8px;
    color:#4b5563;
    text-decoration:none;
    font-size:13px;
}

/* =========================================================
   ACCIONES
   ========================================================= */

.actions{
    display:flex;
    gap:6px;
    align-items:center;
    flex-wrap:wrap;
}

.inline{
    display:inline;
}

details.card summary{
    cursor:pointer;
}

/* =========================================================
   TABLET / MÓVIL
   ========================================================= */

@media(max-width:1100px){

    .admin-grid{
        grid-template-columns:repeat(2,minmax(0,1fr));
    }

}

@media(max-width:900px){

    .sidebar{
        position:static;
        width:100%;
        height:auto;
        padding:18px 16px;
    }

    .app-shell{
        display:block;
    }

    .main{
        margin:0;
        width:100%;
    }

    /*
     * Logo móvil:
     * se fuerza el tamaño para impedir que la imagen
     * utilice sus dimensiones originales.
     */
    .sidebar .brand{
        display:block;
        width:100%;
        max-width:220px;
        margin-bottom:20px;
        overflow:hidden;
    }

    .sidebar .brand .brand-logo{
        display:block !important;
        width:180px !important;
        max-width:180px !important;
        height:auto !important;
        object-fit:contain !important;
    }

    .brand span{
        margin-top:6px;
    }

    .kpis,
    .two-col,
    .form-grid{
        grid-template-columns:1fr;
    }

    .topbar{
        position:static;
    }

    .sidebar nav{
        grid-template-columns:repeat(2,minmax(0,1fr));
    }

}

@media(max-width:700px){

    .admin-grid{
        grid-template-columns:1fr;
    }

}