/* =====================================================================
   APEX LT — Design System (Light Premium)
   ===================================================================== */

:root {
    /* Paleta */
    --bg: #F4F6FA;
    --surface: #FFFFFF;
    --surface-2: #F8FAFD;
    --border: #E4E9F1;
    --border-2: #D3DCE8;

    --text: #101A2C;
    --text-2: #4A5A74;
    --text-3: #93A2B9;

    --primary: #F26B1D;
    --primary-hover: #DD5A0F;
    --primary-soft: #FFF1E7;
    --primary-ring: rgba(242, 107, 29, .16);

    --navy: #13294B;
    --navy-soft: #EDF1F8;

    --success: #17A34A;
    --success-soft: #EAF8F0;
    --warning: #D97706;
    --warning-soft: #FEF5E7;
    --danger: #DC2626;
    --danger-soft: #FDEEEE;
    --info: #2563EB;
    --info-soft: #EBF1FE;

    /* Sombras */
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-md: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
    --shadow-lg: 0 8px 32px rgba(16, 24, 40, .12);

    /* Métricas */
    --radius: 12px;
    --radius-sm: 10px;
    --radius-lg: 16px;
    --sidebar-w: 262px;
    --topbar-h: 66px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ---------- Reset ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* Ícones lucide */
svg.lucide { width: 18px; height: 18px; stroke-width: 2; flex-shrink: 0; }

/* =====================================================================
   LAYOUT
   ===================================================================== */
.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.brand-mark {
    width: 38px; height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, #FB8B3C, var(--primary));
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    box-shadow: 0 4px 12px rgba(242, 107, 29, .35);
}
.brand-mark svg.lucide { width: 20px; height: 20px; }
.brand-mark.lg { width: 52px; height: 52px; border-radius: 15px; margin: 0 auto; }
.brand-mark.lg svg.lucide { width: 26px; height: 26px; }

.brand-text { font-size: 19px; letter-spacing: .3px; color: var(--navy); font-weight: 500; }
.brand-text strong { font-weight: 800; color: var(--primary); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 12px 20px; }

.nav-section {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--text-3);
    padding: 18px 10px 7px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-weight: 500;
    margin-bottom: 2px;
    position: relative;
    transition: background .15s, color .15s;
}
.nav-item svg.lucide { width: 19px; height: 19px; color: var(--text-3); transition: color .15s; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:hover svg.lucide { color: var(--text-2); }

.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary-hover);
    font-weight: 600;
}
.nav-item.active svg.lucide { color: var(--primary); }
.nav-item.active::before {
    content: '';
    position: absolute;
    left: -12px; top: 8px; bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--primary);
}

.nav-item.disabled { cursor: default; opacity: .55; }
.nav-item.disabled:hover { background: transparent; color: var(--text-2); }

.nav-badge {
    margin-left: auto;
    font-style: normal;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-3);
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 1px 7px;
    border-radius: 20px;
}

.sidebar-foot {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}
.version { font-size: 11.5px; color: var(--text-3); font-weight: 500; }

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(16, 26, 44, .4);
    z-index: 49;
}

/* ---------- Main / Topbar ---------- */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 26px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar-title { font-size: 17px; font-weight: 700; color: var(--navy); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.sidebar-toggle { display: none; }

.icon-btn {
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    display: inline-flex; align-items: center; justify-content: center;
    transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-2); }

/* Seletor de obra */
.obra-select {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 4px 0 12px;
    height: 40px;
}
.obra-select > svg.lucide { width: 16px; height: 16px; color: var(--primary); }
.select-plain {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    height: 100%;
    padding: 0 8px 0 0;
    outline: none;
    max-width: 230px;
    cursor: pointer;
}

/* Chip do usuário + dropdown */
.dropdown { position: relative; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 5px 8px;
    transition: background .15s;
}
.user-chip:hover { background: var(--surface-2); }
.user-chip > svg.lucide { width: 15px; height: 15px; color: var(--text-3); }

.user-chip-info { text-align: left; line-height: 1.2; }
.user-chip-info strong { display: block; font-size: 13px; font-weight: 600; }
.user-chip-info small { color: var(--text-3); font-size: 11.5px; }

.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12.5px; font-weight: 700;
    color: hsl(var(--hue, 210), 45%, 32%);
    background: hsl(var(--hue, 210), 60%, 92%);
    flex-shrink: 0;
}
.avatar.sm { width: 30px; height: 30px; font-size: 11px; }

.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    display: none;
    z-index: 60;
}
.dropdown.open .dropdown-menu { display: block; animation: pop .15s ease; }

@keyframes pop {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.dropdown-header { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-header strong { display: block; font-size: 13.5px; }
.dropdown-header small { color: var(--text-3); font-size: 12px; }

.dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-2);
    font-weight: 500;
    font-size: 13.5px;
}
.dropdown-item svg.lucide { width: 16px; height: 16px; }
.dropdown-item:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Conteúdo ---------- */
.content {
    padding: 26px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 22px;
    max-width: 1440px;
    width: 100%;
}

.page-header { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.page-header .grow { flex: 1; min-width: 200px; }
.page-header h2 { font-size: 21px; font-weight: 800; color: var(--navy); letter-spacing: -.01em; }
.page-header p { color: var(--text-2); margin-top: 3px; }
.page-actions { display: flex; gap: 10px; align-items: center; }

/* =====================================================================
   COMPONENTES
   ===================================================================== */

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px; }
.card-header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap;
}
.card-header h3 { font-size: 15px; font-weight: 700; color: var(--navy); }
.card-header .spacer { flex: 1; }
.card-body { padding: 22px; }

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

/* KPI */
.kpi {
    display: flex; align-items: center; gap: 15px;
    padding: 20px;
}
.kpi-icon {
    width: 46px; height: 46px;
    border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
}
.kpi-icon svg.lucide { width: 22px; height: 22px; }
.kpi-icon.orange { background: var(--primary-soft); color: var(--primary); }
.kpi-icon.blue   { background: var(--info-soft); color: var(--info); }
.kpi-icon.green  { background: var(--success-soft); color: var(--success); }
.kpi-icon.navy   { background: var(--navy-soft); color: var(--navy); }
.kpi-info strong { display: block; font-size: 23px; font-weight: 800; color: var(--navy); line-height: 1.15; }
.kpi-info span { color: var(--text-2); font-size: 13px; font-weight: 500; }

/* ---------- Botões ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    padding: 0 18px;
    height: 40px;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    white-space: nowrap;
}
.btn svg.lucide { width: 16px; height: 16px; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(242, 107, 29, .3); }
.btn-primary:hover { background: var(--primary-hover); }

.btn-outline { background: var(--surface); border-color: var(--border-2); color: var(--text-2); }
.btn-outline:hover { border-color: var(--text-3); color: var(--text); background: var(--surface-2); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #B91C1C; }

.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-danger-soft:hover { background: #FBDBDB; }

.btn-sm { height: 33px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn-sm svg.lucide { width: 14px; height: 14px; }
.btn-lg { height: 46px; font-size: 14.5px; border-radius: var(--radius); }
.btn-block { width: 100%; }

.btn-icon { width: 33px; height: 33px; padding: 0; border-radius: 8px; }

/* =====================================================================
   FORMULÁRIOS — inputs padronizados
   ===================================================================== */
.field { margin-bottom: 16px; }

.label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 6px;
    letter-spacing: .01em;
}
.label .req { color: var(--danger); }

.input, .select, .textarea {
    width: 100%;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--border-2);
    border-radius: var(--radius-sm);
    height: 42px;
    padding: 0 13px;
    outline: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.textarea { height: auto; min-height: 92px; padding: 11px 13px; resize: vertical; }

.input::placeholder, .textarea::placeholder { color: var(--text-3); }

.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }

.input:focus, .select:focus, .textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-ring);
}

.input:disabled, .select:disabled, .textarea:disabled {
    background: var(--surface-2);
    color: var(--text-3);
    cursor: not-allowed;
}

.input.error, .select.error, .textarea.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 4px rgba(220, 38, 38, .1);
}

.select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2393A2B9' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 38px;
    cursor: pointer;
}

/* Input com ícone à esquerda / ação à direita */
.input-icon { position: relative; }
.input-icon > svg.lucide {
    position: absolute;
    left: 13px; top: 50%;
    transform: translateY(-50%);
    width: 17px; height: 17px;
    color: var(--text-3);
    pointer-events: none;
}
.input-icon .input { padding-left: 40px; }
.input-action {
    position: absolute;
    right: 6px; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    color: var(--text-3);
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
}
.input-action:hover { background: var(--surface-2); color: var(--text-2); }
.input-icon .input-action ~ .input, .input-icon .input:has(+ .input-action) { padding-right: 40px; }

.hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.hint.error { color: var(--danger); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* Checkbox e switch */
.check {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    font-size: 13.5px;
    color: var(--text-2);
    font-weight: 500;
    user-select: none;
}
.check input {
    appearance: none;
    -webkit-appearance: none;
    width: 19px; height: 19px;
    border: 1.5px solid var(--border-2);
    border-radius: 6px;
    background: var(--surface);
    cursor: pointer;
    position: relative;
    transition: background .15s, border-color .15s;
    flex-shrink: 0;
}
.check input:hover { border-color: var(--text-3); }
.check input:checked {
    background: var(--primary);
    border-color: var(--primary);
}
.check input:checked::after {
    content: '';
    position: absolute;
    left: 5.5px; top: 2px;
    width: 5px; height: 9px;
    border: solid #fff;
    border-width: 0 2.2px 2.2px 0;
    transform: rotate(45deg);
}
.check input:focus-visible { box-shadow: 0 0 0 4px var(--primary-ring); }

.switch {
    display: inline-flex; align-items: center; gap: 10px;
    cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--text-2);
    user-select: none;
}
.switch input {
    appearance: none;
    -webkit-appearance: none;
    width: 40px; height: 23px;
    background: var(--border-2);
    border-radius: 20px;
    position: relative;
    cursor: pointer;
    transition: background .2s;
    flex-shrink: 0;
}
.switch input::after {
    content: '';
    position: absolute;
    left: 3px; top: 3px;
    width: 17px; height: 17px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: left .2s;
}
.switch input:checked { background: var(--primary); }
.switch input:checked::after { left: 20px; }
.switch input:focus-visible { box-shadow: 0 0 0 4px var(--primary-ring); }

/* ---------- Select com busca ---------- */
.ss { position: relative; width: 100%; }
/* O select nativo continua renderizado (invisível, atrás do botão) para que
   o envio do formulário e a validação HTML5 de campos obrigatórios funcionem. */
.ss .ss-nativo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    z-index: 0;
}
.ss-toggle { position: relative; z-index: 1; }
.ss-toggle {
    width: 100%;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--border-2);
    border-radius: var(--radius-sm);
    height: 42px;
    padding: 0 12px 0 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    transition: border-color .15s, box-shadow .15s;
}
.ss-toggle:hover { border-color: var(--text-3); }
.ss-toggle > svg.lucide { width: 16px; height: 16px; color: var(--text-3); margin-left: auto; flex-shrink: 0; }
.ss-valor { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-valor.vazio { color: var(--text-3); }
.ss.aberto .ss-toggle {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-ring);
}
.ss.aberto .ss-toggle > svg.lucide { transform: rotate(180deg); color: var(--primary); }

/* Altura reduzida quando dentro de barras compactas */
.filtros .ss-toggle, .lista-barra .ss-toggle { height: 40px; }
.obra-select .ss { width: 232px; }
.obra-select .ss-toggle { height: 100%; border: none; background: transparent; box-shadow: none; font-weight: 600; font-size: 13.5px; padding-left: 0; }
.obra-select .ss.aberto .ss-toggle { box-shadow: none; }
.obra-select .ss-panel { min-width: 300px; right: auto; }

.ss-panel {
    display: none;
    position: absolute;
    z-index: 70;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    min-width: 240px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.ss.aberto .ss-panel { display: block; animation: pop .13s ease; }
.ss.acima .ss-panel { top: auto; bottom: calc(100% + 5px); }

.ss-search { padding: 8px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.ss-search .input { height: 36px; font-size: 13.5px; }

.ss-lista { max-height: 240px; overflow-y: auto; padding: 5px; }

.ss-grupo {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-3);
    padding: 9px 10px 4px;
}
.ss-opt {
    padding: 8px 10px;
    border-radius: 7px;
    font-size: 13.5px;
    color: var(--text-2);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ss-opt.hl { background: var(--surface-2); color: var(--text); }
.ss-opt.sel { background: var(--primary-soft); color: var(--primary-hover); font-weight: 600; }
.ss-opt.off { opacity: .45; cursor: not-allowed; }

.ss-vazio { display: none; padding: 16px; text-align: center; font-size: 13px; color: var(--text-3); }

/* Barra de busca */
.searchbar { position: relative; width: 280px; max-width: 100%; }
.searchbar svg.lucide {
    position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; color: var(--text-3); pointer-events: none;
}
.searchbar .input { padding-left: 38px; height: 40px; }

/* ---------- Alertas ---------- */
.alert {
    display: flex; align-items: center; gap: 10px;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 16px;
}
.alert svg.lucide { width: 17px; height: 17px; flex-shrink: 0; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--success-soft); color: #15803D; }
.alert-info { background: var(--info-soft); color: var(--info); }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 12px; font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
}
.badge svg.lucide { width: 12px; height: 12px; }
.badge-green { background: var(--success-soft); color: #15803D; }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-orange { background: var(--primary-soft); color: var(--primary-hover); }
.badge-blue { background: var(--info-soft); color: var(--info); }
.badge-navy { background: var(--navy-soft); color: var(--navy); }
.badge-gray { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    white-space: nowrap;
}
.table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }

.table .cell-main { font-weight: 600; color: var(--text); }
.table .cell-sub { font-size: 12.5px; color: var(--text-3); }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }

.table .row-user { display: flex; align-items: center; gap: 11px; }

/* ---------- Listagens: ordenação, filtros e paginação ---------- */
.th-sort {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: inherit;
    white-space: nowrap;
    transition: color .12s;
}
.th-sort svg.lucide { width: 13px; height: 13px; opacity: .45; }
.th-sort:hover { color: var(--text-2); }
.th-sort:hover svg.lucide { opacity: .8; }
.th-sort.ativo { color: var(--primary-hover); }
.th-sort.ativo svg.lucide { opacity: 1; color: var(--primary); }

.filtros {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}
.filtros .field { margin-bottom: 0; }
.filtros .select, .filtros .input { height: 40px; }
.filtros .grow { flex: 1; min-width: 180px; }

.select-sm, .input-sm { height: 34px; font-size: 13px; padding: 0 10px; }
.select-sm { padding-right: 32px; background-position: right 9px center; }

.lista-barra {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 12px 22px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.lista-info { font-size: 13px; color: var(--text-2); }
.lista-info strong { color: var(--navy); }
.lista-pp { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.lista-pp .label { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.lista-pp .select { width: auto; }

.paginacao { display: flex; align-items: center; gap: 4px; }
.pg-btn {
    min-width: 32px; height: 32px;
    padding: 0 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .12s, border-color .12s, color .12s;
}
.pg-btn svg.lucide { width: 15px; height: 15px; }
.pg-btn:hover { background: var(--surface-2); border-color: var(--border-2); color: var(--text); }
.pg-btn.atual { background: var(--primary); border-color: var(--primary); color: #fff; }
.pg-btn.atual:hover { background: var(--primary-hover); }
.pg-btn.off { opacity: .4; pointer-events: none; }

@media (max-width: 720px) {
    .lista-barra { justify-content: center; }
    .lista-pp { margin-left: 0; }
}

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(16, 26, 44, .45);
    z-index: 90;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow-y: auto;
}
.modal-backdrop.open { display: flex; animation: fadeIn .15s ease; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    animation: slideUp .2s ease;
}
.modal.modal-lg { max-width: 760px; }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--navy); flex: 1; }
.modal-body { padding: 22px 24px 6px; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 16px 24px 22px;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: 26px; right: 26px;
    z-index: 120;
    display: flex; align-items: center; gap: 10px;
    background: var(--navy);
    color: #fff;
    font-size: 13.5px;
    font-weight: 500;
    padding: 13px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: toastIn .25s ease;
    max-width: 400px;
}
.toast svg.lucide { width: 18px; height: 18px; }
.toast-success svg.lucide { color: #4ADE80; }
.toast-error svg.lucide { color: #F87171; }
.toast.hide { opacity: 0; transform: translateY(8px); transition: all .3s; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Empty state ---------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty-icon {
    width: 64px; height: 64px;
    border-radius: 18px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-3);
    margin-bottom: 8px;
}
.empty-icon svg.lucide { width: 28px; height: 28px; }
.empty-icon.danger { background: var(--danger-soft); border-color: #F6C8C8; color: var(--danger); }
.empty-state h2 { font-size: 17px; color: var(--navy); }
.empty-state p { color: var(--text-2); margin-bottom: 12px; }

/* ---------- Abas ---------- */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}
.tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-weight: 600;
    font-size: 13.5px;
    color: var(--text-2);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}
.tab svg.lucide { width: 16px; height: 16px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-hover); border-bottom-color: var(--primary); }
.tab-count {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 11px;
    padding: 0 8px;
    color: var(--text-3);
    font-weight: 700;
}
.tab.active .tab-count { background: var(--primary-soft); border-color: transparent; color: var(--primary-hover); }

/* ---------- Matriz de permissões ---------- */
.perm-module {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}
.perm-module-head {
    display: flex; align-items: center; gap: 10px;
    background: var(--surface-2);
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
}
.perm-module-head h4 {
    font-size: 13px; font-weight: 700; color: var(--navy);
    text-transform: capitalize;
    flex: 1;
}
.perm-toggle-all { font-size: 12px; color: var(--primary); font-weight: 600; cursor: pointer; background: none; border: none; }
.perm-toggle-all:hover { text-decoration: underline; }
.perm-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 4px 16px;
    padding: 13px 16px;
}

/* ---------- Radio cards (seleção de tipo) ---------- */
.radio-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.radio-card { position: relative; cursor: pointer; }
.radio-card input { position: absolute; opacity: 0; }
.radio-card-body {
    border: 1.5px solid var(--border-2);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.radio-card-body svg.lucide { width: 22px; height: 22px; color: var(--text-3); }
.radio-card-body strong { display: block; font-size: 13.5px; color: var(--text); }
.radio-card-body small { color: var(--text-3); font-size: 12px; }
.radio-card input:checked + .radio-card-body {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 0 0 4px var(--primary-ring);
}
.radio-card input:checked + .radio-card-body svg.lucide { color: var(--primary); }

/* ---------- Lista de seleção de estruturas ---------- */
.pick-list {
    border: 1.5px solid var(--border-2);
    border-radius: var(--radius-sm);
    max-height: 240px;
    overflow-y: auto;
    background: var(--surface);
}
.pick-list-search {
    position: sticky;
    top: 0;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    padding: 8px;
}
.pick-list-search .input { height: 34px; font-size: 13px; }
.pick-list-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 2px 10px;
    padding: 10px 12px;
}
.pick-list .check { padding: 4px 0; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
    background: var(--navy-soft);
    color: var(--navy);
    font-size: 11.5px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 14px;
    white-space: nowrap;
}

/* ---------- Barra de progresso ---------- */
.progress {
    height: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    min-width: 90px;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #FB8B3C, var(--primary));
    border-radius: 8px;
    transition: width .4s ease;
}
.progress-fill.done { background: linear-gradient(90deg, #34C979, var(--success)); }

/* ---------- Fotos ---------- */
.foto-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.foto-thumb {
    position: relative;
    width: 96px; height: 96px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    display: block;
}
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-thumb .foto-del {
    position: absolute;
    top: 4px; right: 4px;
    background: rgba(16, 26, 44, .65);
    border-radius: 7px;
    padding: 3px 6px;
}
.foto-thumb .foto-del .check { gap: 0; }
.foto-thumb .foto-del input { width: 15px; height: 15px; border-radius: 4px; }

/* ---------- Matriz de avanço ---------- */
.matriz-wrap { overflow: auto; max-height: 70vh; }
.matriz { border-collapse: separate; border-spacing: 0; width: 100%; }
.matriz th, .matriz td {
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    padding: 8px 10px;
    font-size: 12.5px;
    text-align: center;
    white-space: nowrap;
    background: var(--surface);
}
.matriz thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--surface-2);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-2);
}
.matriz tbody th {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface-2);
    font-weight: 700;
    color: var(--navy);
    text-align: left;
}
.matriz thead th:first-child { left: 0; z-index: 4; }
.matriz td.feito { font-weight: 600; }
.matriz td .m-data { display: block; font-size: 10.5px; color: var(--text-3); font-weight: 500; }

/* ---------- Calendário ---------- */
.cal-wrap { overflow-x: auto; }

.cal-head, .cal {
    display: grid;
    /* minmax(0,1fr) impede que o texto das atividades estoure a grade */
    grid-template-columns: repeat(7, minmax(0, 1fr));
    min-width: 700px;
}
.cal-head {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
    padding: 10px 0 8px;
    border-bottom: 1px solid var(--border);
}
.cal-day {
    min-height: 118px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    padding: 7px 6px;
    min-width: 0;
    transition: background .12s;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day:hover { background: var(--surface-2); }
.cal-day.out { background: var(--surface-2); }
.cal-day.out .cal-num { color: var(--text-3); }
.cal-num {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px; height: 24px;
    border-radius: 50%;
}
.cal-day.today .cal-num { background: var(--primary); color: #fff; }
.cal-item {
    display: block;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.35;
    padding: 3px 6px;
    border-radius: 5px;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 3px solid transparent;
    transition: filter .12s;
}
.cal-item:hover { filter: brightness(.95); }
.cal-item.plan { background: var(--info-soft); color: var(--info); border-left-color: var(--info); }
.cal-item.done { background: var(--success-soft); color: #15803D; border-left-color: var(--success); }
.cal-item.miss { background: var(--danger-soft); color: var(--danger); border-left-color: var(--danger); }
.cal-more { display: block; font-size: 10.5px; color: var(--text-3); margin-top: 5px; font-weight: 600; }
.cal-more:hover { color: var(--primary); }

/* ---------- Documento RDO ---------- */
.rdo-doc {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.rdo-cab {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 26px;
    border-bottom: 2px solid var(--navy);
}
.rdo-cab h2 { font-size: 19px; color: var(--navy); }
.rdo-cab .rdo-obra { font-size: 13px; color: var(--text-2); margin-top: 2px; }

.rdo-info {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    border-bottom: 1px solid var(--border);
}
.rdo-info > div {
    padding: 10px 12px;
    border-right: 1px solid var(--border);
    text-align: center;
}
.rdo-info > div:last-child { border-right: none; }
.rdo-info small {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-3);
    margin-bottom: 3px;
}
.rdo-info strong { font-size: 13px; color: var(--navy); }

.rdo-sec {
    background: var(--navy);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 8px 26px;
}
.rdo-bloco { padding: 16px 26px; }

.rdo-tabela { width: 100%; border-collapse: collapse; }
.rdo-tabela th {
    text-align: left;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-3);
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
}
.rdo-tabela td {
    padding: 6px 10px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.rdo-tabela tr:last-child td { border-bottom: none; }
.rdo-tabela .num { text-align: right; font-weight: 600; }
.rdo-tabela tfoot td {
    font-weight: 800;
    color: var(--navy);
    border-top: 2px solid var(--navy);
    background: var(--surface-2);
}
.rdo-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }

.rdo-clima { display: grid; gap: 8px; }
.rdo-clima-row {
    display: grid;
    grid-template-columns: 160px repeat(3, 1fr);
    gap: 10px;
    align-items: center;
}
.rdo-clima-row .cidade { font-weight: 700; color: var(--navy); font-size: 13px; }

@media (max-width: 900px) {
    .rdo-info { grid-template-columns: repeat(3, 1fr); }
    .rdo-info > div { border-bottom: 1px solid var(--border); }
    .rdo-2col { grid-template-columns: 1fr; }
    .rdo-clima-row { grid-template-columns: 1fr; }
}

/* ---------- Impressão (Exportar PDF) ---------- */
@media print {
    .sidebar, .sidebar-overlay, .topbar, .page-header, .no-print, .toast { display: none !important; }
    .main { margin-left: 0 !important; }
    .content { padding: 0 !important; max-width: none !important; gap: 0 !important; }
    body { background: #fff !important; }
    .rdo-doc { border: none !important; border-radius: 0 !important; box-shadow: none !important; }
    .rdo-sec { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .rdo-bloco { page-break-inside: avoid; }
    .foto-thumb { width: 130px; height: 130px; }
}

/* ---------- Mapa da linha (torre a torre) ---------- */
.mapa-strip {
    display: flex;
    overflow-x: auto;
    padding: 22px 14px 18px;
    gap: 0;
}
.torre-block {
    flex: 0 0 118px;
    text-align: center;
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 6px 4px 10px;
    position: relative;
    transition: background .15s;
}
.torre-block:hover { background: var(--surface-2); }
.torre-block.ativa { background: var(--primary-soft); box-shadow: inset 0 0 0 1.5px var(--primary); }
.torre-svg { width: 78px; height: 92px; display: block; margin: 0 auto; }
.torre-numero { font-size: 12.5px; font-weight: 800; color: var(--navy); margin-top: 2px; }
.torre-tipo { font-size: 10.5px; color: var(--text-3); font-weight: 600; }
.torre-data { font-size: 10.5px; color: var(--text-2); font-weight: 600; margin-top: 4px; }
.torre-etapas { display: flex; justify-content: center; gap: 2px; margin-top: 6px; flex-wrap: nowrap; }
.torre-dot {
    width: 10px; height: 10px;
    border-radius: 3px;
    border: 1.5px solid var(--border-2);
    background: var(--surface);
    display: inline-block;
}
.torre-vao { font-size: 9.5px; color: var(--text-3); margin-top: 5px; }
.torre-obs {
    position: absolute;
    top: 2px; right: 8px;
    color: var(--danger);
}
.torre-obs svg.lucide { width: 13px; height: 13px; }

/* =====================================================================
   LOGIN
   ===================================================================== */
.login-body {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background:
        radial-gradient(700px 380px at 85% -10%, rgba(242, 107, 29, .10), transparent 60%),
        radial-gradient(600px 350px at -5% 105%, rgba(19, 41, 75, .08), transparent 60%),
        var(--bg);
    padding: 24px;
}

.login-wrap { width: 100%; max-width: 410px; }

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    padding: 38px 34px 34px;
}

.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand h1 { font-size: 26px; color: var(--navy); font-weight: 500; margin-top: 14px; letter-spacing: .3px; }
.login-brand h1 strong { color: var(--primary); font-weight: 800; }
.login-brand p { color: var(--text-2); font-size: 13px; margin-top: 4px; }

.login-foot { text-align: center; color: var(--text-3); font-size: 12px; margin-top: 22px; }

/* =====================================================================
   RESPONSIVO
   ===================================================================== */
@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .main { margin-left: 0; }
    .sidebar-toggle { display: inline-flex; }
    .user-chip-info { display: none; }
    .obra-select { display: none; }
    .content { padding: 18px; }
    .grid-2 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .grid-4, .grid-3 { grid-template-columns: 1fr; }
    .topbar-title { font-size: 15px; }
}

/* ---------- Utilitários ---------- */
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.text-muted { color: var(--text-3); }
.text-danger { color: var(--danger); }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.grow { flex: 1; }
