/* ============================================================
   ERP Financeiro — CSS Universal
   Todas as variáveis em :root — edite aqui para mudar o tema
   ============================================================ */
:root {
  --primary:       #4f46e5;
  --primary-dark:  #3730a3;
  --primary-light: #818cf8;
  --primary-bg:    #eef2ff;

  --success:    #10b981; --success-bg: #d1fae5;
  --danger:     #ef4444; --danger-bg:  #fee2e2;
  --warning:    #f59e0b; --warning-bg: #fef3c7;
  --info:       #3b82f6; --info-bg:    #dbeafe;

  --gray-50:  #f8fafc; --gray-100: #f1f5f9; --gray-200: #e2e8f0;
  --gray-300: #cbd5e1; --gray-400: #94a3b8; --gray-500: #64748b;
  --gray-600: #475569; --gray-700: #334155; --gray-800: #1e293b;
  --gray-900: #0f172a;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-sm: 6px; --radius: 10px; --radius-lg: 14px; --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow:    0 2px 8px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --sidebar-w: 240px;
  --topbar-h:  60px;
  --transition: .2s ease;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--gray-50); color: var(--gray-800); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }
ul { list-style: none; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

/* ---- Layout ---- */
.app-wrapper { display: flex; min-height: 100vh; }
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.page-content { padding: 2rem; flex: 1; }

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100; overflow-y: auto;
  transition: transform var(--transition);
}
.sidebar-logo { padding: 1.25rem 1.5rem; border-bottom: 1px solid rgba(255,255,255,.07); display: flex; align-items: center; gap: .75rem; }
.logo-icon { width: 34px; height: 34px; background: var(--primary); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logo-text { font-size: .875rem; font-weight: 700; color: #fff; line-height: 1.2; }
.logo-sub  { font-size: 10px; color: var(--gray-400); }
.nav-section { padding: 1rem 0; }
.nav-label { padding: .5rem 1.5rem .25rem; font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--gray-500); }
.nav-item { display: flex; align-items: center; gap: .75rem; padding: .5rem 1.5rem; color: var(--gray-400); font-size: .875rem; font-weight: 500; transition: all var(--transition); cursor: pointer; border: none; background: none; width: 100%; text-align: left; text-decoration: none; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); text-decoration: none; }
.nav-item.active { color: #fff; background: var(--primary); }
.nav-item-danger { color: var(--danger) !important; }
.nav-item-danger:hover { background: rgba(239,68,68,.1) !important; }
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.07); padding: .5rem 0; }

/* ---- Topbar ---- */
.topbar { height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; padding: 0 2rem; position: sticky; top: 0; z-index: 50; gap: 1rem; }
.topbar-title { font-size: 1.125rem; font-weight: 600; color: var(--gray-800); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }
.topbar-date { font-size: .75rem; color: var(--gray-400); }
.topbar-user { display: flex; align-items: center; gap: .5rem; font-size: .875rem; color: var(--gray-600); }
.avatar { width: 34px; height: 34px; background: var(--primary-bg); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--primary); font-weight: 700; font-size: .875rem; }

/* ---- Cards ---- */
.card { background: #fff; border-radius: var(--radius-lg); border: 1px solid var(--gray-200); box-shadow: var(--shadow-sm); }
.card-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card-title { font-size: 1rem; font-weight: 600; color: var(--gray-800); }
.card-body { padding: 1.5rem; }
.card-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--gray-100); }

/* KPI Cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.25rem; }
.kpi-card { background: #fff; border-radius: var(--radius-lg); padding: 1.5rem; border: 1px solid var(--gray-200); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: .75rem; }
.kpi-card-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: .875rem; color: var(--gray-500); font-weight: 500; }
.kpi-icon { width: 40px; height: 40px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; }
.kpi-value { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
.kpi-change { font-size: .75rem; display: flex; align-items: center; gap: 4px; }
.kpi-change.up { color: var(--success); }
.kpi-change.down { color: var(--danger); }

/* ---- Grids ---- */
.grid-2  { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3  { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.25rem; }
.grid-12 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; }

/* ---- Botões ---- */
.btn { display: inline-flex; align-items: center; gap: .5rem; padding: .5rem 1.25rem; border-radius: var(--radius); font-size: .875rem; font-weight: 500; border: none; cursor: pointer; transition: all var(--transition); white-space: nowrap; text-decoration: none; }
.btn:hover { text-decoration: none; opacity: .9; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-outline   { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-sm        { padding: .25rem .75rem; font-size: .75rem; }
.btn-icon      { padding: .5rem; border-radius: var(--radius-sm); }
.btn-ghost     { background: none; border: none; color: var(--gray-500); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); transform: none; box-shadow: none; }

/* ---- Forms ---- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: .25rem; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: .875rem; font-weight: 500; color: var(--gray-700); }
.form-control { padding: .5rem .75rem; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); font-size: .875rem; color: var(--gray-800); background: #fff; transition: border-color var(--transition), box-shadow var(--transition); width: 100%; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.form-control:disabled { background: var(--gray-50); color: var(--gray-400); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: .75rem; color: var(--gray-400); }
.form-actions { display: flex; gap: .75rem; padding-top: 1rem; border-top: 1px solid var(--gray-100); margin-top: 1rem; }

/* ---- Tabela ---- */
.table-wrapper { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { padding: .75rem 1rem; background: var(--gray-50); font-weight: 600; color: var(--gray-600); text-align: left; border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
.table td { padding: .75rem 1rem; border-bottom: 1px solid var(--gray-100); color: var(--gray-700); vertical-align: middle; }
.table tr:hover td { background: var(--gray-50); }
.table tr:last-child td { border-bottom: none; }
.table-actions { display: flex; gap: .5rem; }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 99px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge-success { background: var(--success-bg); color: #065f46; }
.badge-danger  { background: var(--danger-bg);  color: #991b1b; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-info    { background: var(--info-bg);    color: #1e40af; }
.badge-gray    { background: var(--gray-100);   color: var(--gray-600); }

/* ---- Modal ---- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius-xl); width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-header { padding: 1.5rem; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 1.25rem; font-weight: 700; color: var(--gray-900); }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--gray-100); display: flex; gap: .75rem; justify-content: flex-end; }
.modal-lg { max-width: 900px; }

/* ---- Alerts ---- */
.alert { padding: 1rem 1.25rem; border-radius: var(--radius); font-size: .875rem; display: flex; align-items: flex-start; gap: .75rem; margin-bottom: 1rem; }
.alert-success { background: var(--success-bg); color: #065f46; }
.alert-danger  { background: var(--danger-bg);  color: #991b1b; }
.alert-warning { background: var(--warning-bg); color: #92400e; }
.alert-info    { background: var(--info-bg);    color: #1e40af; }

/* ---- Page Header ---- */
.page-header { margin-bottom: 2rem; display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
.page-header p { font-size: .875rem; color: var(--gray-500); margin-top: .25rem; }

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 2.5rem; color: var(--gray-400); }
.empty-state h3 { font-size: 1.125rem; font-weight: 600; color: var(--gray-600); margin-top: 1rem; }
.empty-state p { font-size: .875rem; margin-top: .5rem; }

/* ---- Pagination ---- */
.pagination { display: flex; gap: .25rem; align-items: center; justify-content: flex-end; margin-top: 1rem; }
.page-btn { padding: .25rem .75rem; border-radius: var(--radius-sm); font-size: .875rem; border: 1px solid var(--gray-200); background: #fff; color: var(--gray-600); cursor: pointer; transition: all var(--transition); text-decoration: none; }
.page-btn:hover { background: var(--primary-bg); color: var(--primary); border-color: var(--primary); text-decoration: none; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- Progress ---- */
.progress { background: var(--gray-100); border-radius: 99px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 99px; background: var(--primary); transition: width .5s ease; }

/* ---- Chart wrapper ---- */
.chart-wrapper { position: relative; height: 280px; }

/* ---- Login ---- */
.auth-body { background: linear-gradient(135deg, var(--gray-900) 0%, #1a1040 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { background: #fff; border-radius: var(--radius-xl); padding: 2.5rem; width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); }
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo .icon { width: 56px; height: 56px; background: var(--primary); border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; margin: 0 auto .75rem; }
.login-logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
.login-logo p { font-size: .875rem; color: var(--gray-500); margin-top: 4px; }
.login-footer { text-align: center; margin-top: 1.5rem; font-size: .75rem; color: var(--gray-400); }

/* ---- Responsive ---- */
@media (max-width: 1024px) { .grid-2, .grid-3, .grid-12 { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); width: 240px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-content { padding: 1rem; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) { .kpi-grid { grid-template-columns: 1fr; } }
