:root {
    --primary: #111827;
    --secondary: #2563EB;
    --success: #059669;
    --danger: #DC2626;
    --bg-color: #F3F4F6;
    --surface: #FFFFFF;
    --text-main: #111827;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --shadow: rgba(0,0,0,0.05);
}

[data-theme="dark"] {
    --primary: #F9FAFB;
    --secondary: #3B82F6;
    --success: #10B981;
    --danger: #F87171;
    --bg-color: #0F172A;
    --surface: #1E293B;
    --text-main: #F1F5F9;
    --text-muted: #94A3B8;
    --border: #334155;
    --shadow: rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }

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

.sidebar { width: 260px; background: var(--surface); border-right: 1px solid var(--border); padding: 2rem 1.5rem; display: flex; flex-direction: column; }
.logo { margin-bottom: 2.5rem; }
.logo h2 { color: var(--primary); font-weight: 700; font-size: 1.5rem; letter-spacing: -0.02em; }
.badge { background: #DBEAFE; color: #1E40AF; font-size: 0.75rem; padding: 0.2rem 0.5rem; border-radius: 4px; font-weight: 600; }
[data-theme="dark"] .badge { background: #1E3A5F; color: #93C5FD; }

.sidebar nav { flex: 1; }
.sidebar nav a { display: block; text-decoration: none; color: var(--text-muted); padding: 0.8rem 1rem; border-radius: 8px; margin-bottom: 0.5rem; font-weight: 500; transition: all 0.2s; }
.sidebar nav a:hover, .sidebar nav a.active { background: var(--bg-color); color: var(--primary); font-weight: 600; }

.upload-container { margin-top: auto; padding-top: 2rem; border-top: 1px solid var(--border); text-align: center; }
.btn-upload { width: 100%; background: var(--primary); color: white; border: none; padding: 0.75rem; border-radius: 8px; font-weight: 500; cursor: pointer; transition: 0.2s; }
.btn-upload:hover { opacity: 0.85; }
.micro-text { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.5rem; }

.content { flex: 1; padding: 2.5rem 3rem; overflow-y: auto; }
header { margin-bottom: 2rem; }
header h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; }
header p { color: var(--text-muted); font-size: 1rem; }

.hidden { display: none !important; }

/* ── Loading overlay ─────────────────────────────────────────────────── */
#loading {
    position: fixed; inset: 0; z-index: 9999;
    background: color-mix(in srgb, var(--bg-color) 55%, transparent);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2rem;
    opacity: 1; transition: opacity 0.4s ease;
}
#loading.hidden { display: none !important; }
#loading.fading { opacity: 0; pointer-events: none; }

.loading-label {
    font-size: 0.9rem; font-weight: 500; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--text-muted);
}

/* Campo de pontos que sobem */
.loading-particles {
    position: fixed; inset: 0; overflow: hidden; pointer-events: none;
}
.loading-particles span {
    position: absolute; bottom: -20px;
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--secondary);
    animation: floatUp linear infinite;
    will-change: transform, opacity;
}

/* Distribui 12 pontos em posições/tamanhos/tempos variados */
.loading-particles span:nth-child(1)  { left:  8%; width:5px;  height:5px;  animation-duration:3.2s; animation-delay:0s;    opacity:.5; }
.loading-particles span:nth-child(2)  { left: 16%; width:4px;  height:4px;  animation-duration:2.8s; animation-delay:0.4s;  opacity:.3; }
.loading-particles span:nth-child(3)  { left: 25%; width:7px;  height:7px;  animation-duration:3.6s; animation-delay:0.8s;  opacity:.6; }
.loading-particles span:nth-child(4)  { left: 33%; width:4px;  height:4px;  animation-duration:2.5s; animation-delay:1.2s;  opacity:.4; }
.loading-particles span:nth-child(5)  { left: 42%; width:6px;  height:6px;  animation-duration:3.0s; animation-delay:0.2s;  opacity:.5; }
.loading-particles span:nth-child(6)  { left: 51%; width:5px;  height:5px;  animation-duration:3.4s; animation-delay:0.6s;  opacity:.35;}
.loading-particles span:nth-child(7)  { left: 60%; width:8px;  height:8px;  animation-duration:2.7s; animation-delay:1.0s;  opacity:.55;}
.loading-particles span:nth-child(8)  { left: 68%; width:4px;  height:4px;  animation-duration:3.1s; animation-delay:0.3s;  opacity:.3; }
.loading-particles span:nth-child(9)  { left: 76%; width:6px;  height:6px;  animation-duration:2.9s; animation-delay:0.7s;  opacity:.5; }
.loading-particles span:nth-child(10) { left: 83%; width:5px;  height:5px;  animation-duration:3.5s; animation-delay:1.4s;  opacity:.4; }
.loading-particles span:nth-child(11) { left: 91%; width:7px;  height:7px;  animation-duration:2.6s; animation-delay:0.5s;  opacity:.45;}
.loading-particles span:nth-child(12) { left: 97%; width:4px;  height:4px;  animation-duration:3.3s; animation-delay:0.9s;  opacity:.3; }

@keyframes floatUp {
    0%   { transform: translateY(0)   scale(1);   opacity: inherit; }
    60%  { opacity: inherit; }
    100% { transform: translateY(-105vh) scale(0.5); opacity: 0; }
}

.modern-select { padding: 0.75rem 1rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text-main); font-weight: 500; font-size: 0.875rem; cursor: pointer; outline: none; }
.modern-select:focus { border-color: var(--secondary); }

.exec-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 2rem; gap: 2rem; }
.exec-title h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; }
.exec-title p { color: var(--text-muted); font-size: 1rem; margin-top: 0.25rem; }
.exec-controls { display: flex; flex-direction: column; align-items: flex-end; }
.filter-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }

.btn-outline { background: transparent; border: 1px solid var(--border); padding: 0.4rem 0.85rem; border-radius: 8px; font-weight: 500; cursor: pointer; transition: 0.2s; color: var(--text-main); font-size: 0.85rem; }
.btn-outline:hover, .btn-outline.active { border-color: var(--secondary); color: var(--secondary); background: #EFF6FF; }
[data-theme="dark"] .btn-outline:hover, [data-theme="dark"] .btn-outline.active { background: #1E3A5F; }
.modern-input { border: 1px solid var(--border); border-radius: 6px; outline: none; padding: 0.4rem 0.5rem; font-family: 'Inter'; color: var(--text-main); font-size: 0.85rem; background: var(--surface); }
.modern-input:focus { border-color: var(--secondary); }
.btn-primary { background: var(--secondary); color: white; border: none; padding: 0.4rem 0.85rem; border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 0.85rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.card { background: var(--surface); padding: 1.5rem; border-radius: 16px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); border: 1px solid var(--border); }
.card h3 { font-size: 0.875rem; color: var(--text-muted); font-weight: 500; margin-bottom: 0.5rem; }
.card .val { font-size: 1.75rem; font-weight: 700; color: var(--text-main); }
.card .mom { font-size: 0.875rem; font-weight: 500; margin-top: 0.5rem; }
.mom.positive { color: var(--success); }
.mom.negative { color: var(--danger); }

.card.danger .val { color: var(--danger); }

.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 2rem; }
.charts-row-compact { grid-template-columns: 340px 1fr; }
.chart-container { background: var(--surface); padding: 1.5rem; border-radius: 16px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); border: 1px solid var(--border); margin-bottom: 2rem; }
.chart-container h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; color: var(--text-main); }
.chart-sm canvas { max-height: 260px; }
.chart-full { width: 100%; }
.card-alert .val { color: var(--danger); }
.card-label { color: var(--text-muted) !important; font-size: 0.8rem !important; }

.table-container { background: var(--surface); padding: 1.5rem; border-radius: 16px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); border: 1px solid var(--border); overflow-x: auto; }
.table-container h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }
.modern-table { width: 100%; border-collapse: collapse; text-align: left; }
.modern-table th { padding: 1rem; border-bottom: 2px solid var(--border); color: var(--text-muted); font-weight: 500; font-size: 0.875rem; }
.modern-table td { padding: 1rem; border-bottom: 1px solid var(--border); font-size: 0.875rem; color: var(--text-main); }
.modern-table tr:last-child td { border-bottom: none; }
.modern-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.modern-table th.sortable:hover { color: var(--text-main); }
.modern-table th.sortable::after { content: ' ⇅'; opacity: 0.35; font-size: 0.75rem; }
.modern-table th.sortable.sort-asc::after { content: ' ▲'; opacity: 1; }
.modern-table th.sortable.sort-desc::after { content: ' ▼'; opacity: 1; }
.badge-assinante { background:#dcfce7;color:#166534;padding:2px 8px;border-radius:999px;font-size:11px;font-weight:600; }
.badge-nao-assinante { background:var(--border);color:var(--text-muted);padding:2px 8px;border-radius:999px;font-size:11px; }
[data-theme="dark"] .badge-assinante { background:#14532d;color:#86efac; }
[data-theme="dark"] .badge-nao-assinante { background:#374151;color:#9ca3af; }
.badge-danger { background: #FEE2E2; color: #991B1B; padding: 0.25rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
[data-theme="dark"] .badge-danger { background: #450A0A; color: #FCA5A5; }
.mt-2 { margin-top: 2rem; }

/* ── Termômetro de Meta ──────────────────────────────────────────────────── */
.termometro-container {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 1.5rem 2rem; margin-bottom: 2rem;
    box-shadow: 0 1px 3px var(--shadow);
}
.termometro-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.termometro-titulo { font-size: 1rem; font-weight: 600; color: var(--text-main); }
.termometro-desc   { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }
.termometro-pct    { font-size: 2.5rem; font-weight: 800; line-height: 1; color: var(--text-main); }

.termometro-track {
    position: relative; height: 18px; background: var(--bg-color);
    border-radius: 999px; overflow: hidden; margin-bottom: 0.6rem;
}
.termometro-fill {
    height: 100%; border-radius: 999px;
    background: linear-gradient(90deg, #3B82F6, #10B981);
    transition: width 1s cubic-bezier(.4,0,.2,1), background 0.5s;
}
.termometro-segmentos { position: absolute; inset: 0; pointer-events: none; }
.termometro-segmentos span {
    position: absolute; top: 0; bottom: 0; width: 2px;
    background: var(--surface); opacity: 0.6;
}

.termometro-labels {
    display: flex; gap: 2rem; font-size: 0.78rem; color: var(--text-muted);
}
.termometro-labels span strong { color: var(--text-main); }

/* Theme toggle button */
.btn-theme { background: none; border: 1px solid var(--border); color: var(--text-muted); border-radius: 8px; padding: 0.5rem 0.75rem; cursor: pointer; font-size: 0.85rem; transition: 0.2s; width: 100%; margin-top: 0.75rem; }
.btn-theme:hover { border-color: var(--secondary); color: var(--secondary); }
