﻿:root {
  --bg: #f1f3f6;
  --panel: #ffffff;
  --border: #e0e3e8;
  --text: #1c2430;
  --text-muted: #6b7684;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eaf1ff;
  --green: #16a34a;
  --green-light: #eafcf0;
  --red: #dc2626;
  --red-light: #fdeaea;
  --orange: #d97706;
  --orange-light: #fff6e8;
  --sidebar-w: 220px;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
}

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

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #000;
  color: #dbe3f2;
  display: flex;
  flex-direction: column;
  padding: 16px 10px;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px 10px;
  font-weight: 700;
  font-size: 17px;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 12px;
}

.sidebar .brand .dot { color: var(--primary); }
.sidebar .brand { padding: 0 0 12px 0; }
.sidebar .brand img { display: block; width: 100%; max-width: 140px; margin: 0 auto; height: auto; border-radius: 8px; }

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: #c4cfe3;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background .15s, color .15s;
}

.nav-btn .ic { width: 20px; text-align: center; font-size: 16px; }

.nav-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

.nav-btn.active {
  background: #e8772e;
  color: #fff;
}

.nav-group-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #5c6d94;
  padding: 14px 12px 4px 12px;
}
.nav-group-label:first-of-type { padding-top: 4px; }

.sidebar-nav {
  overflow-y: auto;
  flex: 1;
}

.sidebar-footer {
  margin-top: auto;
  padding: 10px 12px;
  font-size: 11px;
  color: #6f7fa3;
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* ---------- Main ---------- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar h1 { font-size: 19px; margin: 0; }
.topbar .clock { color: var(--text-muted); font-size: 13px; }

.view {
  flex: 1;
  overflow: auto;
  padding: 20px 24px 40px 24px;
}

.view[hidden] { display: none; }

/* ---------- Generic components ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.card h2, .card h3 { margin-top: 0; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; align-items: center; }
.grow { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eef0f4;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { background: #e3e6ec; }
.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); }

.btn-danger { background: var(--red-light); color: var(--red); border-color: #f5c6c6; }
.btn-danger:hover { background: #fbdada; }

.btn-green { background: var(--green-light); color: var(--green); border-color: #bfe9cc; }
.btn-green:hover { background: #d7f5e0; }

.btn-sm { padding: 5px 9px; font-size: 12.5px; border-radius: 6px; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.field input, .field select, .field textarea {
  padding: 9px 10px;
  border: 1px solid #cfd5de;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 4px 16px;
}

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  padding: 8px 10px;
  white-space: nowrap;
}
tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:hover { background: #f8f9fb; }
.table-wrap { overflow-x: auto; }

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
.sort-arrow { font-size: 10px; color: var(--primary); }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}
.badge-green { background: var(--green-light); color: var(--green); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-gray { background: #eef0f4; color: var(--text-muted); }
.badge-blue { background: var(--primary-light); color: var(--primary); }

.os-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.pattern-box { background: #fff; border: 1px solid var(--border); border-radius: 10px; flex-shrink: 0; margin-right: 14px; touch-action: manipulation; }
textarea { resize: vertical; }

.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mono { font-family: Consolas, "Courier New", monospace; }

.empty-state {
  text-align: center;
  padding: 40px 10px;
  color: var(--text-muted);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: #fff;
  border-radius: 12px;
  width: 520px;
  max-width: 92vw;
  max-height: 88vh;
  overflow: auto;
  padding: 20px 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal h3 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ---------- Toasts ---------- */
#toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: #1c2430;
  color: #fff;
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  min-width: 220px;
  animation: toast-in .15s ease-out;
}
.toast.success { background: #15803d; }
.toast.error { background: #b91c1c; }
.toast.info { background: #1e3a8a; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- Vendas (PDV) ---------- */
.pdv-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
  height: 100%;
}
.scan-box input {
  font-size: 20px;
  padding: 14px 16px;
  text-align: left;
  letter-spacing: .02em;
}
.cart-table td, .cart-table th { padding: 8px 8px; }
.qty-input { width: 60px; padding: 5px 6px; border: 1px solid #cfd5de; border-radius: 6px; text-align: center; }
.totais-box { border-top: 2px dashed var(--border); margin-top: 10px; padding-top: 10px; }
.totais-box .linha { display: flex; justify-content: space-between; margin-bottom: 6px; }
.totais-box .linha.total { font-size: 22px; font-weight: 800; }
.pagamento-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0; }
.pagamento-grid button {
  padding: 10px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f7f8fa;
  cursor: pointer;
  font-weight: 600;
}
.pagamento-grid button.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

.scan-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 14px 30px rgba(0,0,0,0.14);
  max-height: 300px;
  overflow-y: auto;
  z-index: 20;
}
.scan-suggestions .sg-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.scan-suggestions .sg-item:last-child { border-bottom: none; }
.scan-suggestions .sg-item:hover { background: var(--primary-light); }
.scan-suggestions .sg-nome { font-weight: 600; font-size: 13.5px; }
.scan-suggestions .sg-meta { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* ---------- Barcode ---------- */
.barcode-preview-box {
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
}

/* ---------- Print ---------- */
.print-only { display: none; }

@media print {
  body * { visibility: hidden; }
  .print-only, .print-only * { visibility: visible; }
  .print-only { display: block; position: absolute; top: 0; left: 0; width: 100%; }
}

#labels-print-area { display: flex; flex-wrap: wrap; }
.label-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
}
.label-item img { max-width: 100%; }
.label-item .label-caption { font-size: 9px; text-align: center; margin-top: 1mm; }

#receipt-print-area { font-family: Consolas, monospace; font-size: 12px; width: 280px; }
#receipt-print-area .rline { display: flex; justify-content: space-between; }
#receipt-print-area hr { border: none; border-top: 1px dashed #000; }

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #c7ccd4; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Login e marca ---------- */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: #000; }
.login-screen[hidden] { display: none; }
.login-card { background: #fff; border-radius: 14px; padding: 28px 26px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.login-brand { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.login-erro { background: var(--red-light); color: var(--red); border: 1px solid #f5c6c6; border-radius: 8px; padding: 9px 12px; margin-bottom: 12px; font-size: 13px; }
.sidebar .brand-text { font-size: 17px; font-weight: 800; color: #fff; text-align: center; padding: 6px 0 2px 0; word-break: break-word; }
.app-shell[hidden] { display: none; }

