/* ==========================================================================
   BatVancecontrol v2 - Style
   Sistema profissional de gestão de sucata e baterias (CONAMA 401/2008)
   ========================================================================== */

/* --------------------------------------------- Design tokens ------------ */
:root {
  --bg-primary: #0E1117;
  --bg-sidebar: #0E1117;
  --bg-card: #ffffff;
  --bg-page: #fafafa;
  --text-primary: #18181b;
  --text-secondary: #71717a;
  --text-muted: #a1a1aa;
  --border-color: #e4e4e7;
  --accent-yellow: #eab308;
  --accent-yellow-hover: #ca8a04;
  --accent-amber: #f59e0b;
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-zinc: #71717a;
  --radius: 0.625rem;
  --radius-lg: 1rem;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.03), 0 4px 12px -2px rgba(0,0,0,0.04);
  --shadow-card-hover: 0 4px 8px rgba(0,0,0,0.04), 0 12px 28px -8px rgba(0,0,0,0.1);
  --shadow-modal: 0 24px 64px -12px rgba(0,0,0,0.35), 0 0 0 1px rgba(0,0,0,0.05);
}

/* --------------------------------------------- Reset --------------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #fafafa 0%, #f4f4f5 100%);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* --------------------------------------------- Scrollbar ----------------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #d4d4d8;
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: #a1a1aa;
  border: 2px solid transparent;
  background-clip: content-box;
}

/* --------------------------------------------- Layout -------------------- */
#app { min-height: 100vh; }

.sidebar-bg {
  background: linear-gradient(180deg, #0E1117 0%, #151a23 100%);
  border-right: 1px solid #1f2733;
}
@media(max-width:768px){
  #sidebar {
    position:fixed;z-index:50;top:0;left:0;height:100vh;
    transform:translateX(-100%);
    transition:transform 0.3s ease;
    box-shadow:2px 0 12px rgba(0,0,0,0.3);
  }
  #sidebar.open { transform:translateX(0); }
}

header {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #ececee;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

/* --------------------------------------------- Inputs -------------------- */
.input-base {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid #e4e4e7;
  border-radius: var(--radius);
  font-size: 0.875rem;
  outline: none;
  transition: all 0.18s ease;
  background: #fdfdfd;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
  color: var(--text-primary);
}

.input-base:hover { border-color: #d4d4d8; }

.input-base:focus {
  border-color: var(--accent-yellow);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.15), inset 0 1px 2px rgba(0,0,0,0.02);
}

.input-base::placeholder { color: #a1a1aa; }
.input-base:disabled { background: #f4f4f5; color: #a1a1aa; cursor: not-allowed; }

.select-base {
  width: 100%;
  padding: 0.5rem 0.5rem;
  border: 1.5px solid #e4e4e7;
  border-radius: var(--radius);
  font-size: 0.875rem;
  outline: none;
  transition: all 0.18s ease;
  background: #fdfdfd;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
  color: var(--text-primary);
}

.select-base:hover { border-color: #d4d4d8; }

.select-base:focus {
  border-color: var(--accent-yellow);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.15), inset 0 1px 2px rgba(0,0,0,0.02);
}

.label-base {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  color: #71717a;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* --------------------------------------------- Tables -------------------- */
.table-container {
  overflow-x: auto;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.75rem;
}

th {
  text-align: left;
  padding: 0.625rem 0.75rem;
  color: #8b8b93;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 0.625rem;
  white-space: nowrap;
  background: #fafafa;
  border-bottom: 1px solid #e9e9ec;
}

td {
  padding: 0.75rem;
  border-bottom: 1px solid #f4f4f5;
  vertical-align: middle;
}

tbody tr { transition: background 0.15s ease; }
tbody tr:hover td { background: #fafafb; }
tbody tr:last-child td { border-bottom: none; }

/* --------------------------------------------- Badges -------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1875rem 0.625rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  border-radius: 9999px;
  white-space: nowrap;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.7);
}

.badge::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  margin-right: 0.375rem;
  vertical-align: middle;
  background: currentColor;
}

.badge-entrada-nova   { background: #ecfdf5; color: #065f46; }
.badge-entrada-sucata { background: #fffbeb; color: #92400e; }
.badge-saida-venda    { background: #eff6ff; color: #1e40af; }
.badge-saida-sucata   { background: #fff1f2; color: #9f1239; }

/* --------------------------------------------- Buttons ------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.6875rem;
}

.btn-xs {
  padding: 0.25rem 0.5rem;
  font-size: 0.625rem;
}

.btn-primary {
  background: linear-gradient(135deg, #facc15, #eab308);
  color: #1c1917;
  box-shadow: 0 1px 2px rgba(234, 179, 8, 0.3), 0 4px 12px -2px rgba(234, 179, 8, 0.4);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #fde047, #ca8a04);
  box-shadow: 0 2px 4px rgba(234, 179, 8, 0.4), 0 8px 20px -4px rgba(234, 179, 8, 0.5);
}

.btn-secondary {
  background: #f4f4f5;
  color: #3f3f46;
  border: 1px solid var(--border-color);
}
.btn-secondary:hover { background: #e4e4e7; }

.btn-success {
  background: linear-gradient(135deg, #34d399, #10b981);
  color: white;
  box-shadow: 0 1px 2px rgba(16, 185, 129, 0.3), 0 4px 12px -2px rgba(16, 185, 129, 0.4);
}
.btn-success:hover { background: linear-gradient(135deg, #6ee7b7, #059669); }

.btn-amber {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: white;
  box-shadow: 0 1px 2px rgba(245, 158, 11, 0.3), 0 4px 12px -2px rgba(245, 158, 11, 0.4);
}
.btn-amber:hover { background: linear-gradient(135deg, #fcd34d, #d97706); }

.btn-blue {
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
  color: white;
  box-shadow: 0 1px 2px rgba(59, 130, 246, 0.3), 0 4px 12px -2px rgba(59, 130, 246, 0.4);
}
.btn-blue:hover { background: linear-gradient(135deg, #93c5fd, #2563eb); }

.btn-rose {
  background: linear-gradient(135deg, #fb7185, #f43f5e);
  color: white;
  box-shadow: 0 1px 2px rgba(244, 63, 94, 0.3), 0 4px 12px -2px rgba(244, 63, 94, 0.4);
}
.btn-rose:hover { background: linear-gradient(135deg, #fda4af, #e11d48); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  box-shadow: none;
}
.btn-ghost:hover { background: #f4f4f5; color: var(--text-primary); }

.btn-icon {
  padding: 0.375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon svg, .btn-icon i { width: 14px; height: 14px; }

/* --------------------------------------------- Cards --------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid rgba(228, 228, 231, 0.9);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
}

.card-header {
  padding: 1.1rem 1.25rem;
  background: linear-gradient(180deg, #fff 0%, #fcfcfd 100%);
  border-bottom: 1px solid var(--border-color);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.card-body {
  padding: 1.25rem;
}

/* --------------------------------------------- Metric cards -------------- */
.metric-card {
  position: relative;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(228, 228, 231, 0.9);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: all 0.25s ease;
}

.metric-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-yellow), #fbbf24, #f59e0b);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.metric-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.05), 0 16px 40px -12px rgba(0,0,0,0.12);
}

.metric-card:hover::after { opacity: 1; }

.metric-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, #fefce8, #fef3c7);
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.8);
}

.metric-icon svg, .metric-icon i { width: 18px; height: 18px; }

.metric-value {
  font-size: 1.75rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 0.25rem;
  background: linear-gradient(135deg, #18181b, #3f3f46);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.metric-label {
  font-size: 0.6875rem;
  font-weight: 700;
  color: #71717a;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.metric-sub {
  font-size: 0.6875rem;
  color: #a1a1aa;
  margin-top: 0.125rem;
}

/* --------------------------------------------- Nav items ----------------- */
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #a1a1aa;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
  transform: translateX(2px);
}

.nav-item.active {
  background: linear-gradient(135deg, #facc15, #eab308);
  color: #1c1917;
  font-weight: 700;
  box-shadow: 0 4px 12px -2px rgba(234, 179, 8, 0.4);
}

.nav-item.active svg { color: #1c1917; }
.nav-item svg, .nav-item i { width: 16px; height: 16px; flex-shrink: 0; }

/* --------------------------------------------- Quick actions ------------- */
.quick-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 0.5rem;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.quick-btn:hover {
  background: rgba(255,255,255,0.06);
  color: #facc15 !important;
  transform: translateX(2px);
}

/* --------------------------------------------- Modals -------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 10, 15, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 40;
  animation: fadeIn 0.15s ease;
}

.modal-content {
  background: white;
  border-radius: 1.25rem;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 30rem;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-content-lg { max-width: 46rem; }
.modal-content-xl { max-width: 56rem; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  border-radius: 1.25rem 1.25rem 0 0;
  background: linear-gradient(135deg, #fefce8, #fef9c3);
}

.modal-header-yellow  { background: linear-gradient(135deg, #fefce8, #fef9c3); border-color: #fde047; }
.modal-header-amber   { background: linear-gradient(135deg, #fffbeb, #fef3c7); border-color: #fcd34d; }
.modal-header-blue    { background: linear-gradient(135deg, #eff6ff, #dbeafe); border-color: #bfdbfe; }
.modal-header-rose    { background: linear-gradient(135deg, #fff1f2, #ffe4e6); border-color: #fecdd3; }
.modal-header-zinc    { background: linear-gradient(135deg, #f4f4f5, #fafafa); border-color: var(--border-color); }
.modal-header-emerald { background: linear-gradient(135deg, #ecfdf5, #d1fae5); border-color: #a7f3d0; }

.modal-title { font-weight: 800; font-size: 0.9375rem; color: var(--text-primary); }
.modal-subtitle { font-size: 0.75rem; color: #71717a; margin-top: 0.125rem; }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --------------------------------------------- Toast --------------------- */
.toast {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border-radius: 0.875rem;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 12px 32px -4px rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.08);
  animation: slideInRight 0.3s ease;
  margin-bottom: 0.5rem;
}

.toast-success {
  background: linear-gradient(135deg, #27272a, #18181b);
  color: #fff;
}

.toast-success svg { color: #4ade80; }

.toast-error {
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  color: #fff;
}

.toast-error svg { color: #fff; }

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

/* --------------------------------------------- Form grid ----------------- */
.form-grid {
  display: grid;
  gap: 0.875rem;
}

.form-grid-1 { grid-template-columns: 1fr; }
.form-grid-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 640px) {
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}

/* --------------------------------------------- Chips --------------------- */
.chip-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chip {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.chip-active-yellow {
  border-color: #facc15;
  background: linear-gradient(135deg, #fefce8, #fef3c7);
  color: #854d0e;
  box-shadow: 0 2px 8px -2px rgba(234, 179, 8, 0.35);
}

.chip-inactive {
  border-color: var(--border-color);
  color: var(--text-secondary);
}

.chip-inactive:hover {
  border-color: #a1a1aa;
  color: var(--text-primary);
}

/* --------------------------------------------- Itens de venda/compra ----- */
.item-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.item-row .item-prod { flex: 1; }
.item-row .item-qty,
.item-row .item-price { flex-shrink: 0; }

/* Bloco de item em card (venda/compra) */
.item-card {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding: 0.875rem;
  margin-bottom: 0.75rem;
  background: #fafafa;
  border: 1px solid #e9e9ec;
  border-radius: var(--radius-lg);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.item-card:focus-within {
  border-color: var(--accent-yellow);
  box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.12);
}

.item-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.item-card-fields {
  display: grid;
  grid-template-columns: 96px 64px 1fr 120px;
  gap: 0.5rem;
  align-items: end;
}

.item-subtotal-val {
  display: block;
  font-size: 0.8125rem;
  font-weight: 800;
  color: var(--text-primary);
  text-align: right;
  padding-bottom: 0.5rem;
  white-space: nowrap;
}

/* Seletor de produto com busca (picker) */
.prod-picker { position: relative; }

.prod-picker-input { padding-right: 2.25rem; }

.prod-picker-clear {
  position: absolute;
  right: 0.375rem;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.125rem;
  border: none;
  background: transparent;
  color: #a1a1aa;
  cursor: pointer;
  border-radius: 9999px;
  display: none;
}

.prod-picker-clear:hover { color: var(--accent-rose); background: #fff1f2; }

.prod-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card-hover);
}

.prod-dropdown.open { display: block; }

.prod-drop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  cursor: pointer;
  border-bottom: 1px solid #f4f4f5;
  transition: background 0.12s ease;
}

.prod-drop-item:last-child { border-bottom: none; }
.prod-drop-item:hover, .prod-drop-item.is-highlight { background: #fffbeb; }

.prod-drop-main {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.prod-drop-name {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prod-drop-sub {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.prod-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.625rem;
  color: var(--text-muted);
  background: #f4f4f5;
  padding: 0.0625rem 0.375rem;
  border-radius: 0.25rem;
}

.prod-model-pill {
  font-size: 0.625rem;
  font-weight: 700;
  color: #1e40af;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  padding: 0.0625rem 0.4375rem;
  border-radius: 9999px;
  white-space: nowrap;
}

.prod-stock {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.prod-stock.ok { color: #047857; }
.prod-stock.low { color: #b91c1c; }

.prod-drop-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.125rem;
  flex-shrink: 0;
}

.prod-price {
  font-size: 0.8125rem;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
}

.prod-drop-empty {
  padding: 1rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.prod-selected {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #ecfdf5;
  border: 1px solid #d1fae5;
  border-radius: var(--radius);
}

.prod-selected.show { display: flex; }

.prod-selected-name {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #065f46;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --------------------------------------------- Empty states -------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
  color: #a1a1aa;
}

.empty-state svg {
  width: 40px;
  height: 40px;
  opacity: 0.35;
  margin-bottom: 0.75rem;
}

/* --------------------------------------------- Error banner -------------- */
#runtime-error {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  padding: 0.5rem 1rem;
  background: linear-gradient(90deg, #f43f5e, #e11d48);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

#runtime-error.error-shown { display: block; }

/* ==========================================================================
   UTILIDADES (classes usadas pelo app.js e index.html)
   ========================================================================== */

/* Layout */
.flex { display: flex; }
.flex-1 { flex: 1 1 0%; }
.flex-2 { flex: 2 1 0%; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-shrink-0 { flex-shrink: 0; }
.grid { display: grid; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-2\.5 { gap: 0.625rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.space-y-0\.5 > * + * { margin-top: 0.125rem; }

/* Spacing */
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-1\.5 { margin-bottom: 0.375rem; }
.ml-2 { margin-left: 0.5rem; }
.mr-2 { margin-right: 0.5rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-0 { padding: 0; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-5 { padding-top: 1.25rem; padding-bottom: 1.25rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.py-10 { padding-top: 2.5rem; padding-bottom: 2.5rem; }

/* Width / Height */
.w-full { width: 100%; }
.w-4 { width: 1rem; }
.w-8 { width: 2rem; }
.w-12 { width: 3rem; }
.w-56 { width: 14rem; }
.h-4 { height: 1rem; }
.h-8 { height: 2rem; }
.h-12 { height: 3rem; }
.min-h-screen { min-height: 100vh; }
.max-w-xs { max-width: 20rem; }
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.max-w-24 { max-width: 6rem; }
.max-w-28 { max-width: 7rem; }
.max-w-32 { max-width: 8rem; }
.max-w-48 { max-width: 12rem; }

/* Typography */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.font-black { font-weight: 900; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.font-mono { font-family: ui-monospace, SFMono-Regular, monospace; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.text-\[10px\] { font-size: 10px; }
.leading-none { line-height: 1; }
.leading-tight { line-height: 1.25; }
.uppercase { text-transform: uppercase; }
.tracking-wide { letter-spacing: 0.025em; }
.tracking-wider { letter-spacing: 0.05em; }
.italic { font-style: italic; }
.whitespace-nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Colors - backgrounds */
.bg-white { background: #fff; }
.bg-zinc-50 { background: #fafafa; }
.bg-yellow-50 { background: #fefce8; }
.bg-yellow-400 { background: #facc15; }
.bg-amber-50 { background: #fffbeb; }
.bg-amber-500 { background: #f59e0b; }
.bg-blue-50 { background: #eff6ff; }
.bg-emerald-50 { background: #ecfdf5; }
.bg-rose-50 { background: #fff1f2; }

/* Colors - text */
.text-white { color: #fff; }
.text-zinc-900 { color: #18181b; }
.text-zinc-700 { color: #3f3f46; }
.text-zinc-600 { color: #52525b; }
.text-zinc-500 { color: #71717a; }
.text-zinc-400 { color: #a1a1aa; }
.text-zinc-300 { color: #d4d4d8; }
.text-zinc-200 { color: #e4e4e7; }
.text-yellow-800 { color: #854d0e; }
.text-amber-800 { color: #92400e; }
.text-amber-700 { color: #b45309; }
.text-blue-800 { color: #1e40af; }
.text-emerald-800 { color: #065f46; }
.text-emerald-700 { color: #047857; }
.text-rose-800 { color: #9f1239; }
.text-rose-700 { color: #be123c; }
.text-rose-600 { color: #e11d48; }

/* Borders */
.border { border: 1px solid var(--border-color); }
.border-t { border-top: 1px solid var(--border-color); }
.border-b { border-bottom: 1px solid var(--border-color); }
.border-zinc-200 { border-color: #e4e4e7; }
.border-zinc-800 { border-color: #27272a; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }

/* Position / Misc */
.fixed { position: fixed; }
.absolute { position: absolute; }
.relative { position: relative; }
.inset-0 { inset: 0; }
.left-3 { left: 0.75rem; }
.top-1\/2 { top: 50%; }
.-translate-y-1\/2 { transform: translateY(-50%); }
.pl-8 { padding-left: 2rem; }
.bottom-5 { bottom: 1.25rem; }
.right-5 { right: 1.25rem; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }
.overflow-auto { overflow: auto; }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.opacity-0 { opacity: 0; }
.opacity-100 { opacity: 1; }
.transition-opacity { transition: opacity 0.15s ease; }
.transition-all { transition: all 0.15s ease; }
.transition-colors { transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease; }
.group:hover .group-hover\:opacity-100 { opacity: 1; }

/* Hover states usadas pelo index.html */
.hover\:bg-amber-600:hover { background: #d97706; }
.hover\:bg-zinc-800:hover { background: #27272a; }
.hover\:text-white:hover { color: #fff; }

/* ==========================================================================
   IMPRESSÃO / CUPONS / ETIQUETAS
   ========================================================================== */

#print-area { display: none; }

@media print {
  @page { size: landscape; margin: 10mm; }

  #app, #modals, #toast-container, #runtime-error { display: none !important; }
  #print-area { display: block !important; }
  #print-area * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  thead { display: table-header-group; }
  tr { page-break-inside: avoid; }
  h1, h2, h3 { color: inherit; }
  .no-print { display: none !important; }
  .print-only { display: block !important; }
  body { background: white; }
  .btn, .btn-icon { display: none !important; }
  .btn { background: #f4f4f5 !important; color: #18181b !important; border: 1px solid #d4d4d8 !important; }
  .card { border: none; box-shadow: none; }
}

/* Cupom não fiscal (A4 / preview) */
.print-coupon {
  font-family: 'Courier New', Courier, monospace;
  color: #000;
  background: #fff;
  margin: 0 auto;
  font-size: 12px;
  line-height: 1.35;
  padding: 4mm 2mm;
}
.print-coupon .cp-line { white-space: pre-wrap; }
.print-coupon .cp-c { text-align: center; }
.print-coupon .cp-r { text-align: right; }
.print-coupon .cp-l { text-align: left; }
.print-coupon .cp-b { font-weight: 700; }
.print-coupon .cp-dash { letter-spacing: 1px; }
.print-coupon .cp-title { font-weight: 700; font-size: 13px; }
.print-coupon .cp-total { font-weight: 700; font-size: 14px; }
.print-coupon svg { display: block; margin: 1mm auto; }

/* Cupom fiscal (preview em tela) */
.fiscal-preview {
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  line-height: 1.35;
  background: #fff;
  color: #000;
  padding: 8px;
  white-space: pre-wrap;
  max-height: 60vh;
  overflow: auto;
}

/* Etiquetas (folha A4 / preview) */
.labelsheet { display: flex; flex-wrap: wrap; align-items: flex-start; }
.label {
  border: 1px dashed #b9b9b9;
  box-sizing: border-box;
  margin: 1.5mm;
  overflow: hidden;
  page-break-inside: avoid;
  break-inside: avoid;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8mm;
  text-align: center;
  padding: 1mm;
}
.label .lb-loja { font-weight: 700; font-size: 2.6mm; }
.label .lb-nome { font-size: 2.4mm; }
.label .lb-preco { font-weight: 800; font-size: 3.4mm; }
.label .lb-cod { font-size: 2mm; }
.label .lb-data { font-size: 1.8mm; color: #333; }
.label svg { max-width: 95%; }

/* Checkbox inline (configurações de impressora) */
.check-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #3f3f46;
  cursor: pointer;
  user-select: none;
}
.check-inline input[type="checkbox"] { width: 16px; height: 16px; accent-color: #f59e0b; cursor: pointer; }

/* Seções da configuração de impressoras */
.printer-group {
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
  background: #fafafa;
}
.printer-group h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #71717a;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.printer-group h4 svg { width: 14px; height: 14px; }

/* Prévia de etiqueta no modal */
.label-preview-wrap {
  display: flex;
  justify-content: center;
  padding: 8px;
  background: #f4f4f5;
  border-radius: 8px;
  margin-top: 8px;
}
.label-preview-wrap .label { border-color: #71717a; }

/* ==========================================================================
   RESPONSIVIDADE
   ========================================================================== */
@media (max-width: 640px) {
  #sidebar { width: 4rem !important; }
  #sidebar .px-4 { padding-left: 0.5rem; padding-right: 0.5rem; }
  #sidebar .text-sm, #sidebar .text-xs, #sidebar .text-zinc-600, #sidebar .text-zinc-700 { display: none; }
  #quick-actions { display: none; }
}

/* ==========================================================================
   SYNC BADGE
   ========================================================================== */
.sync-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}
.sync-badge.online { background: #10b981; color: #fff; }
.sync-badge.syncing { background: #facc15; color: #1f2937; }
.sync-badge.offline { background: #fef3c7; color: #facc15; }
.sync-badge.error { background: #fca5a5; color: #fff; }

/* ==========================================================================
   CONFIG PAGE - Status Cards
   ========================================================================== */
.cfg-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.cfg-card {
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 0.625rem;
  padding: 1rem;
  text-align: center;
  transition: box-shadow 0.2s;
}
.cfg-card:hover { box-shadow: var(--shadow-card); }
.cfg-card h4 { font-size: 0.75rem; font-weight: 600; color: #71717a; margin: 0 0 0.25rem 0; text-transform: uppercase; letter-spacing: 0.05em; }
.cfg-card strong { font-size: 1.4rem; display: block; margin-bottom: 0.25rem; }
.cfg-card p { font-size: 0.7rem; color: #a1a1aa; margin: 0; }
@media(max-width:768px){ .cfg-cards{grid-template-columns:repeat(2,1fr);} }

/* ==========================================================================
   CONFIG PAGE - Card Header with Icon
   ========================================================================== */
.cfg-card-header { display: flex; align-items: center; gap: 0.5rem; }
.cfg-card-header i { color: #eab308; width: 1.2rem; height: 1.2rem; }
.cfg-card-header h3 { margin: 0; }

/* ==========================================================================
   IMPRESSÃO - Layout 2 colunas
   ========================================================================== */
.impressao-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.25rem;
  margin-top: 0.5rem;
}
.impressao-config {
  border-right: 1px solid #e4e4e7;
  padding-right: 1rem;
}
.impressao-secao {
  background: #fafafa;
  border: 1px solid #e4e4e7;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}
.impressao-secao h4 {
  font-size: 0.78rem;
  font-weight: 700;
  color: #3f3f46;
  margin: 0 0 0.5rem 0;
}
.impressao-checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 0.6rem;
}
.impressao-checks label {
  font-size: 0.72rem;
  color: #52525b;
}

/* ==========================================================================
   CUPOM PREVIEW (direita, sticky)
   ========================================================================== */
.cupom-preview-box {
  position: sticky;
  top: 1rem;
  align-self: start;
}
.cupom-preview {
  background: #e4e4e7;
  border-radius: 0.5rem;
  padding: 0.75rem;
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}
.cupom-doc {
  background: #fff;
  border: 1px solid #d4d4d8;
  border-radius: 2px;
  padding: 3mm 2mm;
  margin: 0 auto;
  font-family: 'Courier New', monospace;
  font-size: 9px;
  line-height: 1.3;
  color: #000;
}
.cupom-doc-body { word-wrap: break-word; }
.cp-line { padding: 0.1mm 0; }
.cp-c { text-align: center; }
.cp-r { text-align: right; }
.cp-l { text-align: left; }
.cp-b { font-weight: bold; }
.cp-total { font-size: 12px; font-weight: bold; border-top: 1px dashed #000; margin-top: 1mm; padding-top: 1mm; }
.cp-pequeno { font-size: 7px; color: #52525b; }

/* ==========================================================================
   RESPONSIVE IMPRESSÃO LAYOUT
   ========================================================================== */
@media(max-width:1200px){
  .impressao-layout { grid-template-columns: 1fr; }
  .impressao-config { border-right: none; padding-right: 0; }
  .cupom-preview-box { position: static; }
}

/* ==========================================================================
   LOGO THUMBNAIL
   ========================================================================== */
.logo-thumb { max-width: 90px; max-height: 60px; object-fit: contain; border: 1px solid #e4e4e7; border-radius: 6px; margin-top: 4px; }

/* ==========================================================================
   PDV - VENDAS (grid de produtos + carrinho)
   ========================================================================== */
.pdv-caixa-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 0.625rem;
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.pdv-caixa-fechado { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.pdv-caixa-ok { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }

.pdv-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 1.25rem;
  align-items: start;
}
.pdv-produtos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.75rem;
}
.pdv-produto-card {
  position: relative;
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 0.625rem;
  padding: 0.9rem;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.pdv-produto-card:hover { box-shadow: var(--shadow-card); border-color: #facc15; }
.pdv-produto-sem-estoque { opacity: 0.55; }
.pdv-produto-nome { font-size: 0.8rem; font-weight: 700; color: #18181b; line-height: 1.25; }
.pdv-produto-sub { font-size: 0.68rem; color: #a1a1aa; margin: 2px 0 6px; }
.pdv-produto-preco { font-size: 1rem; font-weight: 800; color: #eab308; margin-bottom: 4px; }
.pdv-produto-estoque { font-size: 0.68rem; color: #71717a; }
.pdv-produto-add {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  padding: 0.25rem 0.5rem;
  min-width: 2rem;
  border-radius: 0.5rem;
}

.pdv-cart {
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 0.75rem;
  padding: 1rem;
  position: sticky;
  top: 1rem;
  max-height: 78vh;
  overflow-y: auto;
}
.pdv-cart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.pdv-cart-items { min-height: 60px; }
.pdv-cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 1px solid #f4f4f5;
  background: #fafafa;
  border-radius: 0.5rem;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.4rem;
}
.pdv-cart-item-nome { font-size: 0.78rem; font-weight: 600; }
.pdv-cart-item-preco { font-size: 0.7rem; color: #71717a; }
.pdv-cart-item-acoes { display: flex; align-items: center; gap: 0.35rem; flex-shrink: 0; }
.pdv-cart-summary {
  border-top: 1px dashed #d4d4d8;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
}
.pdv-total { color: #eab308; }
.pdv-troco { font-size: 0.8rem; font-weight: 700; color: #059669; margin-top: 0.25rem; min-height: 1rem; }
.pdv-cart-dados { margin-top: 0.75rem; }

/* ==========================================================================
   PAGAMENTO - linhas de forma/valor/parcelas
   ========================================================================== */
.pagamento-row {
  border: 1px solid #e4e4e7;
  background: #fafafa;
  border-radius: 0.5rem;
  padding: 0.6rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.pag-forma { flex: 1 1 130px; }
.pag-valor { flex: 1 1 90px; }
.pag-parcelas { flex: 0 0 64px; }
.pag-venc-wrap { flex: 1 1 100%; }
.pag-taxa { flex: 1 1 100%; font-size: 0.68rem; color: #b45309; min-height: 0.9rem; }

/* ==========================================================================
   COMPRAS - resumo verde
   ========================================================================== */
.resumo-compra {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 0.625rem;
  padding: 0.75rem 1rem;
}
.resumo-compra .text-lg { color: #059669; }

@media(max-width:1200px){
  .pdv-layout { grid-template-columns: 1fr; }
  .pdv-cart { position: static; max-height: none; }
}
