/* Peptiva — estilos */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --line: #e7ebf3;
  --line-strong: #d6dce8;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-soft: #eef2ff;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --info: #4338ca;
  --info-soft: #eef2ff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 8px rgba(16, 24, 40, .05);
  --font: "Segoe UI", system-ui, -apple-system, "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14.5px;
}

body.modal-open { overflow: hidden; }

a { color: var(--primary); text-decoration: none; }

h1, h2, h3, p { margin: 0; }

button { font-family: inherit; }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #101a33 0%, #0d1528 100%);
  color: #c8d1e2;
  padding: 22px 14px 16px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 10px 22px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, .45);
  flex: none;
}

.brand-text {
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .2px;
}

.nav { display: flex; flex-direction: column; gap: 3px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #aab5c9;
  font-weight: 500;
  transition: background .15s, color .15s;
  position: relative;
}

.nav-link svg { flex: none; opacity: .9; }

.nav-link:hover { background: rgba(255, 255, 255, .06); color: #e7ecf5; }

.nav-link.active {
  background: rgba(99, 102, 241, .18);
  color: #fff;
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 3px;
  background: #818cf8;
}

.sidebar-bottom {
  margin-top: auto;
  padding: 16px 6px 0;
  border-top: 1px solid rgba(255, 255, 255, .08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.side-action {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .09);
  color: #c8d1e2;
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background .15s;
}

.side-action:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.side-note {
  font-size: 11.5px;
  color: #7c879c;
  padding: 2px 4px 0;
}

.content { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 32px;
  background: rgba(244, 246, 251, .86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.page-heading h1 { font-size: 21px; font-weight: 700; letter-spacing: -.2px; }
.page-heading p { color: var(--muted); font-size: 13px; margin-top: 3px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.view { padding: 26px 32px 48px; display: flex; flex-direction: column; gap: 18px; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
  line-height: 1.2;
}

.btn:focus-visible { outline: 3px solid rgba(79, 70, 229, .25); outline-offset: 1px; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .1);
}

.btn-primary:hover { background: var(--primary-600); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink-2);
}

.btn-ghost:hover { border-color: #b9c2d4; background: #fafbfe; }

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

.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }

.icon-btn {
  border: none;
  background: transparent;
  color: #98a2b3;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  transition: background .15s, color .15s;
}

.icon-btn:hover { background: var(--danger-soft); color: var(--danger); }

.link {
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.link:hover { text-decoration: underline; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.pad { padding: 16px 18px; }

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

.card-head h3 { font-size: 14.5px; font-weight: 650; }

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.stack { display: flex; flex-direction: column; gap: 18px; }

/* ---------- KPIs ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.kpi {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

.kpi-value { font-size: 24px; font-weight: 750; letter-spacing: -.4px; font-variant-numeric: tabular-nums; }

.kpi-sub { font-size: 12.5px; color: var(--muted); }

.kpi-sub.warn { color: var(--warn); font-weight: 600; }

/* ---------- Gráfico ---------- */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 150px;
  padding: 18px 18px 14px;
}

.bar-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  height: 100%;
}

.bar-track {
  flex: 1;
  width: 100%;
  max-width: 38px;
  display: flex;
  align-items: flex-end;
  border-radius: 7px;
  background: #f2f4f9;
  overflow: hidden;
}

.bar-fill {
  width: 100%;
  border-radius: 7px;
  background: linear-gradient(180deg, #818cf8 0%, #4f46e5 100%);
  transition: height .4s ease;
}

.bar-fill.bar-empty { background: #e4e8f1; min-height: 3px !important; }

.bar-label { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ---------- Listas mini ---------- */
.mini-list { list-style: none; margin: 0; padding: 8px; }

.mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 9px;
}

.mini-row:hover { background: #f8f9fd; }

.mini-name {
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-list { padding: 8px; display: flex; flex-direction: column; }

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}

.recent-item:hover { background: #f8f9fd; }

.recent-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.recent-side { display: flex; align-items: center; gap: 10px; flex: none; }

.cell-strong { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--muted); }

.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 9px;
}

.rank-row:hover { background: #f8f9fd; }

.rank {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary-600);
  font-size: 11.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex: none;
}

.rank-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rank-main .cell-strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  padding: 3px 9px;
  white-space: nowrap;
}

.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warning { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: #f2f4f7; color: #475467; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  flex-wrap: wrap;
}

.search-input {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 420px;
}

.search-input svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #98a2b3;
  pointer-events: none;
}

.search-input input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  font: inherit;
  background: var(--surface);
  color: var(--ink);
}

.search-input input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .14);
}

.toolbar-info { color: var(--muted); font-size: 13px; }

/* ---------- Tabelas ---------- */
.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  background: #fafbfe;
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
  white-space: nowrap;
}

tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

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

tbody tr.row-click { cursor: pointer; }
tbody tr.row-click:hover { background: #f8f9fd; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.table-empty { padding: 28px 16px !important; text-align: center; color: var(--muted); }

.table-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }

.nowrap { white-space: nowrap; }

.muted { color: var(--muted); }

/* ---------- Estado vazio ---------- */
.empty {
  padding: 56px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}

.empty h3 { font-size: 15.5px; }
.empty p { color: var(--muted); max-width: 420px; font-size: 13.5px; line-height: 1.5; }

.hero-empty {
  padding: 34px;
  display: flex;
  align-items: center;
  gap: 20px;
  background:
    radial-gradient(600px 300px at 100% 0%, rgba(99, 102, 241, .12), transparent 60%),
    var(--surface);
}

.hero-empty h2 { font-size: 20px; margin-bottom: 8px; }
.hero-empty p { color: var(--muted); max-width: 640px; line-height: 1.55; font-size: 14px; }
.hero-actions { display: flex; gap: 9px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- Formulários ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }

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

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field > span {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}

.input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .14);
}

textarea.input { resize: vertical; min-height: 62px; }

select.input { appearance: auto; }

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

.hint-ok { color: var(--ok); font-weight: 600; }
.hint-err { color: var(--danger); font-weight: 600; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}

.checkbox-row input { width: 16px; height: 16px; accent-color: var(--primary); }

.form-block { display: flex; flex-direction: column; gap: 10px; }

.block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.block-title { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 18px 18px;
  z-index: 100;
  overflow-y: auto;
  animation: fadeIn .18s ease;
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
  width: 100%;
  max-width: 560px;
  animation: popIn .2s ease;
  display: flex;
  flex-direction: column;
  max-height: 88vh;
}

.modal.modal-sm { max-width: 420px; }
.modal.modal-lg { max-width: 880px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 { font-size: 16.5px; font-weight: 700; }

.modal-close { font-size: 22px; color: #98a2b3; }
.modal-close:hover { background: #f2f4f7; color: var(--ink); }

.modal-body { padding: 20px; overflow-y: auto; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 9px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: #fafbfe;
  border-radius: 0 0 16px 16px;
  flex-wrap: wrap;
}

.confirm-text { line-height: 1.6; color: var(--ink-2); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }

/* ---------- Venda ---------- */
.sale-items { display: flex; flex-direction: column; gap: 8px; }

.sale-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 110px 36px;
  align-items: center;
  gap: 8px;
}

.sale-item .item-qty { text-align: center; }

.line-total {
  text-align: right;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  padding-right: 4px;
  white-space: nowrap;
}

.sale-summary {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  color: var(--ink-2);
}

.summary-row > span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }

.summary-total {
  border-top: 1px dashed var(--line-strong);
  margin-top: 4px;
  padding-top: 10px;
  font-size: 17px;
  font-weight: 750;
  color: var(--ink);
}

.text-ok { color: var(--ok); }

.coupon-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 0;
}

.chips-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }

.chip {
  border: 1px dashed #c7d0e2;
  background: #f8f9fd;
  color: var(--ink-2);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.chip:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-600); }

.chip:empty { display: none; }

/* ---------- Movimentações ---------- */
.mov-list { display: flex; flex-direction: column; }

.mov-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--line);
}

.mov-row:last-child { border-bottom: none; }

.mov-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.mov-main .cell-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mov-qty { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mov-qty.pos { color: var(--ok); }
.mov-qty.neg { color: var(--danger); }

/* ---------- Toasts ---------- */
#toast-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  z-index: 300;
  max-width: min(360px, calc(100vw - 40px));
}

.toast {
  background: #101828;
  color: #f2f4f7;
  border-radius: 11px;
  padding: 12px 15px;
  font-size: 13.5px;
  line-height: 1.45;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .32);
  border-left: 3px solid #4ade80;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .22s, transform .22s;
}

.toast.show { opacity: 1; transform: none; }

.toast-err { border-left-color: #f87171; }

/* ---------- Loading ---------- */
.loading { display: grid; place-items: center; padding: 80px 0; }

.spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid #dbe1ee;
  border-top-color: var(--primary);
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsivo ---------- */
@media (max-width: 1080px) {
  .hide-md { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    overflow-x: auto;
  }

  .brand { padding: 0 10px 0 2px; }
  .brand-text { display: none; }

  .nav { flex-direction: row; gap: 4px; }

  .nav-link { padding: 8px 12px; white-space: nowrap; font-size: 13.5px; }
  .nav-link.active::before { display: none; }

  .sidebar-bottom { display: none; }

  .topbar { padding: 14px 18px; }
  .view { padding: 18px 16px 42px; }

  .modal-backdrop { padding: 3vh 12px 12px; }
  .modal { max-height: 94vh; }

  .hero-empty { padding: 24px; }
}

@media (max-width: 640px) {
  .hide-sm { display: none; }

  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 13px 14px; }
  .kpi-value { font-size: 19px; }

  .topbar { align-items: flex-start; flex-direction: column; gap: 10px; }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1; }

  .sale-item { grid-template-columns: 90px minmax(0, 1fr) 36px; }
  .sale-item .item-product { grid-column: 1 / -1; }
  .sale-item .item-qty { grid-column: 1; }
  .line-total { grid-column: 2; text-align: right; }
  .sale-item .item-remove { grid-column: 3; }

  .chart { height: 120px; gap: 6px; padding: 14px 12px 10px; }

  .search-input { max-width: none; }
}
