:root {
    --primary-color: #9e1a1a;
    --primary-gradient: linear-gradient(135deg, #a81c1c, #5c0c0c);
    --secondary-color: #f39200;
    --secondary-gradient: linear-gradient(135deg, #f39200, #d97706);
    --bg-dark: #0f172a;
    --bg-light: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --radius-lg: 16px;
    --radius-md: 10px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 20px rgba(243, 146, 0, 0.35);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Status Colors */
    --st-enviado: #64748b;
    --st-contato: #0284c7;
    --st-interessado: #d97706;
    --st-inscrito: #7c3aed;
    --st-matriculado: #16a34a;
    --st-perdido: #dc2626;
}

body.dark-mode {
    --bg-light: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

/* Nono Requisito: Garantia de Contraste para o Botão Copiar Link no Dark Mode */
body.dark-mode .btn-copy-link {
    background: #ffffff !important;
    color: #0f172a !important;
}

/* Sétimo Requisito: Spinner e Animação de Carregamento Global */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.7);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 5px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-main);
    min-height: 100vh;
    padding-bottom: 60px;
    transition: var(--transition);
}

input[type="text"],
input[type="email"] {
    text-transform: uppercase;
}

.app-container {
    max-width: 1550px;
    margin: 0 auto;
    padding: 25px 20px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(243, 146, 0, 0.2);
    }
    50% {
        box-shadow: var(--shadow-glow);
    }
}

.animate-fade {
    animation: fadeIn 0.4s ease forwards;
}

header {
    background: var(--primary-gradient);
    padding: 20px 32px;
    border-radius: var(--radius-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 12px 30px rgba(158, 26, 26, 0.25);
    margin-bottom: 25px;
    color: white;
}

.brand-logo h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.brand-logo p {
    font-size: 12px;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.user-profile-widget {
    display: flex;
    align-items: center;
    gap: 15px;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--secondary-color);
    display: grid;
    place-items: center;
    font-weight: bold;
    font-size: 18px;
    color: white;
    border: 2px solid white;
    box-shadow: var(--shadow-sm);
}

.btn-action {
    background: var(--secondary-color);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: white;
    padding: 9px 16px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-action.active-tab {
    background: var(--primary-color) !important;
    color: #ffffff !important;
}

.btn-action:hover {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    transform: translateY(-2px);
}

.btn-small {
    padding: 5px 10px;
    font-size: 11px;
    border-radius: 6px;
}

.grid-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 25px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-md);
    margin-bottom: 25px;
    transition: var(--transition);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

body.dark-mode .card-title {
    color: var(--secondary-color);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
}

input,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 13px;
    background: var(--bg-light);
    color: var(--text-main);
    outline: none;
    transition: var(--transition);
}

input:focus,
select:focus {
    border-color: var(--primary-color);
    background: var(--card-bg);
    box-shadow: 0 0 0 3px rgba(158, 26, 26, 0.1);
}

.btn-submit {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 700;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(158, 26, 26, 0.3);
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(158, 26, 26, 0.4);
}

.hero-gamification {
    background: linear-gradient(135deg, #1e1b18, #0f0d0c);
    color: white;
    padding: 30px;
    border-radius: var(--radius-lg);
    margin-bottom: 25px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(243, 146, 0, 0.2);
}

.progress-bar-container {
    width: 100%;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    padding: 3px;
    margin: 15px 0;
}

.progress-bar-fill {
    height: 100%;
    background: var(--secondary-gradient);
    border-radius: 50px;
    width: 0%;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
    animation: pulseGlow 3s infinite;
}

.badges-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.badge-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    padding: 12px;
    text-align: center;
    opacity: 0.35;
    filter: grayscale(1);
    transition: var(--transition);
}

.badge-card.unlocked {
    opacity: 1;
    filter: grayscale(0);
    background: rgba(243, 146, 0, 0.12);
    border-color: var(--secondary-color);
    transform: scale(1.03);
}

.badge-card .icon {
    font-size: 28px;
    margin-bottom: 6px;
    display: block;
}

.badge-card .title {
    font-size: 11px;
    font-weight: 800;
    color: #fff;
    text-transform: uppercase;
}

.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow-y: visible !important;
}

table {
    width: 100%;
    border-collapse: separate;
    text-align: left;
    font-size: 12px;
    border-spacing: 0;
}

th {
    background: var(--bg-light);
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

td {
    min-width: 140px;
    width: auto;
    padding: 12px 14px;
    padding-left: 8px;
    padding-right: 22px;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

td:has(.tooltip-status) {
    position: relative;
    z-index: 10;
}

tr:hover {
    background: rgba(243, 146, 0, 0.03);
}

.tag-status {
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    color: white;
    display: inline-block;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.kpi-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary-color);
    margin-top: 5px;
}

body.dark-mode .kpi-value {
    color: var(--secondary-color);
}

.toast {
    position: fixed;
    bottom: -70px;
    left: 50%;
    transform: translateX(-50%);
    background: #16a34a;
    color: white;
    padding: 14px 28px;
    border-radius: 50px;
    font-weight: 700;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    opacity: 0;
    z-index: 9999;
}

.toast.show {
    bottom: 30px;
    opacity: 1;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    place-items: center;
    z-index: 999;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: grid;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 30px;
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

#canvas-confetti {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    display: none;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}