:root {
    --navy: #051428;
    --navy-dark: #020a14;
    --gold: #c69c38;
    --gold-hover: #a88126;
    --gold-light: #e6c875;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --ink: #1e293b;
    --muted: #64748b;
    --line: #e2e8f0;
    --red: #ef4444;
    --green: #10b981;
    --shadow: 0 10px 30px -10px rgba(5, 20, 40, 0.15);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-family: 'Inter', sans-serif; color: var(--ink); -webkit-font-smoothing: antialiased; }

/* Login System */
#login-overlay { position: fixed; inset: 0; background: var(--navy); background-image: radial-gradient(circle at top right, #0a2542, #051428); z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: white; border-radius: 20px; padding: 40px; width: 100%; max-width: 440px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5); text-align: center; position: relative; overflow: hidden; }
.login-card::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 6px; background: linear-gradient(90deg, var(--gold), var(--gold-light)); }

.login-logo-img { max-width: 280px; width: 100%; height: auto; margin-bottom: 16px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

.login-input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 16px; font: inherit; font-size: 15px; transition: border 0.2s; background: #f8fafc; }
.login-input:focus { outline: none; border-color: var(--gold); background: white; box-shadow: 0 0 0 3px rgba(198, 156, 56, 0.15); }
.login-btn { background: linear-gradient(135deg, var(--gold) 0%, var(--gold-hover) 100%); color: white; border: none; border-radius: 8px; width: 100%; padding: 14px; font-size: 16px; font-weight: 800; cursor: pointer; transition: 0.2s; margin-bottom: 12px; box-shadow: 0 4px 15px rgba(198, 156, 56, 0.3); }
.login-btn:hover { background: linear-gradient(135deg, var(--gold-hover) 0%, var(--gold) 100%); transform: translateY(-1px); }
.password-wrapper { position: relative; }
.password-toggle { position: absolute; right: 14px; top: 16px; color: var(--muted); cursor: pointer; }
.tab-auth { display: flex; gap: 10px; margin-bottom: 20px; }
.tab-auth button { flex: 1; padding: 10px; border: none; background: transparent; border-bottom: 2px solid var(--line); font-weight: 700; color: var(--muted); cursor: pointer; transition: 0.2s; }
.tab-auth button.active { border-bottom-color: var(--gold); color: var(--gold); }
.forgot-link { font-size: 13px; color: var(--muted); text-decoration: underline; cursor: pointer; display: inline-block; margin-top: 4px; font-weight: 600; }
.forgot-link:hover { color: var(--gold); }

/* Header */
header { background: var(--navy); color: white; padding: 20px 24px; display: flex; justify-content: space-between; align-items: center; border-bottom: 3px solid var(--gold); flex-wrap: wrap; gap: 16px; }
.brand { display: flex; align-items: center; gap: 16px; }
.brand-logo-img { max-height: 55px; width: auto; border-radius: 6px; }
.head-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.btn-social { background: transparent; border: 1px solid rgba(255,255,255,0.2); color: white; padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 12px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; transition: 0.2s; }
.btn-social:hover { border-color: var(--gold); color: var(--gold); background: rgba(198, 156, 56, 0.1); }
.user-badge { font-size: 13px; font-weight: 600; color: #cbd5e1; display: flex; align-items: center; gap: 6px; }

/* Main Content */
main { max-width: 1280px; margin: 30px auto; padding: 0 20px 60px; }
.tabs { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; background: white; padding: 8px; border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.tab { padding: 12px 18px; border-radius: 8px; border: none; background: transparent; font-weight: 700; color: var(--muted); cursor: pointer; font-size: 13px; transition: 0.2s; display: flex; align-items: center; gap: 8px; }
.tab.active { background: var(--navy); color: var(--gold-light); }

.grid { display: grid; grid-template-columns: 1.3fr 0.7fr; gap: 24px; }
.card { background: var(--surface); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); margin-bottom: 24px; border: 1px solid var(--line); }
.card h2 { font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: 800; color: var(--navy); margin-top: 0; margin-bottom: 6px; display: flex; align-items: center; gap: 10px; }
.card p.sub { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; margin-top: 0; line-height: 1.5; }

/* Sub-tabs inside Custos */
.subtabs { display: flex; gap: 6px; margin-bottom: 20px; border-bottom: 2px solid var(--line); padding-bottom: 10px; }
.subtab { padding: 8px 16px; border-radius: 6px; border: 1px solid var(--line); background: #f8fafc; font-weight: 700; color: var(--muted); cursor: pointer; font-size: 12px; transition: 0.2s; }
.subtab.active { background: var(--navy); color: var(--gold-light); border-color: var(--navy); }

/* Fields */
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.field label { display: block; font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }
.field input, .field select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 12px; font: inherit; font-size: 14px; background: #f8fafc; transition: 0.2s; }
.field input:focus, .field select:focus { outline: none; border-color: var(--gold); background: white; }

/* Days Grid */
.days { display: grid; gap: 12px; margin-top: 20px; }
.day { display: grid; grid-template-columns: 100px repeat(4, 1fr) 90px; gap: 12px; align-items: end; background: #f8fafc; padding: 12px; border-radius: 12px; border: 1px solid var(--line); border-left: 3px solid var(--navy); }
.dayname { font-weight: 700; color: var(--navy); font-size: 14px; align-self: center; }
.day label.sm { font-size: 10px; color: var(--muted); display: block; margin-bottom: 4px; font-weight: 600; text-transform: uppercase; }
.day input[type="time"] { width: 100%; padding: 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 13px; }
.check-wrap { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--navy); cursor: pointer; padding-bottom: 8px; }

/* Buttons */
.btn { background: var(--navy); color: white; border: none; padding: 12px 20px; border-radius: 8px; font-weight: 700; cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; transition: 0.2s; }
.btn:hover { background: var(--navy-dark); }
.btn-gold { background: linear-gradient(135deg, var(--gold) 0%, var(--gold-hover) 100%); color: white; }
.btn-gold:hover { background: linear-gradient(135deg, var(--gold-hover) 0%, var(--gold) 100%); }
.btn-outline { border: 1px solid var(--line); background: white; color: var(--navy); }
.btn-outline:hover { border-color: var(--navy); background: #f8fafc; }

/* Alerts & Summaries */
.summary-dark { background: var(--navy); background-image: radial-gradient(circle at top right, #0a2542, #051428); color: white; border-radius: 16px; padding: 24px; margin-bottom: 24px; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.summary-dark::before { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--gold); }
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.kpi-item span { display: block; font-size: 10px; color: #cbd5e1; text-transform: uppercase; font-weight: 700; margin-bottom: 4px; }
.kpi-item strong { display: block; font-size: 20px; font-weight: 800; font-family: 'Montserrat', sans-serif; color: white; }
.alerts { display: grid; gap: 10px; }
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; line-height: 1.5; border: 1px solid; display: flex; gap: 12px; align-items: flex-start; }
.alert i { margin-top: 2px; }
.alert.ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert.bad { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* Dashboard */
.dash-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.d-card { background: white; border: 1px solid var(--line); padding: 20px; border-radius: 12px; border-left: 4px solid var(--navy); box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
.d-card.highlight { border-left-color: var(--gold); }
.d-card-title { font-size: 11px; color: var(--muted); font-weight: 800; text-transform: uppercase; margin-bottom: 8px; }
.d-card-val { font-size: 20px; font-weight: 800; color: var(--navy); font-family: 'Montserrat', sans-serif; }

.charts { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.chart-box { background: white; border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.chart-box h3 { margin-top: 0; font-size: 15px; color: var(--navy); margin-bottom: 20px; border-bottom: 1px solid var(--line); padding-bottom: 10px; font-family: 'Montserrat', sans-serif; font-weight: 800; }
.bar-chart-container { position: relative; height: 260px; width: 100%; }

.donut { width: 140px; height: 140px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; }
.donut-inner { width: 70px; height: 70px; background: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; font-family: 'Montserrat', sans-serif;}
.legend { font-size: 12px; color: var(--muted); display: grid; gap: 8px; }
.leg-item { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.leg-color { width: 12px; height: 12px; border-radius: 3px; }

/* Revezamento Strategy & Table */
.strat-box { border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; background: white; border-left: 3px solid var(--navy); }
.strat-title { font-weight: 800; color: var(--navy); margin-bottom: 8px; font-size: 14px; display: flex; justify-content: space-between; }
.strat-desc { font-size: 13px; color: var(--muted); line-height: 1.5; }
.strat-tag { background: #f8fafc; color: var(--navy); border: 1px solid var(--line); padding: 2px 8px; border-radius: 12px; font-size: 11px; }

/* Barra de Abas / Seleção de Colaborador */
.emp-selector-bar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.emp-tab-btn { background: #f8fafc; border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; font-weight: 700; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; transition: 0.2s; }
.emp-tab-btn:hover { background: #e2e8f0; color: var(--navy); }
.emp-tab-btn.active { background: var(--navy); color: var(--gold-light); border-color: var(--navy); box-shadow: 0 4px 6px rgba(5,20,40,0.1); }

/* Modal / Painel de Edição de Nomes */
.modal-nomes { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.modal-nomes-grid { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.modal-nomes-item { display: grid; grid-template-columns: 90px 1fr 180px 220px; gap: 12px; align-items: center; background: white; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line); box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.modal-nomes-item label { font-size: 11px; font-weight: 800; color: var(--navy); white-space: nowrap; margin-bottom: 0; }
.modal-nomes-item input, .modal-nomes-item select { padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; background: white; width: 100%; }

/* Calendário Mensal Intuitivo */
.cal-container { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-top: 16px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02); }
.cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; font-weight: 800; color: var(--navy); font-size: 15px; flex-wrap: wrap; gap: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; }
.cal-day-name { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; padding-bottom: 6px; }
.cal-cell { background: white; border: 1px solid var(--line); border-radius: 6px; padding: 6px 2px; font-size: 11px; min-height: 52px; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.cal-cell.work { border-left: 3px solid #0369a1; }
.cal-cell.off { background: #dcfce7; border-color: #bbf7d0; color: #15803d; font-weight: 700; }
.cal-day-num { font-size: 12px; font-weight: 700; color: var(--navy); }
.cal-status { font-size: 9px; margin-top: 2px; }
.cal-hours { font-size: 8px; color: var(--muted); margin-top: 1px; }

.emp-gender { font-size: 11px; color: var(--muted); background: #f1f5f9; padding: 3px 8px; border-radius: 6px; font-weight: 600; }

.hidden { display: none !important; }

@media(max-width: 900px) {
    .grid, .charts { grid-template-columns: 1fr; }
    .day { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .dayname { grid-column: 1 / -1; }
    .check-wrap { grid-column: 1 / -1; }
    .modal-nomes-item { grid-template-columns: 1fr; gap: 8px; }
}

/* REGRAS DE IMPRESSÃO */
@media print {
    @page { size: A4; margin: 10mm; }
    body { background: white; color: black; }
    header, .tabs, .btn, .no-print, #login-overlay, #escala, #custos, #dashboard { display: none !important; }
    
    body.print-mode-relatorio #relatorio,
    body.print-mode-relatorio #relatorio #printArea { display: block !important; }
    
    body.print-mode-revezamento #revezamento { display: block !important; }
    
    .card { border: none !important; box-shadow: none !important; padding: 0 !important; margin: 0 !important; }
    .avoid-break { page-break-inside: avoid; }
    
    /* Layout dinâmico e compacto para Impressão da Escala Geral de Todos */
    .print-grid-geral {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        width: 100% !important;
    }
    .print-grid-geral .cal-container {
        margin-top: 0 !important;
        margin-bottom: 8px !important;
        padding: 10px !important;
        border: 1px solid #cbd5e1 !important;
        page-break-inside: avoid !important;
        border-radius: 8px !important;
    }
    .print-grid-geral .cal-header {
        font-size: 12px !important;
        margin-bottom: 8px !important;
    }
    .print-grid-geral .cal-cell {
        min-height: 36px !important;
        padding: 2px 1px !important;
    }
    .print-grid-geral .cal-day-num {
        font-size: 10px !important;
    }
    .print-grid-geral .cal-status {
        font-size: 8px !important;
    }
    .print-grid-geral .cal-hours {
        font-size: 7px !important;
    }

    .saraiva-footer-print {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        text-align: center;
        padding-top: 10px;
        border-top: 2px solid var(--gold);
        background: white;
        display: block !important;
    }
}
.saraiva-footer-print { display: none; }
