:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #818cf8;
    --primary-subtle: #eef2ff;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #3b82f6;
    --info-light: #dbeafe;
    --dark: #0f172a;
    --sidebar-bg: #0f172a;
    --sidebar-w: 260px;
    --body-bg: #f8fafc;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --card-shadow: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
    --card-shadow-hover: 0 4px 12px rgba(0,0,0,.08);
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --table-stripe: #f8fafc;
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --navbar-bg: #ffffff;
    --modal-bg: #ffffff;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --transition: all .2s ease;
}

/* Dark Theme */
[data-theme="dark"] {
    --body-bg: #0b1120;
    --card-bg: #151d2e;
    --card-border: #1e293b;
    --card-shadow: 0 1px 3px rgba(0,0,0,.2);
    --card-shadow-hover: 0 4px 16px rgba(0,0,0,.3);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #1e293b;
    --table-stripe: #1a2332;
    --input-bg: #1a2332;
    --input-border: #334155;
    --navbar-bg: #111827;
    --modal-bg: #151d2e;
    --sidebar-bg: #070d1a;
    --primary-subtle: #1e1b4b;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--body-bg);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background .3s, color .3s;
}

a { text-decoration: none; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--sidebar-bg);
    color: #fff;
    transition: margin-left .3s cubic-bezier(.4,0,.2,1);
    position: fixed;
    z-index: 1050;
    border-right: 1px solid rgba(255,255,255,.05);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-header h5 {
    margin: 0;
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -.3px;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.sidebar-header h5 i {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.3rem;
}

.sidebar .nav { flex: 1; padding: .5rem 0; }
.sidebar .nav-link {
    color: rgba(255,255,255,.55);
    padding: .65rem 1.25rem;
    font-size: .875rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: .65rem;
}
.sidebar .nav-link:hover {
    color: rgba(255,255,255,.9);
    background: rgba(255,255,255,.04);
}
.sidebar .nav-link.active {
    color: #fff;
    background: rgba(99,102,241,.15);
    border-left-color: var(--primary-light);
}
.sidebar .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    opacity: .8;
}
.sidebar .nav-link.active i { opacity: 1; }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.06);
}

#page-content {
    margin-left: var(--sidebar-w);
    transition: margin-left .3s cubic-bezier(.4,0,.2,1);
    min-height: 100vh;
}

.sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }
.sidebar.collapsed + #page-content { margin-left: 0; }

/* ===== NAVBAR ===== */
.top-navbar {
    background: var(--navbar-bg);
    border-bottom: 1px solid var(--border-color);
    padding: .6rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1040;
    backdrop-filter: blur(10px);
    transition: background .3s;
}

/* ===== CARDS ===== */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--card-border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}
.stat-card .label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: .35rem;
}
.stat-card .value {
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -.5px;
    line-height: 1.2;
}

.stat-card .icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}
.icon-purple { background: var(--primary-subtle); color: var(--primary); }
.icon-green  { background: var(--success-light); color: var(--success); }
.icon-red    { background: var(--danger-light); color: var(--danger); }
.icon-blue   { background: var(--info-light); color: var(--info); }
.icon-yellow { background: var(--warning-light); color: var(--warning); }

[data-theme="dark"] .icon-purple { background: rgba(99,102,241,.15); }
[data-theme="dark"] .icon-green  { background: rgba(16,185,129,.15); }
[data-theme="dark"] .icon-red    { background: rgba(239,68,68,.15); }
[data-theme="dark"] .icon-blue   { background: rgba(59,130,246,.15); }
[data-theme="dark"] .icon-yellow { background: rgba(245,158,11,.15); }

.text-profit  { color: var(--success) !important; }
.text-loss    { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info    { color: var(--info) !important; }

/* ===== TABLES ===== */
.table-custom {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--card-border);
}
.table-custom .table {
    color: var(--text-primary);
    margin: 0;
}
.table-custom thead th {
    background: var(--table-stripe);
    border-bottom: 2px solid var(--border-color);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-muted);
    font-weight: 700;
    padding: .85rem 1rem;
    white-space: nowrap;
}
.table-custom td {
    padding: .8rem 1rem;
    vertical-align: middle;
    border-color: var(--border-color);
    font-size: .875rem;
}
.table-custom tbody tr { transition: background .15s; }
.table-custom tbody tr:hover { background: var(--table-stripe); }
.table-custom tfoot th {
    background: var(--table-stripe);
    border-top: 2px solid var(--border-color);
}

[data-theme="dark"] .table { --bs-table-bg: transparent; --bs-table-hover-bg: rgba(255,255,255,.03); }
[data-theme="dark"] .table-light { --bs-table-bg: var(--table-stripe); color: var(--text-primary); }

/* ===== CHART CARDS ===== */
.chart-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--card-border);
    transition: var(--transition);
}
.chart-card h6 {
    font-size: .85rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* ===== FILTER BAR ===== */
.filter-bar {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--card-border);
    transition: var(--transition);
}

/* ===== FORMS ===== */
.form-control, .form-select {
    background: var(--input-bg);
    border-color: var(--input-border);
    color: var(--text-primary);
    border-radius: var(--radius-xs);
    transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    background: var(--input-bg);
    color: var(--text-primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.form-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ===== BUTTONS ===== */
.btn-primary, .btn-primary-custom {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    border-radius: var(--radius-xs);
    font-weight: 600;
    transition: var(--transition);
}
.btn-primary:hover { background: var(--primary-hover) !important; transform: translateY(-1px); }

.btn { border-radius: var(--radius-xs); font-weight: 500; transition: var(--transition); }
.btn-outline-secondary { border-color: var(--border-color); color: var(--text-secondary); }
.btn-outline-secondary:hover { background: var(--table-stripe); color: var(--text-primary); border-color: var(--text-muted); }

/* ===== BADGES ===== */
.badge { border-radius: var(--radius-xs); font-weight: 600; letter-spacing: .3px; }

/* ===== PROGRESS / CAPACITY ===== */
.capacity-bar { height: 6px; border-radius: 3px; background: var(--border-color); }
.capacity-fill { height: 100%; border-radius: 3px; transition: width .4s ease; }
.cap-normal  { background: linear-gradient(90deg, #10b981, #34d399); }
.cap-warning { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.cap-danger  { background: linear-gradient(90deg, #f97316, #fb923c); }
.cap-full    { background: linear-gradient(90deg, #ef4444, #f87171); }

/* ===== GOAL INDICATOR ===== */
.goal-indicator {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .75rem;
    color: var(--text-muted);
}
.goal-indicator .dot { width: 8px; height: 8px; border-radius: 50%; }
.goal-above { background: var(--success); }
.goal-below { background: var(--danger); }

/* ===== ALERTS ===== */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    font-size: .875rem;
}
[data-theme="dark"] .alert-warning { background: rgba(245,158,11,.12); color: #fbbf24; }
[data-theme="dark"] .alert-success { background: rgba(16,185,129,.12); color: #34d399; }
[data-theme="dark"] .alert-danger  { background: rgba(239,68,68,.12); color: #f87171; }

/* ===== CARDS (Bootstrap) ===== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    transition: var(--transition);
}
.card-body { color: var(--text-primary); }

/* ===== MODALS ===== */
.modal-content {
    background: var(--modal-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
}
.modal-header .modal-title {
    font-weight: 700;
    font-size: 1.05rem;
}
.modal-body { padding: 1.5rem; }
.modal-footer { border-top: 1px solid var(--border-color); padding: 1rem 1.5rem; }
.modal-backdrop.show { opacity: .6; }
[data-theme="dark"] .modal-backdrop.show { opacity: .75; }
.btn-close { filter: var(--text-primary); }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* ===== LOGIN ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
    position: relative;
    overflow: hidden;
}
.login-wrapper::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(99,102,241,.15), transparent 70%);
    top: -200px; right: -200px;
    border-radius: 50%;
}
.login-wrapper::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(129,140,248,.1), transparent 70%);
    bottom: -100px; left: -100px;
    border-radius: 50%;
}
.login-card {
    background: rgba(255,255,255,.97);
    border-radius: 20px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 80px rgba(0,0,0,.35);
    position: relative;
    z-index: 1;
    backdrop-filter: blur(20px);
}
.login-card h3 {
    font-weight: 800;
    letter-spacing: -.5px;
    margin-bottom: .3rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background: var(--border-color);
    border: none;
    cursor: pointer;
    position: relative;
    transition: background .3s;
    padding: 0;
}
.theme-toggle::after {
    content: '';
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #fff;
    position: absolute;
    top: 3px; left: 3px;
    transition: transform .3s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
[data-theme="dark"] .theme-toggle { background: var(--primary); }
[data-theme="dark"] .theme-toggle::after { transform: translateX(20px); }
.theme-toggle-icon {
    font-size: .85rem;
    color: var(--text-muted);
    cursor: pointer;
}

/* ===== SUMMARY ROW (Resumo Geral) ===== */
.summary-row {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--card-border);
    transition: var(--transition);
}
.summary-item {
    text-align: center;
    padding: .5rem;
}
.summary-item .summary-label {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: .2rem;
}
.summary-item .summary-value {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -.3px;
}

/* ===== PLATFORM BUTTONS ===== */
.platform-btn {
    padding: .5rem 1rem;
    border-radius: var(--radius-xs);
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-primary);
    font-weight: 600;
    font-size: .85rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}
.platform-btn:hover { border-color: var(--text-muted); }
.btn-check:checked + .platform-btn {
    border-color: var(--primary);
    background: var(--primary-subtle);
    color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { margin-left: calc(-1 * var(--sidebar-w)); }
    .sidebar.show { margin-left: 0; }
    #page-content { margin-left: 0 !important; }
    .stat-card .value { font-size: 1.25rem; }
    .container-fluid { padding: 1rem !important; }
    .top-navbar { padding: .5rem 1rem; }
}

/* ===== ANIMATION ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.stat-card, .chart-card, .filter-bar, .table-custom, .card, .summary-row {
    animation: fadeInUp .4s ease both;
}
.row > [class*="col"]:nth-child(2) .stat-card { animation-delay: .05s; }
.row > [class*="col"]:nth-child(3) .stat-card { animation-delay: .1s; }
.row > [class*="col"]:nth-child(4) .stat-card { animation-delay: .15s; }
.row > [class*="col"]:nth-child(5) .stat-card { animation-delay: .2s; }
.row > [class*="col"]:nth-child(6) .stat-card { animation-delay: .25s; }
.row > [class*="col"]:nth-child(7) .stat-card { animation-delay: .3s; }
.row > [class*="col"]:nth-child(8) .stat-card { animation-delay: .35s; }

/* ===== PAGE TITLE ===== */
.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -.5px;
    color: var(--text-primary);
}
.page-subtitle {
    font-size: .85rem;
    color: var(--text-muted);
}

/* ===== LIST GROUP ===== */
.list-group-item {
    background: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* ===== PROGRESS ===== */
.progress {
    background: var(--border-color);
    border-radius: var(--radius-xs);
}
