/*
 * Agromilk — tema visual da gestão e da loja.
 * Cores da logo nova: azul-marinho #011643 (tinta e botão principal) e verde-pasto #85b744 (dados e destaques).
 * Fundo verde-acinzentado claro (pasto), cartões brancos. As telas são as do sistema original; aqui muda só o visual.
 * Arquivos: tema.css (base, estrutura, visão geral) · componentes.css (tabelas, formulários, janelas, loja) · movimento.css (animações).
 */
:root {
  --ground: #f1f4ef;
  --surface: #ffffff;
  --raised: #f7f9f5;
  --active: #e3e9df;
  --border: #e1e6dd;
  --rule: #edf0ea;
  --control: #ccd4c7;

  --ink: #0d1b33;
  --muted: #55606b;
  --faint: #646d76;

  --navy: #011643;
  --navy-hover: #0c2c69;
  --navy-soft: #e6ebf4;
  --green: #85b744;
  --green-ink: #3d7614;
  --green-soft: #ebf5df;

  --positive-bg: #e6f3da;  --positive-ink: #23500c;
  --warning-bg: #fdf3dc;   --warning-ink: #7a4a00;  --warning-line: #f1dca6;
  --negative: #b42318;     --negative-bg: #fdeceb;  --negative-ink: #8a1f17;

  --r-card: 16px;
  --r-inner: 10px;
  --r-pill: 999px;
  --shadow-float: 0 18px 50px rgba(1, 22, 67, 0.16), 0 2px 8px rgba(1, 22, 67, 0.06);
  --shadow-hover: 0 10px 28px rgba(1, 22, 67, 0.08);

  --font: "Geist", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-press: cubic-bezier(0.2, 0, 0, 1);
  --fast: 140ms;
  --normal: 260ms;

  /* nomes usados pelo código original */
  --line: var(--border);
  --bg: var(--ground);
  --brand: var(--navy);
  --red: var(--negative);
  --amber: var(--warning-ink);
  --accent-soft: var(--green-soft);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: var(--font); color: var(--ink); }
h1 { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; margin-bottom: 6px; }
h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 4px; }
h3 { font-size: 15px; font-weight: 600; }
p { line-height: 1.6; }
small { color: var(--faint); font-size: 12px; }
.muted { color: var(--muted); font-size: 14px; }
b, strong { font-weight: 600; }

::selection { background: var(--green-soft); color: var(--ink); }

:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

/* ---------- Estrutura: menu lateral sobre o fundo, conteúdo à direita ---------- */
.shell { display: flex; min-height: 100dvh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: 248px;
  padding: 24px 14px 18px;
  background: var(--ground);
}

.brand { display: block; margin: 0 6px 22px; text-decoration: none; border-radius: var(--r-inner); }
.brand-logo { display: block; width: 100%; max-width: 168px; height: auto; object-fit: contain; }

.nav-label { display: none; }

nav { display: flex; flex-direction: column; gap: 2px; }
nav button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-inner);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  white-space: normal;
  cursor: pointer;
}
nav button svg { flex: none; width: 18px; height: 18px; stroke-width: 1.6px; }
nav button:hover { background: var(--active); color: var(--ink); }
nav button.active { background: var(--surface); color: var(--ink); font-weight: 600; }
nav button.active svg { color: var(--green-ink); }
nav button em {
  margin-left: auto;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: var(--navy);
  color: #fff;
  font-size: 12px;
  font-style: normal;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.sidebar-bottom { margin-top: auto; padding: 20px 6px 0; }
.secure { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.secure svg { flex: none; color: var(--green-ink); }
.secure small { display: block; margin-top: 2px; font-size: 12px; }
.sidebar-bottom a, .sidebar-bottom .btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  margin-top: 14px;
  padding: 0 12px;
  min-height: 38px;
  border: 0;
  border-radius: var(--r-inner);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}
.sidebar-bottom a:hover { background: var(--active); color: var(--ink); }

main { width: calc(100% - 248px); min-width: 0; margin-left: 248px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 40px;
  background: var(--ground);
}
.breadcrumbs { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 14px; }
.breadcrumbs > span { color: var(--faint); }
.breadcrumbs svg { color: var(--faint); }
.breadcrumbs b { font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}
.connection i, .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.connection.offline { color: var(--warning-ink); background: var(--warning-bg); }
.connection.offline i { background: #d79a1c; }
.avatar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.mobile-toggle, .menu-backdrop, .mobile-brand-logo { display: none; }

.content { max-width: 1440px; margin: 0 auto; padding: 8px 40px 32px; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading p { margin: 0; color: var(--muted); font-size: 15px; }
.eyebrow { display: none; }
.heading-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* ---------- Visão geral ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--surface);
  overflow: hidden;
}
.stat { position: relative; padding: 20px 24px 22px; }
.stat + .stat::before { content: ""; position: absolute; left: 0; top: 20px; bottom: 20px; width: 1px; background: var(--rule); }
.stat > div { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; }
.stat svg { display: none; }
.stat strong {
  display: block;
  margin: 10px 0 6px;
  color: var(--ink);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.stat small { font-size: 12px; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 20px; }

.card { min-width: 0; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); overflow: hidden; }
.padded { padding: 24px; }
.below { margin-top: 20px; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 24px 8px; }
.card-heading h2 { margin-bottom: 2px; }
.card-heading p { margin: 0; color: var(--muted); font-size: 13px; }

.chart { display: flex; gap: 14px; height: 210px; margin: 0 8px; padding: 18px 20px 0; }
.chart-col { display: flex; flex: 1; flex-direction: column; align-items: center; gap: 10px; }
.chart-col small { color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart-col span { color: var(--faint); font-size: 12px; text-transform: capitalize; }
.chart-col:last-child small, .chart-col:last-child span { color: var(--ink); font-weight: 600; }
.bar-track { display: flex; align-items: flex-end; width: 62%; height: 130px; border-radius: 8px; background: var(--raised); }
.bar-track div { width: 100%; min-height: 4px; border-radius: 8px; background: var(--green); }
.chart-col:last-child .bar-track div { background: var(--green-ink); }
.chart-footer { display: flex; align-items: center; gap: 8px; margin: 18px 24px 0; padding: 14px 0 18px; border-top: 1px solid var(--rule); color: var(--muted); font-size: 13px; }
.chart-footer .dot { background: var(--green); }
.chart-footer > span:last-child { margin-left: auto; color: var(--faint); font-size: 12px; }

.quick-card {
  position: relative;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--ink);
  overflow: hidden;
}
.quick-icon { position: absolute; top: 24px; right: 24px; color: var(--green-ink); opacity: 1; }
.quick-card h2 { margin: 0 0 8px; font-size: 22px; line-height: 1.25; letter-spacing: -0.02em; }
.quick-card p { max-width: 260px; margin-bottom: 18px; color: var(--muted); font-size: 14px; }
.quick-card button {
  display: flex;
  justify-content: flex-start;
  width: 100%;
  margin-top: 8px;
  padding: 0 16px;
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: var(--raised);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
}
.quick-card button:hover:not(:disabled) { background: var(--navy); color: #fff; }
.quick-card button svg:first-child { color: var(--green-ink); }
.quick-card button:hover:not(:disabled) svg { color: #fff; }
.quick-card button svg:last-child { margin-left: auto; }

.stock-row { display: flex; align-items: center; gap: 14px; padding: 14px 24px; border-top: 1px solid var(--rule); }
.stock-row > div:nth-child(2) { flex: 1; min-width: 0; }
.stock-row b { display: block; max-width: 320px; overflow: hidden; font-size: 14px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.stock-row small { display: block; margin-top: 2px; font-size: 12px; }
.date-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 10px 8px;
  border-radius: 12px;
  background: var(--navy-soft);
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.product-thumb {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--raised);
  color: var(--faint);
  overflow: hidden;
}
.product-thumb img { width: 100%; height: 100%; object-fit: cover; }

.import-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
  padding: 18px 22px;
  border-radius: var(--r-card);
  background: var(--navy);
  color: #fff;
}
.success-icon { display: flex; flex: none; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: var(--green); color: var(--navy); }
.import-banner b { font-size: 15px; }
.import-banner p { margin: 2px 0 0; color: #c7d0e0; font-size: 13px; }
.import-banner > button { margin-left: auto; background: var(--green); border-color: var(--green); color: var(--navy); }
.import-banner > button:hover { background: #9ccc5a; border-color: #9ccc5a; color: var(--navy); }

.empty { padding: 44px 24px; text-align: center; }
.empty > div:first-child { display: flex; align-items: center; justify-content: center; width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 50%; background: var(--raised); color: var(--faint); }
.empty h3 { margin-bottom: 6px; font-size: 16px; }
.empty p { max-width: 360px; margin: 0 auto 18px; color: var(--muted); font-size: 14px; }

.footer { display: flex; justify-content: space-between; margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--faint); font-size: 12px; }
.footer span span { padding: 0 6px; }

.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; min-height: 100dvh; }
.loading h1 { margin: 0; }
.loading p { color: var(--muted); }
.loading-logo { width: 240px; max-width: 70vw; }
.loading > svg { color: var(--green-ink); }

@media (max-width: 1200px) {
  .sidebar { width: 224px; }
  main { width: calc(100% - 224px); margin-left: 224px; }
  .topbar, .content { padding-left: 28px; padding-right: 28px; }
  .stat { padding: 18px 18px 20px; }
  .stat strong { font-size: 24px; }
  .page-heading { align-items: flex-start; }
}

@media (max-width: 980px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(3)::before { display: none; }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--rule); }
  .overview-grid { grid-template-columns: 1fr; }
  .page-heading { flex-direction: column; align-items: flex-start; gap: 16px; }
  .footer > span:last-child { display: none; }
  .import-banner { flex-wrap: wrap; }
  .import-banner > button { margin-left: 56px; }
}

@media (max-width: 700px) {
  .sidebar { display: none; }
  .sidebar.mobile-open {
    display: flex;
    top: 64px;
    width: min(310px, 88vw);
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: var(--shadow-float);
  }
  .sidebar.mobile-open .brand { width: 150px; margin: 4px auto 14px; }
  .sidebar.mobile-open nav { flex-shrink: 0; }
  .sidebar.mobile-open nav button { min-height: 48px; font-size: 15px; }
  .menu-backdrop { position: fixed; inset: 64px 0 0; z-index: 19; display: block; border: 0; border-radius: 0; background: rgba(1, 22, 67, 0.4); }
  .mobile-toggle { display: flex; }
  main { width: 100%; margin-left: 0; }
  .topbar { height: 64px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .breadcrumbs > span, .breadcrumbs > svg, .top-actions .connection { display: none; }
  .breadcrumbs b { max-width: 50vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top-actions { gap: 4px; }
  .content { padding: 20px max(16px, env(safe-area-inset-right)) 28px max(16px, env(safe-area-inset-left)); }
  .mobile-brand-logo { display: block; width: 132px; height: auto; margin: 0 0 18px; object-fit: contain; }
  h1 { font-size: 24px; }
  .page-heading { margin-bottom: 20px; }
  .page-heading p { font-size: 14px; }
  .heading-actions { width: 100%; justify-content: flex-start; gap: 8px; }
  .stat { padding: 16px 14px; }
  .stat strong { font-size: clamp(18px, 5.6vw, 24px); white-space: normal; overflow-wrap: anywhere; }
  .chart { gap: 8px; margin: 0; padding: 16px 14px 0; }
  .chart-col small { font-size: 10px; }
  .bar-track { width: 78%; }
  .card-heading { padding: 18px 16px 8px; }
  .stock-row { align-items: flex-start; padding: 14px 16px; }
  .stock-row b { max-width: 100%; white-space: normal; }
  .padded { padding: 20px; }
  .empty { padding: 32px 18px; }
  .import-banner { padding: 16px; }
  .import-banner > button { margin-left: 0; width: 100%; }
}

@media (max-width: 359px) {
  .stats { grid-template-columns: 1fr; }
  .stat + .stat::before { display: none; }
  .stat + .stat { border-top: 1px solid var(--rule); }
  .top-actions .avatar { display: none; }
}

/* ---------- Entrada (área de gestão e login) ---------- */
.access-gate { display: grid; place-items: center; width: 100%; min-height: 100dvh; margin: 0; padding: 24px; }
.access-gate section { width: 100%; max-width: 480px; padding: 36px 36px 32px; border-radius: 24px; }
.access-gate .loading-logo { display: block; width: 210px; margin: 0 auto 28px; }
.access-gate h1 { font-size: 26px; }
.access-gate p { color: var(--muted); line-height: 1.6; }
.access-gate .heading-actions { flex-wrap: wrap; justify-content: flex-start; margin-top: 8px; }
@media (max-width: 700px) {
  .access-gate { padding: 16px; }
  .access-gate section { padding: 28px 22px 24px; }
}
