/* ==========================================================================
   VARIÁVEIS DE SISTEMA (PALETA MODERNA SaaS)
   ========================================================================== */
:root {
  --primary: #2563eb;       
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  
  --bg-app: #f8fafc;        
  --bg-panel: #ffffff;
  --bg-sidebar: #0f172a;    
  
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-light: #e2e8f0;
  --border-focus: #93c5fd;
  
  --gold: #fbbf24;
  --silver: #94a3b8;
  --bronze: #b45309;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body { margin: 0; background: var(--bg-app); color: var(--text-main); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
main { padding: 32px 40px; max-width: 1800px; margin: 0 auto; width: 100%; }

.sidebar { background: var(--bg-sidebar); color: #f8fafc; padding: 24px; display: flex; flex-direction: column; gap: 24px; border-right: 1px solid rgba(255, 255, 255, 0.1); }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-icon { width: 44px; height: 44px; background: linear-gradient(135deg, #38bdf8, #2563eb); border-radius: var(--radius-md); display: grid; place-items: center; font-size: 20px; color: #fff; font-weight: 900; box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3); }
.brand strong { font-size: 18px; letter-spacing: -0.02em; }
.brand small { color: #94a3b8; font-size: 12px; font-weight: 500; }

.nav { display: grid; gap: 6px; }
.nav-button { border: 0; border-radius: var(--radius-sm); min-height: 40px; padding: 0 16px; cursor: pointer; font-weight: 600; font-size: 14px; text-align: left; background: transparent; color: #94a3b8; transition: all 0.2s ease; }
.nav-button:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.nav-button.active { background: rgba(255, 255, 255, 0.1); color: #fff; font-weight: 700; }

.sidebar-card { margin-top: auto; background: rgba(255, 255, 255, 0.03); padding: 16px; border-radius: var(--radius-md); border: 1px solid rgba(255, 255, 255, 0.05); }
.sidebar-card span { font-size: 11px; color: #64748b; text-transform: uppercase; font-weight: 800; letter-spacing: 0.05em; }
.sidebar-card input { margin-top: 8px; width: 100%; border: 1px solid rgba(255, 255, 255, 0.1); background: rgba(0, 0, 0, 0.2); color: #fff; border-radius: var(--radius-sm); padding: 10px; font-size: 14px; outline: none; transition: border 0.2s; }
.sidebar-card input:focus { border-color: var(--primary); }

.topbar, .panel-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; flex-wrap: wrap; gap: 16px; }
h1 { font-size: 28px; font-weight: 800; margin: 0; letter-spacing: -0.03em; color: #0f172a; }
h2 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.topbar p, .panel-heading p { color: var(--text-muted); margin: 6px 0 0; font-size: 15px; }
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.primary-button, .ghost-button, .danger-button, .file-button { border: 0; border-radius: var(--radius-sm); min-height: 40px; padding: 0 18px; cursor: pointer; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; transition: all 0.2s ease; outline: none; }
.primary-button { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.primary-button:hover { background: var(--primary-hover); box-shadow: var(--shadow-md); }
.primary-button:active { transform: scale(0.98); }

.ghost-button { background: #fff; color: var(--text-main); border: 1px solid var(--border-light); }
.ghost-button:hover { background: #f1f5f9; border-color: #cbd5e1; }
.danger-button { background: #fff; color: var(--danger); border: 1px solid #fca5a5; }
.danger-button:hover { background: #fef2f2; }

.file-button { background: #0f766e; color: #fff; position: relative; overflow: hidden; box-shadow: var(--shadow-sm); }
.file-button:hover { filter: brightness(0.9); }
.file-button input { position: absolute; opacity: 0; cursor: pointer; height: 100%; width: 100%; }

.view { display: none; animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

.day-dashboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 24px; }
.dash-card { background: var(--bg-panel); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); transition: transform 0.2s; }
.dash-card:hover { transform: translateY(-3px); }
.dash-card.primary { background: linear-gradient(135deg, var(--primary), var(--primary-hover)); color: #fff; border: none; box-shadow: 0 10px 25px rgba(37, 99, 235, 0.25); }
.dash-card.primary span { color: rgba(255, 255, 255, 0.8); }
.dash-card span { font-size: 13px; text-transform: uppercase; font-weight: 800; color: var(--text-muted); letter-spacing: 0.05em; margin-bottom: 8px; }
.dash-card strong { font-size: 48px; font-weight: 900; line-height: 1; letter-spacing: -0.02em; }

.department-switch { display: inline-flex; background: #e2e8f0; padding: 4px; border-radius: var(--radius-md); margin-bottom: 24px; }
.department-tab { border: none; padding: 8px 20px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; background: transparent; color: var(--text-muted); cursor: pointer; transition: 0.2s; }
.department-tab.active { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }

.import-status { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--radius-md); padding: 14px 18px; color: #1e3a8a; font-weight: 500; font-size: 14px; margin-bottom: 24px; }

.worker-times-container { background: var(--bg-panel); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: 24px; margin-bottom: 32px; box-shadow: var(--shadow-sm); }
.worker-times-container h3 { margin: 0 0 20px; color: var(--text-main); font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
.worker-times-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.worker-time-card { background: var(--bg-app); border: 1px solid var(--border-light); padding: 16px; border-radius: var(--radius-md); }
.worker-time-card strong { display: block; color: var(--text-main); font-size: 15px; margin-bottom: 12px; }
.time-inputs { display: flex; gap: 12px; }
.time-inputs label { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.time-inputs input { border: 1px solid var(--border-light); background: #fff; border-radius: var(--radius-sm); padding: 8px; text-align: center; font-weight: 600; outline: none; transition: 0.2s; }
.time-inputs input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

.boards { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.board { background: var(--bg-panel); border-radius: var(--radius-lg); border: 1px solid var(--border-light); box-shadow: var(--shadow-md); overflow: hidden; }

.board-header { padding: 20px 24px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-light); }
.board.marketplace .board-header { border-top: 4px solid var(--primary); }
.board.site .board-header { border-top: 4px solid var(--success); }
.board-title { display: flex; align-items: center; gap: 12px; }
.board-icon { font-size: 24px; }
.date-stamp { background: var(--bg-app); border: 1px solid var(--border-light); padding: 4px 12px; border-radius: 20px; font-weight: 600; font-size: 13px; color: var(--text-muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: center; min-width: 600px; }
th, td { padding: 14px 12px; border-bottom: 1px solid var(--border-light); font-size: 14px; }
thead th { background: var(--bg-app); color: var(--text-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 2px solid var(--border-light); }
tbody tr { transition: background 0.2s; }
tbody tr:hover { background: #f8fafc; }

.carrier-cell { display: flex; flex-direction: column; align-items: flex-start; font-weight: 600; padding-left: 24px; }
.carrier-logo { display: flex; align-items: center; gap: 8px; }
.lote-badge { background: #e0e7ff; color: #3730a3; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 700; margin-top: 4px; }

.worker-input { width: 100%; max-width: 80px; border: 1px solid transparent; background: transparent; padding: 8px; border-radius: var(--radius-sm); text-align: center; font-weight: 600; transition: all 0.2s; outline: none; }
.worker-input:hover { background: #f1f5f9; }
.worker-input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.row-total { font-weight: 800; color: var(--text-main); font-size: 15px; }

.summary-grid { padding: 24px; }
.summary-card.notes textarea { width: 100%; height: 100px; border: 1px solid var(--border-light); background: var(--bg-app); border-radius: var(--radius-sm); padding: 14px; resize: vertical; font-family: inherit; font-size: 14px; outline: none; transition: 0.2s; }
.summary-card.notes textarea:focus { border-color: var(--primary); background: #fff; }
.summary-card h3 { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin: 0 0 12px; letter-spacing: 0.05em;}

/* RANKING & TIERS */
.ranking-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.ranking-section-title { text-align: center; color: var(--text-main); border-bottom: 2px solid var(--border-light); padding-bottom: 16px; margin-bottom: 32px; letter-spacing: -0.02em;}
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 16px; min-height: 220px; margin-bottom: 40px; }
.podium-card { background: var(--bg-panel); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: 24px 16px; text-align: center; flex: 1; box-shadow: var(--shadow-md); position: relative; }
.podium-card.first { transform: translateY(-20px); border: 2px solid var(--gold); z-index: 10; box-shadow: 0 10px 25px rgba(251, 191, 36, 0.15); }
.podium-avatar { width: 72px; height: 72px; border-radius: 50%; border: 3px solid var(--bg-app); object-fit: cover; }
.first .podium-avatar { border-color: var(--gold); width: 88px; height: 88px; }
.podium-card h3 { font-size: 16px; margin: 12px 0 4px; }

.tier-badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em;}
.tier-diamante { background: #f3e8ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.tier-ouro { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.tier-prata { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.tier-bronze { background: #ffedd5; color: #9a3412; border: 1px solid #fed7aa; }
.tier-iniciante { background: #f8fafc; color: #94a3b8; border: 1px solid #e2e8f0; }

.game-rank-row { display: flex; align-items: center; gap: 16px; background: var(--bg-panel); padding: 16px; border-radius: var(--radius-md); margin-bottom: 12px; border: 1px solid var(--border-light); box-shadow: var(--shadow-sm); }
.rank-number { font-weight: 800; font-size: 16px; color: var(--text-muted); width: 24px; text-align: center; }
.rank-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: var(--bg-app); }
.rank-info { flex: 1; }
.rank-info strong { font-size: 15px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;}
.xp-bar-container { height: 6px; background: #e2e8f0; border-radius: 10px; overflow: hidden; }
.xp-bar { height: 100%; background: var(--primary); border-radius: 10px; }
.rank-score { font-weight: 700; font-size: 15px; color: var(--text-main); }

/* AUDITORIA, HISTÓRICO E ADMIN */
.audit-container { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.audit-card { background: var(--bg-panel); padding: 32px; border-radius: var(--radius-lg); border: 1px solid var(--border-light); text-align: center; box-shadow: var(--shadow-sm); }
.audit-card h3 { margin-bottom: 24px; color: var(--text-main); }
.audit-status { margin-top: 10px; font-weight: 700; font-size: 14px;}
.audit-status.ok { color: var(--success); }
.audit-results-panel { background: var(--bg-panel); border-radius: var(--radius-lg); border: 1px solid var(--border-light); overflow: hidden; box-shadow: var(--shadow-sm); }
.status-badge { padding: 4px 10px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.status-missing { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.status-match { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

.history-layout, .admin-grid { display: grid; gap: 24px; }
.history-layout { grid-template-columns: 320px 1fr; }
.admin-grid { grid-template-columns: 1fr 1fr 1fr; }

.history-list, .history-detail, .admin-card { background: var(--bg-panel); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-sm); }
.history-item { width: 100%; text-align: left; background: var(--bg-app); border: 1px solid var(--border-light); padding: 16px; border-radius: var(--radius-md); margin-bottom: 12px; cursor: pointer; transition: 0.2s; }
.history-item:hover { border-color: var(--border-focus); background: #fff; }

.admin-card select, .admin-card input { width: 100%; padding: 10px 14px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); outline: none; margin-bottom: 16px; transition: 0.2s; background: #fff;}
.admin-card input:focus, .admin-card select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 13px; }
.chip button { border: 0; width: 20px; height: 20px; border-radius: 50%; background: #cbd5e1; cursor: pointer; font-size: 10px; font-weight: 900;}
.chip button:hover { background: #fca5a5; color: #fff;}
.chip-card { display: flex; align-items: center; gap: 12px; background: var(--bg-app); border: 1px solid var(--border-light); border-radius: 40px 12px 12px 40px; padding: 6px 16px 6px 6px; font-size: 14px; font-weight: 600; }
.chip-card button { border: 0; width: 24px; height: 24px; border-radius: 50%; background: #fecaca; color: #b91c1c; cursor: pointer; font-weight: 900; }
.avatar-upload { width: 32px; height: 32px; border-radius: 50%; border: 2px solid #fff; box-shadow: var(--shadow-sm); overflow: hidden; cursor: pointer; position: relative; }
.avatar-upload img { width: 100%; height: 100%; object-fit: cover; }

.toast { position: fixed; right: 32px; bottom: 32px; background: var(--bg-sidebar); color: #fff; padding: 16px 24px; border-radius: var(--radius-md); font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg); transform: translateY(150%); opacity: 0; transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); z-index: 9999; border: 1px solid rgba(255,255,255,0.1); }
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 1200px) { .boards, .admin-grid, .ranking-grid, .audit-container, .history-layout { grid-template-columns: 1fr; } main { padding: 24px; } }
@media (max-width: 768px) { .app-shell { grid-template-columns: 1fr; } .sidebar { padding: 16px; border-right: none; border-bottom: 1px solid rgba(255, 255, 255, 0.1); } .nav { display: flex; overflow-x: auto; padding-bottom: 8px; } .nav-button { white-space: nowrap; } }