/* FlexMeal — Design System */
:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-card-hover: #1f2231;
  --bg-sidebar: #141620;
  --bg-input: #1e2130;
  --border: #2a2d3a;
  --border-light: #333649;
  --text: #e4e6ed;
  --text-muted: #8b8fa3;
  --text-dim: #6b6f82;
  --primary: #4f7cff;
  --primary-hover: #6b91ff;
  --primary-bg: rgba(79,124,255,.12);
  --green: #22c55e;
  --green-bg: rgba(34,197,94,.12);
  --orange: #f59e0b;
  --orange-bg: rgba(245,158,11,.12);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,.12);
  --purple: #a855f7;
  --purple-bg: rgba(168,85,247,.12);
  --blue: #3b82f6;
  --blue-bg: rgba(59,130,246,.12);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --transition: .2s ease;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  display: flex; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w); background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  transition: transform var(--transition);
}
.sidebar-header { padding: 20px 20px 16px; border-bottom: 1px solid var(--border); }
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon { font-size: 28px; }
.logo-title { font-size: 18px; font-weight: 700; color: var(--text); }
.logo-sub { font-size: 11px; color: var(--text-muted); letter-spacing: .3px; }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: all var(--transition);
}
.nav-item:hover { color: var(--text); background: var(--bg-card); }
.nav-item.active { color: var(--primary); background: var(--primary-bg); }
.nav-item svg { flex-shrink: 0; }
.sidebar-footer {
  padding: 16px 20px; border-top: 1px solid var(--border);
}
.user-info { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary-bg); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-muted); }

/* ===== MAIN ===== */
.main {
  margin-left: var(--sidebar-w); flex: 1; min-height: 100vh;
  display: flex; flex-direction: column;
}
.topbar {
  height: var(--topbar-h); padding: 0 28px;
  display: flex; align-items: center; gap: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
  position: sticky; top: 0; z-index: 50;
}
.menu-toggle { display: none; background: none; border: none; color: var(--text); cursor: pointer; }
.page-title { font-size: 18px; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.badge-env {
  background: var(--green-bg); color: var(--green);
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600;
}
.today-date { font-size: 13px; color: var(--text-muted); }
.content { padding: 24px 28px; flex: 1; }

/* ===== STATS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--border-light); }
.stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon.blue { background: var(--blue-bg); color: var(--blue); }
.stat-icon.green { background: var(--green-bg); color: var(--green); }
.stat-icon.orange { background: var(--orange-bg); color: var(--orange); }
.stat-icon.purple { background: var(--purple-bg); color: var(--purple); }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.card-header {
  padding: 16px 20px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-period { font-size: 12px; color: var(--text-muted); }
.card-body { padding: 20px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ===== CC BARS ===== */
.cc-bar-item { margin-bottom: 14px; }
.cc-bar-label { display: flex; justify-content: space-between; margin-bottom: 6px; }
.cc-bar-name { font-size: 13px; font-weight: 500; }
.cc-bar-val { font-size: 13px; color: var(--text-muted); }
.cc-bar-track { height: 8px; background: var(--bg-input); border-radius: 4px; overflow: hidden; }
.cc-bar-fill { height: 100%; border-radius: 4px; transition: width .6s ease; }

/* ===== RECENT LIST ===== */
.recent-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.recent-item:last-child { border-bottom: none; }
.recent-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-bg); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.recent-info { flex: 1; }
.recent-name { font-size: 13px; font-weight: 500; }
.recent-meta { font-size: 11px; color: var(--text-muted); }
.recent-time { font-size: 12px; color: var(--text-dim); white-space: nowrap; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 12px 16px; font-size: 12px;
  font-weight: 600; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .5px; border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
}
.data-table td {
  padding: 12px 16px; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--bg-card-hover); }
.table-footer {
  padding: 12px 16px; font-size: 12px; color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ===== BADGES ===== */
.badge-status {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.badge-status.active { background: var(--green-bg); color: var(--green); }
.badge-status.inactive { background: var(--red-bg); color: var(--red); }
.badge-status.pending { background: var(--orange-bg); color: var(--orange); }
.badge-status.ok { background: var(--green-bg); color: var(--green); }
.badge-status.duplicado { background: var(--orange-bg); color: var(--orange); }
.badge-status.sem_match { background: var(--red-bg); color: var(--red); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: all var(--transition);
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--text-muted); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; margin-top: 12px; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: .9; }

/* ===== PAGE ACTIONS ===== */
.page-actions {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0 12px;
}
.search-box input {
  background: transparent; border: none; color: var(--text);
  padding: 8px 0; font-size: 13px; width: 200px; outline: none;
}
.search-box svg { color: var(--text-muted); flex-shrink: 0; }
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-group label { font-size: 13px; color: var(--text-muted); }
select, input[type="date"], input[type="number"], input[type="text"] {
  background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text); padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 13px; outline: none; transition: border-color var(--transition);
}
select:focus, input:focus { border-color: var(--primary); }

/* ===== REPORTS ===== */
.reports-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.report-card { padding: 24px; text-align: center; }
.report-card h3 { margin: 12px 0 8px; font-size: 16px; }
.report-card p { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 16px; }
.report-icon {
  width: 56px; height: 56px; border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center;
}
.report-icon.green { background: var(--green-bg); color: var(--green); }
.report-icon.blue { background: var(--blue-bg); color: var(--blue); }
.report-icon.orange { background: var(--orange-bg); color: var(--orange); }
.report-fields { display: flex; gap: 8px; justify-content: center; margin-bottom: 4px; }

/* ===== CONFIG ===== */
.cc-list { margin-bottom: 16px; }
.cc-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.cc-item .cc-empresa { color: var(--text-muted); font-size: 12px; }
.cc-add { display: flex; gap: 8px; margin-top: 12px; }
.cc-add input { flex: 1; }
.config-item { display: flex; flex-direction: column; gap: 10px; }
.config-item label { font-size: 13px; font-weight: 500; }
.config-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.catraca-status { margin: 4px 0; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: none; align-items: center; justify-content: center; z-index: 200;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); width: 480px; max-height: 85vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 24px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.form-group input, .form-group select { width: 100%; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ===== TOAST ===== */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 20px;
  font-size: 13px; box-shadow: var(--shadow);
  animation: toastIn .3s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--primary); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ===== LOGIN ===== */
.login-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.login-overlay.hidden { display: none; }
.login-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px; width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5); text-align: center;
}
.login-logo h1 { font-size: 28px; margin: 12px 0 4px; }
.login-logo p { font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }
.login-form .form-group { text-align: left; margin-bottom: 14px; }
.login-form .form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.login-form .form-group input { width: 100%; padding: 10px 14px; font-size: 14px; }
.login-error { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }
.sidebar.locked, .main.locked { filter: blur(3px); pointer-events: none; }

/* ===== PAGE VIS ===== */
.page { display: none; }
.page.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--text-muted);
}
.empty-state svg { margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .reports-grid { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .stats-grid { grid-template-columns: 1fr; }
  .reports-grid { grid-template-columns: 1fr; }
  .page-actions { flex-direction: column; align-items: stretch; }
  .search-box input { width: 100%; }
  .content { padding: 16px; }
}
