:root {
    --bg-main: #070a13;
    --bg-surface: #0e1526;
    --bg-card: #131c33;
    --bg-card-hover: #1a2747;
    --border-color: #202e52;
    
    --primary: #3b82f6;
    --accent: #38bdf8;
    --success: #10b981;
    --warning: #f59e0b;
    --gold: #fbbf24;

    --color-megasena: #209869;
    --glow-megasena: rgba(32, 152, 105, 0.4);
    --color-quina: #6a38eb;
    --glow-quina: rgba(106, 56, 235, 0.4);
    --color-lotofacil: #d63384;
    --glow-lotofacil: rgba(214, 51, 132, 0.4);
    --color-lotomania: #f78100;
    --glow-lotomania: rgba(247, 129, 0, 0.4);

    --theme-color: var(--color-megasena);
    --theme-glow: var(--glow-megasena);
    --theme-gradient: linear-gradient(135deg, #106b47, #209869);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
}

body.theme-megasena {
    --theme-color: #209869;
    --theme-glow: rgba(32, 152, 105, 0.45);
    --theme-gradient: linear-gradient(135deg, #106b47, #209869, #00d084);
}
body.theme-quina {
    --theme-color: #6a38eb;
    --theme-glow: rgba(106, 56, 235, 0.45);
    --theme-gradient: linear-gradient(135deg, #260085, #6a38eb, #8c52ff);
}
body.theme-lotofacil {
    --theme-color: #d63384;
    --theme-glow: rgba(214, 51, 132, 0.45);
    --theme-gradient: linear-gradient(135deg, #930089, #d63384, #f783ac);
}
body.theme-lotomania {
    --theme-color: #f78100;
    --theme-glow: rgba(247, 129, 0, 0.45);
    --theme-gradient: linear-gradient(135deg, #c05e00, #f78100, #ffab40);
}

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

body {
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(32, 152, 105, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(56, 189, 248, 0.04) 0%, transparent 40%);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ==========================================
   TOPBAR
   ========================================== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2.5rem;
    background: rgba(14, 21, 38, 0.9);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--theme-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 0 20px var(--theme-glow);
    transition: all 0.3s ease;
}

.brand-text h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #fff;
}

.brand-text h1 span {
    color: var(--theme-color);
    transition: color 0.3s ease;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-scan {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    font-weight: 700;
    padding: 10px 20px;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    box-shadow: 0 4px 18px rgba(245, 158, 11, 0.35);
    transition: all 0.25s ease;
}

.btn-scan:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(245, 158, 11, 0.5);
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}

.status-dot.pulsing {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ==========================================
   CONTAINER PRINCIPAL
   ========================================== */
.main-container {
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

/* Barra de Navegação das 4 Loterias */
.lottery-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
}

.lottery-tab {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.lottery-tab::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 5px;
    background: transparent;
    transition: all 0.25s ease;
}

.lottery-tab[data-game="megasena"]::before { background: var(--color-megasena); }
.lottery-tab[data-game="quina"]::before { background: var(--color-quina); }
.lottery-tab[data-game="lotofacil"]::before { background: var(--color-lotofacil); }
.lottery-tab[data-game="lotomania"]::before { background: var(--color-lotomania); }

.lottery-tab:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
}

.lottery-tab.active {
    background: var(--bg-card);
    border-color: var(--theme-color);
    box-shadow: 0 0 24px var(--theme-glow);
}

.tab-badge-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 1.05rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.3), 0 4px 12px rgba(0,0,0,0.5);
}

.icon-ms { background: radial-gradient(circle at 35% 35%, #34d399, #209869 60%, #064e3b); }
.icon-qn { background: radial-gradient(circle at 35% 35%, #a78bfa, #6a38eb 60%, #2e1065); }
.icon-lf { background: radial-gradient(circle at 35% 35%, #f472b6, #d63384 60%, #701a75); }
.icon-lm { background: radial-gradient(circle at 35% 35%, #fbbf24, #f78100 60%, #78350f); }

.tab-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.tab-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
}

.tab-prize {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 600;
    color: #34d399;
}

/* ==========================================
   CARDS DE RESULTADO E PREVISÃO
   ========================================== */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 36px -4px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border-color);
    overflow: hidden;
    backdrop-filter: blur(14px);
    transition: border-color 0.3s ease;
}

/* CARD 1: RESULTADO OFICIAL */
.result-card {
    border-top: 4px solid var(--theme-color);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 2.5rem 1.5rem 2.5rem;
    border-bottom: 1px solid rgba(32, 46, 82, 0.5);
}

.official-tag {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #34d399;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 3px 10px;
    border-radius: 999px;
    margin-bottom: 6px;
}

.contest-highlight h2 {
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #fff;
    margin-bottom: 4px;
}

.contest-date {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.jackpot-box {
    text-align: right;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    padding: 12px 20px;
    border-radius: var(--radius-md);
}

.jackpot-status {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 800;
    color: #fbbf24;
}

.jackpot-title {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 2px;
}

.jackpot-amount {
    display: block;
    font-family: var(--font-mono);
    font-size: 1.45rem;
    font-weight: 800;
    color: #34d399;
}

.next-contest-date {
    display: block;
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-top: 2px;
}

/* Seção de Bolas */
.balls-section {
    padding: 2rem 2.5rem;
}

.balls-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.balls-heading {
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-text:hover {
    background: rgba(56, 189, 248, 0.1);
}

/* ==========================================
   3D LOTTERY BALLS (ESFERAS ILUMINADAS)
   ========================================== */
.lottery-balls-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.lottery-balls-row.compact {
    gap: 10px;
}

.ball {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 1.45rem;
    color: #ffffff;
    cursor: default;
    user-select: none;
    box-shadow: 
        inset -5px -7px 14px rgba(0, 0, 0, 0.65),
        inset 5px 7px 12px rgba(255, 255, 255, 0.45),
        0 10px 24px rgba(0, 0, 0, 0.5);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}

.ball:hover {
    transform: scale(1.12) translateY(-4px);
    box-shadow: 
        inset -5px -7px 14px rgba(0, 0, 0, 0.65),
        inset 5px 7px 12px rgba(255, 255, 255, 0.55),
        0 14px 30px var(--theme-glow);
}

.ball.compact-size {
    width: 46px;
    height: 46px;
    font-size: 1.1rem;
}

.ball.mini-size {
    width: 36px;
    height: 36px;
    font-size: 0.85rem;
}

/* Temas das Bolas */
.ball-megasena { background: radial-gradient(circle at 35% 30%, #4ade80, #209869 65%, #064e3b); }
.ball-quina { background: radial-gradient(circle at 35% 30%, #a78bfa, #6a38eb 65%, #2e1065); }
.ball-lotofacil { background: radial-gradient(circle at 35% 30%, #f472b6, #d63384 65%, #701a75); }
.ball-lotomania { background: radial-gradient(circle at 35% 30%, #fbbf24, #f78100 65%, #78350f); }

.ball.hit-match {
    border: 3px solid #fbbf24;
    box-shadow: 0 0 24px #fbbf24;
    animation: matchGlow 1.8s infinite alternate;
}

@keyframes matchGlow {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

/* Payout Table */
.payout-accordion {
    padding: 0 2.5rem 2rem 2.5rem;
}

.payout-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.payout-table th {
    text-align: left;
    padding: 12px 16px;
    background: rgba(32, 46, 82, 0.4);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
}

.payout-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(32, 46, 82, 0.3);
    font-family: var(--font-mono);
    color: var(--text-main);
}

.payout-table tr:last-child td { border-bottom: none; }
.payout-table td.prize-money { color: #34d399; font-weight: 700; }

/* CARD 2: PREVISÃO IA */
.ai-card {
    background: linear-gradient(180deg, var(--bg-surface) 0%, rgba(14, 21, 38, 0.7) 100%);
}

.ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.75rem 2.5rem 1rem 2.5rem;
    border-bottom: 1px solid rgba(32, 46, 82, 0.4);
}

.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent);
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.25);
    padding: 3px 10px;
    border-radius: 999px;
    margin-bottom: 6px;
}

.ai-header-left h3 {
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
}

.ai-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.ai-actions {
    display: flex;
    gap: 12px;
}

.ai-footer-metrics {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 0 2.5rem 1.75rem 2.5rem;
}

.metric-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    font-size: 0.82rem;
}

.pill-label { color: var(--text-muted); }
.pill-val { font-family: var(--font-mono); font-weight: 700; color: #fff; }
.pill-val.highlight { color: #38bdf8; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--theme-gradient);
    color: #fff;
    box-shadow: 0 4px 16px var(--theme-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px var(--theme-glow);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--bg-card-hover);
    border-color: var(--theme-color);
}

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================
   MODAL DE SCANNER & CONFERIDOR
   ========================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(7, 10, 19, 0.85);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
}

.modal-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    max-width: 640px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.75rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.scanner-icon-badge {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(245, 158, 11, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.modal-title-group h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
}

.modal-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
}

.modal-close-btn:hover { color: #fff; }

.scanner-mode-switch {
    display: flex;
    padding: 1rem 1.75rem 0.5rem 1.75rem;
    gap: 8px;
}

.scanner-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.scanner-tab.active {
    background: rgba(245, 158, 11, 0.15);
    border-color: #f59e0b;
    color: #fff;
}

.scanner-camera-box {
    padding: 1.25rem 1.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.camera-reader-viewport {
    width: 100%;
    max-width: 480px;
    height: 300px;
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    border: 2px solid var(--border-color);
}

.camera-guideline {
    text-align: center;
    position: relative;
}

.scanner-instruction {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Manual Check Box */
.manual-check-box {
    padding: 1.25rem 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.manual-hint { font-size: 0.82rem; color: var(--text-muted); }

.manual-input-group {
    display: flex;
    gap: 8px;
}

.custom-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    outline: none;
}

.custom-input:focus { border-color: var(--theme-color); }

.quick-picker-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
    padding: 8px 0;
}

.pick-ball {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.pick-ball:hover {
    border-color: var(--theme-color);
    color: #fff;
}

.pick-ball.selected {
    background: var(--theme-color);
    border-color: var(--theme-color);
    color: #fff;
    box-shadow: 0 0 10px var(--theme-glow);
}

/* Ticket Check Result */
.ticket-check-result {
    padding: 1.5rem 1.75rem;
    border-top: 1px solid var(--border-color);
    background: rgba(14, 21, 38, 0.6);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.result-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.result-banner.loser {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.result-badge-icon { font-size: 1.75rem; }
.result-banner h4 { font-size: 1.05rem; font-weight: 700; color: #fff; }
.result-banner p { font-size: 0.78rem; color: var(--text-muted); }

.prize-summary-box {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.prize-stat {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: var(--radius-sm);
    text-align: center;
}

.stat-label { display: block; font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; }
.stat-val { font-family: var(--font-mono); font-size: 1.15rem; font-weight: 800; color: #fff; }
.stat-val.prize-color { color: #34d399; }

/* Responsividade */
@media (max-width: 900px) {
    .lottery-nav { grid-template-columns: repeat(2, 1fr); }
    .result-header { flex-direction: column; align-items: flex-start; gap: 16px; }
    .jackpot-box { width: 100%; text-align: left; }
    .ai-header { flex-direction: column; align-items: flex-start; gap: 14px; }
    .ai-footer-metrics { flex-direction: column; gap: 8px; }
    .topbar { padding: 0.75rem 1rem; flex-direction: column; gap: 10px; }
    .main-container { padding: 1rem; }
}
