
/* ============ RESET & BASE ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; font-size: 14px; transition: background 0.3s, color 0.3s; }

/* ============ TEMA CLARO ============ */
.light-theme { background: #f0f2f5; color: #333; }
.light-theme .sidebar { background: #2c3e50; color: #ecf0f1; }
.light-theme .main-content { background: #f0f2f5; }
.light-theme .card { background: #fff; border: 1px solid #ddd; }
.light-theme .table-container { background: #fff; }
.light-theme table th { background: #4a4a4a; color: #fff; }
.light-theme table td { border-bottom: 1px solid #eee; }
.light-theme table tr:hover td { background: #f5f5f5; }
.light-theme .form-control { background: #fff; border: 1px solid #ccc; color: #333; }
.light-theme .modal-content { background: #fff; color: #333; }
.light-theme .page-title { color: #2c3e50; border-bottom: 3px solid #4a4a4a; }
.light-theme .subtotal-bar { background: #f8f8f8; border: 1px solid #ddd; }
.light-theme .input-group label { color: #555; }

/* ============ TEMA ESCURO ============ */
.dark-theme { background: #1a1a2e; color: #e0e0e0; }
.dark-theme .sidebar { background: #16213e; color: #e0e0e0; }
.dark-theme .main-content { background: #1a1a2e; }
.dark-theme .card { background: #16213e; border: 1px solid #0f3460; }
.dark-theme .table-container { background: #16213e; }
.dark-theme table th { background: #0f3460; color: #e0e0e0; }
.dark-theme table td { border-bottom: 1px solid #1a1a4e; color: #e0e0e0; }
.dark-theme table tr:hover td { background: #1a1a4e; }
.dark-theme .form-control { background: #16213e; border: 1px solid #0f3460; color: #e0e0e0; }
.dark-theme .modal-content { background: #16213e; color: #e0e0e0; }
.dark-theme .page-title { color: #e0e0e0; border-bottom: 3px solid #0f3460; }
.dark-theme .subtotal-bar { background: #16213e; border: 1px solid #0f3460; }
.dark-theme .input-group label { color: #aaa; }
.dark-theme .btn-primary { background: #0f3460; }
.dark-theme .btn-secondary { background: #533483; border-color: #533483; }
.dark-theme select option { background: #16213e; color: #e0e0e0; }
.dark-theme .sidebar-footer { border-top-color: #0f3460; }

/* ============ LAYOUT ============ */
.app-container { display: flex; height: 100vh; }
.sidebar { width: 250px; min-width: 250px; display: flex; flex-direction: column; overflow-y: auto; z-index: 100; }
.sidebar-header { padding: 15px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.logo-container { display: flex; align-items: center; gap: 10px; }
.logo-img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.logo-text { width: 40px; height: 40px; background: #3498db; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 18px; color: #fff; }
.logo-title { font-size: 16px; font-weight: 600; }
.nav-menu { list-style: none; padding: 10px 0; flex: 1; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 12px 20px; color: inherit; text-decoration: none; transition: all 0.2s; border-left: 3px solid transparent; }
.nav-link:hover { background: rgba(255,255,255,0.1); border-left-color: #3498db; }
.icon { font-size: 18px; }
.sidebar-footer { padding: 15px; border-top: 1px solid rgba(255,255,255,0.1); }
.user-info { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.user-name { font-weight: 600; font-size: 14px; }
.user-level { font-size: 11px; padding: 2px 8px; border-radius: 10px; display: inline-block; width: fit-content; }
.badge-master { background: #e74c3c; color: #fff; }
.badge-admin { background: #f39c12; color: #fff; }
.badge-usuario { background: #3498db; color: #fff; }
.btn-logout { display: block; text-align: center; padding: 8px; background: #c0392b; color: #fff; text-decoration: none; border-radius: 6px; font-size: 13px; transition: background 0.2s; }
.btn-logout:hover { background: #a93226; }

.main-content { flex: 1; overflow-y: auto; padding: 20px 30px; }

/* ============ PAGE ============ */
.page-title { font-size: 22px; font-weight: 700; padding-bottom: 10px; margin-bottom: 20px; display: inline-block; }

/* ============ SUBTOTAL BAR ============ */
.subtotal-bar { display: flex; align-items: center; gap: 15px; padding: 12px 20px; border-radius: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.subtotal-item { display: flex; align-items: center; gap: 6px; }
.subtotal-label { font-weight: 600; font-size: 12px; text-transform: uppercase; color: #888; }
.subtotal-value { font-weight: 700; font-size: 16px; }
.subtotal-value.green { color: #27ae60; }
.subtotal-value.blue { color: #2980b9; }
.subtotal-value.red { color: #c0392b; }
.subtotal-value.yellow { color: #f39c12; }

/* ============ BUTTONS ============ */
.btn { padding: 8px 18px; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; transition: all 0.2s; text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
.btn-primary { background: #2c3e50; color: #fff; }
.btn-primary:hover { background: #34495e; }
.btn-success { background: #27ae60; color: #fff; }
.btn-success:hover { background: #229954; }
.btn-danger { background: #c0392b; color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-warning { background: #f39c12; color: #fff; }
.btn-warning:hover { background: #d68910; }
.btn-info { background: #2980b9; color: #fff; }
.btn-info:hover { background: #2471a3; }
.btn-secondary { background: #7f8c8d; color: #fff; }
.btn-secondary:hover { background: #707b7c; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }

/* ============ TOOLBAR ============ */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; justify-content: space-between; }
.toolbar-left { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar-right { display: flex; gap: 10px; align-items: center; }

/* ============ TABLES ============ */
.table-container { border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.08); margin-bottom: 20px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
table th { padding: 10px 12px; text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; position: sticky; top: 0; }
table td { padding: 8px 12px; font-size: 13px; }
table th select { background: transparent; color: inherit; border: none; font-size: 11px; cursor: pointer; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ============ STATUS BADGES ============ */
.status { padding: 4px 12px; border-radius: 12px; font-size: 11px; font-weight: 700; display: inline-block; text-align: center; min-width: 110px; }
.status-recebido { background: #d4edda; color: #155724; }
.status-recebido-parcial { background: #fff3cd; color: #856404; }
.status-vencido { background: #f8d7da; color: #721c24; }
.status-no-prazo { background: #cce5ff; color: #004085; }

/* ============ FORMS ============ */
.form-control { padding: 8px 12px; border-radius: 6px; font-size: 13px; width: 100%; transition: border-color 0.2s; }
.form-control:focus { outline: none; border-color: #3498db; box-shadow: 0 0 0 2px rgba(52,152,219,0.2); }
select.form-control { cursor: pointer; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 12px; text-transform: uppercase; }
.form-row { display: flex; gap: 15px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 180px; }

/* ============ CARDS ============ */
.card { border-radius: 10px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.card-title { font-size: 12px; font-weight: 700; text-transform: uppercase; color: #888; margin-bottom: 8px; }
.card-value { font-size: 24px; font-weight: 800; }
.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 25px; }

.card-vendido { border-left: 4px solid #2c3e50; }
.card-vendido .card-value { color: #2c3e50; }
.card-recebido { border-left: 4px solid #27ae60; }
.card-recebido .card-value { color: #27ae60; }
.card-pendente { border-left: 4px solid #c0392b; }
.card-pendente .card-value { color: #c0392b; }
.card-saldo { border-left: 4px solid #f39c12; }
.card-saldo .card-value { color: #f39c12; }

/* ============ CHARTS ============ */
.chart-container { padding: 20px; margin-bottom: 25px; border-radius: 10px; }
.chart-title { font-size: 14px; font-weight: 700; margin-bottom: 15px; text-transform: uppercase; }
.chart-wrapper { position: relative; height: 300px; }

/* ============ MODAL ============ */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 1000; justify-content: center; align-items: flex-start; padding-top: 50px; }
.modal-overlay.active { display: flex; }
.modal-content { width: 90%; max-width: 750px; border-radius: 12px; padding: 30px; position: relative; max-height: 85vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 2px solid #3498db; }
.modal-close { position: absolute; top: 15px; right: 20px; font-size: 24px; cursor: pointer; background: none; border: none; color: inherit; line-height: 1; }
.modal-close:hover { color: #e74c3c; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 15px; border-top: 1px solid #eee; }

/* ============ VENDA FORM TOP ============ */
.venda-form-top { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; padding: 15px; border-radius: 8px; margin-bottom: 15px; align-items: end; }
.venda-form-top .input-group { display: flex; flex-direction: column; }
.venda-form-top .input-group label { font-size: 11px; font-weight: 700; text-transform: uppercase; margin-bottom: 4px; }

/* ============ FILTER BAR ============ */
.filter-bar { display: flex; gap: 15px; align-items: end; margin-bottom: 25px; padding: 15px; border-radius: 8px; flex-wrap: wrap; }
.filter-bar .input-group { display: flex; flex-direction: column; }
.filter-bar .input-group label { font-size: 11px; font-weight: 700; text-transform: uppercase; margin-bottom: 4px; padding: 4px 10px; border-radius: 4px; }
.label-ano { background: #c0392b; color: #fff; }
.label-cliente { background: #27ae60; color: #fff; }
.label-mes { background: #2980b9; color: #fff; }

/* ============ MARCA TABLE ============ */
.marca-table { width: auto; min-width: 250px; }
.marca-table th { background: #4a4a4a; color: #fff; }
.dark-theme .marca-table th { background: #0f3460; }
.marca-farm { border-left: 4px solid #2c3e50; }
.marca-open { border-left: 4px solid #27ae60; }
.marca-raia { border-left: 4px solid #e74c3c; }
.marca-fpm { border-left: 4px solid #3498db; }
.marca-outros { border-left: 4px solid #f39c12; }

/* ============ LOGIN ============ */
.login-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { width: 400px; padding: 40px; border-radius: 16px; text-align: center; }
.login-box .logo-img { width: 80px; height: 80px; margin-bottom: 20px; }
.login-box h2 { margin-bottom: 30px; font-size: 22px; }
.login-box .form-group { text-align: left; }
.login-box .btn { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.login-error { background: #f8d7da; color: #721c24; padding: 10px; border-radius: 6px; margin-bottom: 15px; font-size: 13px; }

/* ============ CONFIG PAGE ============ */
.config-section { margin-bottom: 30px; }
.config-section h3 { margin-bottom: 15px; padding-bottom: 8px; border-bottom: 2px solid #3498db; display: inline-block; }
.theme-selector { display: flex; gap: 15px; }
.theme-option { padding: 20px 30px; border-radius: 10px; cursor: pointer; border: 3px solid transparent; transition: all 0.2s; text-align: center; font-weight: 600; }
.theme-option.active { border-color: #3498db; }
.theme-light { background: #f0f2f5; color: #333; }
.theme-dark { background: #1a1a2e; color: #e0e0e0; }
.theme-option:hover { transform: scale(1.05); }

/* ============ DASHBOARD ============ */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }

/* ============ RANKING ============ */
.ranking-table { max-height: 400px; overflow-y: auto; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .sidebar { position: fixed; left: -250px; height: 100%; transition: left 0.3s; }
    .sidebar.open { left: 0; }
    .main-content { padding: 15px; }
    .venda-form-top { grid-template-columns: 1fr 1fr; }
    .cards-row { grid-template-columns: 1fr; }
}

/* ============ INSTALL ============ */
.install-container { max-width: 600px; margin: 50px auto; padding: 30px; }
.install-title { text-align: center; font-size: 28px; margin-bottom: 30px; }
.step-indicator { display: flex; justify-content: center; gap: 30px; margin-bottom: 40px; }
.step { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.step-number { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; background: #ddd; color: #666; }
.step.active .step-number { background: #2c3e50; color: #fff; }
.step.done .step-number { background: #27ae60; color: #fff; }
.step-label { font-size: 12px; color: #888; }

.scrollable-table { max-height: 500px; overflow-y: auto; }

/* Action buttons in table */
.action-btns { display: flex; gap: 5px; }
