/* ============================================================
   Baby Maricota — Painel Administrativo
   Paleta extraída do logo: teal, dourado, creme e rosa
   ============================================================ */

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

:root {
  /* Dourado/mostarda do logo — cor de ação */
  --primary:        #E08A1E;
  --primary-dark:   #B86D12;
  --primary-light:  #F2A431;
  --primary-bg:     #FDF3E3;
  /* Teal/petróleo do logo — cor institucional */
  --teal:           #00808F;
  --teal-dark:      #00646F;
  --teal-light:     #0D99A8;
  --teal-bg:        #E6F4F6;
  /* Tons de apoio do logo */
  --cream:          #F6E3C8;
  --rose:           #F3C9C9;
  --peach:          #F2A574;
  --secondary:      #6B7A80;
  --success:        #2E8B6F;
  --success-bg:     #E8F5F0;
  --warning:        #D98324;
  --warning-bg:     #FDF3E3;
  --danger:         #C6534E;
  --danger-bg:      #FBECEB;
  --info:           #00808F;
  --info-bg:        #E6F4F6;
  --body-bg:        #FAF4EA;
  --sidebar-bg:     #00646F;
  --sidebar-hover:  #007D8B;
  --sidebar-active: #F2A431;
  --sidebar-text:   #B7DCE1;
  --sidebar-active-text: #003C43;
  --card-bg:        #ffffff;
  --text-primary:   #13333A;
  --text-secondary: #4A6167;
  --text-muted:     #8FA3A8;
  --border:         #E7DCCB;
  --border-focus:   #F2A431;
  --input-bg:       #ffffff;
  --shadow-xs:      0 1px 2px rgba(0,0,0,.05);
  --shadow-sm:      0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:      0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:      0 10px 15px rgba(0,0,0,.10), 0 4px 6px rgba(0,0,0,.05);
  --radius:         8px;
  --radius-lg:      12px;
  --radius-xl:      16px;
  --sidebar-width:  260px;
  --header-h:       64px;
  --font:           -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --transition:     all 0.2s ease;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--body-bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100vw;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }
button, [type=button], [type=submit] { cursor: pointer; touch-action: manipulation; }
input, select, textarea { max-width: 100%; }

/* ---- SCROLLBAR ------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CFE8EC; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9FC6CC; }

/* ---- LAYOUT ---------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 200;
  transition: transform 0.3s ease;
  will-change: transform;
  -webkit-overflow-scrolling: touch;
}

.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
  min-width: 0;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 299;
}

/* ---- SIDEBAR BRAND --------------------------------------- */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.brand-logo {
  width: 42px; height: 42px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--cream);
  box-shadow: 0 0 0 2px rgba(255,255,255,.25);
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-size: 14px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub  { font-size: 11px; color: var(--sidebar-text); white-space: nowrap; }

/* ---- SIDEBAR NAV ----------------------------------------- */
.sidebar-nav { flex: 1; padding: 16px 12px; }

.nav-section { margin-bottom: 4px; }

.nav-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #8ABFC7;
  padding: 12px 8px 6px;
  display: block;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
}

.nav-item svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: .7;
  transition: var(--transition);
}

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

.nav-item:hover svg { opacity: 1; }

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-active-text);
  font-weight: 600;
}

.nav-item.active svg { opacity: 1; }

/* ---- SIDEBAR FOOTER -------------------------------------- */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }

.user-avatar {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-detail { display: flex; flex-direction: column; min-width: 0; }
.user-name   { font-size: 13px; font-weight: 600; color: #DCEFF2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role   { font-size: 11px; color: var(--sidebar-text); }

.logout-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  transition: var(--transition);
  flex-shrink: 0;
}
.logout-btn svg { width: 17px; height: 17px; }
.logout-btn:hover { background: rgba(198,83,78,.18); color: #E27B76; }

/* ---- TOPBAR ---------------------------------------------- */
.topbar {
  height: var(--header-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
  width: 100%;
  box-sizing: border-box;
}

.topbar-left  { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 20px; }

.menu-toggle {
  display: none;
  background: none;
  border: none;
  padding: 6px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  transition: var(--transition);
}
.menu-toggle svg { width: 22px; height: 22px; display: block; }
.menu-toggle:hover { background: var(--body-bg); color: var(--text-primary); }

.page-heading { font-size: 17px; font-weight: 600; color: var(--text-primary); }

.topbar-date { font-size: 13px; color: var(--text-muted); }

.topbar-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: var(--transition);
}
.topbar-logout svg { width: 16px; height: 16px; }
.topbar-logout:hover { background: var(--danger-bg); color: var(--danger); }

/* ---- CONTENT --------------------------------------------- */
.content { flex: 1; padding: 28px 28px 40px; max-width: 1400px; width: 100%; min-width: 0; box-sizing: border-box; }

/* ---- CARDS ----------------------------------------------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title svg { width: 18px; height: 18px; color: var(--primary); }

.card-body { padding: 24px; }

/* ---- STAT CARDS ------------------------------------------ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 18px;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.blue   { background: var(--primary-bg); color: var(--primary); }
.stat-icon.green  { background: var(--success-bg); color: var(--success); }
.stat-icon.yellow { background: var(--warning-bg); color: var(--warning); }
.stat-icon.red    { background: var(--danger-bg);  color: var(--danger);  }
.stat-icon.cyan   { background: var(--info-bg);    color: var(--info);    }

.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.stat-label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

/* ---- PAGE HEADER ----------------------------------------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header-title { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.page-header-sub   { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ---- BUTTONS --------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: var(--transition);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

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

.btn-secondary { background: #FBF7F0; color: var(--text-secondary); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text-primary); }

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

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

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

.btn-outline-primary { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary-bg); }

.btn-outline-danger  { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-outline-danger:hover  { background: var(--danger-bg); }

.btn-outline-success { background: transparent; color: var(--success); border-color: var(--success); }
.btn-outline-success:hover { background: var(--success-bg); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 8px; gap: 0; }
.btn-icon svg { width: 17px; height: 17px; }

/* ---- TABLE ----------------------------------------------- */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); width: 100%; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

thead th {
  background: #FBF7F0;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--border); transition: background 0.15s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #FBF7F0; }

tbody td { padding: 13px 16px; color: var(--text-primary); vertical-align: middle; }

.table-actions { display: flex; gap: 6px; align-items: center; }
.no-results { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.no-results svg { width: 40px; height: 40px; opacity: .4; display: block; margin: 0 auto 10px; }

/* ---- FORMS ----------------------------------------------- */
.form-grid   { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr;           gap: 20px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr;       gap: 20px; max-width: 100%; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr);    gap: 20px; }

/* ---- VENDAS GRID (nova/editar venda) --------------------- */
.vendas-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
  max-width: 100%;
}
.vendas-grid > * { min-width: 0; }
.vendas-grid > div:last-child { position: sticky; top: calc(var(--header-h) + 20px); }

/* ---- ADD ITEM FORM --------------------------------------- */
.add-item-grid {
  display: grid;
  grid-template-columns: 1fr 80px 100px 80px 90px 100px;
  gap: 10px;
  align-items: end;
}
.aif-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.aif-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  white-space: nowrap;
}
.aif-field input { width: 100%; }
.aif-preview {
  background: var(--primary-bg);
  border-radius: var(--radius);
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  justify-content: flex-end;
}
.aif-preview-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}
.aif-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
@media (max-width: 768px) {
  .add-item-grid {
    grid-template-columns: 1fr 1fr;
  }
  .aif-produto { grid-column: 1 / -1; }
  .aif-preview { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; }
}

/* ---- ITEMS LIST TABLE ------------------------------------ */
.items-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.items-list-table thead th {
  background: #FBF7F0;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.items-list-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.items-list-table tbody tr:last-child { border-bottom: none; }
.items-list-table tbody tr:hover { background: #FBF7F0; }
.items-list-table tbody tr.editing { background: #E6F4F6 !important; }
.items-list-table tbody td {
  padding: 9px 12px;
  vertical-align: middle;
}
.il-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}
.btn-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  flex-shrink: 0;
}
.btn-icon svg { width: 14px; height: 14px; }
.btn-icon:hover { background: var(--primary-bg); color: var(--primary); border-color: var(--primary); }
.btn-icon-danger:hover { background: #FBECEB; color: #C6534E; border-color: #C6534E; }

/* ---- ITEM CARDS (tabela de itens da venda) --------------- */
.items-body {
  display: flex;
  flex-direction: column;
}
.item-card {
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  background: var(--card-bg);
  transition: background 0.12s;
}
.item-card:hover { background: #FBF7F0; }
.item-card:last-child { border-bottom: none; }

.item-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.item-card-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.item-prod-wrap {
  flex: 1;
  min-width: 0;
}
.item-prod-wrap .product-search-input { width: 100%; }

.item-card-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.item-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.item-field-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  white-space: nowrap;
}
.item-field input { width: 100%; text-align: right; }
.item-field .product-search-input { text-align: left; }
.item-subtotal-field {
  background: var(--primary-bg);
  border-radius: var(--radius);
  padding: 6px 10px;
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 3px;
  justify-content: flex-end;
}
.item-subtotal-field .item-subtotal {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--primary);
}

/* Mobile ≤ 768px */
@media (max-width: 768px) {
  .item-card { padding: 12px 14px; }
}

.form-section { margin-bottom: 28px; }
.form-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.required::after { content: ' *'; color: var(--danger); }

input[type=text],
input[type=email],
input[type=number],
input[type=password],
input[type=date],
input[type=tel],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--input-bg);
  transition: var(--transition);
  font-family: var(--font);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(196,28,28,.15);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { resize: vertical; min-height: 80px; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%2394a3b8' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 36px; cursor: pointer; }

.input-group { display: flex; }
.input-group input { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .input-addon { background: #FBF7F0; border: 1.5px solid var(--border); border-left: none; padding: 9px 12px; border-radius: 0 var(--radius) var(--radius) 0; color: var(--text-muted); font-size: 13px; white-space: nowrap; display: flex; align-items: center; }

.form-hint { font-size: 12px; color: var(--text-muted); }
.form-error { font-size: 12px; color: var(--danger); }

/* ---- BADGES ---------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
}
.badge-primary  { background: var(--primary-bg); color: var(--primary); }
.badge-success  { background: var(--success-bg); color: var(--success); }
.badge-warning  { background: var(--warning-bg); color: var(--warning); }
.badge-danger   { background: var(--danger-bg);  color: var(--danger);  }
.badge-info     { background: var(--info-bg);    color: var(--info);    }
.badge-secondary{ background: #F0EAE0;           color: var(--secondary);}

/* ---- ALERTS ---------------------------------------------- */
.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  border: 1px solid transparent;
  animation: slideDown 0.3s ease;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.alert-content { display: flex; align-items: center; gap: 10px; flex: 1; font-size: 13.5px; font-weight: 500; }
.alert-content svg { width: 18px; height: 18px; flex-shrink: 0; }

.alert-success { background: var(--success-bg); border-color: #B9DCCF; color: #1F5C4A; }
.alert-error   { background: var(--danger-bg);  border-color: #F0C4C2; color: #8E3A36; }
.alert-warning { background: var(--warning-bg); border-color: #F3D9A6; color: #8A5316; }
.alert-info    { background: var(--info-bg);    border-color: #A9D9DF; color: #00646F; }

.alert-close { background: none; border: none; font-size: 20px; line-height: 1; opacity: .6; padding: 0 4px; transition: var(--transition); }
.alert-close:hover { opacity: 1; }

/* ---- TOOLBAR (search + actions) -------------------------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.search-box { position: relative; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.search-box input { padding-left: 36px; width: 280px; }

.toolbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- PAGINATION ------------------------------------------ */
.pagination { display: flex; align-items: center; gap: 4px; padding: 20px 24px; border-top: 1px solid var(--border); justify-content: center; }
.page-btn { padding: 6px 11px; border-radius: var(--radius); font-size: 13px; color: var(--text-secondary); border: 1px solid var(--border); background: var(--card-bg); transition: var(--transition); }
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.page-dots { color: var(--text-muted); padding: 6px 4px; }

/* ---- DETAIL VIEW ----------------------------------------- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
.detail-item label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; display: block; }
.detail-item p { font-size: 14px; color: var(--text-primary); font-weight: 500; }

/* ---- VENDA ITEMS TABLE ----------------------------------- */
.items-table-wrapper { overflow-x: auto; width: 100%; max-width: 100%; -webkit-overflow-scrolling: touch; }
.items-table { min-width: 700px; }
.items-table thead th { background: #FBF7F0; }
.items-table input, .items-table select { border-radius: var(--radius); }
.remove-item-btn { padding: 6px 8px; background: var(--danger-bg); color: var(--danger); border: 1px solid #F0C4C2; border-radius: var(--radius); transition: var(--transition); display: flex; align-items: center; justify-content: center; }
.remove-item-btn:hover { background: var(--danger); color: #fff; }
.remove-item-btn svg { width: 15px; height: 15px; }

/* ---- TOTAL SUMMARY --------------------------------------- */
.total-summary {
  background: #FBF7F0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  max-width: 400px;
  margin-left: auto;
}
.total-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14px; color: var(--text-secondary); }
.total-row.subtotal { border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 4px; }
.total-row.total-final { font-size: 18px; font-weight: 700; color: var(--text-primary); border-top: 2px solid var(--border); margin-top: 4px; padding-top: 10px; }
.total-row.discount { color: var(--danger); }

/* ---- MODAL ---------------------------------------------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; visibility: hidden; transition: var(--transition); }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal { background: var(--card-bg); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); max-width: 480px; width: 100%; padding: 32px; transform: translateY(-12px); transition: var(--transition); }
.modal-overlay.active .modal { transform: translateY(0); }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; }
.modal-body  { font-size: 14px; color: var(--text-secondary); margin-bottom: 24px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---- LOGIN PAGE ------------------------------------------ */
.login-page { min-height: 100vh; background: linear-gradient(140deg, var(--teal-dark) 0%, var(--teal) 55%, #0D99A8 100%); display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-logo-img { width: 92px; height: 92px; object-fit: cover; border-radius: 50%; display: block; margin: 0 auto 14px; box-shadow: 0 0 0 4px var(--cream), var(--shadow-md); }
.login-card { background: var(--card-bg); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); padding: 48px 44px; width: 100%; max-width: 420px; }
.login-logo { text-align: center; margin-bottom: 36px; }
.login-logo-icon { width: 56px; height: 56px; background: var(--primary); border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; color: #fff; margin: 0 auto 12px; letter-spacing: -1px; }
.login-logo h1 { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.login-logo p  { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.login-form .form-group { margin-bottom: 18px; }
.login-form label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 7px; }
.login-submit { width: 100%; margin-top: 8px; justify-content: center; padding: 12px; font-size: 15px; }
.login-footer { text-align: center; margin-top: 24px; font-size: 12.5px; color: var(--text-muted); }

/* ---- PRODUCT SEARCH (in vendas) -------------------------- */
.product-search-wrapper { position: relative; }
.product-results { position: absolute; top: 100%; left: 0; right: 0; background: var(--card-bg); border: 1.5px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow-md); z-index: 50; max-height: 220px; overflow-y: auto; }
.product-result-item { padding: 10px 14px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border); transition: background 0.15s; }
.product-result-item:last-child { border-bottom: none; }
.product-result-item:hover,
.product-result-item.hover { background: var(--primary-bg); color: var(--primary); }
.product-result-item strong { font-weight: 600; }
.product-result-item small  { color: var(--text-muted); font-size: 11.5px; display: block; }

/* ---- CHIPS / FILTER ------------------------------------- */
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 500; border: 1.5px solid var(--border); background: var(--card-bg); color: var(--text-secondary); transition: var(--transition); cursor: pointer; }
.chip:hover, .chip.active { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }

/* ---- BREADCRUMB ----------------------------------------- */
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb span { color: var(--text-primary); font-weight: 500; }
.breadcrumb-sep { color: var(--border); }

/* ---- TABS ----------------------------------------------- */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 24px; gap: 2px; }
.tab { padding: 10px 18px; font-size: 13.5px; font-weight: 500; color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: var(--transition); cursor: pointer; }
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---- EMPTY STATE ---------------------------------------- */
.empty-state { text-align: center; padding: 64px 24px; }
.empty-state svg { width: 52px; height: 52px; color: var(--text-muted); margin: 0 auto 16px; opacity: .4; display: block; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p  { font-size: 13.5px; color: var(--text-muted); }

/* ---- ESTOQUE BAIXO -------------------------------------- */
.estoque-baixo { color: var(--danger); font-weight: 600; }
.estoque-ok    { color: var(--success); }
.estoque-zero  { color: var(--danger); font-weight: 700; }

/* ---- DIVIDER -------------------------------------------- */
.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ---- UTILITY -------------------------------------------- */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.text-primary-color { color: var(--primary); }
.fw-bold     { font-weight: 700; }
.fw-medium   { font-weight: 500; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }

/* ---- FORM ACTIONS --------------------------------------- */
.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 24px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
}

/* ---- RESPONSIVE ----------------------------------------- */

/* Tablet e abaixo (< 1024px) */
@media (max-width: 1024px) {
  /* Sidebar deslizante */
  .sidebar {
    transform: translateX(-100%);
    z-index: 300;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.25);
  }
  .main-wrapper { margin-left: 0 !important; max-width: 100vw; overflow-x: hidden; }
  .content { overflow-x: hidden; max-width: 100%; }
  .sidebar-overlay { display: block; opacity: 0; visibility: hidden; transition: opacity .3s, visibility .3s; }
  .sidebar-overlay.visible { opacity: 1; visibility: visible; }
  .menu-toggle { display: flex; }

  /* Grids de formulário */
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
  .form-grid-4 { grid-template-columns: 1fr 1fr; }

  /* Vendas: colapsa para 1 coluna */
  .vendas-grid {
    grid-template-columns: 1fr !important;
  }
  /* Evita que filhos flex/grid extrapolem a largura do grid */
  .vendas-grid > * { min-width: 0; }
  /* Painel direito: remove sticky em mobile (fica abaixo do form) */
  .vendas-grid > div:last-child { position: static !important; top: auto !important; }

  /* Tabelas: scroll horizontal com suavidade */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* Mobile (< 768px) */
@media (max-width: 768px) {
  /* iOS Safari: prevent zoom on input focus (requires font-size >= 16px) */
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Layout geral */
  .content { padding: 16px 14px 40px; padding-bottom: max(40px, env(safe-area-inset-bottom)); }

  /* Topbar */
  .topbar { padding: 0 14px; gap: 8px; }
  .topbar-date { display: none; }
  .topbar-logout span { display: none; }
  .topbar-logout { padding: 6px 8px; }
  .page-heading { font-size: 15px; }

  /* Page header */
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-header > div:last-child { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
  .page-header .btn { flex: 1 1 auto; justify-content: center; min-width: 140px; }

  /* Cards */
  .card-body { padding: 16px; }
  .card-header { padding: 14px 16px 12px; flex-direction: row; flex-wrap: wrap; gap: 10px; }
  .card-header .btn { padding: 6px 12px; font-size: 12px; }

  /* Stats */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
  .stat-card { padding: 16px; gap: 12px; }
  .stat-value { font-size: 18px; }
  .stat-icon { width: 42px; height: 42px; }
  .stat-icon svg { width: 20px; height: 20px; }

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

  /* Sobrescrever grid-column:span nos formulários */
  .form-group[style*="grid-column"] { grid-column: 1 / -1 !important; }

  /* Toolbar de filtros */
  .toolbar { flex-direction: column; align-items: stretch; gap: 10px; padding: 14px 14px; }
  .search-box { width: 100%; }
  .search-box input { width: 100%; }
  .toolbar form { width: 100%; flex-wrap: wrap; gap: 8px; }
  .toolbar form input[type=date] { flex: 1 1 120px; width: auto; }
  .toolbar form .btn { flex-shrink: 0; }
  .filter-chips { flex-wrap: wrap; gap: 6px; }

  /* Tabelas */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 0; width: 100%; }
  thead th { padding: 10px 12px; }
  tbody td { padding: 11px 12px; }

  /* Ações nas tabelas: botões menores */
  .table-actions { gap: 4px; }
  .table-actions .btn-sm { padding: 5px 8px; font-size: 12px; }

  /* Breadcrumb */
  .breadcrumb { flex-wrap: wrap; font-size: 12px; margin-bottom: 14px; }

  /* Botões gerais */
  .btn-lg { padding: 11px 20px; font-size: 14px; }

  /* Total summary */
  .total-summary { max-width: 100%; margin: 0; }

  /* Form actions */
  .form-actions { flex-direction: column-reverse; gap: 10px; }
  .form-actions .btn { width: 100%; justify-content: center; }

  /* Modal */
  .modal { padding: 24px 20px; margin: 16px; max-width: calc(100vw - 32px); }

  /* Detalhes de venda */
  .detail-grid { grid-template-columns: 1fr !important; gap: 14px; }

  /* Dashboard / Configurações / Visualizar venda: 2 col → 1 col */
  .dash-grid { grid-template-columns: 1fr !important; }
}

/* Mobile pequeno (< 480px) */
@media (max-width: 480px) {
  /* Layout */
  .content { padding: 12px 12px 36px; }

  /* Topbar */
  .topbar { padding: 0 12px; }
  .menu-toggle svg { width: 20px; height: 20px; }
  .page-heading { font-size: 14px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Stats: 1 coluna */
  .stats-grid { grid-template-columns: 1fr; gap: 10px; }
  .stat-card { padding: 14px 16px; }

  /* Login */
  .login-card { padding: 28px 20px; }
  .login-logo-icon { width: 48px; height: 48px; font-size: 18px; }
  .login-logo h1 { font-size: 18px; }

  /* Cards */
  .card-header { padding: 12px 14px 10px; }
  .card-body { padding: 14px 12px; }
  .card-title { font-size: 13.5px; }

  /* Botões: touch-friendly (min 44px altura) */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }

  /* Tabelas ainda menores */
  table { font-size: 12.5px; }
  thead th { font-size: 11px; padding: 8px 10px; }
  tbody td { padding: 9px 10px; }

  /* Toolbar */
  .toolbar { padding: 12px; }

  /* Item cards já responsivos via CSS acima */
  .items-table-wrapper { border-radius: 0; }

  /* Sobrepor inline style="width:Xpx" em inputs de toolbars e formulários */
  .toolbar input[type=date] { width: auto !important; max-width: 140px !important; }
  .toolbar .search-box input { width: 100% !important; max-width: 100% !important; }
  .card { max-width: 100%; }
  form { max-width: 100%; }

  /* Page header: botões empilhados */
  .page-header .btn { min-width: 0; flex: 1 1 100%; }

  /* Vendas e dash grids já colapsados desde 768px */
  .vendas-grid, .dash-grid { gap: 16px !important; }

}

/* ============================================================
   LOJA INFANTIL — grade, busca de peças, PDV e caixa
   ============================================================ */

/* ---- CHIPS DE GRADE (tamanhos e cores) ------------------- */
.grade-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.grade-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}
.grade-chip:hover { border-color: var(--primary); color: var(--primary); }
.grade-chip input { display: none; }
.grade-chip:has(input:checked) {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

.cor-dot {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.18);
  vertical-align: -1px;
}

/* ---- BUSCA DE PEÇAS (autocomplete) ----------------------- */
.product-search-results {
  display: none;
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 60;
  max-height: 260px;
  overflow-y: auto;
}
.product-search-results.open { display: block; }

.product-result {
  padding: 9px 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.product-result:last-child { border-bottom: none; }
.product-result:hover,
.product-result.active { background: var(--primary-bg); }
.product-result-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.product-result-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.product-result-empty { padding: 12px 13px; font-size: 12.5px; color: var(--text-muted); text-align: center; }
.product-result.sem-estoque { opacity: .55; }
.product-result.sem-estoque .product-result-meta { color: var(--danger); }

/* ---- PDV ------------------------------------------------- */
.pdv-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 18px;
  align-items: start;
}

.pdv-busca-wrap { position: relative; }
.pdv-busca-wrap input {
  font-size: 16px;
  padding: 14px 16px 14px 42px;
  font-weight: 500;
}
.pdv-busca-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.pdv-cart { min-height: 220px; }
.pdv-cart-item {
  display: grid;
  grid-template-columns: 1fr 78px 104px 104px 36px;
  gap: 10px;
  align-items: center;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}
.pdv-cart-item:last-child { border-bottom: none; }
.pdv-cart-item:hover { background: #FBF7F0; }
.pdv-item-nome { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.pdv-item-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.pdv-cart-item input { padding: 7px 9px; font-size: 13px; text-align: right; }
.pdv-cart-item input.qtd { text-align: center; }
.pdv-item-subtotal { font-size: 14px; font-weight: 700; color: var(--text-primary); text-align: right; }

.pdv-cart-head {
  display: grid;
  grid-template-columns: 1fr 78px 104px 104px 36px;
  gap: 10px;
  padding: 9px 14px;
  background: #FBF7F0;
  border-bottom: 1.5px solid var(--border);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
.pdv-cart-head span:nth-child(n+2) { text-align: center; }

.pdv-resumo { position: sticky; top: 16px; }
.pdv-linha {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  font-size: 13.5px;
  color: var(--text-secondary);
}
.pdv-linha strong { color: var(--text-primary); font-weight: 600; }
.pdv-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 14px 0 6px;
  border-top: 2px solid var(--border);
  margin-top: 8px;
}
.pdv-total-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .05em; }
.pdv-total-valor { font-size: 28px; font-weight: 800; color: var(--teal); letter-spacing: -0.5px; }

.pdv-pagamentos { display: flex; flex-direction: column; gap: 8px; }
.pdv-pagamento-linha {
  display: grid;
  grid-template-columns: 1fr 110px 32px;
  gap: 8px;
  align-items: center;
}
.pdv-pagamento-linha select,
.pdv-pagamento-linha input { padding: 8px 10px; font-size: 13px; }

.pdv-troco {
  background: var(--success-bg);
  border: 1px solid #B9DCCF;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13.5px;
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  color: #1F5C4A;
}
.pdv-troco.negativo { background: var(--danger-bg); border-color: #F0C4C2; color: #8E3A36; }

.pdv-empty {
  padding: 42px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}
.pdv-empty svg { width: 40px; height: 40px; opacity: .35; margin-bottom: 10px; }

/* ---- CAIXA ----------------------------------------------- */
.caixa-hero {
  background: linear-gradient(135deg, var(--teal-dark), var(--teal));
  color: #fff;
  border-radius: var(--radius-xl);
  padding: 22px 24px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.caixa-hero-label { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; opacity: .8; }
.caixa-hero-valor { font-size: 32px; font-weight: 800; letter-spacing: -0.5px; margin-top: 2px; }
.caixa-hero-sub { font-size: 12.5px; opacity: .85; margin-top: 4px; }
.caixa-hero .btn { flex-shrink: 0; }

.caixa-formas { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.caixa-forma {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
}
.caixa-forma-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.caixa-forma-valor { font-size: 19px; font-weight: 700; color: var(--text-primary); margin-top: 4px; }

/* ---- RELATÓRIOS ------------------------------------------ */
.rel-presets { display: flex; gap: 6px; flex-wrap: wrap; }

.rel-bars { display: flex; flex-direction: column; gap: 9px; }
.rel-bar-row { display: grid; grid-template-columns: 116px 1fr 108px; gap: 10px; align-items: center; font-size: 12.5px; }
.rel-bar-track { background: #F0EAE0; border-radius: 999px; height: 20px; overflow: hidden; }
.rel-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 999px;
  min-width: 2px;
  transition: width .4s ease;
}
.rel-bar-fill.teal { background: linear-gradient(90deg, var(--teal-dark), var(--teal-light)); }
.rel-bar-valor { text-align: right; font-weight: 600; color: var(--text-primary); }

/* ---- RESPONSIVO ------------------------------------------ */
@media (max-width: 1100px) {
  .pdv-layout { grid-template-columns: 1fr; }
  .pdv-resumo { position: static; }
}

@media (max-width: 720px) {
  .pdv-cart-head { display: none; }
  .pdv-cart-item {
    grid-template-columns: 1fr 64px;
    grid-template-areas:
      "nome remover"
      "qtd  preco"
      "sub  sub";
    row-gap: 8px;
  }
  .pdv-cart-item .celula-nome     { grid-area: nome; }
  .pdv-cart-item .celula-qtd      { grid-area: qtd; }
  .pdv-cart-item .celula-preco    { grid-area: preco; }
  .pdv-cart-item .celula-subtotal { grid-area: sub; text-align: right; }
  .pdv-cart-item .celula-remover  { grid-area: remover; justify-self: end; }
  .pdv-total-valor { font-size: 24px; }
  .rel-bar-row { grid-template-columns: 90px 1fr 92px; font-size: 11.5px; }
  .caixa-hero-valor { font-size: 26px; }
}

/* ---- SELETOR VENDA / ORÇAMENTO --------------------------- */
.modo-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.modo-opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 16px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  font-family: inherit;
}
.modo-opt svg { width: 18px; height: 18px; color: var(--text-muted); }
.modo-opt span  { font-size: 14.5px; font-weight: 700; color: var(--text-primary); }
.modo-opt small { font-size: 11.5px; color: var(--text-muted); line-height: 1.35; }
.modo-opt:hover { border-color: var(--primary-light); }

.modo-opt.active {
  border-color: var(--primary);
  background: var(--primary-bg);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.modo-opt.active svg   { color: var(--primary-dark); }
.modo-opt.active small { color: var(--text-secondary); }

/* No modo orçamento o total deixa de ser "a receber" */
body.modo-orcamento .pdv-total-valor { color: var(--primary-dark); }

@media (max-width: 620px) {
  .modo-switch { grid-template-columns: 1fr; gap: 8px; }
  .modo-opt { flex-direction: row; align-items: center; gap: 10px; padding: 10px 14px; }
  .modo-opt small { display: none; }
}

/* ============================================================
   MOBILE — refinamento
   ============================================================ */

/* ---- Utilitários de grid que colapsam ---------------------
   Substituem os grid-template-columns inline, que media query
   não consegue sobrescrever sem !important.                   */
.grid-2       { display: grid; grid-template-columns: 1fr 1fr;     gap: 18px; align-items: start; }
.grid-3       { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; align-items: start; }
.grid-principal { display: grid; grid-template-columns: 1.4fr 1fr;  gap: 18px; align-items: start; }
.grid-detalhe   { display: grid; grid-template-columns: 1fr 280px;   gap: 24px; align-items: start; }
.grid-2 > *, .grid-3 > *, .grid-principal > *, .grid-detalhe > * { min-width: 0; }

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

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-principal, .grid-detalhe {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

/* ---- Dica de rolagem nas tabelas largas -------------------- */
.table-wrapper { position: relative; }

@media (max-width: 1024px) {
  /* Sombra à direita indica que há mais conteúdo para o lado */
  .table-wrapper.tem-scroll::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 28px;
    pointer-events: none;
    background: linear-gradient(to right, rgba(255,255,255,0), rgba(19,51,58,.10));
  }
}

/* ============================================================
   TABELAS EMPILHADAS NO CELULAR
   Cada linha vira um cartão e cada célula mostra seu rótulo,
   lido do atributo data-label. Evita o scroll horizontal em
   tabelas de 8 e 9 colunas.
   ============================================================ */
@media (max-width: 640px) {
  .table-wrapper { overflow-x: visible; }
  .table-wrapper.tem-scroll::after { display: none; }

  .table-wrapper table,
  .table-wrapper tbody,
  .table-wrapper tr,
  .table-wrapper td { display: block; width: 100%; }

  .table-wrapper thead { display: none; }

  .table-wrapper tbody tr {
    background: var(--card-bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    margin: 0 0 10px;
    padding: 6px 0;
    box-shadow: var(--shadow-xs);
    overflow: hidden;
  }
  .table-wrapper tbody tr:hover { background: var(--card-bg); }
  .table-wrapper tbody tr:last-child { margin-bottom: 4px; }

  .table-wrapper tbody td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    padding: 7px 14px;
    border: none;
    text-align: right;
    font-size: 13px;
  }

  /* Rótulo da coluna, vindo do data-label */
  .table-wrapper tbody td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    text-align: left;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    white-space: nowrap;
  }
  .table-wrapper tbody td:not([data-label])::before { display: none; }

  /* Célula sem rótulo ocupa a linha inteira */
  .table-wrapper tbody td[data-label=""] { justify-content: flex-end; }

  /* Primeira célula destacada como título do cartão */
  .table-wrapper tbody td.celula-principal {
    display: block;
    text-align: left;
    background: #FBF7F0;
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
    margin-bottom: 4px;
    font-size: 14px;
  }
  .table-wrapper tbody td.celula-principal::before { display: none; }

  /* Estado vazio e linhas com colspan não viram cartão */
  .table-wrapper tbody td[colspan] {
    display: block;
    text-align: center;
    padding: 0;
  }
  .table-wrapper tbody td[colspan]::before { display: none; }
  .table-wrapper tbody tr:has(td[colspan]) {
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 0;
  }

  /* Ações: botões lado a lado, alvo de toque confortável */
  .table-wrapper tbody td .table-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
  }
  .table-wrapper tbody td .table-actions .btn {
    padding: 8px 14px;
    font-size: 12.5px;
    min-height: 36px;
  }

  /* Campo de reposição dentro da tabela */
  .table-wrapper tbody td input[type="number"] {
    width: 100% !important;
    max-width: 140px;
    min-height: 40px;
  }
}

/* ============================================================
   PDV NO CELULAR
   ============================================================ */

/* Barra fixa com o total e atalho para o pagamento */
.pdv-bar-mobile { display: none; }

@media (max-width: 1100px) {
  .pdv-bar-mobile {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 200;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: var(--card-bg);
    border-top: 1.5px solid var(--border);
    box-shadow: 0 -4px 16px rgba(19,51,58,.10);
  }
  .pdv-bar-info  { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
  .pdv-bar-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
  .pdv-bar-total { font-size: 21px; font-weight: 800; color: var(--teal); letter-spacing: -0.4px; }
  .pdv-bar-mobile .btn { flex-shrink: 0; min-height: 44px; padding: 11px 18px; }

  /* Espaço para a barra não cobrir o conteúdo */
  body.tem-pdv-bar .content { padding-bottom: 96px; }

  /* Busca de peças acompanha a rolagem */
  .pdv-busca-sticky {
    position: sticky;
    top: 0;
    z-index: 90;
    background: var(--body-bg);
    margin: -16px -14px 0;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  .pdv-busca-sticky .card { margin: 0; box-shadow: var(--shadow-sm); }
}

@media (max-width: 720px) {
  /* Resultados da busca ocupam mais da tela, com toque maior */
  .product-search-results { max-height: 52vh; }
  .product-result { padding: 12px 14px; }
  .product-result-name { font-size: 14px; }

  /* Itens do carrinho: campos maiores para dedo */
  .pdv-cart-item input { min-height: 40px; font-size: 15px; }
  .pdv-cart-item { padding: 12px 14px; }
  .pdv-item-nome { font-size: 14px; }

  .pdv-cart-item .celula-remover .btn-icon-danger {
    width: 38px; height: 38px;
    font-size: 20px;
    display: flex; align-items: center; justify-content: center;
  }

  /* Pagamento: forma em cima, valor embaixo */
  .pdv-pagamento-linha {
    grid-template-columns: 1fr 44px;
    grid-template-areas: "forma remover" "valor valor" "parcelas parcelas";
    gap: 8px;
  }
  .pdv-pagamento-linha > select:first-child { grid-area: forma; }
  .pdv-pagamento-linha > input             { grid-area: valor; text-align: left; }
  .pdv-pagamento-linha > button,
  .pdv-pagamento-linha > span              { grid-area: remover; }
  .pdv-pagamento-linha select,
  .pdv-pagamento-linha input               { min-height: 44px; }
}

/* ============================================================
   MODAIS COMO FOLHA INFERIOR NO CELULAR
   ============================================================ */
@media (max-width: 640px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    width: 100%;
    max-width: 100% !important;
    margin: 0;
    max-height: 92vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 20px 18px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
  /* Alça visual indicando que arrasta/fecha */
  .modal::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    border-radius: 99px;
    background: var(--border);
    margin: -6px auto 14px;
  }
  .modal-title { font-size: 16px; }
  .modal-actions { flex-direction: column-reverse; gap: 8px; }
  .modal-actions .btn { width: 100%; justify-content: center; min-height: 44px; }
}

/* ============================================================
   AJUSTES FINAIS DE TOQUE E LEGIBILIDADE
   ============================================================ */
@media (max-width: 768px) {
  /* Alvo mínimo de toque em botões e campos */
  .btn { min-height: 42px; }
  .btn-sm { min-height: 34px; }
  input, select, textarea { min-height: 44px; }
  textarea { min-height: 76px; }

  /* Chips de filtro roláveis em vez de quebrar linha */
  .chips, .rel-presets {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 7px;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .chips::-webkit-scrollbar, .rel-presets::-webkit-scrollbar { display: none; }
  .chip { flex-shrink: 0; min-height: 34px; padding: 7px 14px; }

  /* Grade de chips (tamanhos e cores) com alvo maior */
  .grade-chip { min-height: 38px; padding: 8px 13px; font-size: 13px; }

  /* Caixa */
  .caixa-hero { padding: 18px; border-radius: var(--radius-lg); }
  .caixa-hero > div:last-child { width: 100%; display: flex; gap: 8px; }
  .caixa-hero .btn { flex: 1 1 auto; justify-content: center; }
  .caixa-formas { grid-template-columns: 1fr 1fr; gap: 8px; }
  .caixa-forma { padding: 12px; }
  .caixa-forma-valor { font-size: 16px; }

  /* Relatórios: rótulo do período acima da barra */
  .rel-bar-row { grid-template-columns: 1fr; gap: 3px; padding-bottom: 8px; }
  .rel-bar-row > span:first-child { font-weight: 600; color: var(--text-secondary); }
  .rel-bar-valor { text-align: left; }
  .rel-bar-track { height: 16px; }

  /* Seletor de modo do PDV */
  .modo-switch { position: relative; z-index: 1; }
}

@media (max-width: 420px) {
  .stat-value { font-size: 17px; }
  .pdv-total-valor { font-size: 22px; }
  .caixa-hero-valor { font-size: 24px; }
  .caixa-formas { grid-template-columns: 1fr; }
  .page-header .btn { min-width: 0; flex: 1 1 100%; }
}

/* Telas baixas na horizontal: modal não pode passar da tela */
@media (max-height: 520px) {
  .modal { max-height: 96vh; overflow-y: auto; }
}
