/* Avaliador para Stands
   Layout: desktop com barra lateral fixa; telemóvel com barra superior e navegação inferior.
   Um campo por linha, valores grandes, botões de pelo menos 48px. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --line: #dde3ec;
  --fg: #101828;
  --muted: #5b6678;
  --accent: #1f4fd8;
  --accent-fg: #ffffff;
  --accent-soft: #e6edfd;
  --warn-bg: #fff4d6;
  --warn-fg: #5c4300;
  --good: #17794a;
  --good-bg: #e2f5ea;
  --bad: #b3261e;
  --bad-bg: #fde7e5;
  --font-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d121b; --surface: #161d2a; --line: #28324a; --fg: #eef2f9; --muted: #9aa6bb;
    --accent: #7f9cff; --accent-fg: #0b1020; --accent-soft: #1c2848;
    --warn-bg: #3a2f10; --warn-fg: #f5dd9b;
    --good: #55d08f; --good-bg: #12301f; --bad: #ff8a80; --bad-bg: #3a1714;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d121b; --surface: #161d2a; --line: #28324a; --fg: #eef2f9; --muted: #9aa6bb;
  --accent: #7f9cff; --accent-fg: #0b1020; --accent-soft: #1c2848;
  --warn-bg: #3a2f10; --warn-fg: #f5dd9b;
  --good: #55d08f; --good-bg: #12301f; --bad: #ff8a80; --bad-bg: #3a1714;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100dvh;
}
h1, h2, h3 { font-family: var(--font-display); margin: 0; text-wrap: balance; }
h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 20px; }
h3 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---- Autenticação ---- */
.auth {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding-block: max(24px, env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.auth-card {
  width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 24px; display: flex; flex-direction: column; gap: 18px;
}
.brand { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: .02em; color: var(--accent); }
.qr { align-self: center; background: #fff; padding: 12px; border-radius: 10px; width: 232px; max-width: 100%; line-height: 0; }
.qr svg { width: 100%; height: auto; display: block; }
.secret { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 17px; letter-spacing: .06em; word-break: break-all; background: var(--bg); border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; user-select: all; }
.code-input { text-align: center; font: 700 28px var(--font-display) !important; letter-spacing: .3em; font-variant-numeric: tabular-nums; }

/* ---- Avisos ---- */
.banner { background: var(--warn-bg); color: var(--warn-fg); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.error { background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  background: var(--fg); color: var(--bg); padding: 12px 18px; border-radius: 10px; font-weight: 600; z-index: 50; max-width: calc(100% - 32px);
}

/* ---- Campos ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field[hidden] { display: none; }
.list-row.editing { background: var(--accent-soft); border-radius: 8px; padding-inline: 10px; }
.list-row .btn { min-height: 36px; padding: 0 14px; font-size: 14px; }
.field.inline-hint { flex-direction: row; flex-wrap: wrap; align-items: baseline; column-gap: 10px; row-gap: 6px; }
.field.inline-hint > .control { flex: 0 0 100%; }
.transp-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.transp-row > .field:first-child { flex: 0 0 auto; }
.transp-row > .field:last-child { flex: 0 1 auto; flex-direction: row; align-items: center; gap: 10px; }
.transp-row > .field:last-child > label { white-space: nowrap; font-weight: 500; }
.faixa > .field { flex: 0 1 auto !important; flex-direction: row !important; align-items: center; gap: 10px; }
.faixa > .field > label { white-space: nowrap; font-weight: 500; }
.faixa .control { max-width: 150px; }
.faixa .input { min-width: 200px; }
.transp-row .money input:disabled { opacity: .5; }
.field > label, .label { font-weight: 600; font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 42px; border: 1.5px solid var(--line); border-radius: 8px;
  background: var(--bg); padding: 0 10px; font-size: 15px;
}
textarea.input { padding: 8px 10px; min-height: 72px; resize: vertical; }
.input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.control { display: flex; align-items: center; gap: 8px; }
.control { max-width: 190px; }
.money {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--line); border-radius: 8px; background: var(--bg); padding-inline: 10px; height: 42px;
}
.money:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.money input { flex: 1; min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; font: 600 17px var(--font-display); font-variant-numeric: tabular-nums; }
.money input:focus-visible { outline: 0; }
.money input::placeholder { color: var(--muted); font-weight: 500; }
.money .unit { color: var(--muted); font-weight: 600; font-size: 15px; }
.money.big { height: 52px; }
.money.big input { font-size: 24px; }
.clear { width: 42px; height: 42px; flex: none; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
.clear:hover { color: var(--fg); border-color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }

/* ---- Botões ---- */
.btn {
  min-height: 48px; padding: 0 18px; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 15px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--fg);
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger.armed { border-color: var(--bad); color: var(--bad); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-mini { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 140px; }

/* ---- Estrutura da app ---- */
.shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; min-height: 100dvh; }
.side { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.topbar-in { height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar .co { font-family: var(--font-display); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main {
  padding-block: 20px 120px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.content { width: 100%; max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; flex-direction: column; gap: 6px; }
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
.navitem {
  flex: 1; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600;
}
.navitem svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.navitem.active { color: var(--accent); }

@media (min-width: 900px) {
  .shell { grid-template-columns: 264px 1fr; }
  .side {
    display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100vh; height: 100dvh;
    background: var(--surface); border-right: 1px solid var(--line); padding: 24px 16px;
  }
  .side .co { font-family: var(--font-display); font-weight: 700; font-size: 18px; padding-inline: 10px; }
  .side nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
  .side .navitem { flex: none; flex-direction: row; justify-content: flex-start; min-height: 46px; padding: 0 12px; border-radius: 10px; font-size: 15px; gap: 12px; }
  .side .navitem.active { background: var(--accent-soft); }
  .side .foot { padding-inline: 10px; display: flex; flex-direction: column; gap: 8px; }
  .topbar, .bottomnav { display: none; }
  .main { padding: 36px 40px 60px; }
  .content { max-width: 880px; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-2 .wide { grid-column: 1 / -1; }
  .toast { bottom: 32px; }
}

/* ---- Menu Admin com submenu ---- */
.navgroup { display: flex; flex-direction: column; flex: 1; }
.navgroup > .navitem { flex: 1; }
.submenu { display: none; }
.navgroup.open .submenu { display: flex; }
.subitem { text-decoration: none; color: var(--fg); font-size: 15px; font-weight: 500; min-height: 44px; display: flex; align-items: center; padding: 0 14px; border-radius: 8px; }
.subitem.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.submenu-back { display: none; }
.bottomnav .navgroup.open .submenu-back { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.25); }
.bottomnav .submenu {
  position: fixed; left: 12px; right: 12px; bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 8px); z-index: 40;
  flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px;
  max-height: 60vh; overflow-y: auto; box-shadow: 0 8px 28px rgba(0,0,0,.18);
}
.side .navgroup { flex: none; gap: 4px; }
.side .submenu { flex-direction: column; margin-left: 22px; padding-left: 8px; border-left: 2px solid var(--line); }
.side .navgroup > .navitem::after { content: "▾"; margin-left: auto; transition: transform .15s; }
.side .navgroup.open > .navitem::after { transform: rotate(180deg); }

/* ---- Painéis, separadores, tabelas ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { padding: 12px 14px; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list-row:last-child { border-bottom: 0; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.tag.ok { background: var(--good-bg); color: var(--good); }
.tag.no { background: var(--warn-bg); color: var(--warn-fg); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.kv:last-child { border-bottom: 0; }
.kv span:last-child { font-weight: 600; text-align: right; }

/* ---- Avaliação ---- */
.progress { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); }
.choices { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.choice {
  width: 100%; max-width: 460px; align-items: center; text-align: center; border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 18px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; min-height: 76px;
}
.choice:hover { border-color: var(--accent); }
.choice strong { font-family: var(--font-display); font-size: 20px; }
.choice span { color: var(--muted); font-size: 14px; }
.wiz-nav { justify-content: center; }
.wiz-nav .btn { flex: 0 1 auto; min-height: 40px; padding: 0 22px; font-size: 14px; }
.result-hero { border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 4px; }
.result-hero.good { background: var(--good-bg); color: var(--good); }
.result-hero.bad { background: var(--bad-bg); color: var(--bad); }
.result-hero .big { font-family: var(--font-display); font-weight: 700; font-size: 40px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.result-hero .lbl { font-weight: 600; }
.maxbuy { background: var(--accent-soft); border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; }
.maxbuy .big { font-family: var(--font-display); font-weight: 700; font-size: 30px; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: no-preference) {
  .money, .input, .choice { transition: border-color .15s, box-shadow .15s; }
}

/* simulador de ISV */
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; cursor: pointer; }
label.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--accent); }
.isvdet { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 0 16px; }
.isvdet > summary { cursor: pointer; padding: 14px 0; font-weight: 600; min-height: 44px; }
.isvdet[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.isvdet[open] { padding-bottom: 16px; }
