/* acesso.css — login, usuário logado e regras de visibilidade por papel */

/* ---------- Visibilidade por papel ---------- */
body.papel-vendedor .so-gerente { display: none !important; }
.nav-item[hidden], .topbar__search[hidden], .icon-btn[hidden] { display: none !important; }

/* ---------- Tela de login ---------- */
.auth-screen {
  position: fixed; inset: 0; z-index: 300;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, #C89B6C14, transparent 60%),
    var(--bg);
  overflow-y: auto;
}
.auth-screen[hidden] { display: none; }

.auth-panel { width: 100%; max-width: 380px; }

.auth-brand {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  margin-bottom: 28px;
}
.auth-logo {
  width: 96px; height: 96px; border-radius: 22px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.auth-brand-sub {
  font-family: var(--font-display); font-size: 13px; font-weight: 600;
  color: var(--accent); letter-spacing: .02em;
}

.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 26px;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: var(--shadow-md);
}
.auth-title { font-size: 22px; font-weight: 700; }
.auth-sub { font-size: 13px; color: var(--text-dim); line-height: 1.55; margin-top: -8px; }
.auth-box .input { height: 44px; font-size: 15px; }
.auth-btn { height: 46px; font-size: 14px; font-weight: 700; width: 100%; justify-content: center; }
.auth-btn:disabled { opacity: .6; cursor: wait; }
.auth-erro { min-height: 18px; margin: -4px 0 -6px; font-size: 12.5px; color: var(--danger); line-height: 1.4; }
.auth-erro:empty { min-height: 0; margin: 0; }

/* ---------- Carregando dados ---------- */
.app-loading {
  position: fixed; inset: 0; z-index: 250;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg); color: var(--text-dim); font-size: 13px;
}
.app-loading[hidden] { display: none; }
.app-loading__spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--surface-2); border-top-color: var(--accent);
  animation: girar .8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .app-loading__spinner { animation-duration: 2.4s; } }

/* ---------- Usuário logado (rodapé do menu) ---------- */
.user-chip {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 0 10px;
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}
.user-chip:empty { display: none; }
.user-chip__avatar {
  width: 32px; height: 32px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-strong);
  font-family: var(--font-display); font-weight: 700; font-size: 13px;
}
.user-chip__text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-chip__name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip__role { font-size: 11px; color: var(--text-faint); display: flex; align-items: center; gap: 6px; }
.user-chip__out {
  width: 30px; height: 30px; flex-shrink: 0;
  display: grid; place-items: center;
  background: none; border: 1px solid transparent; border-radius: var(--radius-sm);
  color: var(--text-faint); cursor: pointer;
}
.user-chip__out:hover { color: var(--danger); border-color: var(--border); }
.user-chip__out:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.user-chip__out svg { width: 16px; height: 16px; }

.app-shell.is-collapsed .user-chip { padding: 8px; justify-content: center; margin: 12px 0 10px; }
.app-shell.is-collapsed .user-chip__text,
.app-shell.is-collapsed .user-chip__avatar { display: none; }

.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); display: inline-block; }
.sync-dot[data-status="enviando"] { background: var(--warning); }
.sync-dot[data-status="offline"] { background: var(--danger); }

/* ---------- Tela de usuários ---------- */
.usr-login { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); background: var(--surface-2); padding: 2px 7px; border-radius: 6px; }
.usr-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); cursor: pointer; }
.usr-check input { accent-color: var(--accent); width: 16px; height: 16px; }
.usr-credenciais {
  margin: 0; padding: 14px 16px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md);
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.7; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}

/* ---------- Importar planilha ---------- */
.imp-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 38px 20px; margin-bottom: 16px;
  border: 1.5px dashed var(--border); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text-dim); text-align: center; cursor: pointer;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.imp-drop:hover, .imp-drop.is-over { border-color: var(--accent); background: var(--surface-2); }
.imp-drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.imp-drop strong { color: var(--text); font-size: 14px; }
.imp-drop span { font-size: 12px; color: var(--text-faint); }
.imp-drop__icon { width: 30px; height: 30px; color: var(--accent); margin-bottom: 4px; }
.imp-dica { margin-bottom: 20px; }
.imp-dica p { font-size: 12.5px; color: var(--text-dim); line-height: 1.6; }
.imp-mapa { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 14px; }
@media (max-width: 900px) { .imp-mapa { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .imp-mapa { grid-template-columns: 1fr; } }
.imp-modos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .imp-modos { grid-template-columns: 1fr; } }
.imp-modo {
  display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
  padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-elevated);
}
.imp-modo.is-on { border-color: var(--accent); background: var(--accent-soft); }
.imp-modo input { accent-color: var(--accent); margin-top: 3px; }
.imp-modo span { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }
.imp-modo strong { color: var(--text); font-size: 13.5px; }
.imp-preview { max-height: 460px; overflow: auto; }

/* ---------- Rankings do dashboard ---------- */
.rk-grid { margin-bottom: 16px; align-items: start; }
.rk-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.rk-head h3 { font-size: 14px; }
.rk-periodo { font-size: 11.5px; color: var(--text-faint); }
.rk-vazio { font-size: 12.5px; color: var(--text-faint); padding: 8px 0; }
.rk-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rk-item {
  position: relative; display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm); background: var(--bg-elevated); overflow: hidden;
}
.rk-item.is-eu { outline: 1px solid var(--accent); background: var(--accent-soft); }
.rk-medalha { font-size: 17px; text-align: center; position: relative; z-index: 1; }
.rk-pos { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); }
.rk-nome { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; z-index: 1; }
.rk-nome em { font-style: normal; font-weight: 500; color: var(--accent); font-size: 12px; }
.rk-valores { font-size: 12px; color: var(--text-dim); white-space: nowrap; position: relative; z-index: 1; }
.rk-valores strong { color: var(--text); font-size: 13px; }
.rk-barra { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-soft); z-index: 0; border-radius: var(--radius-sm); }
@media (max-width: 900px) { .rk-grid { grid-template-columns: 1fr; } }

/* ---------- Nova Venda: cabeçalho, busca de produto e totais ---------- */
.vd-cabecalho { grid-template-columns: 2fr 1fr 1.3fr 1.2fr; }
@media (max-width: 900px) { .vd-cabecalho { grid-template-columns: 1fr 1fr; } .vd-campo-cliente { grid-column: 1 / -1; } }
.vd-busca { position: relative; min-width: 0; }
.vd-sugestoes {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40;
  list-style: none; margin: 0; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); max-height: 300px; overflow-y: auto;
}
.vd-sugestoes[hidden] { display: none; }
.vd-sugestoes li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
}
.vd-sugestoes li span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vd-sugestoes li small { flex-shrink: 0; font-size: 11px; color: var(--text-faint); }
.vd-sugestoes li small.vd-sem-estoque { color: var(--danger); }
.vd-sugestoes li.is-on, .vd-sugestoes li[data-sugestao]:hover { background: var(--accent-soft); }
.vd-sugestoes li.vd-sug-vazio { cursor: default; color: var(--text-faint); }
.vd-totais { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; max-width: 760px; }
.vd-totais .field[hidden] { display: none; }
@media (max-width: 700px) { .vd-totais { grid-template-columns: 1fr; } }
@media (max-width: 780px) { .venda-item-row .vd-busca { grid-column: 1 / -1; } }

/* ---------- Tema claro ---------- */
:root[data-theme="light"] {
  color-scheme: light;
  --bg:            #F4F2EE;
  --bg-elevated:   #FAF9F6;
  --surface:       #FFFFFF;
  --surface-2:     #F1EEE8;
  --surface-hover: #E9E5DD;
  --border:        #DDD7CC;
  --border-soft:   #E9E4DB;

  --text:          #1A1C22;
  --text-dim:      #50566A;
  --text-faint:    #858A97;

  --accent-soft:   #B07D4A24;
  --accent-strong: #8A5C2E;

  --info:          #3557C9;
  --info-soft:     #3557C91A;
  --success:       #0E8F63;
  --success-soft:  #0E8F631A;
  --danger:        #D23A4F;
  --danger-soft:   #D23A4F1A;
  --warning:       #A86A12;
  --warning-soft:  #D9921F24;

  --shadow-sm: 0 1px 2px rgba(30,25,15,.08);
  --shadow-md: 0 8px 24px -10px rgba(30,25,15,.18);
  --shadow-lg: 0 24px 60px -24px rgba(30,25,15,.28);
}
:root[data-theme="light"] .topbar { background: rgba(250,249,246,.85); }
:root[data-theme="light"] .modal-overlay { background: rgba(30,25,15,.35); }
:root[data-theme="light"] .badge--esgotado { color: #fff; background: #3a3a3a; border-color: #3a3a3a; }
:root[data-theme="light"] .auth-screen { background: radial-gradient(1200px 600px at 50% -10%, #C89B6C1F, transparent 60%), var(--bg); }

/* Botão de tema no menu lateral */
.theme-toggle {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 0 0; padding: 9px 12px;
  background: none; border: 1px solid var(--border-soft); border-radius: var(--radius-md);
  color: var(--text-dim); font: inherit; font-size: 13px; cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.theme-toggle:hover { background: var(--surface-hover); color: var(--text); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { width: 18px; height: 18px; flex-shrink: 0; }
.theme-toggle__lua { display: none; }
:root[data-theme="light"] .theme-toggle__sol { display: none; }
:root[data-theme="light"] .theme-toggle__lua { display: block; }
.app-shell.is-collapsed .theme-toggle { justify-content: center; padding: 9px; }
.app-shell.is-collapsed .theme-toggle span { display: none; }
.theme-toggle + .user-chip { margin-top: 8px; }

/* ---------- Filtro de período do dashboard ---------- */
.dash-filtro { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -6px 0 18px; }
.dash-filtro__btn {
  padding: 7px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.dash-filtro__btn:hover { color: var(--text); background: var(--surface-hover); }
.dash-filtro__btn.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.dash-filtro__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dash-filtro__datas { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: 4px; }
.dash-filtro__datas[hidden] { display: none; }
.dash-filtro__datas label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); }
.dash-filtro__datas .input { height: 34px; width: auto; }

/* ---------- Entrada de mercadorias: abas e pedido por planilha ---------- */
.ent-abas { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.ent-aba {
  padding: 8px 16px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.ent-aba:hover { color: var(--text); background: var(--surface-hover); }
.ent-aba.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ent-aba:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#entPlanilha[hidden], #entManual[hidden] { display: none; }
.imp-entrada-topo { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.imp-entrada-topo .field { min-width: 180px; }
.imp-entrada-botoes { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Ranking de clientes (Dashboard Gerencial) ---------- */
.rk-cli-topo { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.rk-cli-barra { height: 6px; width: 90px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-bottom: 3px; }
.rk-cli-barra span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* ---------- Estoque: estrela de monitoramento (estoque baixo) ---------- */
.est-estrela {
  width: 30px; height: 30px; display: grid; place-items: center;
  background: none; border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: 18px; line-height: 1; color: var(--text-faint); cursor: pointer;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.est-estrela:hover { background: var(--surface-hover); color: var(--accent); }
.est-estrela.is-on { color: #E8B23A; }
.est-estrela:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.est-mon-dica { margin: 0; padding: 8px 16px; font-size: 12px; color: var(--text-faint); border-bottom: 1px solid var(--border-soft); }

/* ---------- Vendas: link na Nova Venda ---------- */
.vd-ver-vendas { margin-top: 18px; font-size: 12.5px; color: var(--text-faint); }
.vd-ver-vendas a { color: var(--accent); font-weight: 600; }
#view-listaVendas .search-mini { flex: 1 1 220px; min-width: 200px; }

/* ---------- Pedido de compra ---------- */
.pc-item { display: grid; grid-template-columns: 1fr 110px 40px; gap: 8px; margin-bottom: 8px; }
.pc-pedido { margin-bottom: 14px; }
.pc-pedido__topo { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.pc-pedido__topo strong { display: block; font-size: 14px; }
.pc-pedido__meta { font-size: 12px; color: var(--text-faint); }
.pc-pedido__tabela { margin-bottom: 12px; }
.pc-pedido__acoes { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.pc-pedido__dica { margin-right: auto; font-size: 12px; color: var(--text-faint); }

/* ---------- Estoque em trânsito ---------- */
.ger-transito { border-color: var(--info); }
.est-transito { color: var(--info); font-weight: 600; white-space: nowrap; }
