:root {
    --primary-blue: #4A80C3;
    --dark-blue: #1A2F4C;
    --text-main: #333333;
    --text-muted: #888888;
    --border-color: #D1D5DB;
    --bg-color: #F8F9FA;
    --card-bg: #FFFFFF;
    --font-family: 'Outfit', sans-serif;
    --error-red: #EF4444;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
}

/* ── Tela de login/cadastro (centralizada) ───────────── */
body.tela-auth {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    background-image: radial-gradient(#d1d5db 1px, transparent 1px);
    background-size: 20px 20px;
}

.card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 3rem 2.5rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 480px;
    animation: fadeIn 0.4s ease-out forwards;
}

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

.card-header { margin-bottom: 2rem; text-align: center; }
.logo { font-size: 2.2rem; font-weight: 700; margin-bottom: 0.5rem; }
.title { font-size: 1.8rem; color: var(--dark-blue); line-height: 1.3; }
.subtitle { color: var(--text-muted); font-size: 0.95rem; }

.form { display: flex; flex-direction: column; gap: 1.25rem; }
.form-group { display: flex; flex-direction: column; gap: 0.5rem; }
label { font-size: 0.9rem; color: var(--text-muted); font-weight: 500; }

input, select {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: var(--font-family);
    color: var(--text-main);
    transition: all 0.2s ease;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(74, 128, 195, 0.1);
}

.error-text { color: var(--error-red); font-size: 0.85rem; margin-top: 0.2rem; }
.success-text { color: #16a34a; font-size: 0.85rem; margin-top: 0.2rem; }

.btn {
    background-color: var(--dark-blue);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 1.1rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn:hover { background-color: #122136; transform: translateY(-2px); box-shadow: 0 8px 15px rgba(26, 47, 76, 0.2); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ── Dashboard / App shell ────────────────────────────── */
.topbar {
    background: var(--dark-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.topbar .brand { font-weight: 700; font-size: 1.1rem; }
.topbar .nav-tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.topbar .nav-tabs button {
    background: transparent; border: none; color: #cbd5e1;
    font-family: var(--font-family); font-size: 0.85rem; font-weight: 600;
    padding: 0.5rem 0.85rem; border-radius: 8px; cursor: pointer; transition: all 0.15s;
}
.topbar .nav-tabs button:hover { background: rgba(255,255,255,0.1); color: #fff; }
.topbar .nav-tabs button.active { background: var(--primary-blue); color: #fff; }
.topbar .user-area { display: flex; align-items: center; gap: 0.75rem; font-size: 0.85rem; color: #cbd5e1; }

.app-content { max-width: 1200px; margin: 2rem auto; padding: 0 1.5rem 3rem; }
.section { display: none; }
.section.active { display: block; }

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}
.metric-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s, box-shadow 0.2s;
}
.metric-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08); }
.metric-card .metric-icon { font-size: 1.6rem; margin-bottom: 0.75rem; }
.metric-card .metric-value { font-size: 2rem; font-weight: 700; color: var(--dark-blue); line-height: 1; margin-bottom: 0.35rem; }
.metric-card .metric-label { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.table-section { margin-bottom: 2rem; }
.table-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem; flex-wrap: wrap; gap: 0.75rem;
}
.table-toolbar h3 { font-size: 1.15rem; font-weight: 600; color: var(--dark-blue); }

.search-input {
    padding: 0.6rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: var(--font-family);
    min-width: 220px;
}
.search-input:focus { outline: none; border-color: var(--primary-blue); box-shadow: 0 0 0 3px rgba(74, 128, 195, 0.1); }

.portal-table-wrapper {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}
.portal-table { width: 100%; border-collapse: collapse; }
.portal-table th {
    padding: 1rem 1.25rem; text-align: left; font-size: 0.78rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted);
    background: #F9FAFB; border-bottom: 1px solid #E5E7EB;
}
.portal-table td { padding: 0.9rem 1.25rem; font-size: 0.9rem; color: var(--text-main); border-bottom: 1px solid #E5E7EB; }
.portal-table tr:last-child td { border-bottom: none; }
.portal-table tbody tr:hover { background: #F3F4F6; }
.portal-table .actions-cell { display: flex; gap: 0.5rem; }

.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-pendente { background: rgba(234, 179, 8, 0.12); color: #a16207; }
.badge-importado { background: rgba(22, 163, 74, 0.12); color: #16a34a; }
.badge-erro { background: rgba(239, 68, 68, 0.1); color: var(--error-red); }

.btn-table {
    padding: 0.4rem 0.75rem; border-radius: 8px; font-size: 0.78rem; font-weight: 600;
    font-family: var(--font-family); cursor: pointer; transition: all 0.15s; border: none;
}
.btn-table-primary { background: rgba(74, 128, 195, 0.1); color: var(--primary-blue); }
.btn-table-primary:hover { background: var(--primary-blue); color: #fff; }
.btn-table-danger { background: rgba(239, 68, 68, 0.08); color: var(--error-red); }
.btn-table-danger:hover { background: var(--error-red); color: #fff; }
.btn-table-success { background: rgba(22,163,74,0.1); color: #16a34a; }
.btn-table-success:hover { background: #16a34a; color: #fff; }

.btn-portal {
    padding: 0.6rem 1.2rem; border-radius: 10px; font-size: 0.85rem; font-weight: 600;
    font-family: var(--font-family); cursor: pointer; transition: all 0.2s; border: none;
    display: inline-flex; align-items: center; gap: 0.4rem;
}
.btn-portal-primary { background: var(--primary-blue); color: #fff; }
.btn-portal-primary:hover { background: var(--dark-blue); }
.btn-portal-secondary { background: #E2E8F0; color: #475569; border: 1px solid var(--border-color); }
.btn-portal-secondary:hover { background: #CBD5E1; color: #1E293B; }

.dropzone {
    border: 2px dashed var(--primary-blue);
    border-radius: 12px;
    padding: 2.5rem 1rem;
    background-color: #FFFFFF;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}
.dropzone:hover, .dropzone.dragover {
    background-color: rgba(74, 128, 195, 0.05);
    border-color: var(--dark-blue);
    transform: translateY(-2px);
}

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.5rem; }
.checkbox-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
.checkbox-item input { width: auto; }

.empty-state-portal { text-align: center; padding: 3rem 1rem; color: var(--text-muted); font-size: 0.95rem; }

/* ── Modal ──────────────────────────────────────────── */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 9998; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-box {
    background: #fff; border-radius: 16px; width: 92%; max-width: 720px; max-height: 85vh;
    overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-header, .modal-footer { padding: 1.25rem 1.5rem; border-bottom: 1px solid #E5E7EB; display: flex; justify-content: space-between; align-items: center; }
.modal-footer { border-top: 1px solid #E5E7EB; border-bottom: none; }
.modal-body { padding: 1.5rem; }

/* ── Toast ──────────────────────────────────────────── */
#toastContainer { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 10000; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
    background: #16a34a; color: #fff; padding: 0.85rem 1.4rem; border-radius: 12px;
    font-size: 0.9rem; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    animation: slideInToast 0.3s ease-out;
}
.toast.erro { background: var(--error-red); }
@keyframes slideInToast { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }

.loading-spinner {
    display: inline-block; width: 18px; height: 18px;
    border: 2px solid rgba(26, 47, 76, 0.2); border-top-color: var(--dark-blue);
    border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle; margin-right: 0.4rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
    .portal-table th, .portal-table td { padding: 0.7rem 0.75rem; font-size: 0.8rem; }
    .topbar { flex-direction: column; align-items: flex-start; }
}
