:root{
    --green:#07843f;
    --green2:#0aa348;
    --orange:#f58220;
    --bg:#f4f6f7;
    --border:#d9e1e5;
}

/* =========================
   BASE
========================= */

*{
    box-sizing:border-box;
}

body{
    margin:0;
    font-family:Arial,Helvetica,sans-serif;
    background:var(--bg);
    color:#0c1b27;
}

/* =========================
   TOPBAR
========================= */

.topbar{
    height:58px;
    background:white;
    border-bottom:1px solid var(--border);
    margin-left:260px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:0 18px;
}

.hamb{
    border:0;
    background:white;
    color:var(--green);
    font-size:24px;
    cursor:pointer;
}

.brand-pill{
    background:var(--green2);
    color:white;
    font-weight:800;
    border-radius:5px;
    padding:10px 24px;
}

.user-label{
    color:#06f;
    text-transform:uppercase;
    font-weight:700;
}

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

.sidebar{
    position:fixed;
    left:0;
    top:0;
    width:260px;
    height:100vh;
    background:#fff;
    border-right:1px solid var(--border);
    box-shadow:2px 0 8px #0001;
    z-index:10;
    overflow-y:auto;
    overflow-x:hidden;
}

.logo-box{
    height:58px;
    display:flex;
    align-items:center;
    gap:8px;
    padding:8px 12px;
    color:var(--green);
    font-size:22px;
    font-weight:800;
    white-space:nowrap;
    overflow:hidden;
    position:sticky;
    top:0;
    background:#fff;
    z-index:20;
    border-bottom:1px solid var(--border);
}

.logo{
    width:38px;
    height:38px;
    object-fit:contain;
    flex-shrink:0;
}

.sidebar nav{
    padding:18px 8px 36px;
}

.sidebar a{
    display:block;
    color:var(--green);
    font-weight:700;
    text-decoration:none;
    padding:11px 8px;
    border-radius:7px;
    margin:4px 0;
}

.sidebar a:hover,
.sidebar a.active{
    background:#eaf7ef;
}

/* =========================
   CONTENT
========================= */

.content{
    margin-left:260px;
    padding:18px;
}

.title-bar{
    background:var(--green2);
    color:white;
    font-size:18px;
    font-weight:800;
    padding:14px 20px;
    border-radius:4px;
    margin-bottom:14px;
}

.grid-2{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:14px;
}

.layout-map{
    display:grid;
    grid-template-columns:1fr 330px;
    gap:14px;
}

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

.card{
    background:white;
    border:1px solid var(--border);
    border-radius:7px;
    box-shadow:0 2px 7px #0001;
    overflow:hidden;
}

.card-header{
    padding:14px;
    border-bottom:1px solid var(--border);
    font-weight:800;
}

.card-body{
    padding:14px;
}

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

input,
select,
textarea{
    width:100%;
    padding:10px;
    border:1px solid #cfdbe2;
    border-radius:5px;
    margin:5px 0 14px;
    background:#fff;
    font-size:14px;
}

label{
    font-weight:800;
    color:var(--green);
    font-size:13px;
}

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

.btn,
.btn-orange,
.btn-light,
.btn-danger,
button,
input[type="submit"]{

    display:inline-flex;
    align-items:center;
    justify-content:center;

    min-width:110px;
    height:38px;

    padding:0 18px;

    border:none;
    border-radius:6px;

    font-size:13px;
    font-weight:800;

    text-decoration:none;
    cursor:pointer;

    transition:all .2s ease;
}

/* VERDE */

.btn,
button,
input[type="submit"]{
    background:var(--green2);
    color:white;
}

.btn:hover,
button:hover,
input[type="submit"]:hover{
    background:#07843f;
}

/* NARANJA */

.btn-orange{
    background:var(--orange);
    color:white;
}

.btn-orange:hover{
    background:#d96c10;
}

/* CLARO */

.btn-light{
    background:#eaf7ef;
    color:var(--green);
}

.btn-light:hover{
    background:#dcefe4;
}

/* ROJO */

.btn-danger{
    background:#b91c1c;
    color:white;
}

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

/* ESPACIADO ENTRE BOTONES */

.btn + .btn,
.btn + .btn-light,
.btn + .btn-orange,
.btn-light + .btn,
.btn-orange + .btn,
.btn-light + .btn-light,
.btn-orange + .btn-orange{
    margin-left:6px;
}

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

.table{
    width:100%;
    border-collapse:collapse;
}
/* Contenedor automático para tablas anchas.
   Si una tabla queda dentro de .card-body, aparecerá scroll horizontal inferior. */
.card-body{
    max-width:100%;
}

.card-body:has(.table),
.card-body:has(table),
.table-scroll{
    width:100%;
    max-width:100%;
    overflow-x:auto;
    overflow-y:hidden;
    -webkit-overflow-scrolling:touch;
}

/* Evita que los listados se corten en tablet/PC angosta */
.table{
    min-width:900px;
}

.table-compact{
    min-width:700px;
}

.table-clientes,
.permisos-table{
    min-width:1200px;
}


.table th,
.table td{
    border:1px solid var(--border);
    padding:10px;
    text-align:left;
    vertical-align:top;
}

.table th{
    background:#edf6f1;
    color:var(--green);
    font-weight:800;
}

/* =========================
   BADGES
========================= */

.badge{
    padding:6px 10px;
    border-radius:12px;
    background:#dff5e8;
    color:var(--green);
    font-weight:800;
}

/* =========================
   UTILIDADES
========================= */

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

.mt{
    margin-top:14px;
}

.small{
    font-size:12px;
    color:#555;
}

/* =========================
   MAPAS
========================= */

#mapCliente,
#mapPredio,
#mapPluviometro{
    width:100%;
    height:520px;
    border:1px solid var(--border);
    border-radius:7px;
}

/* =========================
   LEAFLET
========================= */

.leaflet-control-layers{
    font-size:13px;
    border-radius:8px;
}

.leaflet-control-layers label{
    display:flex!important;
    align-items:center!important;
    gap:7px;
    margin:6px 0;
    color:var(--green);
    font-weight:700;
    white-space:nowrap;
}

.leaflet-control-layers input{
    width:14px;
    height:14px;
    margin:0!important;
}

/* =========================
   MENU ARBOL
========================= */

.menu-tree h4{
    color:var(--green);
    margin:8px 0;
}

.menu-tree h5{
    color:#c75a00;
    margin:8px 0 4px 12px;
}

.predio-link{
    display:block;
    margin:5px 0 5px 26px;
    padding:8px 10px;
    border-left:3px solid var(--green);
    background:#edf8f2;
    border-radius:7px;
    text-decoration:none;
    color:var(--green);
    font-weight:800;
}

/* =========================
   RESPONSIVE
========================= */

@media(max-width:900px){

    .topbar,
    .content{
        margin-left:0;
    }

    .sidebar{
        display:block;
        transform:translateX(-100%);
        transition:transform .25s ease;
        z-index:9999;
    }

    body.sidebar-open .sidebar{
        transform:translateX(0);
    }

    body.sidebar-open::after{
        content:"";
        position:fixed;
        inset:0;
        background:rgba(0,0,0,.25);
        z-index:9998;
    }

    .grid-2,
    .layout-map{
        grid-template-columns:1fr;
    }
}
/* =========================
   PLUVIOMETROS - FORMULARIO + MAPA
   Mismo diseño para cliente_pluviometros.php y admin_pluviometros.php
========================= */

.pluv-page-layout{
    display:block;
    width:100%;
}

.pluv-registro-card,
.pluv-list-card{
    width:100%;
    margin-bottom:18px;
}

.pluv-registro-card .card-body{
    width:100%;
}

.pluv-registro-table{
    width:100%;
    table-layout:fixed;
    border-collapse:separate;
    border-spacing:0;
}

.pluv-registro-table td{
    vertical-align:top;
}

.pluv-form-col{
    width:38%;
    padding-right:18px;
    border-right:1px solid #e0e6ea;
}

.pluv-map-col{
    width:62%;
    padding-left:18px;
}

.pluv-map-col #mapPluviometro,
.pluv-registro-card #mapPluviometro{
    width:100%;
    height:520px;
    border:1px solid var(--border);
    border-radius:8px;
    margin-top:8px;
}

.form-actions{
    margin-top:12px;
    display:flex;
    gap:10px;
    flex-wrap:wrap;
}

.form-actions .btn{
    min-width:110px;
    text-align:center;
}

.table-scroll{
    width:100%;
    overflow-x:auto;
    overflow-y:hidden;
    -webkit-overflow-scrolling:touch;
}

.table-clientes{
    min-width:920px;
    width:100%;
}

.table-clientes th,
.table-clientes td{
    vertical-align:top;
}

.table-clientes td:last-child,
.table-clientes th:last-child{
    text-align:center;
    min-width:120px;
}

.cliente-group{
    margin-bottom:18px;
    border:1px solid var(--border);
    border-radius:7px;
    overflow:hidden;
    background:#fff;
}

.cliente-title{
    background:var(--green);
    color:white;
    font-weight:800;
    padding:11px 14px;
    text-transform:uppercase;
}

.predio-subgroup{
    border-top:1px solid var(--border);
}

.predio-title{
    background:#eaf7ef;
    color:var(--green);
    font-weight:800;
    padding:9px 12px;
    text-transform:uppercase;
}

.cliente-total td{
    background:#f3faf6;
    color:var(--green);
    font-weight:700;
}

.cliente-resumen{
    background:var(--green);
    color:white;
    font-weight:800;
    padding:9px 12px;
}

@media(max-width:1000px){
    .pluv-registro-table,
    .pluv-registro-table tbody,
    .pluv-registro-table tr,
    .pluv-registro-table td{
        display:block;
        width:100%;
    }

    .pluv-form-col{
        padding-right:0;
        border-right:0;
    }

    .pluv-map-col{
        padding-left:0;
        margin-top:18px;
    }

    .pluv-map-col #mapPluviometro,
    .pluv-registro-card #mapPluviometro{
        height:420px;
    }
}

@media(max-width:1200px){
    .layout-map{
        grid-template-columns:1fr;
    }

    #mapCliente,
    #mapPredio,
    #mapPluviometro{
        height:460px;
    }
}

@media(max-width:768px){
    .topbar{
        height:auto;
        min-height:58px;
        gap:8px;
        flex-wrap:wrap;
    }

    .brand-pill{
        padding:8px 14px;
        font-size:13px;
    }

    .user-label{
        font-size:12px;
    }

    .content{
        padding:10px;
    }

    .title-bar{
        font-size:15px;
        padding:11px 14px;
    }

    #mapCliente,
    #mapPredio,
    #mapPluviometro{
        height:380px;
    }

    .card-body{
        padding:10px;
    }

    .btn,
    .btn-orange,
    .btn-light,
    .btn-danger,
    button,
    input[type="submit"]{
        min-width:95px;
        height:36px;
        font-size:12px;
        padding:0 12px;
    }
}

/* =========================
   AJUSTES RESPONSIVE FINALES
   Tablas, sidebar y pantallas tablet
========================= */

html,
body{
    max-width:100%;
}

.content,
.card,
.card-body{
    min-width:0;
}

@media(max-width:1200px){
    .content{
        padding:12px;
    }

    .table{
        min-width:950px;
    }

    .layout-map{
        grid-template-columns:1fr;
    }
}

@media(max-width:900px){
    .topbar{
        position:sticky;
        top:0;
        z-index:9000;
    }

    .hamb{
        display:inline-flex;
        align-items:center;
        justify-content:center;
    }

    .sidebar{
        width:260px;
        max-width:85vw;
    }

    .table{
        min-width:900px;
    }

    .table-clientes,
    .permisos-table{
        min-width:1150px;
    }
}

@media(max-width:768px){
    .content{
        padding:10px;
    }

    .card{
        border-radius:6px;
    }

    .card-header,
    .card-body{
        padding:10px;
    }

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

    .form-actions{
        gap:8px;
    }
}
