:root {
    --sidebar-width: 260px;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: #f4f6f9;
}

#sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

#sidebar .nav-link {
    border-radius: 0.5rem;
    margin-bottom: 2px;
    font-size: 0.9rem;
}

#sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#sidebar .nav-link.active {
    background-color: var(--bs-primary);
}

#page-content {
    min-height: 100vh;
    overflow-x: hidden;
}

.sidebar-collapsed #sidebar {
    margin-left: calc(var(--sidebar-width) * -1);
}

.card {
    border-radius: 0.75rem;
}

.table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
}

.badge-status-ativa {
    background-color: #198754;
}

.badge-status-pausada {
    background-color: #ffc107;
    color: #000;
}

.badge-status-encerrada {
    background-color: #6c757d;
}

.kpi-card .card-body {
    padding: 1.25rem;
}

/* ===== OVERLAY SIDEBAR MOBILE ===== */
#sidebarOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1040;
    transition: opacity .3s;
}
#sidebarOverlay.show {
    display: block;
}

/* ===== RESPONSIVE: TABLET (<992px) ===== */
@media (max-width: 991.98px) {
    #sidebar {
        position: fixed;
        z-index: 1050;
        margin-left: calc(var(--sidebar-width) * -1);
        transition: margin-left .3s ease;
        overflow-y: auto;
    }
    #sidebar.show {
        margin-left: 0;
    }
    .sidebar-collapsed #sidebar {
        margin-left: calc(var(--sidebar-width) * -1);
    }
}

/* ===== RESPONSIVE: MOBILE (<576px) ===== */
@media (max-width: 575.98px) {
    .page-header-actions {
        flex-direction: column;
        align-items: stretch !important;
        gap: .5rem !important;
    }
    .page-header-actions .btn {
        width: 100%;
        justify-content: center;
    }
    .container-fluid.px-4 {
        padding-left: .75rem !important;
        padding-right: .75rem !important;
    }
    main.container-fluid {
        padding-left: .75rem !important;
        padding-right: .75rem !important;
    }
    h4.fw-bold { font-size: 1.15rem; }
    .table { font-size: .8rem; }
    .table th { font-size: .7rem; }
    .table .btn-sm { padding: .2rem .35rem; font-size: .7rem; }
    .card-body { padding: .75rem; }
    .kpi-card .card-body { padding: .75rem; }
    .kpi-card h5 { font-size: 1.1rem; }
    .kpi-card .small, .kpi-card p { font-size: .72rem; }
}

/* ===== RESPONSIVE: TOPBAR ===== */
@media (max-width: 767.98px) {
    .topbar-username { display: none; }
    .navbar.px-4 { padding-left: .75rem !important; padding-right: .75rem !important; }
    .breadcrumb { font-size: .8rem; }
}

/* ===== TOUCH TARGETS ===== */
@media (pointer: coarse) {
    .btn-sm { min-height: 38px; min-width: 38px; }
    .nav-link { min-height: 40px; display: flex; align-items: center; }
    .form-select-sm, .form-control-sm { min-height: 38px; }
}

/* ===== TABLE CELL OVERFLOW ===== */
.table td {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.table td.text-wrap { white-space: normal; max-width: none; }

/* ===== ACTION BUTTONS WRAP ===== */
.d-flex.gap-2 { flex-wrap: wrap; }

/* ===== DASHBOARD MAP RESPONSIVE ===== */
@media (max-width: 575.98px) {
    #mapa-obras { height: 200px !important; }
}
@media (min-width: 576px) and (max-width: 991.98px) {
    #mapa-obras { height: 240px !important; }
}
