/* =============================================
   AppAdmin - Estilos Completos
   Painel de Gerenciamento AppOnline
   ============================================= */

/* RESET & BASE */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-dark: #1d4ed8;
  --primary-soft: rgba(37,99,235,0.12);
  --danger: #ef4444;
  --danger-soft: rgba(239,68,68,0.12);
  --success: #22c55e;
  --success-soft: rgba(34,197,94,0.12);
  --warning: #f59e0b;
  --warning-soft: rgba(245,158,11,0.12);

  --sidebar-bg: #111827;
  --sidebar-text: #e5e7eb;
  --sidebar-muted: rgba(229,231,235,0.5);
  --sidebar-item-hover: rgba(255,255,255,0.07);
  --sidebar-item-active: rgba(37,99,235,0.25);
  --sidebar-item-active-border: rgba(59,130,246,0.6);

  --content-bg: #f3f4f6;
  --card-bg: #ffffff;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.06);
  --card-radius: 14px;

  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --border-focus: #3b82f6;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 16px;
  --radius-full: 999px;

  --sidebar-w: 260px;
  --topbar-h: 64px;
}

html {
  font-size: 14px;
  overflow-x: hidden;
}

body {
  font-family: var(--font);
  background: var(--sidebar-bg);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100vw;
}

.hidden { display: none !important; }

/* =============================================
   TELA DE LOGIN
   ============================================= */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
  position: relative;
  overflow: hidden;
}

.login-view::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 60% 40%, rgba(37,99,235,0.18) 0%, transparent 60%),
              radial-gradient(ellipse at 20% 80%, rgba(139,92,246,0.12) 0%, transparent 50%);
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  padding: 36px 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.1);
}

.login-logo {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.login-logo img {
  width: 130px;
  height: 130px;
  object-fit: contain;
  border-radius: 16px;
}

.login-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  text-align: center;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
  margin-bottom: 24px;
  line-height: 1.4;
  text-align: center;
}

.login-card .lbl {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  margin-top: 14px;
}

.login-card .lbl:first-of-type { margin-top: 0; }

.login-card .ipt {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: #f9fafb;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.login-card .ipt:focus {
  outline: none;
  border-color: var(--border-focus);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.login-card .btn.primary {
  width: 100%;
  margin-top: 18px;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(37,99,235,0.35);
}

.login-card .btn.primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 6px 16px rgba(37,99,235,0.45);
}

.login-card .btn.primary:active { transform: translateY(1px); }

.login-card .btn.primary:disabled {
  background: #93c5fd;
  cursor: not-allowed;
  box-shadow: none;
}

.login-hint {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 14px;
  text-align: center;
}

.login-links {
  display: flex;
  gap: 14px;
  margin-top: 12px;
  justify-content: center;
}

.login-links a {
  color: var(--primary);
  font-weight: 600;
  font-size: 12px;
  text-decoration: none;
}

.login-links a:hover { text-decoration: underline; }

/* =============================================
   LAYOUT PRINCIPAL (SIDEBAR + CONTENT)
   ============================================= */
.main-view {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  max-width: 100vw;
  overflow: hidden;
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  padding: 20px 16px;
  border-right: 1px solid rgba(255,255,255,0.06);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* Logo/brand na sidebar */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(37,99,235,0.4);
}

.brand-info { flex: 1; min-width: 0; }

.brand-title {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -0.2px;
}

.brand-sub {
  font-size: 11px;
  color: var(--sidebar-muted);
  letter-spacing: 0.03em;
}

/* Box do usuário logado */
.userbox {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
  margin-bottom: 8px;
}

.user-name {
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  line-height: 1.3;
}

.user-role {
  font-size: 11px;
  color: var(--sidebar-muted);
  margin-bottom: 10px;
}

/* Navegação */
.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(229,231,235,0.35);
  padding: 12px 10px 4px;
}

.nav-item {
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: rgba(229,231,235,0.75);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.1px;
}

.nav-item:hover {
  background: var(--sidebar-item-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--sidebar-item-active);
  border-color: var(--sidebar-item-active-border);
  color: #93c5fd;
  font-weight: 700;
}

.nav-item .nav-icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
  opacity: 0.85;
}

/* Botão sair */
.btn-logout {
  width: 100%;
  margin-top: 12px;
  padding: 8px;
  background: rgba(239,68,68,0.15);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-logout:hover {
  background: rgba(239,68,68,0.25);
  color: #fecaca;
}

/* =============================================
   ÁREA DE CONTEÚDO
   ============================================= */
.content {
  background: var(--content-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(243,244,246,0.92);
  backdrop-filter: blur(8px);
  padding: 0 24px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.topbar-left { min-width: 0; }

.view-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.view-subtitle {
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 1px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}
.link:hover { text-decoration: underline; }

/* Área de scroll do conteúdo */
.content-inner {
  flex: 1;
  padding: 20px 24px 32px;
  max-width: 1400px;
  width: 100%;
}

/* =============================================
   VIEWS / SEÇÕES
   ============================================= */
.view { display: block; }

/* =============================================
   CARDS
   ============================================= */
.card {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(0,0,0,0.04);
  overflow: hidden;
}

.card-header {
  padding: 16px 18px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.card-title {
  font-weight: 800;
  font-size: 14px;
  color: var(--text-primary);
  letter-spacing: -0.1px;
}

.card-body {
  padding: 16px 18px;
}

/* Compatibilidade com .card-head antigo */
.card-head {
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.card .card-head + * { }

/* =============================================
   KPI CARDS
   ============================================= */
.grid-kpi {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.kpi {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  padding: 18px 20px;
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(0,0,0,0.04);
  position: relative;
  overflow: hidden;
}

.kpi::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--kpi-color, var(--primary));
  border-radius: var(--card-radius) var(--card-radius) 0 0;
}

.kpi.kpi-blue   { --kpi-color: #3b82f6; }
.kpi.kpi-green  { --kpi-color: #22c55e; }
.kpi.kpi-orange { --kpi-color: #f59e0b; }
.kpi.kpi-purple { --kpi-color: #8b5cf6; }

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--primary-soft);
  margin-bottom: 12px;
}

.kpi.kpi-green  .kpi-icon { background: var(--success-soft); }
.kpi.kpi-orange .kpi-icon { background: var(--warning-soft); }
.kpi.kpi-purple .kpi-icon { background: rgba(139,92,246,0.12); }

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 900;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 5px;
}

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

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 14px; }
.mt-3 { margin-top: 20px; }

/* =============================================
   TABELAS
   ============================================= */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tbl thead tr {
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
}

.tbl th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  white-space: nowrap;
  user-select: none;
}

.tbl td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-primary);
  vertical-align: middle;
}

.tbl tbody tr:last-child td { border-bottom: none; }

.tbl tbody tr:hover td { background: #f8fafc; }

.tbl td.muted,
.tbl td .muted,
.muted-row td {
  color: var(--text-muted);
  font-size: 12px;
}

/* =============================================
   FORMULÁRIOS
   ============================================= */
.form { }

.lbl {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 5px;
  margin-top: 14px;
}

.lbl:first-child { margin-top: 0; }

.ipt {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: #fafafa;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-primary);
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
  appearance: none;
}

.ipt:focus {
  outline: none;
  border-color: var(--border-focus);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.ipt::placeholder { color: var(--text-muted); }

.ipt.small {
  width: auto;
  min-width: 120px;
  max-width: 180px;
}

.ipt[type="file"] {
  padding: 6px 10px;
  cursor: pointer;
  background: #fff;
}

select.ipt {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

textarea.ipt {
  resize: vertical;
  min-height: 80px;
}

/* =============================================
   BOTÕES
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.btn:hover {
  background: #f1f5f9;
  border-color: #d1d5db;
}

.btn:active { transform: translateY(1px); }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}

.btn.primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(37,99,235,0.35);
}

.btn.danger {
  background: #fff;
  color: var(--danger);
  border-color: rgba(239,68,68,0.3);
}

.btn.danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn.success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.btn.sm {
  padding: 5px 10px;
  font-size: 11px;
}

/* =============================================
   FILTROS / TOOLBAR
   ============================================= */
.filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
  align-items: center;
}

/* =============================================
   PILLS / BADGES
   ============================================= */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text-secondary);
}

.pill.ok {
  background: #dcfce7;
  border-color: #86efac;
  color: #15803d;
}

.pill.warn {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
}

.pill.bad {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.pill.info {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1d4ed8;
}

/* =============================================
   IMAGENS DE PRODUTOS
   ============================================= */
.thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #f1f5f9;
  display: block;
}

.preview-wrap {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: #fafafa;
  margin-top: 8px;
}

.preview-img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--border);
  display: block;
}

/* =============================================
   TEXTO AUXILIAR
   ============================================= */
.muted {
  color: var(--text-muted);
  font-size: 12px;
}

.text-sm { font-size: 12px; }
.text-bold { font-weight: 700; }

/* =============================================
   DASHBOARD - VENDAS
   ============================================= */
#vendas-resumo,
#rel-resumo,
#caixa-resumo {
  padding: 10px 16px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

/* =============================================
   ESTILO DAS VIEWS ESPECÍFICAS
   ============================================= */

/* Dashboard */
#view-dashboard .card {
  margin-top: 0;
}

/* Produtos - form com padding interno */
#produto-form,
#entregador-form,
#usuario-form,
#caixa-form,
#config-form {
  padding: 16px;
}

/* Configurações */
#config-form .grid-2 > div { display: flex; flex-direction: column; }

/* Caixa - resumo colorido */
.caixa-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 14px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.caixa-kpi { text-align: center; }
.caixa-kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 700; }
.caixa-kpi-value { font-size: 18px; font-weight: 900; margin-top: 2px; }
.caixa-kpi-value.entrada { color: #16a34a; }
.caixa-kpi-value.saida   { color: #dc2626; }
.caixa-kpi-value.saldo   { color: var(--primary); }

/* =============================================
   ESPAÇAMENTO ENTRE SEÇÕES
   ============================================= */
.section-gap { margin-top: 16px; }

/* =============================================
   ESTADO VAZIO
   ============================================= */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 36px;
  margin-bottom: 10px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 14px;
  font-weight: 500;
}

/* =============================================
   MODAL SWEETALERT OVERRIDES
   ============================================= */
.swal2-popup {
  border-radius: 16px !important;
  padding: 24px !important;
  font-family: var(--font) !important;
}

.swal2-title {
  font-size: 18px !important;
  font-weight: 800 !important;
  color: var(--text-primary) !important;
}

.swal2-html-container {
  font-size: 14px !important;
  color: var(--text-secondary) !important;
}

.swal2-confirm {
  border-radius: var(--radius) !important;
  font-weight: 700 !important;
  font-family: var(--font) !important;
}

.swal2-cancel {
  border-radius: var(--radius) !important;
  font-weight: 700 !important;
  font-family: var(--font) !important;
}

/* =============================================
   SCROLLBAR GLOBAL
   ============================================= */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* Botão fechar sidebar (oculto no desktop) */
.sidebar-close { display: none; }

/* =============================================
   HAMBURGUER (só aparece no mobile)
   ============================================= */
.btn-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 38px;
  height: 38px;
  background: transparent;
  border: 1.5px solid rgba(0,0,0,0.12);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.btn-hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all 0.2s;
}

/* Overlay escuro atrás do drawer */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 99;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.active { display: block; }

/* =============================================
   DASHBOARD — GRÁFICOS
   ============================================= */
.dash-graficos {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 14px;
}

.dash-chart-card { overflow: hidden; }

@media (max-width: 900px) {
  .dash-graficos { grid-template-columns: 1fr; }
}

/* =============================================
   PRODUTOS - LAYOUT SPLIT
   ============================================= */
.produtos-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  transition: grid-template-columns 0.28s cubic-bezier(.4,0,.2,1);
}

.produtos-split.split-open {
  grid-template-columns: 1fr 400px;
}

.produtos-lista-card { overflow: hidden; min-width: 0; }
.produtos-form-card  { overflow: hidden; min-width: 0; }

/* Placeholder quando produto não tem imagem */
.thumb-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
  color: #4338ca;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 16px;
  flex-shrink: 0;
  border: 1px solid #c7d2fe;
}

/* =============================================
   RESPONSIVO — TABLET (≤1024px)
   ============================================= */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }

  .produtos-split.split-open {
    grid-template-columns: 1fr 360px;
  }
}

/* =============================================
   RESPONSIVO — MOBILE (≤768px)
   ============================================= */
@media (max-width: 768px) {

  /* ---------- LAYOUT ---------- */
  .main-view { grid-template-columns: 1fr; overflow: visible; }
  .content { width: 100%; max-width: 100vw; overflow-x: hidden; }

  /* ---------- SIDEBAR — DRAWER ---------- */
  .sidebar {
    position: fixed;
    top: 0;
    left: calc(-1 * var(--sidebar-w) - 10px);
    width: var(--sidebar-w);
    height: 100vh;
    z-index: 100;
    transition: left 0.25s ease;
    box-shadow: none;
    overflow-y: auto;
  }

  .sidebar.open {
    left: 0;
    box-shadow: 6px 0 28px rgba(0,0,0,0.45);
  }

  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: rgba(255,255,255,0.08);
    border: none;
    border-radius: 8px;
    color: var(--sidebar-muted);
    font-size: 16px;
    cursor: pointer;
    margin-left: auto;
    flex-shrink: 0;
  }

  /* ---------- TOPBAR ---------- */
  .btn-hamburger { display: flex; }
  .topbar { padding: 0 12px; height: 52px; gap: 8px; }
  .view-title { font-size: 16px; }
  .topbar-right .link { font-size: 12px; }

  /* ---------- CONTENT ---------- */
  .content { min-height: 100vh; }
  .content-inner { padding: 12px 10px 32px; }

  /* ---------- GRIDS ---------- */
  .grid-kpi { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
  .grid-2   { grid-template-columns: 1fr; gap: 12px; }
  .grid-3   { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* ---------- KPI CARDS ---------- */
  .kpi { padding: 14px; }
  .kpi-value { font-size: 22px; }
  .kpi-sub { font-size: 11px; }

  /* ---------- CARDS ---------- */
  .card-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 14px 10px;
  }
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  /* ---------- FILTROS ---------- */
  .filters { width: 100%; flex-wrap: wrap; }
  .filters .ipt,
  .filters select.ipt { flex: 1; min-width: 120px; max-width: none; }
  .filters .btn { white-space: nowrap; }
  .ipt.small { min-width: 110px; max-width: none; }

  /* ---------- TABELAS ---------- */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .tbl { min-width: 520px; }
  .tbl th, .tbl td { padding: 9px 10px; font-size: 12px; }
  .tbl th { font-size: 10px; letter-spacing: 0.04em; }

  /* Colunas menos importantes somem em mobile */
  .tbl .col-hide-mob { display: none; }

  /* ---------- FORMULÁRIOS ---------- */
  .lbl { margin-top: 12px; }
  .ipt { padding: 10px 12px; font-size: 14px; }
  .ipt[type="file"] { padding: 8px 10px; }
  .row { gap: 8px; margin-top: 14px; flex-wrap: wrap; }
  .row .btn { flex: 1; justify-content: center; }

  /* ---------- PRODUTOS SPLIT ---------- */
  .produtos-split.split-open { grid-template-columns: 1fr; }
  .produtos-form-card {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 32px rgba(0,0,0,0.18);
    max-height: 88vh;
    overflow-y: auto;
  }
  /* Quando o form panel estiver aberto, mostra como bottom sheet */
  .produtos-split.split-open ~ * { }
  body:has(.produtos-form-card:not(.hidden)) { overflow: hidden; }

  /* ---------- CAIXA ---------- */
  .caixa-kpis { grid-template-columns: repeat(3,1fr); gap: 8px; padding: 10px 12px; }
  .caixa-kpi-value { font-size: 14px; }

  /* ---------- CONFIG FORM GRID ---------- */
  #config-form .grid-2 { grid-template-columns: 1fr; }

  /* ---------- INNER FORMS padding ---------- */
  #produto-form,
  #entregador-form,
  #usuario-form,
  #caixa-form,
  #config-form,
  #categoria-form { padding: 14px; }

  /* Filtro de produtos em mobile: empilha */
  #view-produtos > .card > div {
    flex-direction: column;
    align-items: stretch;
  }
  #produtos-busca,
  #produtos-filtro-cat,
  #produtos-filtro-ativo { max-width: none; width: 100%; }
}

/* =============================================
   RESPONSIVO — SMALL MOBILE (≤480px)
   ============================================= */
@media (max-width: 480px) {

  /* KPIs: sempre 2 colunas compactas — NUNCA 1 coluna */
  .grid-kpi {
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-bottom: 10px;
  }

  /* KPI compacto: linha horizontal (ícone + textos lado a lado) */
  .kpi {
    padding: 11px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .kpi::before { height: 2px; }
  .kpi-label { font-size: 9px; letter-spacing: 0.05em; }
  .kpi-value  { font-size: 18px; line-height: 1.1; }
  .kpi-sub    { font-size: 10px; line-height: 1.3; }

  /* Gráficos: empilhados, menores */
  .dash-graficos { gap: 8px; }
  .dash-graficos .card div[style] {
    height: 160px !important;
    padding: 10px 10px 8px !important;
  }
  #chart-barras,
  #chart-rosca  { max-height: 140px; }

  /* Grids gerais */
  .grid-3   { grid-template-columns: 1fr; }
  .caixa-kpis { grid-template-columns: repeat(3,1fr); }

  /* Content compacto */
  .content-inner { padding: 8px 8px 24px; }
  .topbar { padding: 0 10px; height: 50px; }
  .view-title { font-size: 15px; max-width: calc(100vw - 130px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Seções menos espaçadas */
  .section-gap { margin-top: 10px; }
  .card-head   { padding: 10px 12px 8px; }

  /* Botões compactos */
  .btn    { padding: 7px 10px; font-size: 11px; }
  .btn.sm { padding: 5px 8px;  font-size: 10px; }

  /* Tabelas mais compactas */
  .tbl th, .tbl td { padding: 7px 8px; }

  /* Produtos bottom sheet */
  .produtos-form-card { max-height: 92vh; }
}
