/* UMÊ System — base visual. Cores e tipos como variáveis: troque aqui para ajustar a identidade. */
:root {
  --ink: #1b2540;
  --ink-2: #44506b;
  --ink-3: #66718a;
  --paper: #f7f8fa;
  --surface: #ffffff;
  --line: #dde1ea;
  --line-strong: #c3c9d6;
  --plum: #9c2c5e;
  --plum-weak: #f6e6ee;
  --blue: #2457a6;
  --blue-weak: #e5edf9;
  --matcha: #2f7d5b;
  --matcha-weak: #e3f1ea;
  --amber: #a85f00;
  --amber-weak: #fcefd6;
  --alert: #c4161c;
  --alert-weak: #fce6e6;
  --font: "Zen Kaku Gothic New", "Hiragino Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --focus: 0 0 0 3px rgba(36, 87, 166, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 700; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.0625rem; }
p { margin: 0; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: 0.875rem; }
.num { text-align: right; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 44px; padding: 0.5rem 1.1rem;
  border: 1.5px solid var(--ink); border-radius: var(--r-md);
  background: var(--ink); color: #fff; font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #121a2e; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn.secondary:hover { border-color: var(--ink); background: var(--surface); }
.btn.danger { background: var(--alert); border-color: var(--alert); }
.btn.danger.outline { background: var(--surface); color: var(--alert); }
.btn.ok { background: var(--matcha); border-color: var(--matcha); }
.btn.sm { min-height: 36px; padding: 0.25rem 0.8rem; font-size: 0.9rem; }
.btn.block { width: 100%; }
.linklike { background: none; border: 0; padding: 0; color: var(--blue); text-decoration: underline; cursor: pointer; }

/* ---------- Formulários ---------- */
.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.field > label, .field > .label { font-weight: 700; font-size: 0.9rem; }
.field .hint { font-size: 0.85rem; color: var(--ink-3); }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface);
}
textarea.input { min-height: 88px; resize: vertical; }
.input:hover { border-color: var(--ink-3); }
.input:focus-visible { border-color: var(--blue); box-shadow: var(--focus); }
.input[aria-invalid="true"] { border-color: var(--alert); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
.check { display: flex; align-items: flex-start; gap: 0.6rem; cursor: pointer; }
.check input { width: 22px; height: 22px; margin-top: 1px; accent-color: var(--ink); flex: none; }
.form-error { color: var(--alert); font-weight: 700; min-height: 1.5em; }

/* ---------- Estrutura do app ---------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--ink); color: #e8ebf3;
  display: flex; flex-direction: column; padding: 1.25rem 0.75rem; gap: 1.25rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 0.7rem; padding: 0 0.6rem; color: #fff; text-decoration: none; }
.brand img { width: 34px; height: 34px; }
.brand b { font-size: 1.2rem; font-weight: 900; letter-spacing: 0.01em; }
.brand span { display: block; font-size: 0.78rem; color: #aab3c8; font-weight: 400; margin-top: -2px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; min-height: 42px; padding: 0.4rem 0.75rem;
  border-radius: var(--r-md); color: #d5dae7; text-decoration: none; font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav a[aria-current="page"] { background: #fff; color: var(--ink); font-weight: 700; box-shadow: inset 4px 0 0 var(--plum); }
.side .who { margin-top: auto; padding: 0.75rem 0.6rem 0; border-top: 1px solid rgba(255, 255, 255, 0.14); font-size: 0.9rem; }
.side .who b { display: block; color: #fff; }
.side .who .linklike { color: #c9d3ec; }

.main { padding: 1.5rem clamp(1rem, 3vw, 2.25rem) 3rem; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head p { color: var(--ink-3); margin-top: 0.2rem; max-width: 62ch; }
.store-pick { display: flex; align-items: center; gap: 0.5rem; }
.store-pick select { min-height: 40px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.25rem; }
.panel.flush { padding: 0; overflow: hidden; }
.panel > h2 { margin-bottom: 0.75rem; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 0.6rem 0.75rem; gap: 0.4rem 0.75rem; overflow: visible; }
  .side .field { flex: 1 1 160px; }
  .brand span { display: none; }
  .nav { flex-direction: row; overflow-x: auto; order: 3; width: 100%; padding-bottom: 2px; }
  .nav a { white-space: nowrap; }
  .side .who { margin: 0 0 0 auto; border: 0; padding: 0; text-align: right; }
}

/* ---------- Tabela ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 0.7rem 1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { font-size: 0.85rem; font-weight: 700; color: var(--ink-2); background: #fbfcfd; white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #fafbfd; }
.tbl td.actions { white-space: nowrap; text-align: right; }
.tbl .sub { display: block; font-size: 0.85rem; color: var(--ink-3); }

/* ---------- Etiquetas de status ---------- */
.tag { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.1rem 0.65rem; border-radius: 999px; font-size: 0.85rem; font-weight: 700; background: #eceff5; color: var(--ink-2); white-space: nowrap; }
.tag.plum { background: var(--plum-weak); color: var(--plum); }
.tag.blue { background: var(--blue-weak); color: var(--blue); }
.tag.ok { background: var(--matcha-weak); color: var(--matcha); }
.tag.warn { background: var(--amber-weak); color: var(--amber); }
.tag.bad { background: var(--alert-weak); color: var(--alert); }

/* ---------- Avisos ---------- */
.notice { padding: 0.75rem 1rem; border-radius: var(--r-md); background: var(--blue-weak); color: #17407d; }
.notice.warn { background: var(--amber-weak); color: #6e3f00; }
.notice.bad { background: var(--alert-weak); color: #8f1015; }
/* Faixa de alergia/restrição: o elemento mais importante da operação, nunca discreto. */
.allergy {
  display: flex; align-items: flex-start; gap: 0.6rem;
  background: var(--alert); color: #fff; padding: 0.6rem 0.9rem; border-radius: var(--r-md); font-weight: 700;
}
.allergy::before { content: "!"; flex: none; width: 1.6em; height: 1.6em; border-radius: 50%; background: #fff; color: var(--alert); display: grid; place-items: center; font-weight: 900; }
.allergy.none { background: var(--surface); color: var(--ink-2); border: 1.5px dashed var(--line-strong); font-weight: 500; }
.allergy.none::before { content: "✓"; background: var(--matcha-weak); color: var(--matcha); }

.empty { padding: 2.5rem 1rem; text-align: center; color: var(--ink-3); }
.empty b { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: 0.25rem; }

/* ---------- Modal e avisos rápidos ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 22, 40, 0.55); display: grid; place-items: center; padding: 1rem; z-index: 50; overflow-y: auto; }
.dialog { background: var(--surface); border-radius: var(--r-lg); width: min(560px, 100%); max-height: calc(100vh - 2rem); overflow-y: auto; box-shadow: 0 20px 60px rgba(15, 22, 40, 0.35); }
.dialog.wide { width: min(860px, 100%); }
.dialog > header { padding: 1.1rem 1.25rem 0; }
.dialog > .body { padding: 1rem 1.25rem; }
.dialog > footer { padding: 0.9rem 1.25rem 1.1rem; display: flex; justify-content: flex-end; gap: 0.6rem; flex-wrap: wrap; border-top: 1px solid var(--line); }
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 60; max-width: min(420px, calc(100vw - 2rem)); }
.toast { padding: 0.75rem 1rem; border-radius: var(--r-md); background: var(--ink); color: #fff; font-weight: 500; box-shadow: 0 8px 24px rgba(15, 22, 40, 0.3); }
.toast.bad { background: var(--alert); }
.toast.ok { background: var(--matcha); }

/* ---------- Tela de entrada ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; background: var(--ink); }
.login-card { width: min(400px, 100%); background: var(--surface); border-radius: var(--r-lg); padding: 2rem 1.75rem; }
.login-card .brand { color: var(--ink); padding: 0; margin-bottom: 1.5rem; }
.login-card .brand span { color: var(--ink-3); }

/* ---------- Abas e listas ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; border-bottom: 1px solid var(--line-strong); margin-bottom: 1rem; }
.tab { background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; padding: 0.7rem 1rem; font-weight: 500; color: var(--ink-3); cursor: pointer; min-height: 44px; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); font-weight: 700; border-bottom-color: var(--plum); }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 0.9rem 0; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

fieldset { border: 1px solid var(--line, #e3dfe6); border-radius: 8px; padding: 0.7rem 0.9rem; margin: 0; min-width: 0; }
legend { font-weight: 700; padding: 0 0.3rem; }
.tbl td.num, .tbl th.num { text-align: right; }

/* Plataforma (administrador): empresas, ferramentas e atualização */
.plat-grid { display: grid; gap: 1rem; margin-top: 1rem; }
.plat-company > header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.75rem; }
.plat-company h3 { font-size: 1.1rem; }
.mods { display: grid; gap: 0.6rem 1.5rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin: 0.75rem 0 1rem; }
.mods .hint { display: block; font-size: 0.85rem; color: var(--ink-3); }
.log { margin: 0.75rem 0 0; padding: 0.75rem 1rem; max-height: 240px; overflow: auto; background: #101729; color: #dfe6f5; border-radius: var(--r-md); font: 0.8rem/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; }
.upd-state { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; align-items: center; margin-bottom: 0.75rem; }
.upd-state b { font-size: 1.05rem; }
