/* =========================================================
   JR ERP SaaS — Design System v2.0
   ========================================================= */

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

:root {
  --primary:      #3b82f6;
  --primary-dark: #2563eb;
  --primary-light:#eff6ff;
  --secondary:    #6366f1;
  --success:      #22c55e;
  --success-light:#f0fdf4;
  --danger:       #ef4444;
  --danger-light: #fef2f2;
  --warning:      #f59e0b;
  --warning-light:#fffbeb;
  --info:         #06b6d4;
  --info-light:   #ecfeff;

  --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;

  --sidebar-w:     240px;
  --topbar-h:      56px;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --shadow:        0 2px 8px rgba(0,0,0,.10);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.14);
  --transition:    .18s ease;
  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-100);
  line-height: 1.5;
  min-height: 100vh;
}

/* --- Sidebar -------------------------------------------- */
.sidebar {
  position: fixed; top: 0; left: 0; height: 100vh;
  width: var(--sidebar-w);
  background: var(--gray-900);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--gray-700) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--gray-700); border-radius: 2px; }

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.brand-logo { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; }
.brand-icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.brand-name { display: block; color: #fff; font-weight: 600; font-size: 13px; line-height: 1.2; }
.brand-seg  { display: block; color: var(--gray-400); font-size: 11px; }

.sidebar-nav { flex: 1; padding: 8px 8px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius);
  color: var(--gray-400); text-decoration: none;
  font-size: 13px; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}
.nav-item svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item.nav-pdv { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; }
.nav-item.nav-pdv:hover { background: linear-gradient(135deg, #16a34a, #15803d); }
.nav-item.nav-admin { color: var(--warning); }
.nav-item.nav-sub { padding-left: 22px; font-size: 12.5px; }
.nav-group-label {
  display: block; color: var(--gray-600); font-size: 10.5px;
  font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  padding: 12px 10px 4px;
}
.nav-group { margin-bottom: 4px; }
.nav-separator { height: 1px; background: rgba(255,255,255,.06); margin: 8px 0; }

.sidebar-footer {
  padding: 12px 12px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--secondary);
  color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-details { flex: 1; min-width: 0; }
.user-name { display: block; color: #fff; font-size: 12.5px; font-weight: 600; truncate: ellipsis; white-space: nowrap; overflow: hidden; }
.user-role { display: block; color: var(--gray-500); font-size: 11px; }
.btn-logout {
  color: var(--gray-500); display: flex; align-items: center;
  text-decoration: none; padding: 6px; border-radius: 6px;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.btn-logout svg { width: 18px; height: 18px; fill: currentColor; }
.btn-logout:hover { color: var(--danger); background: rgba(239,68,68,.1); }

/* --- Main Layout ---------------------------------------- */
.main-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
}

.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  box-shadow: var(--shadow-sm);
}
.menu-toggle {
  display: none; background: none; border: none; cursor: pointer;
  padding: 6px; border-radius: var(--radius); color: var(--gray-600);
}
.menu-toggle svg { width: 22px; height: 22px; fill: currentColor; }
.page-title { font-size: 16px; font-weight: 600; color: var(--gray-800); flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

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

/* --- Flash Messages ------------------------------------- */
.flash {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; font-size: 14px; font-weight: 500;
  margin: 0 24px; border-radius: var(--radius);
  position: sticky; top: var(--topbar-h); z-index: 40;
}
.flash button { background: none; border: none; cursor: pointer; font-size: 16px; opacity: .7; }
.flash-success { background: var(--success-light); color: #15803d; border: 1px solid #bbf7d0; }
.flash-error   { background: var(--danger-light);  color: #b91c1c; border: 1px solid #fecaca; }
.flash-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.flash-info    { background: var(--info-light);    color: #0e7490; border: 1px solid #a5f3fc; }

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

/* --- KPI Stat Cards ------------------------------------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border-radius: var(--radius-lg);
  padding: 20px; border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 8px;
}
.stat-card-label { font-size: 12px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .05em; }
.stat-card-value { font-size: 24px; font-weight: 700; color: var(--gray-900); }
.stat-card-sub   { font-size: 12px; color: var(--gray-500); }
.stat-card-icon  { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.stat-card-icon svg { width: 22px; height: 22px; fill: currentColor; }
.stat-card.green  { border-left: 4px solid var(--success); }
.stat-card.green  .stat-card-icon { background: var(--success-light); color: var(--success); }
.stat-card.red    { border-left: 4px solid var(--danger); }
.stat-card.red    .stat-card-icon { background: var(--danger-light); color: var(--danger); }
.stat-card.blue   { border-left: 4px solid var(--primary); }
.stat-card.blue   .stat-card-icon { background: var(--primary-light); color: var(--primary); }
.stat-card.amber  { border-left: 4px solid var(--warning); }
.stat-card.amber  .stat-card-icon { background: var(--warning-light); color: var(--warning); }
.stat-card.purple { border-left: 4px solid var(--secondary); }
.stat-card.purple .stat-card-icon { background: #eef2ff; color: var(--secondary); }

/* --- Buttons -------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: none; text-decoration: none;
  transition: all var(--transition); white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; fill: currentColor; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #dc2626; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-100); }
.btn-ghost   { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-light); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 7px; border-radius: var(--radius); background: transparent; border: none; cursor: pointer; color: var(--gray-500); display: inline-flex; transition: all var(--transition); }
.btn-icon:hover { color: var(--primary); background: var(--primary-light); }
.btn-icon.danger:hover { color: var(--danger); background: var(--danger-light); }
.btn-icon.success:hover { color: var(--success); background: var(--success-light); }
.btn-icon.warning:hover { color: var(--warning); background: var(--warning-light); }
.btn-icon svg { width: 17px; height: 17px; fill: currentColor; }

/* --- Forms --------------------------------------------- */
.form-row { display: grid; gap: 16px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--gray-700); }
.form-label.required::after { content: ' *'; color: var(--danger); }
.form-control {
  width: 100%; padding: 8px 12px; border-radius: var(--radius);
  border: 1.5px solid var(--gray-300); font-size: 13px; color: var(--gray-800);
  background: #fff; transition: border-color var(--transition), box-shadow var(--transition);
  font-family: var(--font);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.form-control::placeholder { color: var(--gray-400); }
.form-control:disabled { background: var(--gray-100); cursor: not-allowed; }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius) 0 0 var(--radius); flex: 1; }
.input-group-append { display: flex; }
.input-group-append .btn { border-radius: 0 var(--radius) var(--radius) 0; }

.form-hint { font-size: 11.5px; color: var(--gray-400); }
.form-error { font-size: 11.5px; color: var(--danger); }

/* --- Tables -------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--gray-500); background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
tbody td { padding: 11px 14px; font-size: 13px; color: var(--gray-700); border-bottom: 1px solid var(--gray-100); }
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }
.tbl-actions { display: flex; gap: 4px; }
.tbl-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px;
}

/* --- Badges -------------------------------------------- */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge-success   { background: var(--success-light); color: #15803d; }
.badge-danger    { background: var(--danger-light);  color: #b91c1c; }
.badge-warning   { background: var(--warning-light); color: #92400e; }
.badge-info      { background: var(--info-light);    color: #0e7490; }
.badge-primary   { background: var(--primary-light); color: var(--primary-dark); }
.badge-secondary { background: var(--gray-100);      color: var(--gray-600); }
.badge-purple    { background: #eef2ff;              color: #4338ca; }

/* Status badges específicos */
.badge-aberta     { background: #eff6ff; color: #1d4ed8; }
.badge-recebida   { background: var(--success-light); color: #15803d; }
.badge-paga       { background: var(--success-light); color: #15803d; }
.badge-parcial    { background: var(--warning-light); color: #92400e; }
.badge-vencida    { background: var(--danger-light);  color: #b91c1c; }
.badge-cancelada  { background: var(--gray-100);      color: var(--gray-600); }
.badge-finalizada { background: var(--success-light); color: #15803d; }
.badge-agendado   { background: var(--info-light);    color: #0e7490; }
.badge-confirmado { background: var(--primary-light); color: var(--primary-dark); }
.badge-realizado  { background: var(--success-light); color: #15803d; }
.badge-faltou     { background: var(--danger-light);  color: #b91c1c; }

/* --- Filter/Search Bar --------------------------------- */
.filter-bar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.filter-bar .form-control { height: 36px; min-width: 0; }
.search-input { min-width: 220px; }
.filter-bar .btn { height: 36px; }
.filter-bar-right { margin-left: auto; display: flex; gap: 8px; }

/* --- Pagination ---------------------------------------- */
.pagination { display: flex; align-items: center; gap: 4px; padding: 14px 0 0; flex-wrap: wrap; }
.pag-btn {
  padding: 5px 10px; border-radius: 6px; font-size: 13px;
  color: var(--gray-600); background: #fff; border: 1.5px solid var(--gray-200);
  text-decoration: none; transition: all var(--transition);
}
.pag-btn:hover  { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.pag-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pag-info { font-size: 12px; color: var(--gray-400); margin-left: 8px; }

/* --- Modal --------------------------------------------- */
.erp-modal {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.45);
  align-items: center; justify-content: center;
  padding: 20px;
  overflow-y: auto;               /* permite rolar a sobreposição em telas baixas */
  -webkit-overflow-scrolling: touch;
}
.erp-modal.open { display: flex; }
.erp-modal-box {
  background: #fff; border-radius: var(--radius-lg);
  width: 100%; max-width: 620px; max-height: calc(100vh - 40px);
  margin: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-in .18s ease;
  /* Layout em coluna: cabeçalho e rodapé fixos, corpo rolável */
  display: flex; flex-direction: column; overflow: hidden;
}
.erp-modal-box.wide  { max-width: 860px; }
.erp-modal-box.small { max-width: 420px; }
/* Formulário dentro do modal também é coluna flexível */
.erp-modal-box > form { display: flex; flex-direction: column; min-height: 0; overflow: hidden; flex: 1; }
.erp-modal-header { flex-shrink: 0; }
.erp-modal-body   { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.erp-modal-footer { flex-shrink: 0; }

@keyframes modal-in { from { opacity:0; transform:translateY(-16px) scale(.97); } }

.erp-modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.erp-modal-title { font-size: 15px; font-weight: 600; color: var(--gray-800); }
.erp-modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--gray-400); font-size: 20px; line-height: 1;
  text-decoration: none; padding: 2px 6px; border-radius: 4px;
  transition: color var(--transition);
}
.erp-modal-close:hover { color: var(--danger); }
.erp-modal-body   { padding: 20px; }
.erp-modal-footer { padding: 14px 20px; border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: 8px; }

/* --- Dashboard ----------------------------------------- */
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.chart-container { position: relative; height: 240px; }
.top-list { list-style: none; }
.top-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--gray-100);
}
.top-list li:last-child { border-bottom: none; }
.top-rank { width: 24px; height: 24px; border-radius: 50%; background: var(--primary-light); color: var(--primary); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.top-name { flex: 1; font-size: 13px; }
.top-value { font-size: 13px; font-weight: 600; color: var(--gray-700); }

/* --- PDV ----------------------------------------------- */
.pdv-wrap { display: grid; grid-template-columns: 1fr 380px; gap: 0; height: calc(100vh - var(--topbar-h) - 48px); }
.pdv-products { display: flex; flex-direction: column; overflow: hidden; }
.pdv-search { padding: 12px; background: #fff; border-bottom: 1px solid var(--gray-200); display: flex; gap: 8px; }
.pdv-grid { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.pdv-product-card {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #dbe4f0;
  border-radius: 14px;
  padding: 14px;
  min-height: 210px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .06);
  transition: all var(--transition);
}
.pdv-product-card:hover { border-color: #93c5fd; box-shadow: 0 14px 30px rgba(59,130,246,.14); transform: translateY(-2px); }
.pdv-product-card.out-of-stock { opacity: .5; cursor: not-allowed; }
.pdv-product-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.pdv-product-name { font-size: 15px; line-height: 1.3; font-weight: 700; color: #0f172a; margin: 0; text-transform: uppercase; }
.pdv-product-badge { padding: 4px 8px; border-radius: 999px; background: #dbeafe; color: #1d4ed8; font-size: 11px; font-weight: 700; white-space: nowrap; }
.pdv-product-meta { display: grid; gap: 8px; margin-bottom: 14px; }
.pdv-product-meta-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: #64748b; }
.pdv-product-meta-row strong { color: #0f172a; font-weight: 700; }
.pdv-product-price { font-size: 28px; font-weight: 800; color: #2563eb; line-height: 1; margin: 8px 0 14px; }
.pdv-product-actions { display: grid; grid-template-columns: 40px 1fr 40px; gap: 8px; align-items: center; }
.pdv-product-btn {
  height: 38px; border: none; border-radius: 10px; cursor: pointer; font-size: 18px; font-weight: 700;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), color var(--transition);
}
.pdv-product-btn:hover { transform: translateY(-1px); }
.pdv-product-btn.minus { background: #e2e8f0; color: #334155; }
.pdv-product-btn.plus { background: #2563eb; color: #fff; box-shadow: 0 8px 16px rgba(37, 99, 235, .22); }
.pdv-product-remove {
  height: 38px; border: 1px solid #fecaca; border-radius: 10px; background: #fff1f2; color: #dc2626;
  font-size: 13px; font-weight: 700; cursor: pointer; transition: all var(--transition);
}
.pdv-product-remove:hover { background: #ffe4e6; border-color: #fca5a5; }

.pdv-cart { background: var(--gray-900); color: #fff; display: flex; flex-direction: column; overflow: hidden; }
.pdv-cart-header { padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,.08); font-weight: 600; font-size: 15px; }
.pdv-cart-items { flex: 1; overflow-y: auto; padding: 8px; }
.pdv-cart-item {
  background: rgba(255,255,255,.06); border-radius: 8px;
  padding: 10px; margin-bottom: 6px; display: flex; gap: 8px; align-items: center;
}
.pdv-cart-item-name { flex: 1; font-size: 13px; }
.pdv-cart-item-qty { display: flex; align-items: center; gap: 6px; }
.pdv-cart-item-qty button { background: rgba(255,255,255,.12); border: none; color: #fff; width: 24px; height: 24px; border-radius: 4px; cursor: pointer; font-size: 14px; }
.pdv-cart-item-price { font-weight: 600; font-size: 13px; white-space: nowrap; }
.pdv-cart-item-del { color: var(--danger); background: none; border: none; cursor: pointer; font-size: 16px; }

.pdv-cart-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.pdv-total-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 13px; color: rgba(255,255,255,.7); }
.pdv-total-row.main { font-size: 20px; font-weight: 700; color: #fff; margin: 8px 0; }
.pdv-discount-row { display: flex; gap: 6px; margin-bottom: 10px; }
.pdv-discount-row .form-control { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); color: #fff; font-size: 13px; height: 34px; }
.pdv-discount-row .form-control::placeholder { color: rgba(255,255,255,.35); }
.btn-finalizar { width: 100%; padding: 14px; background: var(--success); color: #fff; border: none; border-radius: var(--radius); font-size: 16px; font-weight: 700; cursor: pointer; transition: background var(--transition); margin-top: 8px; }
.btn-finalizar:hover { background: #16a34a; }
.btn-finalizar:disabled { background: var(--gray-600); cursor: not-allowed; }
.btn-limpar-pdv {
  width: 100%; margin-top: 6px; padding: 10px 12px; background: rgba(255,255,255,.06);
  border: 1.5px solid rgba(255,255,255,.12); border-radius: 6px; color: rgba(255,255,255,.72);
  font-size: 13px; cursor: pointer; font-family: inherit; transition: all var(--transition);
}
.btn-limpar-pdv:hover { background: rgba(255,255,255,.1); color: #fff; }

/* --- Caixa --------------------------------------------- */
.cash-status-banner {
  padding: 16px 20px; border-radius: var(--radius-lg);
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px;
  border: 1px solid;
}
.cash-status-banner.open   { background: #f0fdf4; border-color: #bbf7d0; }
.cash-status-banner.closed { background: #fef2f2; border-color: #fecaca; }
.cash-status-dot { width: 10px; height: 10px; border-radius: 50%; }
.cash-status-banner.open   .cash-status-dot { background: var(--success); }
.cash-status-banner.closed .cash-status-dot { background: var(--danger); }

/* --- Agendamentos -------------------------------------- */
.appt-day { margin-bottom: 20px; }
.appt-day-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
  font-size: 13px; font-weight: 600; color: var(--gray-600);
  text-transform: uppercase; letter-spacing: .05em;
}
.appt-day-header::after { content: ''; flex: 1; height: 1px; background: var(--gray-200); }
.appt-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 10px; }
.appt-card {
  background: #fff; border-radius: var(--radius); border: 1.5px solid var(--gray-200);
  padding: 14px; transition: box-shadow var(--transition);
}
.appt-card:hover { box-shadow: var(--shadow); }
.appt-card.status-agendado   { border-left: 4px solid var(--info); }
.appt-card.status-confirmado { border-left: 4px solid var(--primary); }
.appt-card.status-realizado  { border-left: 4px solid var(--success); }
.appt-card.status-cancelado  { border-left: 4px solid var(--danger); opacity: .7; }
.appt-card.status-faltou     { border-left: 4px solid var(--warning); }
.appt-time   { font-size: 12px; font-weight: 600; color: var(--gray-500); margin-bottom: 4px; }
.appt-name   { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.appt-prof   { font-size: 12px; color: var(--gray-500); }
.appt-actions { display: flex; gap: 4px; margin-top: 10px; }

/* --- Relatórios ---------------------------------------- */
.relat-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.relat-menu   { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 12px; margin-bottom: 24px; }
.relat-card   { background: #fff; border-radius: var(--radius-lg); padding: 20px; border: 1.5px solid var(--gray-200); text-decoration: none; color: inherit; transition: all var(--transition); display: flex; flex-direction: column; gap: 8px; }
.relat-card:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-2px); }
.relat-card-icon { font-size: 28px; }
.relat-card-title { font-size: 14px; font-weight: 600; color: var(--gray-800); }

/* --- Settings ------------------------------------------ */
.settings-sections { display: flex; flex-direction: column; gap: 20px; }
.settings-section { background: #fff; border-radius: var(--radius-lg); border: 1px solid var(--gray-200); }
.settings-section-header {
  padding: 14px 20px; border-bottom: 1px solid var(--gray-100);
  font-size: 14px; font-weight: 600; color: var(--gray-800);
  display: flex; align-items: center; justify-content: space-between;
}
.settings-body   { padding: 20px; }
.settings-footer { padding: 14px 20px; border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: 8px; }

/* --- Auth pages ---------------------------------------- */
.auth-body {
  background: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.1) 0%, transparent 40%),
              radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.1) 0%, transparent 40%),
              #090d16;
  position: relative;
  overflow-x: hidden;
}
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  position: relative;
  z-index: 5;
}
.auth-glow-1 {
  position: absolute; width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.2) 0%, transparent 70%);
  top: 15%; left: 15%; filter: blur(80px); opacity: 0.8; z-index: 1; pointer-events: none;
}
.auth-glow-2 {
  position: absolute; width: 380px; height: 380px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.2) 0%, transparent 70%);
  bottom: 15%; right: 15%; filter: blur(90px); opacity: 0.8; z-index: 1; pointer-events: none;
}
.auth-card {
  background: rgba(17, 24, 39, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 100px rgba(59, 130, 246, 0.05);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  position: relative;
  z-index: 10;
  animation: fadeInUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.auth-brand {
  padding: 36px 36px 24px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.auth-brand h1 {
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.5px;
}
.auth-brand p {
  font-size: 13px;
  color: var(--gray-400);
  margin-top: 4px;
}
.auth-logo-svg {
  margin-bottom: 14px;
  display: flex;
  justify-content: center;
}
.auth-form {
  padding: 28px 36px 36px;
}
.auth-form .form-group {
  margin-bottom: 18px;
}
.auth-form .form-label {
  color: var(--gray-300);
  font-weight: 500;
  font-size: 12.5px;
  margin-bottom: 6px;
  display: inline-block;
}
.auth-form .form-control {
  background: rgba(10, 15, 26, 0.6);
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  color: #ffffff;
  padding: 10px 14px;
  font-size: 13.5px;
  border-radius: var(--radius);
  transition: all var(--transition);
}
.auth-form .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.25);
  background: rgba(10, 15, 26, 0.85);
}
.auth-form .form-control::placeholder {
  color: var(--gray-600);
}
.auth-form select.form-control {
  color: #ffffff;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 10px center;
  background-repeat: no-repeat;
  background-size: 20px;
  padding-right: 36px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
.auth-form select.form-control option {
  background: #111827;
  color: #ffffff;
}
.input-password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-password-wrap .form-control {
  padding-right: 42px;
}
.password-toggle {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 4px;
  transition: color var(--transition);
}
.password-toggle:hover {
  color: #ffffff;
}
.password-toggle svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
.auth-submit {
  width: 100%;
  padding: 11px 24px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}
.auth-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.4), 0 0 10px rgba(59, 130, 246, 0.2);
  filter: brightness(1.08);
}
.auth-submit:active {
  transform: translateY(0);
}
.auth-links {
  text-align: center;
  font-size: 13px;
  color: var(--gray-400);
  margin-top: 18px;
}
.auth-links a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--transition);
}
.auth-links a:hover {
  color: #60a5fa;
}
.auth-form .flash {
  position: static;
  margin: 0 0 18px 0;
  padding: 10px 14px;
  font-size: 13px;
  border-radius: var(--radius);
  animation: fadeInUp 0.3s ease;
}

/* --- Empty State --------------------------------------- */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state h2 { font-size: 18px; color: var(--gray-600); margin-bottom: 8px; }
.empty-state p  { font-size: 14px; }

/* --- Responsive ---------------------------------------- */
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  /* PDV empilha: produtos em cima, carrinho embaixo */
  .pdv-wrap { grid-template-columns: 1fr; height: auto; }
  .pdv-cart { max-height: none; }
  .form-row-3, .form-row-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); width: 240px; }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .menu-toggle { display: flex; }
  .main-content { padding: 14px; }
  .topbar { padding: 0 14px; }

  /* Formulários viram 1 coluna */
  .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }

  /* KPIs em 2 colunas */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* Barra de filtros/ações empilha e ocupa a largura toda */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar-right { margin-left: 0; display: flex; flex-wrap: wrap; gap: 8px; }
  .filter-bar .btn, .filter-bar-right .btn { width: 100%; justify-content: center; }
  .search-input { min-width: 0; width: 100%; }

  /* Tabelas roláveis na horizontal (não cortam) */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 560px; }

  /* Modais ocupam quase a tela inteira, com rodapé sempre visível */
  .erp-modal { padding: 10px; align-items: flex-start; }
  .erp-modal-box, .erp-modal-box.wide, .erp-modal-box.small { max-width: 100%; max-height: calc(100vh - 20px); }
  .erp-modal-body { padding: 14px; }
  .erp-modal-footer { padding: 12px 14px; }
  .erp-modal-footer .btn { flex: 1; justify-content: center; }

  /* PDV: grid de produtos e carrinho em coluna única, sem cortar */
  .pdv-products, .pdv-cart { width: 100%; }
  .pdv-cart-footer { position: sticky; bottom: 0; }

  /* Formas de pagamento (botões) quebram melhor */
  #formasPagamento .fp-btn { flex: 1 0 30%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-form { padding: 20px; }
  .auth-brand { padding: 24px 20px 20px; }
  .main-content { padding: 10px; }
  .card-body { padding: 14px; }
  .page-title, .card-title { font-size: 15px; }
  #formasPagamento .fp-btn { flex: 1 0 45%; }
}

/* --- Utilities ----------------------------------------- */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-0  { margin-top: 0; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

/* --- Print --------------------------------------------- */
@media print {
  .sidebar, .topbar, .btn, .filter-bar, .pagination { display: none !important; }
  .main-wrap { margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* --- PDV extensions (e-commerce) ----------------------- */

/* Botão bloco (full width) */
.btn-block { display: flex; width: 100%; justify-content: center; }

/* Filtro de categorias */
.pdv-categories {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 8px 12px 0; background: #fff;
}
.cat-btn {
  padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 500;
  background: transparent; border: 1.5px solid var(--gray-300); color: var(--gray-600);
  cursor: pointer; transition: all var(--transition); white-space: nowrap;
}
.cat-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.cat-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Card de produto — botão add overlay */
.pdv-product-card { position: relative; }
.pdv-product-add {
  display: none; position: absolute; inset: 0; align-items: center; justify-content: center;
  background: rgba(59,130,246,.85); color: #fff; font-size: 13px; font-weight: 600;
  border-radius: var(--radius); letter-spacing: .03em;
}
.pdv-product-card:hover .pdv-product-add { display: flex; }

/* Empty state do grid de produtos */
.pdv-empty-grid {
  grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 60px 20px; color: var(--gray-400);
  gap: 12px;
}
.pdv-empty-grid p { font-size: 14px; }

/* =========================================================
   PDV — Tela "Caixa Livre" (idle screen)
   ========================================================= */
#pdvIdleScreen {
  /* Cobre apenas a área de conteúdo — sidebar (240px z-index:100) permanece visível */
  position: fixed;
  top: 0; right: 0; bottom: 0;
  left: var(--sidebar-w, 240px);  /* começa após a sidebar */
  z-index: 50;                     /* abaixo da sidebar (100) */
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  overflow: hidden;
  background: #0f172a;
}
#pdvIdleScreen .idle-bg {
  position: absolute; inset: 0;
  background:
    linear-gradient(135deg, rgba(59,130,246,.85) 0%, rgba(99,102,241,.75) 50%, rgba(15,23,42,.95) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cdefs%3E%3CradialGradient id='g' cx='50%25' cy='50%25'%3E%3Cstop offset='0' stop-color='%23ffffff' stop-opacity='.07'/%3E%3Cstop offset='100%25' stop-color='%23ffffff' stop-opacity='0'/%3E%3C/radialGradient%3E%3C/defs%3E%3Ccircle cx='50' cy='50' r='50' fill='url(%23g)'/%3E%3C/svg%3E");
  background-size: cover, 200px 200px;
  animation: idleBgPulse 8s ease-in-out infinite;
}
@keyframes idleBgPulse {
  0%,100% { filter: brightness(1); }
  50%      { filter: brightness(1.12); }
}
/* floating circles */
#pdvIdleScreen .idle-circle {
  position: absolute; border-radius: 50%;
  background: rgba(255,255,255,.04);
  animation: idleFloat linear infinite;
}
@keyframes idleFloat {
  0%   { transform: translateY(0) scale(1); opacity: .5; }
  50%  { transform: translateY(-30px) scale(1.05); opacity: .8; }
  100% { transform: translateY(0) scale(1); opacity: .5; }
}

#pdvIdleScreen .idle-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center;
  gap: 20px; padding: 40px;
  animation: idleFadeIn .6s ease-out both;
}
@keyframes idleFadeIn {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
#pdvIdleScreen .idle-icon {
  width: 100px; height: 100px;
  background: rgba(255,255,255,.1);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 48px;
  box-shadow: 0 0 0 16px rgba(255,255,255,.05), 0 0 0 32px rgba(255,255,255,.025);
  animation: idlePing 3s ease-in-out infinite;
}
@keyframes idlePing {
  0%,100% { box-shadow: 0 0 0 16px rgba(255,255,255,.05), 0 0 0 32px rgba(255,255,255,.025); }
  50%      { box-shadow: 0 0 0 22px rgba(255,255,255,.08), 0 0 0 44px rgba(255,255,255,.04); }
}
#pdvIdleScreen .idle-title {
  font-size: 42px; font-weight: 900; color: #fff;
  letter-spacing: -.02em; text-align: center;
  text-shadow: 0 2px 24px rgba(0,0,0,.4);
}
#pdvIdleScreen .idle-subtitle {
  font-size: 16px; color: rgba(255,255,255,.6);
  text-align: center; max-width: 320px; line-height: 1.5;
}
#pdvIdleScreen .idle-time {
  font-size: 28px; font-weight: 700; color: rgba(255,255,255,.9);
  letter-spacing: .04em; font-variant-numeric: tabular-nums;
}
#pdvIdleScreen .idle-btn {
  margin-top: 8px;
  padding: 16px 48px;
  background: #fff;
  color: var(--primary-dark);
  border: none; border-radius: 50px;
  font-size: 17px; font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  transition: transform .15s, box-shadow .15s;
  display: flex; align-items: center; gap: 10px;
}
#pdvIdleScreen .idle-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
#pdvIdleScreen .idle-btn:active { transform: translateY(0); }
#pdvIdleScreen .idle-btn svg { width: 22px; height: 22px; fill: currentColor; }

/* Área do cliente no carrinho (fundo escuro) */
.pdv-client {
  padding: 10px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.pdv-client-input {
  width: 100%; padding: 7px 10px; border-radius: var(--radius);
  border: 1.5px solid rgba(255,255,255,.14); font-size: 13px;
  background: rgba(255,255,255,.08); color: #fff; font-family: var(--font);
  transition: border-color var(--transition);
}
.pdv-client-input::placeholder { color: rgba(255,255,255,.3); }
.pdv-client-input:focus { outline: none; border-color: var(--primary); background: rgba(255,255,255,.12); }

/* Autocomplete no carrinho */
.pdv-autocomplete-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 2px);
  background: #1e293b; border: 1.5px solid rgba(255,255,255,.12); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3); z-index: 600; max-height: 200px; overflow-y: auto;
}
.pdv-autocomplete-list div {
  padding: 9px 12px; cursor: pointer; font-size: 13px; color: rgba(255,255,255,.8);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.pdv-autocomplete-list div:hover { background: rgba(255,255,255,.08); }
.pdv-autocomplete-list div:last-child { border-bottom: none; }

/* Formas de pagamento no modal (grid de botões) */
.fp-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px; border-radius: var(--radius-lg);
  border: 2px solid var(--gray-200); background: #fff;
  cursor: pointer; transition: all var(--transition); text-align: center;
}
.fp-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.fp-btn.active { border-color: var(--primary); background: var(--primary-light); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.fp-btn-icon { font-size: 22px; line-height: 1; }
.fp-btn-nome { font-size: 12px; font-weight: 600; color: var(--gray-700); }
.fp-btn.active .fp-btn-nome { color: var(--primary-dark); }

/* Badge em_atendimento e concluido (agendamentos) */
.badge-em_atendimento { background: var(--warning-light); color: #92400e; }
.badge-concluido      { background: var(--success-light);  color: #15803d; }
