/* Sistema Vendedores Típico — mobile-first */

:root {
  --c-brand: #b91c1c;
  --c-brand-dark: #7f1d1d;
  --c-bg: #f6f5f3;
  --c-surface: #ffffff;
  --c-text: #1c1917;
  --c-muted: #78716c;
  --c-border: #e7e5e4;
  --c-ok: #15803d;
  --c-warn: #b45309;
  --c-err: #b91c1c;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 6px rgba(0,0,0,.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--c-bg); color: var(--c-text);
             font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
             font-size: 16px; line-height: 1.45; }

a { color: var(--c-brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--c-brand); color: #fff; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10; box-shadow: var(--shadow);
}
.topbar h1 { font-size: 1.05rem; margin: 0; font-weight: 600; }
.topbar .user { font-size: .85rem; opacity: .95; }
.topbar button { background: rgba(255,255,255,.15); border: 0; color: #fff;
  padding: 6px 10px; border-radius: var(--r-sm); cursor: pointer; }

.container { max-width: 720px; margin: 0 auto; padding: 16px; }
.card { background: var(--c-surface); border: 1px solid var(--c-border);
        border-radius: var(--r-md); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }

h2 { margin: 4px 0 12px; font-size: 1.05rem; }
label { display: block; font-size: .82rem; color: var(--c-muted); margin: 10px 0 4px; font-weight: 500; }
input, select, textarea, button {
  font: inherit; border-radius: var(--r-sm); border: 1px solid var(--c-border);
  padding: 11px 12px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--c-brand); outline-offset: 1px; }
textarea { min-height: 64px; resize: vertical; }

button.primary {
  background: var(--c-brand); color: #fff; border: 0; font-weight: 600; padding: 14px;
  cursor: pointer;
}
button.primary:hover { background: var(--c-brand-dark); }
button.primary:disabled { opacity: .5; cursor: not-allowed; }
button.ghost {
  background: transparent; border: 1px solid var(--c-border);
  color: var(--c-text); cursor: pointer;
}
button.danger {
  background: #fff; color: var(--c-err); border: 1px solid var(--c-err); cursor: pointer;
}

.flex { display: flex; gap: 8px; align-items: center; }
.flex.col { flex-direction: column; align-items: stretch; }
.grow { flex: 1; }
.row { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 8px; align-items: end; margin-bottom: 8px; }
.row .full { grid-column: 1 / -1; }
@media (max-width: 600px) {
  .row { grid-template-columns: 1fr 1fr; }
  .row .name { grid-column: 1 / -1; }
  .row .rm { grid-column: 1 / -1; }
}

.muted { color: var(--c-muted); font-size: .85rem; }
.total { font-size: 1.35rem; font-weight: 700; color: var(--c-brand-dark); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px;
         font-size: .75rem; background: #e7e5e4; color: #57534e; }
.badge.ok { background: #dcfce7; color: var(--c-ok); }
.badge.warn { background: #fef3c7; color: var(--c-warn); }
.badge.err { background: #fee2e2; color: var(--c-err); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #111; color: #fff; padding: 10px 18px; border-radius: 999px;
  box-shadow: var(--shadow); opacity: 0; transition: opacity .2s; z-index: 100;
  max-width: 92%; font-size: .9rem;
}
.toast.show { opacity: .95; }
.toast.err { background: var(--c-err); }
.toast.ok  { background: var(--c-ok); }

/* Autocomplete */
.autocomplete { position: relative; }
.ac-list {
  position: absolute; top: 100%; left: 0; right: 0;
  background: #fff; border: 1px solid var(--c-border); border-radius: var(--r-sm);
  box-shadow: var(--shadow); margin-top: 4px; max-height: 260px; overflow: auto; z-index: 5;
}
.ac-list div {
  padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #f2f1ef;
}
.ac-list div:hover, .ac-list div.active { background: #fafaf9; }
.ac-list small { color: var(--c-muted); display: block; }

/* Lista de pedidos */
.pedido {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--c-border);
}
.pedido:last-child { border-bottom: 0; }
.pedido .nome { font-weight: 600; }
.pedido .sub  { font-size: .82rem; color: var(--c-muted); }
.pedido .rv   { text-align: right; }

/* Login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
}
.login-box { max-width: 380px; width: 100%; }
.login-box h1 { text-align: center; color: var(--c-brand); }

/* Tabs (admin) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--c-border); margin-bottom: 14px; }
.tabs button {
  background: transparent; border: 0; padding: 10px 14px; cursor: pointer;
  color: var(--c-muted); font-weight: 600; border-bottom: 2px solid transparent;
  width: auto;
}
.tabs button.active { color: var(--c-brand); border-color: var(--c-brand); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--c-border); }
th { background: #fafaf9; font-weight: 600; color: var(--c-muted); font-size: .8rem; text-transform: uppercase; }

/* Card "cliente selecionado" (mostra apelido/nome/CNPJ antes dos itens) */
.cliente-sel {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: .92rem;
}
.cliente-sel .apelido {
  font-weight: 700; color: var(--c-brand-dark); font-size: 1rem;
}
.cliente-sel .nome { font-weight: 600; color: var(--c-text); }
.cliente-sel .cnpj { color: var(--c-muted); font-size: .85rem; margin-top: 2px; }
.cliente-sel .mini-btn {
  display: inline-block; margin-top: 6px; padding: 3px 10px;
  font-size: .78rem; color: var(--c-brand); background: transparent;
  border: 1px solid var(--c-brand); border-radius: 999px; cursor: pointer; width: auto;
}

/* Autocomplete: apelido em destaque */
.ac-list .ac-apelido { font-weight: 700; color: var(--c-brand-dark); }
.ac-list .ac-nome-sub { color: var(--c-muted); font-size: .82rem; }

/* Lista de apelidos na aba dedicada */
.alias-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--c-border);
}
.alias-item:last-child { border-bottom: 0; }
.alias-item .ap { font-weight: 700; color: var(--c-brand-dark); }
.alias-item .cli { font-size: .85rem; color: var(--c-muted); }
.alias-item .acts { display: flex; gap: 6px; }
.alias-item .acts button { width: auto; padding: 5px 10px; font-size: .82rem; }
