/* =========================================================
   El Toro PDV - estilo (paleta oficial da marca)
   ========================================================= */
:root {
  --toro-yellow: #FFCC27;
  --toro-orange: #FECA20;
  --toro-brown:  #4E270D;
  --toro-cream:  #FEF8EA;
  --toro-celeste:#7AC8F5;

  --bg:            #FEF8EA;
  --fg:            #381703;
  --primary:       #FECA20;
  --primary-fg:    #FEFCF4;
  --secondary:     #FFCC27;
  --secondary-fg:  #4E270D;
  --muted:         #F4EAD5;
  --muted-fg:      #6C4D3C;
  --destructive:   #E7000B;
  --border:        #ECDCC1;
  --ring:          #FECA20;
  --card:          #FFFFFF;

  --radius: 14px;
  --shadow: 0 6px 24px rgba(78, 39, 13, 0.10);
  --shadow-sm: 0 2px 8px rgba(78, 39, 13, 0.08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  min-height: 100%;
}

body {
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.boot {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  color: var(--muted-fg);
  font-size: 1.1rem;
}

/* ---------- Tela centralizada (login / setup) ---------- */
.auth-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(255, 204, 39, 0.45), transparent 60%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
}

.brand-logo {
  display: block;
  width: 100%;
  max-width: 300px;
  height: auto;
  margin: 4px auto 18px;
}

.auth-title {
  margin: 0 0 4px;
  text-align: center;
  font-size: 1.35rem;
  color: var(--toro-brown);
  font-weight: 800;
}

.auth-sub {
  margin: 0 0 20px;
  text-align: center;
  color: var(--muted-fg);
  font-size: 0.95rem;
}

/* ---------- Formularios ---------- */
.field { margin-bottom: 14px; }

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted-fg);
}

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  color: var(--fg);
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(254, 202, 32, 0.35);
  background: #fff;
}

/* ---------- Botoes ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 18px;
  font-size: 1.02rem;
  font-weight: 800;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform .06s ease, filter .15s ease;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { filter: brightness(0.97); }

.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- Mensagens ---------- */
.alert {
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.alert-error {
  background: #fdecec;
  color: var(--destructive);
  border: 1px solid #f6c9cc;
}
.alert-hidden { display: none; }

/* ---------- App logado ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--toro-yellow);
  border-bottom: 3px solid var(--toro-orange);
}
.app-header .h-logo { height: 40px; width: auto; }
.app-header .h-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--toro-brown);
  font-weight: 700;
  font-size: 0.92rem;
}
.role-badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .03em;
  background: var(--toro-brown);
  color: var(--toro-cream);
}
.icon-btn {
  border: none;
  background: rgba(78,39,13,0.10);
  color: var(--toro-brown);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 22px 16px 48px;
}
.page h1 {
  font-size: 1.4rem;
  color: var(--toro-brown);
  margin: 8px 0 4px;
}
.page .lead { color: var(--muted-fg); margin: 0 0 22px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.tile h3 { margin: 0 0 6px; color: var(--toro-brown); font-size: 1.05rem; }
.tile p { margin: 0; color: var(--muted-fg); font-size: 0.88rem; }
.tile .soon {
  position: absolute;
  top: 12px; right: 12px;
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  background: var(--muted);
  color: var(--muted-fg);
  padding: 3px 8px;
  border-radius: 999px;
}

.hint {
  margin-top: 26px;
  padding: 14px 16px;
  background: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted-fg);
  font-size: 0.9rem;
}

/* ---------- Navegacao do admin ---------- */
.app-nav {
  position: sticky;
  top: 58px;
  z-index: 9;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 12px;
  background: var(--toro-cream);
  border-bottom: 1px solid var(--border);
}
.app-nav button {
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-fg);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.app-nav button:hover { background: var(--muted); }
.app-nav button.nav-active {
  background: var(--toro-brown);
  color: var(--toro-cream);
}

/* ---------- Toolbar (cabecalho de cada tela) ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar h2 { margin: 0; color: var(--toro-brown); font-size: 1.25rem; flex: 1 1 auto; }
.toolbar .spacer { flex: 1 1 auto; }

.btn-sm { width: auto; padding: 9px 14px; font-size: 0.9rem; }
.btn-inline { width: auto; padding: 7px 12px; font-size: 0.85rem; }
.btn-danger { background: var(--destructive); color: #fff; }

.search-box { flex: 1 1 220px; max-width: 380px; }
.search-box input { padding: 10px 12px; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
table.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table thead th {
  text-align: left;
  padding: 11px 12px;
  background: var(--muted);
  color: var(--muted-fg);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
.table tbody td { padding: 11px 12px; border-top: 1px solid var(--border); color: var(--fg); vertical-align: middle; }
.table tbody tr:hover { background: #fffdf6; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .row-off td { opacity: .5; }
.table .row-low td { background: #fff6e6; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 800; white-space: nowrap;
}
.badge-ok { background: #e6f4e6; color: var(--toro-brown); }
.badge-warn { background: #fdeccb; color: #8a5a00; }
.badge-off { background: var(--muted); color: var(--muted-fg); }

.empty { padding: 28px; text-align: center; color: var(--muted-fg); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(56, 23, 3, 0.45);
  display: grid; place-items: center; padding: 16px;
}
.modal {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card);
}
.modal-head h3 { margin: 0; color: var(--toro-brown); font-size: 1.1rem; }
.modal-close { border: none; background: var(--muted); color: var(--toro-brown); width: 32px; height: 32px; border-radius: 8px; font-size: 1.2rem; cursor: pointer; }
.modal-body { padding: 18px; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn { flex: 1; }

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.check-row { display: flex; align-items: center; gap: 8px; }
.check-row input { width: auto; }
.check-row label { margin: 0; }

/* ---------- Linhas de entrada de mercadoria ---------- */
.line-items { display: flex; flex-direction: column; gap: 8px; }
.line-item {
  display: grid; grid-template-columns: 1fr 84px 110px 40px; gap: 8px; align-items: center;
}
.line-item .li-name { font-weight: 600; color: var(--fg); font-size: 0.9rem; }
.li-total { text-align: right; font-weight: 800; color: var(--toro-brown); margin-top: 10px; }
.li-remove { border: none; background: var(--muted); color: var(--destructive); border-radius: 8px; padding: 8px; cursor: pointer; font-weight: 800; }
.entrada-add { margin-top: 14px; }
.line-add { display: grid; grid-template-columns: 1fr 150px; gap: 8px; align-items: center; }
.entrada-save { max-width: 420px; margin-left: auto; }

/* ---------- PDV (frente de caixa) ---------- */
.pdv-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.pdv-capture label { font-size: 0.9rem; }
.bip-input { font-size: 1.3rem; padding: 16px 16px; font-weight: 700; }
.pdv-actions { margin-top: 10px; display: flex; gap: 8px; }
#searchResults { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.search-hit {
  display: flex; justify-content: space-between; gap: 10px; text-align: left;
  border: 1px solid var(--border); background: var(--card); border-radius: 10px; padding: 10px 12px; cursor: pointer; font-weight: 600; color: var(--fg);
}
.search-hit:hover { background: var(--muted); }
.search-hit span { color: var(--muted-fg); font-weight: 700; }
.muted-hit { color: var(--muted-fg); padding: 8px; font-size: 0.9rem; }

.pdv-cart { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm); }
.cart-list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; }
.cart-item { display: grid; grid-template-columns: 1fr auto auto 32px; gap: 8px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.ci-name { font-weight: 600; font-size: 0.92rem; }
.ci-price { color: var(--muted-fg); font-size: 0.8rem; font-weight: 500; }
.ci-qty { display: flex; align-items: center; gap: 4px; }
.ci-qty button { width: 30px; height: 30px; border: 1px solid var(--border); background: var(--muted); border-radius: 8px; font-weight: 800; cursor: pointer; color: var(--toro-brown); }
.ci-qty input { width: 52px; text-align: center; padding: 6px; }
.ci-sub { font-weight: 800; color: var(--toro-brown); white-space: nowrap; }
.ci-rm { border: none; background: transparent; color: var(--destructive); font-weight: 800; font-size: 1.1rem; cursor: pointer; }
.cart-total { display: flex; justify-content: space-between; align-items: center; margin: 14px 0; font-size: 1.1rem; color: var(--toro-brown); }
.cart-total strong { font-size: 1.6rem; }
.cart-partner { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; padding: 8px 10px; background: var(--toro-cream); border: 1px solid var(--toro-yellow); border-radius: 8px; font-size: .95rem; }
.link-x { background: none; border: none; color: #a15c00; cursor: pointer; text-decoration: underline; font-size: .85rem; }

/* Anexar parceiro (aviso de visita) */
.attach-list { display: flex; flex-direction: column; gap: 8px; }
.attach-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); cursor: pointer; }
.attach-item:hover { border-color: var(--toro-yellow); background: var(--toro-cream); }
.attach-item span { color: var(--muted-fg); font-size: .88rem; }

/* Secoes de formulario / titulos de secao */
.form-sec { margin: 14px 0 8px; font-weight: 700; color: var(--toro-brown); border-top: 1px solid var(--border); padding-top: 12px; }
.sec-h { margin: 20px 0 8px; color: var(--toro-brown); font-size: 1.05rem; }

/* Relatorios */
.rng-lbl { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--muted-fg); }
.rng-lbl input { width: auto; }
.row-warn { background: #fdf3e0; }
.row-warn td:first-child { font-weight: 600; color: var(--toro-brown); }

/* Offline / sincronizacao */
.hidden { display: none !important; }
.sync-pill { background: var(--toro-brown); color: #fff; border: none; border-radius: 999px; padding: 4px 12px; font-size: .78rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.sync-pill.sync-off { background: #8a5a00; }
.sync-pill.sync-warn { background: #b23b3b; }
.sync-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.sync-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); }

/* Cotacoes do dia */
.cot-form { max-width: 420px; display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }
.cot-row { display: flex; flex-direction: column; gap: 6px; }
.cot-lbl { font-weight: 700; color: var(--toro-brown); }
.cot-code { color: var(--muted-fg); font-weight: 400; font-size: .82rem; margin-left: 4px; }
.cot-inp { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--card); }
.cot-prefix { padding: 0 14px; color: var(--muted-fg); font-weight: 700; border-right: 1px solid var(--border); display: flex; align-items: center; }
.cot-inp input { border: none; padding: 12px; flex: 1; background: transparent; width: 100%; }

/* Parceiro inativo */
.inactive-card { max-width: 480px; margin: 48px auto; background: var(--card); border: 1px solid var(--toro-yellow); border-radius: var(--radius); padding: 28px; text-align: center; box-shadow: var(--shadow-sm); }
.inactive-card h2 { color: var(--toro-brown); margin: 0 0 14px; }
.inactive-card p { color: var(--muted-fg); margin: 8px 0; line-height: 1.5; }

/* Painel de pagamento */
.pay-summary { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 1.05rem; }
.pay-falta strong, .pay-summary strong { color: var(--toro-brown); font-size: 1.2rem; }
.pay-methods { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-bottom: 12px; }
.pay-method { border: 1px solid var(--border); background: var(--muted); color: var(--toro-brown); border-radius: 10px; padding: 12px 8px; font-weight: 700; cursor: pointer; }
.pay-method:hover { background: var(--toro-yellow); }
.pay-entry { border: 1px dashed var(--border); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.pay-lines { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.pay-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--muted); border-radius: 8px; padding: 8px 10px; font-size: 0.9rem; }
.pay-line button { border: none; background: transparent; color: var(--destructive); font-weight: 800; cursor: pointer; }

/* Camera */
.cam-video { width: 100%; border-radius: 12px; background: #000; max-height: 60vh; }

/* Recibo */
.receipt { max-width: 420px; margin: 0 auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.rc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.rc-logo { width: 48px; height: 48px; border-radius: 8px; }
.rc-items { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 0.92rem; }
.rc-items td { padding: 4px 0; border-bottom: 1px dashed var(--border); }
.rc-total { display: flex; justify-content: space-between; font-size: 1.2rem; color: var(--toro-brown); margin: 12px 0; }
.rc-pays { font-size: 0.85rem; color: var(--muted-fg); display: flex; flex-direction: column; gap: 3px; }
.rc-change { margin-top: 8px; font-weight: 800; color: var(--toro-brown); }
.receipt-actions { max-width: 420px; margin: 16px auto 0; }
.narrow-form { max-width: 360px; }

@media (max-width: 720px) { .pdv-layout { grid-template-columns: 1fr; } }
@media print {
  .app-header, .app-nav, .modal-actions, #toast-host { display: none !important; }
  body, .page { background: #fff; }
  .receipt { border: none; box-shadow: none; max-width: 100%; }
}

/* ---------- Toast ---------- */
#toast-host {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  padding: 12px 18px; border-radius: 12px; font-weight: 700; font-size: 0.92rem;
  box-shadow: var(--shadow); max-width: 90vw;
}
.toast-ok { background: var(--toro-brown); color: var(--toro-cream); }
.toast-err { background: var(--destructive); color: #fff; }

/* ---------- Cadastros (secoes) ---------- */
.section-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.section-tabs button {
  border: 1px solid var(--border); background: var(--card); color: var(--muted-fg);
  font-weight: 700; padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: 0.88rem;
}
.section-tabs button.sec-active { background: var(--toro-orange); color: var(--toro-brown); border-color: var(--toro-orange); }

.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.stat {
  flex: 1 1 140px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.stat .n { font-size: 1.6rem; font-weight: 800; color: var(--toro-brown); }
.stat .l { color: var(--muted-fg); font-size: 0.82rem; }

@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .line-item { grid-template-columns: 1fr 60px 90px 36px; }
}

