/* ==============================================
   Whitelabel System V4 - Design System
   Cores via CSS custom properties (--wl-*)
   ============================================== */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
body {
    font-family: var(--wl-font, 'Inter'), system-ui, -apple-system, sans-serif;
    background: #f1f5f9;
    color: #1e293b;
    line-height: 1.6;
    overflow-x: hidden;
    letter-spacing: -0.01em;
}
a { color: var(--wl-primary); text-decoration: none; transition: color 0.15s; }
a:hover { opacity: 0.88; }
.sidebar a:hover, .topbar a:hover { opacity: 1; }

/* ==============================================
   LAYOUT — modelo V1 portado para V4
   Usa --sidebar-width e --sidebar-mini como V1
   ============================================== */
:root {
    --sidebar-width: 260px;
    --sidebar-mini: 72px;
    --topbar-height: 60px;
}

.wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* ==============================================
   SIDEBAR — fiel ao menu.php da V1
   ============================================== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--wl-secondary, #01293c);
    color: #fff;
    position: fixed;
    left: 0; top: 0;
    z-index: 1001;
    transition: width 0.3s ease;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
/* Minimizado: sidebar estreito */
body.menu-fechado .sidebar { width: var(--sidebar-mini); }
/* Minimizado + hover: expande temporariamente (como V1) */
body.menu-fechado .sidebar:hover { width: var(--sidebar-width); }

/* Logo area */
.sidebar-logo-area {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
    overflow: hidden;
}
.sidebar-logo-full { max-height: 34px; width: auto; }
.sidebar-logo-text {
    font-size: 15px; font-weight: 700; color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Esconder texto/logo quando minimizado sem hover */
body.menu-fechado .sidebar:not(:hover) .sidebar-logo-area { justify-content: center; padding: 0; }
body.menu-fechado .sidebar:not(:hover) .sidebar-logo-full { display: none; }
body.menu-fechado .sidebar:not(:hover) .sidebar-logo-text { display: none; }

/* ===== Nav links — estrutura V1 ===== */
.nav-links {
    list-style: none;
    padding: 8px 0 20px;
    margin: 0;
}
.nav-links li a {
    color: #b0c4de;
    padding: 9px 0;
    display: flex;
    align-items: center;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    border-left: 4px solid transparent;
    transition: all 0.2s;
    line-height: 1.35;
    letter-spacing: 0;
}
.nav-links li > a > i {
    width: calc(var(--sidebar-mini) - 4px);
    min-width: calc(var(--sidebar-mini) - 4px);
    text-align: center;
    font-size: 17px;
    flex-shrink: 0;
}
.nav-links li > a > span {
    opacity: 1;
    transition: opacity 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Esconder texto e ajustar quando minimizado sem hover */
body.menu-fechado .sidebar:not(:hover) .nav-links li > a > span { opacity: 0; width: 0; }
body.menu-fechado .sidebar:not(:hover) .nav-links li > a { border-left-color: transparent !important; justify-content: center; }
body.menu-fechado .sidebar:not(:hover) .nav-links li > a > i { min-width: 100%; width: 100%; }

/* Hover e ativo */
.nav-links li > a:hover,
.nav-links li > a.active {
    background: rgba(255,255,255,0.06);
    color: var(--wl-primary, #08b9d8);
    border-left-color: var(--wl-primary, #08b9d8);
}

/* ===== Submenus — modelo V1 ===== */
.submenu {
    background: rgba(0,0,0,0.2);
    list-style: none;
    padding: 0;
    margin: 0;
    display: none;
    overflow: hidden;
}
.submenu.show { display: block; }
/* Esconder submenus quando minimizado sem hover */
body.menu-fechado .sidebar:not(:hover) .submenu { display: none !important; }

.submenu li a {
    padding: 6px 0 6px calc(var(--sidebar-mini) - 4px) !important;
    font-size: 13px;
    color: #94a3b8;
    border: none !important;
    display: block;
    text-decoration: none;
    transition: color 0.15s;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.submenu li a:hover {
    color: #fff;
    background: transparent !important;
    opacity: 1;
}

/* ==============================================
   TOPBAR
   ============================================== */
.topbar {
    position: fixed;
    top: 0; right: 0;
    left: var(--sidebar-width);
    height: var(--topbar-height);
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.03);
    z-index: 1000;
    transition: left 0.3s ease;
}
body.menu-fechado .topbar { left: var(--sidebar-mini); }

.topbar-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--wl-secondary, #01293c);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-hamburger {
    background: none;
    border: none;
    font-size: 20px;
    color: #475569;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: background 0.15s;
}
.btn-hamburger:hover { background: #f1f5f9; }

/* ===== Busca Global (modelo V1 — topbar) ===== */
.busca-global {
    position: relative;
}
.busca-global input {
    width: 180px;
    padding: 7px 14px 7px 34px;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
    background: #f8fafc;
    color: #1e293b;
}
.busca-global input:focus {
    border-color: var(--wl-primary);
    background: #fff;
    width: 260px;
    box-shadow: 0 0 0 3px rgba(8,145,178,0.08);
}
.busca-global input::placeholder { color: #94a3b8; }
.busca-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 12px;
    pointer-events: none;
}
.busca-resultados {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 360px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 2000;
    max-height: 420px;
    overflow-y: auto;
}
.busca-resultados.aberto { display: block; }
.busca-grupo-titulo {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    padding: 10px 14px 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.busca-grupo-titulo i { font-size: 11px; }
.busca-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    text-decoration: none;
    color: #334155;
    font-size: 13px;
    transition: background 0.15s;
}
.busca-item:hover { background: #f0f9ff; color: var(--wl-primary); opacity: 1; }
.busca-item-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 11px;
    color: #fff;
}
.busca-item-info { flex: 1; min-width: 0; }
.busca-item-label { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.busca-item-sub { font-size: 11px; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.busca-vazio {
    text-align: center;
    padding: 20px 14px;
    color: #94a3b8;
    font-size: 13px;
}

/* ===== Alertas / Notificacoes (topbar) ===== */
.topbar-alertas { position: relative; }
.topbar-btn {
    background: none;
    border: none;
    font-size: 17px;
    color: #64748b;
    cursor: pointer;
    padding: 7px 9px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background 0.15s;
}
.topbar-btn:hover { background: #f1f5f9; color: #1e293b; }
.alertas-badge {
    position: absolute;
    top: 2px; right: 2px;
    background: #dc2626;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 99px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}
.alertas-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 2000;
    overflow: hidden;
}
.topbar-alertas.open .alertas-dropdown { display: block; }
.alertas-header {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    color: #1e293b;
}
.alertas-body { max-height: 320px; overflow-y: auto; }
.alerta-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    text-decoration: none;
    font-size: 13px;
    color: #334155;
    transition: background 0.15s;
    border-bottom: 1px solid #f8fafc;
}
.alerta-item:hover { background: #f8fafc; opacity: 1; }
.alerta-item i { font-size: 14px; flex-shrink: 0; width: 18px; text-align: center; }
.alerta-item.alerta-danger i { color: #dc2626; }
.alerta-item.alerta-warning i { color: #d97706; }
.alerta-item.alerta-info i { color: #2563eb; }
.alertas-vazio {
    text-align: center;
    padding: 24px 16px;
    color: #94a3b8;
    font-size: 13px;
}
.alertas-vazio i { font-size: 24px; display: block; margin-bottom: 8px; opacity: 0.3; }

/* ===== User Dropdown (modelo V1) ===== */
.user-dropdown {
    position: relative;
}
.user-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    padding: 5px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
    font-size: 14px;
    color: #1e293b;
}
.user-dropdown-btn:hover { background: #f1f5f9; }
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--wl-primary, #08b9d8);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.user-name {
    font-weight: 600;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-caret { font-size: 10px; color: #94a3b8; transition: transform 0.2s; }
.user-dropdown.open .user-caret { transform: rotate(180deg); }

.user-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    border: 1px solid #e2e8f0;
    min-width: 220px;
    z-index: 2000;
    overflow: hidden;
}
.user-dropdown.open .user-dropdown-menu { display: block; }
.user-dropdown-header {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
}
.user-dropdown-header strong { display: block; font-size: 14px; color: #1e293b; }
.user-dropdown-header small { font-size: 12px; color: #94a3b8; }
.user-dropdown-divider { height: 1px; background: #f1f5f9; }
.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 13px;
    color: #475569;
    text-decoration: none;
    transition: background 0.15s;
}
.user-dropdown-item:hover { background: #f8fafc; opacity: 1; }
.user-dropdown-item i { width: 16px; text-align: center; font-size: 13px; color: var(--wl-primary); }
.user-dropdown-danger { color: #dc2626; font-weight: 600; }
.user-dropdown-danger i { color: #dc2626; }

/* ==============================================
   MAIN CONTENT
   ============================================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: calc(var(--topbar-height) + 24px) 24px 24px;
    transition: margin-left 0.3s ease;
    min-width: 0;
    min-height: 100vh;
}
body.menu-fechado .main-content { margin-left: var(--sidebar-mini); }

/* ==============================================
   MOBILE OVERLAY
   ============================================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    cursor: pointer;
}
body.menu-mobile-aberto .sidebar-overlay { display: block; }
body.menu-mobile-aberto .sidebar {
    transform: translateX(0) !important;
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
        transition: transform 0.3s ease;
    }
    .topbar { left: 0 !important; padding: 0 14px; }
    .main-content { margin-left: 0 !important; padding: calc(var(--topbar-height) + 16px) 14px 16px; }
    .user-name { display: none; }
    .user-caret { display: none; }
    .topbar-title { font-size: 14px; max-width: 160px; }
    .busca-global { display: none; }
    .alertas-dropdown { right: -60px; width: 300px; }

    /* Breadcrumb mobile */
    .breadcrumb-bar { margin-bottom: 10px; font-size: 11px; }

    /* Page header responsivo (V1) */
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .page-header .btn { width: 100%; justify-content: center; }

    /* Tabelas responsivas (V1) */
    .table-container { padding: 12px; }
    .table-wrapper { border-radius: 8px; }
    table th, table td { font-size: 12px; padding: 8px 8px; }
    .btn-sm { padding: 5px 8px; font-size: 11px; }

    /* KPI grid */
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }

    /* Filtros */
    .filter-bar { padding: 10px; }
    .filter-bar .form-control, .filter-bar select { max-width: 100%; width: 100%; }

    /* Dashboard mobile */
    .dash-section-header h3 { font-size: 13px; }
    .obra-fin-card .fin-value { font-size: 16px; }

    /* Grids inline 2-col colapsam */
    [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
    [style*="grid-template-columns:2fr 1fr"] { grid-template-columns: 1fr !important; }
    [style*="grid-template-columns:1fr 1fr 1fr"] { grid-template-columns: 1fr !important; }
}

/* ==============================================
   BOTOES
   ============================================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px;
    padding: 9px 22px; border-radius: 8px;
    font-size: 13px; font-weight: 600;
    border: none; cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.4;
}
.btn i { font-size: 12px; }
.btn-primary { background: var(--wl-primary); color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.btn-primary:hover { opacity: 0.92; box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.btn-secondary { background: #64748b; color: #fff; }
.btn-success { background: var(--wl-success); color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.btn-success:hover { opacity: 0.92; }
.btn-danger { background: var(--wl-danger); color: #fff; }
.btn-danger:hover { opacity: 0.92; }
.btn-warning { background: var(--wl-warning); color: #fff; }
.btn-outline { background: #fff; border: 1px solid #d1d5db; color: #374151; }
.btn-outline:hover { background: #f9fafb; border-color: #9ca3af; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 12px; gap: 5px; }
.btn-logout {
    padding: 5px 14px; border-radius: 6px;
    background: #f1f5f9; color: #64748b;
    font-size: 12px; font-weight: 600;
    text-decoration: none;
}
.btn-logout:hover { background: #e2e8f0; opacity: 1; }

/* ==============================================
   CARDS
   ============================================== */
.card {
    background: #fff; border-radius: 12px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card-body { padding: 20px 24px; }
.card-title { font-size: 14px; font-weight: 700; margin-bottom: 8px; color: #1e293b; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card-info { border-left: 4px solid var(--wl-info); }
.card-success { border-left: 4px solid var(--wl-success); }
.card-warning { border-left: 4px solid var(--wl-warning); }
.card-danger { border-left: 4px solid var(--wl-danger); }

/* ==============================================
   FORMULARIOS
   ============================================== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; margin-bottom: 5px;
    font-size: 12.5px; font-weight: 600; color: #374151;
    letter-spacing: 0.01em;
}
.form-control {
    width: 100%; padding: 10px 14px;
    border: 1px solid #d1d5db; border-radius: 8px;
    font-size: 13.5px; font-family: inherit;
    background: #fff; color: #1e293b;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus { outline: none; border-color: var(--wl-primary); box-shadow: 0 0 0 3px rgba(8,145,178,0.1); }
.form-control::placeholder { color: #9ca3af; }
.form-check { display: flex; align-items: center; gap: 6px; }
.form-check label { margin: 0; font-weight: 400; font-size: 13px; cursor: pointer; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

/* --- Formularios: secoes e layout operacional (Fase 5) --- */
.form-section {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    margin-bottom: 18px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.form-section-header {
    padding: 14px 24px;
    background: var(--wl-secondary, #01293c);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.form-section-title {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.form-section-title i { color: var(--wl-primary, #08b9d8); font-size: 14px; }
.form-section-desc {
    font-size: 12px;
    color: rgba(255,255,255,0.6);
    margin: 0;
}
.form-section-body {
    padding: 18px 24px 22px;
}
.form-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 0;
}
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-grid .form-group { margin-bottom: 0; }
.form-actions {
    display: flex;
    gap: 8px;
    padding-top: 8px;
}
.form-actions .btn { min-width: 160px; }
.form-helper {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 3px;
}
.form-required::after { content: ' *'; color: #dc2626; }

@media (max-width: 768px) {
    .form-grid-2, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr; }
    .form-section-body { padding: 14px 16px 18px; }
    .form-section-header { padding: 10px 16px; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; min-width: 0; }
}

/* ==============================================
   TABELAS — modelo V1 (.table-axel pattern)
   ============================================== */
.table-wrapper {
    overflow-x: auto; background: #fff;
    border-radius: 12px; border: 1px solid #f0f0f0;
    box-shadow: 0 1px 5px rgba(0,0,0,0.03);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    padding: 11px 14px; text-align: left;
    font-size: 11px; font-weight: 700; color: #4b5563;
    text-transform: uppercase; letter-spacing: 0.04em;
    background: #f9fafb; border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}
tbody td {
    padding: 11px 14px; border-bottom: 1px solid #f3f4f6;
    vertical-align: middle; color: #1f2937;
}
tbody tr:hover td { background: #f0f9ff; }
tbody tr { transition: background 0.1s; }
th a { color: #64748b; text-decoration: none; }
th a:hover { color: var(--wl-primary); opacity: 1; }
/* Coluna de ações */
td .btn-sm { margin-right: 3px; }
td .btn-sm:last-child { margin-right: 0; }

/* ==============================================
   ALERTAS
   ============================================== */
.alert {
    padding: 12px 16px; border-radius: 10px; margin-bottom: 16px;
    font-size: 13px; font-weight: 500;
}
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ==============================================
   BADGES
   ============================================== */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 99px;
    font-size: 11px; font-weight: 600; white-space: nowrap;
    letter-spacing: 0.01em;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-neutral { background: #f1f5f9; color: #475569; }
.badge-secondary { background: #f1f5f9; color: #64748b; }

/* Badges semanticos — modelo V1 (badges.css portado) */
.badge-ativo, .badge-pago, .badge-recebido, .badge-aprovado, .badge-concluida, .badge-disponivel { background: #dcfce7; color: #166534; }
.badge-inativo, .badge-cancelado, .badge-reprovado, .badge-vencido, .badge-atrasado { background: #fee2e2; color: #991b1b; }
.badge-pendente, .badge-aguardando, .badge-pausada, .badge-manutencao { background: #fef3c7; color: #92400e; }
.badge-em-andamento, .badge-em-uso, .badge-enviado { background: #dbeafe; color: #1e40af; }
.badge-planejamento { background: #ede9fe; color: #6d28d9; }

/* ==============================================
   PAGINACAO
   ============================================== */
.pagination-wrapper { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; flex-wrap: wrap; gap: 12px; }
.pagination { display: flex; list-style: none; gap: 4px; }
.pagination li a, .pagination li span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 10px;
    border-radius: 8px; font-size: 13px; font-weight: 500;
    border: 1px solid #e5e7eb; color: #374151;
    transition: all 0.15s;
}
.pagination li a:hover { background: #f3f4f6; border-color: #d1d5db; }
.pagination li.active a { background: var(--wl-primary); color: #fff; border-color: var(--wl-primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.pagination-dots { color: #94a3b8; display: flex; align-items: end; padding: 0 4px; }
.pagination-info { font-size: 12px; color: #94a3b8; }

/* ==============================================
   BREADCRUMB — modelo V1 (breadcrumb helper)
   ============================================== */
.breadcrumb-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.breadcrumb-bar a {
    color: #94a3b8;
    text-decoration: none;
    transition: color 0.15s;
}
.breadcrumb-bar a:hover { color: var(--wl-primary); opacity: 1; }
.breadcrumb-bar .bc-sep { opacity: 0.4; font-size: 14px; }
.breadcrumb-bar .bc-atual { color: #111827; font-weight: 700; }

/* ==============================================
   PAGE HEADER — modelo V1 (.page-header)
   ============================================== */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 22px; flex-wrap: wrap; gap: 12px;
}
.page-header h1, .page-header h2 {
    font-size: 22px; font-weight: 800; color: #111827; margin: 0;
    letter-spacing: -0.02em;
}
.page-header h1 i, .page-header h2 i { color: #6b7280; margin-right: 8px; font-size: 20px; }
.page-header .actions { display: flex; gap: 8px; }
.page-header p { font-size: 12px; color: #6b7280; margin: 2px 0 0; }
.page-header .page-header-left { display: flex; flex-direction: column; gap: 3px; }
.page-header .page-subtitle { font-size: 13px; color: #6b7280; margin: 0; font-weight: 400; }

/* ==============================================
   KPI GRID — modelo V1 (.kpi-grid)
   ============================================== */
.kpi-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px; margin-bottom: 20px;
}
.kpi-card {
    background: #fff; border-radius: 10px; padding: 16px 20px;
    border: 1px solid #e5e7eb; box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s, border-color 0.2s;
}
.kpi-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.kpi-card .kpi-value { font-size: 22px; font-weight: 800; margin-bottom: 2px; color: #111827; }
.kpi-card .kpi-label { font-size: 10.5px; color: #6b7280; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.kpi-card.kpi-success .kpi-value { color: #059669; }
.kpi-card.kpi-danger .kpi-value { color: #dc2626; }
.kpi-card.kpi-warning .kpi-value { color: #d97706; }
.kpi-card.kpi-info .kpi-value { color: #2563eb; }

/* ==============================================
   TABLE CONTAINER — modelo V1 (.table-container)
   ============================================== */
.table-container {
    background: #fff; border-radius: 12px; padding: 20px 24px;
    border: 1px solid #e5e7eb; box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    margin-bottom: 20px;
}
.table-container .table-responsive { overflow-x: auto; }

/* ==============================================
   FILTER BAR — modelo V1 (.filter-bar)
   ============================================== */
.filter-bar {
    display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
    margin-bottom: 16px; padding: 12px 18px;
    background: #fff; border-radius: 10px; border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.filter-bar .form-control, .filter-bar select {
    font-size: 13px; padding: 7px 12px; max-width: 200px;
}
.filter-bar .btn { font-size: 12px; padding: 7px 14px; }
.filter-bar .filter-count {
    margin-left: auto;
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
    white-space: nowrap;
}
.filter-bar .filter-count strong { color: #1e293b; font-weight: 700; }

/* ==============================================
   EMPTY STATE — modelo V1 (icone + titulo + desc + CTA)
   ============================================== */
.empty-state {
    text-align: center;
    padding: 52px 24px;
    color: #9ca3af;
}
.empty-state i {
    font-size: 44px;
    margin-bottom: 16px;
    display: block;
    opacity: 0.2;
}
.empty-state .empty-state-title {
    font-size: 15px;
    font-weight: 700;
    color: #4b5563;
    margin: 0 0 6px;
}
.empty-state .empty-state-desc {
    font-size: 13px;
    color: #9ca3af;
    margin: 0;
    max-width: 380px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
}
.empty-state p { font-size: 14px; margin: 0; }

/* ==============================================
   SORT INDICATORS — modelo V1 (setas visuais)
   ============================================== */
.sort-indicator {
    font-size: 10px;
    color: #d1d5db;
    margin-left: 4px;
    vertical-align: middle;
}
.sort-indicator.active {
    color: var(--wl-primary);
    font-weight: 800;
}
th a { display: inline-flex; align-items: center; gap: 2px; }

/* ==============================================
   FLASH CONTEXTUAL — alerta com acao de proximo passo
   ============================================== */
.alert-flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    animation: flash-in 0.3s ease;
}
.alert-flash .alert-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    flex-wrap: wrap;
}
.alert-flash .alert-content i { flex-shrink: 0; }
.alert-flash .alert-action {
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    margin-left: 4px;
}
.alert-success .alert-action { color: #065f46; }
.alert-error .alert-action { color: #991b1b; }
.alert-warning .alert-action { color: #92400e; }
.alert-info .alert-action { color: #1e40af; }
.alert-flash .alert-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
    opacity: 0.5;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
}
.alert-flash .alert-close:hover { opacity: 1; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ==============================================
   TOAST, UTILITIES
   ============================================== */

.toast-container {
    position: fixed; top: 20px; right: 20px;
    z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 14px 20px; border-radius: 10px;
    font-size: 13px; font-weight: 500;
    color: #fff; min-width: 280px; max-width: 400px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    animation: toast-in 0.3s ease;
    display: flex; align-items: center; gap: 10px;
}
.toast-success { background: #059669; }
.toast-error { background: #dc2626; }
.toast-warning { background: #d97706; }
.toast-info { background: #2563eb; }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

.text-muted { color: #6b7280; }
.text-sm { font-size: 11px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }

/* ==============================================
   DASHBOARD — secoes e blocos operacionais
   ============================================== */
.dash-section { margin-bottom: 24px; }
.dash-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.dash-section-header h3 {
    font-size: 15px;
    font-weight: 800;
    color: #111827;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.01em;
}
.dash-section-header h3 i { color: #6b7280; font-size: 16px; }
.dash-alerts { margin-bottom: 16px; }

@media (max-width: 768px) {
    .dash-section-header h3 { font-size: 14px; }
}

/* ==============================================
   HUB DA OBRA — modelo V1 (painel_obra.php)
   ============================================== */

/* Header do hub */
.obra-hub-header {
    background: #fff;
    border-radius: 12px;
    padding: 22px 26px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    margin-bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}
.obra-hub-info { flex: 1; min-width: 0; }
.obra-hub-title-row { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.obra-hub-title { font-size: 22px; font-weight: 800; color: #111827; margin: 0; letter-spacing: -0.02em; }
.obra-hub-meta {
    display: flex; gap: 14px; flex-wrap: wrap;
    font-size: 13px; color: #64748b;
}
.obra-hub-meta span { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.obra-hub-meta i { font-size: 11px; color: #94a3b8; }
.obra-hub-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Navegacao interna (tabs) */
.obra-hub-nav {
    display: flex;
    gap: 2px;
    background: #fff;
    border-left: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    border-radius: 0 0 12px 12px;
    padding: 0 14px;
    margin-bottom: 22px;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.1) transparent;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}
.obra-hub-tab {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-decoration: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    transition: all 0.15s;
}
.obra-hub-tab:hover {
    color: var(--wl-primary);
    background: #f8fafc;
    opacity: 1;
}
.obra-hub-tab.active {
    color: var(--wl-primary);
    border-bottom-color: var(--wl-primary);
}
.obra-hub-tab i { font-size: 13px; }

/* Cards financeiros gradiente (modelo V1 — card-fin) */
.obra-fin-card {
    border-radius: 10px;
    padding: 16px 20px;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.obra-fin-card .fin-label {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.obra-fin-card .fin-value {
    font-size: 22px;
    font-weight: 800;
    margin-top: 4px;
}
.fin-receita { background: linear-gradient(135deg, #10b981, #059669); }
.fin-despesa { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.fin-saldo { background: linear-gradient(135deg, #3b82f6, #2563eb); }

/* Secoes do hub */
.obra-section { margin-bottom: 24px; }
.obra-section-title {
    font-size: 14px;
    font-weight: 800;
    color: #111827;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.01em;
}
.obra-section-title i { color: #6b7280; font-size: 15px; }

/* Mobile responsivo do hub */
@media (max-width: 768px) {
    .obra-hub-header { flex-direction: column; gap: 12px; padding: 16px; }
    .obra-hub-actions { width: 100%; justify-content: flex-end; }
    .obra-hub-title { font-size: 18px; }
    .obra-hub-nav { padding: 0 8px; }
    .obra-hub-tab { padding: 8px 10px; font-size: 11px; }
    .obra-hub-tab span { display: none; }
    .obra-fin-card .fin-value { font-size: 18px; }
}

/* ==============================================
   COMPRAS — FLUXO VISUAL
   ============================================== */

/* Barra de fluxo de compras */
.compras-flow {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #f0f0f0;
    overflow: hidden;
}
.compras-flow-step {
    flex: 1;
    padding: 14px 18px;
    text-align: center;
    text-decoration: none;
    color: #64748b;
    position: relative;
    transition: background 0.2s;
    border-right: 1px solid #f0f0f0;
}
.compras-flow-step:last-child { border-right: none; }
.compras-flow-step:hover { background: #f8fafc; }
.compras-flow-step.active {
    background: var(--wl-primary, #01293c);
    color: #fff;
}
.compras-flow-num {
    font-size: 20px;
    font-weight: 800;
    display: block;
    line-height: 1;
}
.compras-flow-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
    display: block;
}
.compras-flow-count {
    font-size: 10px;
    opacity: 0.7;
    display: block;
    margin-top: 2px;
}

/* Cotacao comparison cards */
.cot-compare-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.cot-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px 18px;
    position: relative;
    transition: box-shadow 0.2s, transform 0.2s;
}
.cot-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.06); transform: translateY(-2px); }
.cot-card.cot-best {
    border: 2px solid #10b981;
    background: #f0fdf4;
}
.cot-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}
.cot-card-fornecedor {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
}
.cot-card-valor {
    font-size: 18px;
    font-weight: 800;
    color: #1e293b;
}
.cot-card.cot-best .cot-card-valor { color: #059669; }
.cot-card-detail {
    font-size: 12px;
    color: #64748b;
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-top: 1px solid #f1f5f9;
}
.cot-best-badge {
    position: absolute;
    top: -1px;
    right: 12px;
    background: #10b981;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 0 0 6px 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@media (max-width: 768px) {
    .compras-flow { flex-direction: column; }
    .compras-flow-step { border-right: none; border-bottom: 1px solid #f0f0f0; }
    .compras-flow-step:last-child { border-bottom: none; }
    .cot-compare-grid { grid-template-columns: 1fr; }
}

/* ==============================================
   FINANCEIRO PREMIUM
   ============================================== */

/* Summary cards row */
.fin-summary-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.fin-summary-card {
    background: #fff;
    border-radius: 10px;
    padding: 14px 18px;
    border: 1px solid #f0f0f0;
    border-left: 4px solid #94a3b8;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.fin-summary-card .fin-s-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #94a3b8;
}
.fin-summary-card .fin-s-value {
    font-size: 20px;
    font-weight: 800;
    color: #1e293b;
}
.fin-summary-card .fin-s-sub {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
}

/* Progress bar for previsto x realizado */
.pr-bar-track {
    height: 10px;
    background: #f1f5f9;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}
.pr-bar-fill {
    height: 100%;
    border-radius: 6px;
    min-width: 2px;
    transition: width 0.4s ease;
}
.pr-bar-fill.pr-over { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.pr-bar-fill.pr-under { background: linear-gradient(90deg, #10b981, #059669); }
.pr-bar-fill.pr-on-track { background: linear-gradient(90deg, #3b82f6, #2563eb); }

/* Difference indicator */
.diff-indicator {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
}
.diff-positive { background: #dcfce7; color: #166534; }
.diff-negative { background: #fee2e2; color: #991b1b; }
.diff-neutral { background: #f1f5f9; color: #64748b; }

/* Fluxo de caixa period table */
.fc-period-label {
    font-weight: 700;
    color: #1e293b;
    font-size: 13px;
}
.fc-period-label small {
    font-weight: 400;
    color: #94a3b8;
    font-size: 11px;
    display: block;
}

/* Section divider inside tables */
.fin-section-header {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    padding: 14px 0 6px;
    margin: 0 0 10px;
    border-bottom: 2px solid #f0f0f0;
}

/* Tag badges for financial */
.fin-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2px;
}
.fin-tag-recorrente { background: #f3e8ff; color: #7e22ce; }
.fin-tag-parcelado { background: #fef3c7; color: #92400e; }
.fin-tag-atrasado { background: #fee2e2; color: #991b1b; }

@media (max-width: 768px) {
    .fin-summary-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .fin-summary-card .fin-s-value {
        font-size: 16px;
    }
}

/* ==============================================
   LOGIN
   ============================================== */
.login-page {
    background: var(--wl-secondary);
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
}
.login-container { text-align: center; }
.login-box {
    background: #fff; padding: 40px;
    border-radius: 16px; box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    width: 400px; max-width: 90vw;
}
.login-logo { max-height: 48px; margin-bottom: 20px; }
.login-title { font-size: 22px; font-weight: 700; color: #1e293b; margin-bottom: 4px; }
.login-slogan { font-size: 13px; color: #94a3b8; margin-bottom: 24px; }
.login-form { text-align: left; }
.login-form .btn { margin-top: 8px; }
.login-footer { margin-top: 24px; font-size: 12px; color: rgba(255,255,255,0.4); }

/* ==============================================
   PREMIUM REFINEMENTS (M8.1)
   ============================================== */

/* Selection color */
::selection { background: var(--wl-primary, #08b9d8); color: #fff; }
::-moz-selection { background: var(--wl-primary, #08b9d8); color: #fff; }

/* Smooth main content scrollbar */
.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
.main-content::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* Strong text utility */
strong, b { font-weight: 700; }

/* Table strong cells */
td strong { color: #111827; }

/* Link in tables — don't wash out */
td a { font-weight: 500; }
td a:hover { opacity: 1; color: var(--wl-primary); }

/* Badge in action column — no margin */
td .badge + .badge { margin-left: 4px; }

/* Clickable rows cursor */
tr[style*="cursor:pointer"]:hover td { background: #eff6ff; }
tr[onclick]:hover td { background: #eff6ff; }

/* Form actions bottom margin */
.form-actions { margin-bottom: 24px; }

/* Filter bar count strong */
.filter-bar .filter-count { font-size: 12px; color: #6b7280; }

/* Fin summary row premium */
.fin-summary-row {
    display: grid; gap: 12px; margin-bottom: 18px;
}
.fin-summary-card {
    background: #fff; border-radius: 10px; padding: 14px 18px;
    border: 1px solid #e5e7eb; border-left: 4px solid #6b7280;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.fin-s-label { font-size: 10.5px; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: 0.04em; }
.fin-s-value { font-size: 20px; font-weight: 800; color: #111827; display: block; margin-top: 2px; }
.fin-s-sub { font-size: 11px; color: #9ca3af; margin-top: 1px; }

/* Fin section header (dashboard) */
.fin-section-header {
    font-size: 11px; font-weight: 800; color: #4b5563;
    text-transform: uppercase; letter-spacing: 0.05em;
    padding-bottom: 6px; margin-bottom: 10px;
    border-bottom: 2px solid #e5e7eb;
}
