/* =========================================================
   Sistema de Contagem de Estoque — visual estilo aplicativo
   ========================================================= */

:root {
  --bg: #F4F5FA;
  --card: #FFFFFF;
  --text: #24243A;
  --muted: #7A7B90;
  --border: #EAEAF2;
  --primary: #7C6CF6;
  --primary-dark: #5F4FDB;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(36, 36, 58, 0.06);

  --pink-bg: #FFE1EC;    --pink-fg: #B23366;
  --blue-bg: #DCEEFF;    --blue-fg: #2765A0;
  --green-bg: #E1F7E6;   --green-fg: #26824F;
  --yellow-bg: #FFF6D2;  --yellow-fg: #9A7300;
  --teal-bg: #DAFBF3;    --teal-fg: #0C7C6E;
  --purple-bg: #EDE3FF;  --purple-fg: #6B46C1;
  --peach-bg: #FFE7D8;   --peach-fg: #C1622A;
  --lilac-bg: #F3E3FF;   --lilac-fg: #8B4FC1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0 0 8px; }
p { margin: 0 0 8px; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar-back { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  background: var(--bg); border-radius: 50%; flex-shrink: 0; }
.topbar-back .ic { width: 18px; height: 18px; }
.topbar-title { flex: 1; font-size: 17px; font-weight: 700; }
.topbar-user { width: 32px; height: 32px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }

/* ---------- Layout ---------- */
.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px calc(100px + env(safe-area-inset-bottom));
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- Painel: botões quadrados coloridos ---------- */
.hello { padding: 4px 4px 8px; }
.hello-stats { display: flex; gap: 10px; margin-top: 10px; }
.hello-stats > div {
  flex: 1; background: var(--card); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 10px; text-align: center;
}
.hello-stats strong { display: block; font-size: 20px; }
.hello-stats span { font-size: 11px; color: var(--muted); }

.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.tile {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  font-weight: 700; font-size: 14px; text-align: center;
  padding: 12px;
  box-shadow: var(--shadow);
  transition: transform .08s ease;
}
.tile:active { transform: scale(0.96); }
.tile .ic { width: 30px; height: 30px; }
.tile-pink   { background: var(--pink-bg);   color: var(--pink-fg); }
.tile-blue   { background: var(--blue-bg);   color: var(--blue-fg); }
.tile-green  { background: var(--green-bg);  color: var(--green-fg); }
.tile-yellow { background: var(--yellow-bg); color: var(--yellow-fg); }
.tile-teal   { background: var(--teal-bg);   color: var(--teal-fg); }
.tile-purple { background: var(--purple-bg); color: var(--purple-fg); }
.tile-peach  { background: var(--peach-bg);  color: var(--peach-fg); }
.tile-lilac  { background: var(--lilac-bg);  color: var(--lilac-fg); }

/* ---------- Bottom nav ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-around;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--muted); padding: 4px 8px; border-radius: 10px;
}
.bottomnav a .ic { width: 20px; height: 20px; }
.bottomnav a.active { color: var(--primary); }
.bottomnav-fab {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary); color: #fff !important;
  display: flex; align-items: center; justify-content: center;
  margin-top: -28px; box-shadow: 0 4px 14px rgba(124,108,246,.45);
}
.bottomnav-fab .ic { width: 24px; height: 24px; }

/* ---------- Formulários e botões ---------- */
.form-grid { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
label.field, .form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=file], select {
  font-size: 15px; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.checkbox-line { flex-direction: row !important; align-items: center; gap: 8px !important; }

.field-with-btn { display: flex; gap: 8px; }
.field-with-btn input { flex: 1; }
.btn-cam {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: var(--radius-sm);
  background: var(--primary); border: none; color: #fff; display: flex; align-items: center; justify-content: center;
}
.btn-cam .ic { width: 20px; height: 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 18px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-weight: 700; font-size: 14px; cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:active { background: var(--primary-dark); }
.btn-block { width: 100%; }
.btn-mini {
  padding: 8px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.inline { display: inline-block; margin-left: 6px; }
.pw-form { display: flex; gap: 6px; margin-top: 6px; }

/* ---------- Tags de status na contagem ---------- */
.tag-status { padding: 10px 14px; border-radius: var(--radius-sm); font-weight: 700; font-size: 13px; }
.tag-ok    { background: var(--green-bg);  color: var(--green-fg); }
.tag-curve { background: var(--yellow-bg); color: var(--yellow-fg); }
.tag-warn  { background: #FFE3E3; color: #C23A3A; }

/* ---------- Autocomplete ---------- */
.autocomplete-wrap { position: relative; }
.suggestions {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 15;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-top: 4px; max-height: 260px; overflow-y: auto; box-shadow: var(--shadow);
}
.suggestion-item { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; border-bottom: 1px solid var(--border); cursor: pointer; }
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:active { background: var(--bg); }
.suggestion-item small { color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-ok   { background: var(--green-bg);  color: var(--green-fg); }
.badge-off  { background: #EDEDF3; color: var(--muted); }
.badge-warn { background: #FFE3E3; color: #C23A3A; }
.badge-curve-a { background: var(--pink-bg);   color: var(--pink-fg); }
.badge-curve-b { background: var(--blue-bg);   color: var(--blue-fg); }
.badge-curve-c { background: var(--purple-bg); color: var(--purple-fg); }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-me { background: #F5F2FF; }

.pagination { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.pagination a { padding: 6px 11px; border-radius: 8px; background: var(--bg); font-size: 12px; font-weight: 700; }
.pagination a.active { background: var(--primary); color: #fff; }

/* ---------- Busca ---------- */
.search-bar { display: flex; gap: 8px; margin-bottom: 4px; }
.search-bar input { flex: 1; }

/* ---------- Progresso ---------- */
.progress-wrap { margin: 8px 0 12px; }
.progress-bar { background: var(--border); border-radius: 999px; height: 10px; overflow: hidden; }
.progress-fill { background: var(--primary); height: 100%; border-radius: 999px; transition: width .3s ease; }

/* ---------- Lista de pendentes (curva) ---------- */
.pending-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; max-height: 320px; overflow-y: auto; }
.pending-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: #fff; text-align: left; cursor: pointer; font-size: 13px;
}
.pending-item span { font-weight: 700; }
.pending-item small { color: var(--muted); margin-left: 6px; }
.pending-item.done { background: var(--green-bg); border-color: var(--green-bg); }
.pending-item em { font-style: normal; color: var(--green-fg); font-size: 11px; font-weight: 700; }

/* ---------- Itens recentes ---------- */
.recent-list { display: flex; flex-direction: column; gap: 10px; }
.recent-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.recent-item:last-child { border-bottom: none; }
.recent-item-main { display: flex; flex-direction: column; }
.recent-item-side { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.recent-item-side .qty { font-weight: 800; font-size: 15px; }

/* ---------- Curvas: abas ---------- */
.curve-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.curve-tabs a { flex: 1; text-align: center; padding: 10px; border-radius: var(--radius-sm); font-weight: 700; font-size: 13px; background: var(--bg); }
.curve-tab-a.active { background: var(--pink-bg);   color: var(--pink-fg); }
.curve-tab-b.active { background: var(--blue-bg);   color: var(--blue-fg); }
.curve-tab-c.active { background: var(--purple-bg); color: var(--purple-fg); }
.curve-counts { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

/* ---------- Produtividade ---------- */
.period-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.period-tabs a { flex: 1; text-align: center; padding: 9px; border-radius: 999px; background: var(--bg); font-size: 12px; font-weight: 700; }
.period-tabs a.active { background: var(--primary); color: #fff; }
.indice-pill { padding: 4px 10px; border-radius: 999px; font-weight: 800; }
.indice-alto  { background: var(--green-bg);  color: var(--green-fg); }
.indice-medio { background: var(--yellow-bg); color: var(--yellow-fg); }
.indice-baixo { background: #FFE3E3; color: #C23A3A; }
.formula-list { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text); }
.formula-list li { margin-bottom: 6px; }

/* ---------- Flash messages ---------- */
.flash { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.flash-sucesso { background: var(--green-bg); color: var(--green-fg); }
.flash-erro    { background: #FFE3E3; color: #C23A3A; }
.flash-aviso   { background: var(--yellow-bg); color: var(--yellow-fg); }

/* ---------- Login ---------- */
.login-body {
  margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #EFE9FF 0%, #F4F5FA 60%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 20px;
}
.login-card { background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 30px 26px; width: 100%; max-width: 360px; text-align: center; }
.login-logo { font-size: 42px; margin-bottom: 6px; }
.login-sub { color: var(--muted); margin-bottom: 18px; }
.login-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-form label { font-size: 13px; font-weight: 700; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.login-hint { margin-top: 16px; font-size: 11px; color: var(--muted); }

/* ---------- Contagem: cabeçalho ---------- */
.count-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ---------- Scanner overlay ---------- */
.scanner-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(10,10,20,.85);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.scanner-box { background: #fff; border-radius: var(--radius); overflow: hidden; width: 100%; max-width: 420px; }
.scanner-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 13px; }
#scanner-reader { width: 100%; min-height: 260px; }

@media (min-width: 640px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
}
