:root {
    --bg: #0f1117;
    --card: #1a1d27;
    --border: #2a2d3a;
    --accent: #6c5ce7;
    --green: #00b894;
    --red: #d63031;
    --yellow: #fdcb6e;
    --text: #e0e0e0;
    --muted: #8a8fa8;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 2rem 1rem;
}

/* ========== TELA DE LOGIN ========== */
.login-screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(135deg, #1a1d27 0%, #0f1117 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-box {
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 20px;
    padding: 3rem;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.lock-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.login-box h2 {
    margin-bottom: 0.5rem;
    color: var(--accent);
    font-size: 1.8rem;
}

.login-box > p {
    color: var(--muted);
    margin-bottom: 2rem;
}

.pin-container {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.pin-digit {
    width: 60px;
    height: 70px;
    font-size: 2rem;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: all 0.3s;
    font-weight: 700;
}

.pin-digit:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.3);
    transform: scale(1.05);
}

.pin-digit.filled {
    border-color: var(--green);
    background: rgba(0, 184, 148, 0.1);
}

.pin-digit.error {
    border-color: var(--red);
    background: rgba(214, 48, 49, 0.1);
    animation: shake 0.5s;
}

.login-box button[type="submit"] {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.3s;
}

.login-box button[type="submit"]:hover {
    transform: scale(1.02);
    opacity: 0.9;
}

.error-msg {
    color: var(--red);
    margin-top: 1rem;
    font-weight: 600;
    font-size: 0.95rem;
}

.hint-msg {
    color: var(--muted);
    margin-top: 0.5rem;
    font-size: 0.85rem;
    opacity: 0.7;
}

/* ========== HEADER ========== */
.container { max-width: 900px; margin: 0 auto; }

header { 
    text-align: center; 
    margin-bottom: 2rem;
    position: relative;
}

header h1 { font-size: 2.2rem; margin-bottom: .5rem; }
header p { color: var(--muted); }

.btn-logout {
    position: absolute;
    top: 0;
    right: 0;
    padding: 0.5rem 1rem;
    background: var(--red);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.btn-logout:hover { opacity: 0.9; }

/* ========== FORM ========== */
.input-group {
    display: flex; gap: .75rem;
    max-width: 700px; margin: 0 auto;
}

.input-group input {
    flex: 1; padding: .9rem 1.2rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    color: var(--text);
    font-size: 1rem;
    outline: none;
    transition: border .3s;
}

.input-group input:focus { border-color: var(--accent); }

.input-group button {
    padding: .9rem 1.8rem;
    border: none; border-radius: 12px;
    background: var(--accent);
    color: #fff; font-weight: 700;
    font-size: 1rem; cursor: pointer;
    transition: transform .15s, opacity .3s;
}

.input-group button:hover { transform: scale(1.03); }
.input-group button:disabled { opacity: .5; cursor: not-allowed; }

/* ========== SCORE ========== */
.score-card {
    text-align: center;
    margin: 2.5rem auto;
    max-width: 250px;
}

.score-circle {
    width: 140px; height: 140px;
    border-radius: 50%;
    border: 6px solid var(--accent);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    margin: 0 auto 1rem;
    font-size: 2.5rem; font-weight: 800;
}

.score-circle.good   { border-color: var(--green); color: var(--green); }
.score-circle.medium { border-color: var(--yellow); color: var(--yellow); }
.score-circle.bad    { border-color: var(--red); color: var(--red); }

.score-circle small  { font-size: .9rem; font-weight: 400; }

#scoreMessage {
    margin-top: 0.5rem;
    font-weight: 600;
    color: var(--muted);
}

/* ========== BOTÕES DE AÇÃO ========== */
.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.btn-primary, .btn-secondary, .btn-ai {
    padding: 1rem 2rem;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.15s;
}

.btn-primary { background: var(--green); color: white; }
.btn-secondary { background: var(--accent); color: white; }
.btn-ai {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover, .btn-secondary:hover, .btn-ai:hover {
    transform: scale(1.05);
}

/* ========== CARDS ========== */
.section { margin-top: 2rem; }
.section > h2 { margin-bottom: 1rem; font-size: 1.4rem; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.3rem 1.5rem;
    margin-bottom: 1rem;
}

.card h3 { margin-bottom: .8rem; color: var(--accent); font-size: 1.1rem; }

table { width: 100%; border-collapse: collapse; }
td {
    padding: .5rem 0;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
td:first-child {
    font-weight: 600; width: 40%;
    color: var(--muted);
}

.badge {
    display: inline-block;
    padding: .15rem .6rem;
    border-radius: 6px;
    font-size: .8rem;
    font-weight: 700;
}
.badge.ok   { background: rgba(0,184,148,.15); color: var(--green); }
.badge.warn { background: rgba(253,203,110,.15); color: var(--yellow); }
.badge.fail { background: rgba(214,48,49,.15); color: var(--red); }

.error {
    background: rgba(214,48,49,.12);
    border: 1px solid var(--red);
    color: var(--red);
    padding: 1rem; border-radius: 12px;
    margin-top: 1.5rem; text-align: center;
}

.progress-row { display: flex; align-items: center; gap: .8rem; margin: .4rem 0; }
.progress-bar {
    flex: 1; height: 8px;
    background: var(--border); border-radius: 4px;
    overflow: hidden;
}
.progress-bar .fill {
    height: 100%; border-radius: 4px;
    transition: width .6s ease;
}

/* ========== RELATÓRIO ========== */
.report-header {
    background: linear-gradient(135deg, var(--accent), #a29bfe);
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    color: white;
}

.report-header h2 { margin-bottom: 1rem; }
.report-info p { margin: 0.3rem 0; font-size: 0.95rem; }

.executive-summary .summary-box {
    background: var(--card);
    border-left: 4px solid var(--accent);
    padding: 1.5rem;
    border-radius: 8px;
}

.priorities .priorities-box { display: grid; gap: 1rem; }

.priority-item {
    background: var(--card);
    border-radius: 8px;
    padding: 1rem;
    border-left: 4px solid;
}

.priority-item.critical { border-left-color: var(--red); }
.priority-item.high { border-left-color: var(--yellow); }
.priority-item.medium { border-left-color: var(--accent); }

.priority-item h4 {
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.recommendations .recommendations-box { display: grid; gap: 1rem; }

.recommendation-item {
    background: var(--card);
    border-radius: 8px;
    padding: 1rem;
}

.recommendation-item h4 {
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.recommendation-item code {
    background: var(--bg);
    padding: 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    display: block;
    margin: 0.5rem 0;
    overflow-x: auto;
    font-size: 0.9rem;
}

/* ========== MODAL IA - CORRIGIDO ========== */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.modal:not([hidden]) {
    display: flex;
}

.modal-content {
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 16px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--card);
    z-index: 10;
}

.modal-header h2 {
    color: var(--accent);
    font-size: 1.5rem;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 0.5rem;
}

.btn-close:hover { color: var(--red); }

.modal-body { padding: 1.5rem; }

.modal-info {
    color: var(--muted);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.ai-selector { margin-bottom: 1.5rem; }

.ai-selector label {
    display: block;
    margin-bottom: 0.8rem;
    font-weight: 600;
    color: var(--text);
}

.ai-options {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.ai-btn {
    padding: 0.6rem 1.2rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.ai-btn:hover { border-color: var(--accent); }

.ai-btn.active {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
}

.prompt-container { margin-bottom: 1.5rem; }

#aiPromptText {
    width: 100%;
    min-height: 400px;
    padding: 1rem;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    outline: none;
}

#aiPromptText:focus { border-color: var(--accent); }

.modal-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-copy, .btn-open-ai {
    flex: 1;
    min-width: 200px;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.15s;
}

.btn-copy { background: var(--green); color: white; }
.btn-open-ai { background: var(--accent); color: white; }

.btn-copy:hover, .btn-open-ai:hover { transform: scale(1.02); }

.copy-feedback {
    margin-top: 1rem;
    padding: 0.8rem;
    background: rgba(0, 184, 148, 0.15);
    border: 1px solid var(--green);
    border-radius: 8px;
    color: var(--green);
    text-align: center;
    font-weight: 600;
}

/* ========== ANIMAÇÃO SHAKE ========== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
    20%, 40%, 60%, 80% { transform: translateX(8px); }
}

/* ========== IMPRESSÃO ========== */
@media print {
    body {
        background: white;
        color: black;
        padding: 0;
    }
    
    .login-screen,
    .input-group,
    .action-buttons,
    .btn-logout,
    #errorBox,
    header p,
    #scoreMessage,
    .modal,
    .btn-ai {
        display: none !important;
    }
    
    #mainSystem {
        display: block !important;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
    }
    
    header {
        text-align: left;
        margin-bottom: 1rem;
    }
    
    header h1 {
        font-size: 1.8rem;
        color: #333;
    }
    
    .report-header {
        background: #6c5ce7 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        page-break-inside: avoid;
    }
    
    .score-card { page-break-inside: avoid; }
    
    .card {
        background: white;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
    
    .section {
        page-break-inside: avoid;
        margin-top: 1.5rem;
    }
    
    .badge { border: 1px solid; }
    .badge.ok { background: #d4edda; color: #155724; border-color: #c3e6cb; }
    .badge.warn { background: #fff3cd; color: #856404; border-color: #ffeeba; }
    .badge.fail { background: #f8d7da; color: #721c24; border-color: #f5c6cb; }
    
    .priority-item,
    .recommendation-item {
        background: #f8f9fa;
        border: 1px solid #dee2e6;
        page-break-inside: avoid;
    }
    
    #results { display: block !important; }
    
    @page {
        margin: 2cm;
        size: A4;
    }
}

@media (max-width: 768px) {
    .input-group { flex-direction: column; }
    .action-buttons { flex-direction: column; }
    .btn-primary, .btn-secondary, .btn-ai { width: 100%; }
    table { font-size: 0.9rem; }
    td:first-child { width: 45%; }
    
    .pin-digit {
        width: 50px;
        height: 60px;
        font-size: 1.5rem;
    }
    
    .modal-content { max-height: 95vh; }
    .modal-actions { flex-direction: column; }
    #aiPromptText { min-height: 300px; font-size: 0.8rem; }
}