/* ============================================================
   QUEBRA GALHO MADEIREIRA — Design System
   Tema Amadeirado + Verde Floresta
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Variáveis ──────────────────────────────────────────────── */
:root {
  --wood-dark:    #3D2B1F;
  --wood-mid:     #5C3D2E;
  --wood-light:   #8B5E3C;
  --wood-pale:    #C9956A;
  --forest-dark:  #1A3A22;
  --forest-mid:   #2D5016;
  --forest-light: #3E7021;
  --forest-pale:  #5A9E30;
  --gold:         #C8860A;
  --gold-light:   #F5A623;
  --cream:        #FAF6F0;
  --cream-dark:   #F0E8DC;
  --sidebar-w:    260px;
  --header-h:     65px;
  --radius:       12px;
  --shadow:       0 4px 24px rgba(61,43,31,.10);
  --shadow-lg:    0 8px 40px rgba(61,43,31,.18);
  --transition:   .22s cubic-bezier(.4,0,.2,1);
}

/* ── Reset e Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--cream);
  color: #2c2c2c;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: linear-gradient(180deg, var(--wood-dark) 0%, var(--wood-mid) 40%, var(--forest-dark) 100%);
  z-index: 1040;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition);
  box-shadow: 4px 0 20px rgba(0,0,0,.35);
  display: flex;
  flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .brand-logo {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff;
  box-shadow: 0 4px 12px rgba(200,134,10,.4);
  flex-shrink: 0;
}
.sidebar-brand .brand-text { color: #fff; line-height: 1.2; }
.sidebar-brand .brand-text strong { font-size: 14px; font-weight: 700; letter-spacing: .3px; }
.sidebar-brand .brand-text small  { font-size: 10px; opacity: .65; letter-spacing: .5px; text-transform: uppercase; }

.sidebar-nav { padding: 12px 0; flex: 1; }
.nav-section-title {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  padding: 12px 20px 4px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 0;
  transition: all var(--transition);
  position: relative;
}
.sidebar-link i { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-link:hover {
  color: #fff;
  background: rgba(255,255,255,.08);
}
.sidebar-link.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(200,134,10,.25), rgba(200,134,10,.08));
  border-right: 3px solid var(--gold);
  font-weight: 600;
}
.sidebar-link.active i { color: var(--gold-light); }
.sidebar-link .badge-sidebar {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--gold);
  color: #fff;
  font-weight: 700;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.15);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  color: rgba(255,255,255,.8);
}
.sidebar-user .avatar {
  width: 34px; height: 34px;
  background: var(--forest-light);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #fff; font-weight: 700; flex-shrink: 0;
}
.sidebar-user .user-info strong { font-size: 12.5px; display: block; font-weight: 600; }
.sidebar-user .user-info small  { font-size: 10.5px; opacity: .65; }

/* ── MAIN CONTENT ───────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin var(--transition);
}
.topbar {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid #ede8e0;
  display: flex; align-items: center;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 900;
  box-shadow: 0 2px 12px rgba(61,43,31,.06);
  gap: 12px;
}
.topbar-title { font-size: 17px; font-weight: 700; color: var(--wood-dark); flex: 1; }
.topbar-title small { font-size: 12px; color: #999; font-weight: 400; display: block; }
.btn-menu-toggle {
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: var(--wood-mid);
  padding: 6px; border-radius: 8px;
  display: none;
  transition: background var(--transition);
}
.btn-menu-toggle:hover { background: var(--cream-dark); }

.main-content { flex: 1; padding: 28px 28px 40px; }

/* ── CARDS ──────────────────────────────────────────────────── */
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(61,43,31,.06);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.stat-card.green::before  { background: linear-gradient(90deg, var(--forest-mid), var(--forest-pale)); }
.stat-card.red::before    { background: linear-gradient(90deg, #dc3545, #ff6b6b); }
.stat-card.gold::before   { background: linear-gradient(90deg, var(--gold), var(--gold-light)); }
.stat-card.wood::before   { background: linear-gradient(90deg, var(--wood-mid), var(--wood-pale)); }
.stat-card.blue::before   { background: linear-gradient(90deg, #0d6efd, #6ea8fe); }
.stat-card.orange::before { background: linear-gradient(90deg, #fd7e14, #ffc107); }

.stat-card .card-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin-bottom: 14px;
}
.stat-card.green .card-icon  { background: rgba(45,80,22,.12); color: var(--forest-mid); }
.stat-card.red .card-icon    { background: rgba(220,53,69,.12); color: #dc3545; }
.stat-card.gold .card-icon   { background: rgba(200,134,10,.12); color: var(--gold); }
.stat-card.wood .card-icon   { background: rgba(92,61,46,.12); color: var(--wood-mid); }
.stat-card.blue .card-icon   { background: rgba(13,110,253,.12); color: #0d6efd; }
.stat-card.orange .card-icon { background: rgba(253,126,20,.12); color: #fd7e14; }

.stat-card .card-value { font-size: 26px; font-weight: 800; color: var(--wood-dark); line-height: 1; }
.stat-card .card-label { font-size: 12px; color: #888; font-weight: 500; margin-top: 4px; }
.stat-card .card-change {
  font-size: 11.5px; font-weight: 600; margin-top: 10px;
  display: flex; align-items: center; gap: 4px;
}
.stat-card .card-change.up   { color: var(--forest-mid); }
.stat-card .card-change.down { color: #dc3545; }

/* ── CARDS GENÉRICOS ─────────────────────────────────────────── */
.card-qg {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(61,43,31,.06);
  overflow: hidden;
}
.card-qg .card-header-qg {
  padding: 16px 22px;
  border-bottom: 1px solid #f0ece5;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.card-qg .card-header-qg h5 { font-size: 15px; font-weight: 700; color: var(--wood-dark); margin: 0; }
.card-qg .card-body-qg { padding: 22px; }

/* ── TABELAS ─────────────────────────────────────────────────── */
.table-qg { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table-qg thead th {
  background: var(--cream-dark);
  color: var(--wood-dark);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 11px 14px;
  border: none;
  white-space: nowrap;
}
.table-qg tbody tr { border-bottom: 1px solid #f5f0e8; transition: background var(--transition); }
.table-qg tbody tr:hover { background: rgba(250,246,240,.7); }
.table-qg tbody td { padding: 10px 14px; color: #3a3a3a; vertical-align: middle; }
.table-qg tbody tr:last-child { border-bottom: none; }

/* ── FORMULÁRIOS ─────────────────────────────────────────────── */
.form-label { font-weight: 600; font-size: 13px; color: var(--wood-dark); margin-bottom: 5px; }
.form-control, .form-select {
  border: 1.5px solid #e0d8cc;
  border-radius: 8px;
  padding: 9px 13px;
  font-size: 13.5px;
  background: #fff;
  color: #2c2c2c;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: 'Inter', sans-serif;
}
.form-control:focus, .form-select:focus {
  border-color: var(--forest-mid);
  box-shadow: 0 0 0 3px rgba(45,80,22,.12);
  outline: none;
}
.input-group-text {
  background: var(--cream-dark);
  border: 1.5px solid #e0d8cc;
  color: var(--wood-mid);
  font-size: 13px;
}

/* ── BOTÕES ──────────────────────────────────────────────────── */
.btn-primary-qg {
  background: linear-gradient(135deg, var(--forest-mid), var(--forest-light));
  color: #fff; border: none;
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-primary-qg:hover {
  background: linear-gradient(135deg, var(--forest-dark), var(--forest-mid));
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(45,80,22,.35);
  color: #fff;
}
.btn-danger-qg {
  background: linear-gradient(135deg, #dc3545, #c82333);
  color: #fff; border: none;
  padding: 9px 20px; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-danger-qg:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(220,53,69,.35); color: #fff; }
.btn-outline-qg {
  background: transparent;
  border: 1.5px solid var(--forest-mid);
  color: var(--forest-mid);
  padding: 8px 18px; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-outline-qg:hover { background: var(--forest-mid); color: #fff; }
.btn-gold-qg {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: #fff; border: none;
  padding: 9px 20px; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: all var(--transition); text-decoration: none;
}
.btn-gold-qg:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(200,134,10,.4); color: #fff; }
.btn-sm-qg { padding: 5px 12px; font-size: 12px; border-radius: 6px; }

/* ── BADGES / STATUS ─────────────────────────────────────────── */
.badge-pago      { background: rgba(45,80,22,.12); color: var(--forest-mid); }
.badge-pendente  { background: rgba(255,193,7,.15); color: #856404; }
.badge-atrasado  { background: rgba(220,53,69,.12); color: #dc3545; }
.badge-cancelado { background: rgba(108,117,125,.12); color: #6c757d; }
.badge-qg { padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }

/* ── ALERTAS ─────────────────────────────────────────────────── */
.alert-qg {
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px;
}
.alert-success-qg { background: rgba(45,80,22,.08); color: var(--forest-mid); border: 1px solid rgba(45,80,22,.2); }
.alert-danger-qg  { background: rgba(220,53,69,.08); color: #dc3545; border: 1px solid rgba(220,53,69,.2); }
.alert-warning-qg { background: rgba(255,193,7,.12); color: #856404; border: 1px solid rgba(255,193,7,.3); }
.alert-info-qg    { background: rgba(13,110,253,.08); color: #0d6efd; border: 1px solid rgba(13,110,253,.2); }

/* ── PAGE HEADER ─────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-header h1 { font-size: 22px; font-weight: 800; color: var(--wood-dark); margin: 0; }
.page-header p  { font-size: 13px; color: #888; margin: 2px 0 0; }

/* ── FILTRO BAR ─────────────────────────────────────────────── */
.filter-bar {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(61,43,31,.06);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.filter-bar .filter-label { font-size: 12px; font-weight: 700; color: var(--wood-dark); white-space: nowrap; }

/* ── CHART CONTAINERS ─────────────────────────────────────────── */
.chart-container { position: relative; width: 100%; }

/* ── MOBILE ──────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .btn-menu-toggle { display: flex !important; }
  .main-content { padding: 18px 14px 30px; }
  .stat-card .card-value { font-size: 20px; }
}
@media (max-width: 575.98px) {
  .page-header { flex-direction: column; align-items: flex-start; }
  .topbar { padding: 0 14px; }
  .topbar-title { font-size: 14px; }
}

/* ── OVERLAY MOBILE ──────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1039;
}
.sidebar-overlay.show { display: block; }

/* ── TABELA PLANILHA ─────────────────────────────────────────── */
.planilha-table { font-size: 13px; }
.planilha-table th { position: sticky; top: 0; z-index: 10; }
.planilha-entrada { color: var(--forest-mid); font-weight: 700; }
.planilha-saida   { color: #dc3545; font-weight: 700; }
.planilha-saldo   { font-weight: 800; }
.planilha-saldo.positivo { color: var(--forest-mid); }
.planilha-saldo.negativo { color: #dc3545; }
.planilha-total-row { background: var(--cream-dark) !important; font-weight: 800; border-top: 2px solid var(--wood-pale); }

/* ── LOADING SPINNER ─────────────────────────────────────────── */
.spinner-qg {
  width: 38px; height: 38px;
  border: 3px solid rgba(45,80,22,.15);
  border-top-color: var(--forest-mid);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── SCROLLBAR GLOBAL ─────────────────────────────────────────── */
::-webkit-scrollbar       { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--cream-dark); }
::-webkit-scrollbar-thumb { background: var(--wood-pale); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--wood-light); }

/* ── ESTOQUE ALERTA ─────────────────────────────────────────── */
.stock-bar { height: 6px; border-radius: 3px; background: #e9ecef; overflow: hidden; }
.stock-bar-fill { height: 100%; border-radius: 3px; transition: width .5s; }
.stock-ok      { background: var(--forest-light); }
.stock-low     { background: #ffc107; }
.stock-critical{ background: #dc3545; }

/* ── LOGIN PAGE ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--wood-dark) 0%, var(--wood-mid) 35%, var(--forest-dark) 70%, var(--forest-mid) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  position: relative; overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.login-box {
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 40px;
  width: 100%; max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,.35);
  position: relative; z-index: 1;
}
.login-logo {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; color: #fff;
  margin: 0 auto 20px;
  box-shadow: 0 8px 24px rgba(200,134,10,.4);
}
.login-title { text-align: center; }
.login-title h1 { font-size: 20px; font-weight: 800; color: var(--wood-dark); margin-bottom: 2px; }
.login-title p  { font-size: 12px; color: #888; margin-bottom: 28px; }
