:root {
  --bg: #f3f4f5;
  --surface: #ffffff;
  --surface-alt: #f6f6f6;
  --text: #1d1f21;
  --muted: #656565;
  --border: #dcdfe2;
  --head-bg: #656565;
  --head-text: #f9f9f9;
  --accent: #1081ba;
  --accent-soft: #e3f2f8;
  --accent-2: #5cb7cd;
  --on-accent: #ffffff;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --ok: #1e7a3a;
  --ok-soft: #e4f4e8;
  --radius: 6px;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 2px 8px rgb(0 0 0 / .05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  color-scheme: light;
}

/* Tema escuro: segue o sistema, a menos que o usuário escolha pelo botão (data-theme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a;
    --surface: #1f2226;
    --surface-alt: #262a2f;
    --text: #e7e9eb;
    --muted: #a0a5aa;
    --border: #353a40;
    --head-bg: #30353b;
    --head-text: #e7e9eb;
    --accent: #5cb7cd;
    --accent-soft: #1c3640;
    --on-accent: #0b1f26;
    --danger: #ff8a80;
    --danger-soft: #3d1f1d;
    --warn: #ffd27a;
    --warn-soft: #3a3020;
    --ok: #7fd59a;
    --ok-soft: #1c3324;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #15171a;
    --surface: #1f2226;
    --surface-alt: #262a2f;
    --text: #e7e9eb;
    --muted: #a0a5aa;
    --border: #353a40;
    --head-bg: #30353b;
    --head-text: #e7e9eb;
    --accent: #5cb7cd;
    --accent-soft: #1c3640;
    --on-accent: #0b1f26;
    --danger: #ff8a80;
    --danger-soft: #3d1f1d;
    --warn: #ffd27a;
    --warn-soft: #3a3020;
    --ok: #7fd59a;
    --ok-soft: #1c3324;
    color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem .9rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; white-space: nowrap; text-decoration: none;
}
@media (hover: hover) { .btn:hover:not(:disabled) { border-color: var(--accent); } }
.btn, .env-option { -webkit-tap-highlight-color: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
a.btn { color: var(--text); }
.btn.ghost { background: transparent; border-color: transparent; }
.theme-toggle { font-size: 1.05rem; line-height: 1; padding: .45rem .6rem; }
.login-wrap { position: relative; }
.login-wrap .theme-toggle { position: absolute; top: 12px; right: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.field { display: flex; flex-direction: column; gap: .3rem; }
.field input, .search input {
  padding: .5rem .6rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
}

/* ---------- Layout ---------- */
.app { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.topbar {
  display: flex; align-items: center; gap: .5rem; padding: .5rem 1rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
/* Logo: placa branca, pois o JPEG não tem transparência (mesmo recurso do login). */
.brand {
  display: inline-flex; align-items: center; flex: none; margin: 0 .35rem 0 .15rem;
  background: #fff; border-radius: 6px; padding: 4px 8px;
}
:root[data-theme="dark"] .brand { box-shadow: 0 0 0 1px rgb(255 255 255 / .08); }
.brand img { display: block; height: 26px; width: auto; }
.brand-mark { display: none !important; }
.topbar h1 {
  font-size: 1.15rem; margin: 0 .75rem 0 0; color: var(--muted); font-weight: 600;
  padding-left: .75rem; border-left: 1px solid var(--border); line-height: 1.6;
}
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: .9rem; }

.main { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 1rem; padding: 1rem; min-height: 0; }
.panel {
  min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; min-height: 0;
}
.panel-head { padding: .75rem; border-bottom: 1px solid var(--border); display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.panel-body { overflow: auto; flex: 1; min-height: 0; }

.search { display: flex; gap: .4rem; width: 100%; }
.search input { flex: 1; min-width: 0; }

/* ---------- Tabelas ---------- */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
thead th {
  position: sticky; top: 0; z-index: 1; background: var(--head-bg); color: var(--head-text);
  font-weight: 500; font-size: .85rem; padding: .55rem .5rem; text-align: left;
}
tbody td { padding: .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:nth-child(even) { background: var(--surface-alt); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.center, th.center { text-align: center; }

.orders tbody tr { cursor: pointer; }
.orders tbody tr:hover { background: var(--accent-soft); }
.orders tbody tr[aria-selected="true"] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.orders .client { color: var(--muted); font-size: .85rem; }

.badge { display: inline-block; padding: .05rem .45rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge.E { background: var(--warn-soft); color: var(--warn); }
.badge.R { background: var(--accent-soft); color: var(--accent); }
.badge.S { background: var(--ok-soft); color: var(--ok); }

.qty {
  width: 8rem; text-align: right; padding: .4rem .5rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); font-variant-numeric: tabular-nums;
}
.qty:disabled { background: transparent; border-color: transparent; }
.qty.changed { border-color: var(--accent); background: var(--accent-soft); }
.qty[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-soft); }
.err { display: block; color: var(--danger); font-size: .78rem; margin-top: .2rem; text-align: right; }
.items .sku::after { content: "-"; }
.qty-wrap { display: inline-flex; align-items: center; gap: 4px; }
.qty-field { position: relative; display: inline-block; }
.qty-wrap .unit { display: none; }
.step {
  flex: none; width: 30px; height: 32px; padding: 0; display: inline-grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--accent); font-size: 1.15rem; font-weight: 600; line-height: 1; cursor: pointer;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
/* Hover só com mouse: em tela de toque o hover fica "preso" após o toque. */
@media (hover: hover) { .step:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); } }
.step { -webkit-tap-highlight-color: transparent; }
.step:active:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.step:active:not(:disabled) { transform: scale(.94); }
.step:disabled { color: var(--muted); opacity: .4; cursor: default; }
/* Pedido enviado: sem botões de ajuste */
.qty-wrap:has(.qty:disabled) .step { display: none; }

.order-title { font-weight: 600; }
.order-sub { color: var(--muted); font-size: .9rem; }
.empty { padding: 2rem 1rem; color: var(--muted); text-align: center; }

/* ---------- Mensagens ---------- */
.notice { margin: .75rem; padding: .6rem .8rem; border-radius: var(--radius); font-size: .92rem; }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }

dialog {
  border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem; max-width: min(440px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgb(0 0 0 / .25);
}
dialog::backdrop { background: rgb(0 0 0 / .35); }
dialog .actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* ---------- Login ---------- */
:root { --brand-red: #e0002a; }

.login-page {
  background:
    radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--brand-red) 9%, transparent), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%),
    var(--bg);
}
.login-wrap {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.25rem; padding: 32px 16px;
}
.login {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 1px 2px rgb(0 0 0 / .06), 0 12px 40px rgb(0 0 0 / .10);
}
/* Faixa da marca: sempre branca, pois o logo é JPEG sem transparência. */
.login-brand {
  background: #fff; padding: 28px 32px 22px; display: flex; justify-content: center;
  border-bottom: 3px solid var(--brand-red);
}
.login-brand img { display: block; width: 100%; max-width: 260px; height: auto; }
.login-body { padding: 26px 32px 30px; display: flex; flex-direction: column; gap: 1.1rem; }
.login-head h1 { margin: 0; font-size: 1.35rem; font-weight: 650; color: var(--text); letter-spacing: -.01em; }
.login-head p { margin: .3rem 0 0; color: var(--muted); font-size: .92rem; }

.login .field label { font-size: .85rem; font-weight: 600; color: var(--muted); }
.login .field input { padding: .7rem .8rem; border-radius: 8px; transition: border-color .15s, box-shadow .15s; }
.login .field input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.pwd { position: relative; }
.pwd input { width: 100%; padding-right: 5.2rem; }
.pwd button {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--accent); font-size: .82rem; font-weight: 600;
  padding: .35rem .5rem; border-radius: 6px; cursor: pointer;
}
.pwd button:hover { background: var(--accent-soft); }

.login .subs {
  display: flex; flex-direction: column; gap: .4rem; margin: 0; padding: .75rem .9rem;
  border: 1px solid var(--border); border-radius: 8px;
}
.login .subs legend { font-size: .85rem; font-weight: 600; color: var(--muted); padding: 0 .3rem; }
.login .subs label { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; cursor: pointer; }
.login .notice { margin: 0; }
.login .btn.primary {
  justify-content: center; padding: .75rem 1rem; border-radius: 8px; font-weight: 600; font-size: 1rem;
}
.login .btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.login-foot { color: var(--muted); font-size: .8rem; text-align: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 50; max-width: min(420px, calc(100vw - 32px)); padding: .7rem 1rem; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: .92rem; box-shadow: 0 8px 28px rgb(0 0 0 / .25);
  animation: toast-in .18s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

.topbar .order-actions { display: flex; gap: .5rem; }
.only-mobile { display: none; }

/* ---------- Mobile: um painel por vez, página com rolagem natural ---------- */
@media (max-width: 760px) {
  :root { --topbar-h: 52px; --actionbar-h: 68px; }
  html, body { height: auto; }
  input, button { font-size: max(16px, 1em); } /* evita zoom automático do iOS */

  .app { display: block; height: auto; min-height: 100dvh; }
  .topbar {
    position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
    padding: 0 .25rem; gap: .15rem;
    padding-left: max(.25rem, env(safe-area-inset-left)); padding-right: max(.25rem, env(safe-area-inset-right));
  }
  .topbar h1 { font-size: 1.05rem; margin: 0 .25rem; white-space: nowrap; padding-left: 0; border-left: 0; }
  .brand { padding: 3px; margin: 0 .2rem 0 0; }
  .brand-full { display: none !important; }
  .brand-mark { display: block !important; height: 28px !important; }
  .topbar .btn { min-height: 44px; min-width: 44px; justify-content: center; padding: .4rem .6rem; }
  .topbar .lbl, .topbar .who { display: none; }
  .topbar > .btn { border-color: transparent; background: transparent; }
  .only-mobile { display: inline-flex; }

  /* Gravar/Enviar viram barra fixa no rodapé, só na tela de itens. */
  .topbar .order-actions {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    padding: .6rem 1rem calc(.6rem + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgb(0 0 0 / .08);
  }
  .topbar .order-actions .btn { flex: 1; min-height: 48px; font-weight: 600; }
  .app[data-view="orders"] .order-actions { display: none; }
  .app[data-editable="false"] .order-actions { display: none; } /* pedido enviado: nada a gravar */
  .app[data-view="items"][data-editable="false"] .main { padding-bottom: 0; }
  .app[data-view="items"] .main { padding-bottom: calc(var(--actionbar-h) + env(safe-area-inset-bottom)); }
  .app[data-view="items"] ~ .toast { bottom: calc(var(--actionbar-h) + 16px + env(safe-area-inset-bottom)); }

  .main { display: block; padding: 0; }
  .app[data-view="items"] .orders-panel { display: none; }
  .app[data-view="orders"] .items-panel { display: none; }
  .panel { border: 0; border-radius: 0; box-shadow: none; min-height: calc(100dvh - var(--topbar-h)); }
  .panel-body { overflow: visible; }
  .panel-head {
    position: sticky; top: var(--topbar-h); z-index: 10; background: var(--surface);
    padding: .6rem 1rem; flex-wrap: nowrap;
  }
  .items-panel .panel-head { padding-left: .25rem; }
  .items-panel .panel-head > div { min-width: 0; }
  .order-title, .order-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .search input, .search .btn { min-height: 44px; }
  .notice { margin: .75rem 1rem 0; }

  /* Pedidos em cartões */
  .orders thead { display: none; }
  .orders, .orders tbody { display: block; }
  .orders tbody tr {
    display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .15rem .75rem;
    padding: .8rem 1rem; min-height: 64px; border-bottom: 1px solid var(--border);
  }
  .orders tbody tr:nth-child(even) { background: transparent; }
  .orders tbody td { display: block; padding: 0; border: 0; }
  .orders td:nth-child(1) { font-weight: 600; font-size: 1rem; }
  .orders td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; font-size: .9rem; }
  .orders td:nth-child(3) { grid-column: 2; grid-row: 1; }
  .orders tbody tr:active { background: var(--accent-soft); }

  /* Itens em cartões */
  .items-panel .panel-body { background: var(--bg); padding: .75rem .75rem 1rem; }
  .items thead { display: none; }
  .items { display: block; }
  .items tbody { display: flex; flex-direction: column; gap: .75rem; }
  .items tbody tr {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas: "head head head" "req bal lot" "inp inp inp";
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 1px 2px rgb(0 0 0 / .05); overflow: hidden;
  }
  .items tbody tr:nth-child(even) { background: var(--surface); }
  .items tbody td { display: block; padding: 0; border: 0; text-align: left !important; }
  .items td:nth-child(1), .items td:nth-child(3) { display: none; }

  /* Cabeçalho: nº do item + código, nome do produto, selo "Alterado" */
  .items td:nth-child(2) {
    grid-area: head; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .5rem;
    padding: .85rem 1rem .75rem;
  }
  .items td:nth-child(2)::before {
    content: attr(data-item); padding: .05rem .45rem; border-radius: 6px;
    background: var(--accent-soft); color: var(--accent); font-size: .78rem; font-weight: 700;
  }
  .items .sku { color: var(--muted); font-size: .82rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
  .items .sku::after { content: none; }
  .items .sku-name { order: 2; flex-basis: 100%; font-weight: 650; font-size: 1rem; line-height: 1.3; }
  .items tr:has(.qty.changed) td:nth-child(2)::after {
    content: "Alterado"; order: 1; margin-left: auto; padding: .05rem .5rem; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent); font-size: .72rem; font-weight: 700;
  }

  /* Faixa de indicadores */
  .items td:nth-child(4), .items td:nth-child(5), .items td:nth-child(6) {
    padding: .6rem 1rem; background: var(--surface-alt);
    border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
    font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap;
  }
  .items td:nth-child(4) { grid-area: req; }
  .items td:nth-child(6) { grid-area: bal; border-left: 1px solid var(--border); }
  .items td:nth-child(5) { grid-area: lot; border-left: 1px solid var(--border); }
  .items td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: .15rem;
    font-size: .74rem; font-weight: 500; color: var(--muted); white-space: nowrap;
  }
  .items td[data-unit]::after { content: " " attr(data-unit); font-size: .75rem; font-weight: 500; color: var(--muted); }

  /* Campo de quantidade */
  .items td:nth-child(7) { grid-area: inp; padding: .75rem 1rem 1rem; }
  .items td:nth-child(7)::before { font-size: .8rem; font-weight: 600; color: var(--text); margin-bottom: .4rem; }
  .qty-wrap { display: flex; gap: .5rem; }
  .qty-field { flex: 1; min-width: 0; display: block; }
  .step { width: 52px; height: 50px; border-radius: 10px; font-size: 1.5rem; }
  .qty-wrap .unit {
    display: block; position: absolute; right: .9rem; top: 50%; transform: translateY(-50%);
    color: var(--muted); font-size: .85rem; font-weight: 600; pointer-events: none;
  }
  .qty {
    width: 100%; min-height: 50px; text-align: right; font-size: 1.2rem; font-weight: 600;
    padding: .5rem 3.2rem .5rem .9rem; border-radius: 10px;
  }
  .qty:disabled { border-color: var(--border); background: var(--surface-alt); color: var(--muted); }
  .err { text-align: left; font-size: .85rem; margin-top: .4rem; }
}

/* ---------- Seleção ----------
   No fim do arquivo para prevalecer sobre as listras e o layout mobile. */
.orders tbody tr, .items tbody tr { transition: background-color .12s ease, box-shadow .12s ease; }

/* Pedido aberto */
.orders tbody tr[aria-selected="true"] {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  box-shadow: inset 4px 0 0 var(--accent);
}
.orders tbody tr[aria-selected="true"] td { font-weight: 600; }
.orders tbody tr[aria-selected="true"] td:first-child { color: var(--accent); }
.orders tbody tr[aria-selected="true"] .client { color: var(--text); }
.orders tbody tr[aria-selected="true"] .badge.R { background: var(--surface); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent); }

/* Item em edição (campo de quantidade com foco) */
.items tbody tr:focus-within {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  box-shadow: inset 4px 0 0 var(--accent);
}
.items tbody tr:focus-within td:nth-child(2) { font-weight: 600; }
.items tbody tr:focus-within .qty:not([aria-invalid="true"]) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
  outline: none;
}
/* Item com erro: barra lateral vermelha mesmo sem foco */
.items tbody tr:has(.qty[aria-invalid="true"]) { box-shadow: inset 4px 0 0 var(--danger); }

@media (prefers-reduced-motion: reduce) {
  .orders tbody tr, .items tbody tr { transition: none; }
}

/* ---------- Login: carrossel de imagens ---------- */
.login-hero { position: relative; overflow: hidden; background: #111; }
.hero-slides, .hero-slide { position: absolute; inset: 0; }
.hero-slide { opacity: 0; transition: opacity 1.4s ease; }
.hero-slide.active { opacity: 1; }
.hero-slide img { width: 100%; height: 100%; object-fit: cover; display: block; transform-origin: 60% 40%; }
.hero-slide.active img { animation: hero-zoom 9s ease-out forwards; }
/* Enquadramento por imagem: a ZinKlad tem o logo do produto à esquerda. */
.hero-slide img[src*="zinklad"] { object-position: 0% 50%; transform-origin: 30% 45%; }
@keyframes hero-zoom { from { transform: scale(1); } to { transform: scale(1.07); } }
/* Escurece a base para a legenda ficar legível sobre qualquer foto. */
.login-hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgb(0 0 0 / 0) 45%, rgb(0 0 0 / .65) 100%);
}
.hero-caption {
  position: absolute; left: 40px; right: 40px; bottom: 56px; z-index: 1; color: #fff;
  display: flex; flex-direction: column; gap: .2rem; text-shadow: 0 1px 8px rgb(0 0 0 / .4);
}
.hero-caption strong { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
.hero-caption strong::before {
  content: ""; display: block; width: 40px; height: 4px; margin-bottom: .75rem;
  background: var(--brand-red); border-radius: 2px;
}
.hero-caption span { font-size: 1rem; opacity: .9; }
.hero-dots { position: absolute; left: 40px; bottom: 28px; z-index: 1; display: flex; gap: 6px; }
.hero-dots i { width: 22px; height: 3px; border-radius: 2px; background: rgb(255 255 255 / .4); transition: background-color .4s; }
.hero-dots i.active { background: #fff; }

/* Desktop: imagem à esquerda, formulário à direita. */
@media (min-width: 900px) {
  .login-page.has-hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(420px, 1fr); min-height: 100vh; }
  .login-page.has-hero .login-hero { position: sticky; top: 0; height: 100vh; }
}
/* Celular/tablet: imagem de fundo atrás do cartão. */
@media (max-width: 899px) {
  .login-page.has-hero .login-hero { position: fixed; inset: 0; z-index: 0; }
  .login-page.has-hero .login-hero::after { background: rgb(0 0 0 / .55); }
  /* Como fundo, a foto não deve competir com o cartão: desfoque leve. */
  .login-page.has-hero .hero-slide img { filter: blur(4px); scale: 1.08; }
  .login-page.has-hero .hero-slide img[src*="zinklad"] { object-position: 62% 50%; }
  .login-page.has-hero .hero-caption, .login-page.has-hero .hero-dots { display: none; }
  .login-page.has-hero .login-wrap { position: relative; z-index: 1; min-height: 100dvh; }
  .login-page.has-hero .login-foot, .login-page.has-hero .login-wrap > .theme-toggle { color: #fff; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-slide { transition: none; }
  .hero-slide.active img { animation: none; }
}

/* ---------- Estados dos cartões de item (celular) ---------- */
@media (max-width: 760px) {
  .items tbody tr:focus-within {
    background: var(--surface); border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  }
  .items tbody tr:focus-within td:nth-child(2) { font-weight: inherit; }
  .items tbody tr:has(.qty.changed) { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
  .items tbody tr:has(.qty[aria-invalid="true"]) {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent);
  }
  .items tbody tr:has(.qty[aria-invalid="true"]) td:nth-child(2)::after { content: none; }
}

/* ---------- Convite de instalação (PWA) ---------- */
.install-banner {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: min(520px, calc(100vw - 24px));
  display: flex; align-items: center; gap: .75rem; padding: .75rem .9rem;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 10px 32px rgb(0 0 0 / .18);
  animation: toast-in .2s ease-out;
}
.install-banner img { flex: none; width: 40px; height: 40px; border-radius: 10px; background: #fff; padding: 4px; }
.install-banner p { margin: 0; flex: 1; font-size: .9rem; line-height: 1.35; }
.install-actions { display: flex; gap: .25rem; flex: none; }
@media (max-width: 760px) {
  .install-banner { flex-wrap: wrap; }
  .install-actions { width: 100%; justify-content: flex-end; }
  /* Na tela de itens o rodapé é da barra Gravar/Enviar. */
  .app[data-view="items"] ~ .install-banner { display: none; }
}
@media (prefers-reduced-motion: reduce) { .install-banner { animation: none; } }

/* ---------- Modal "Selecione o ambiente" ---------- */
.env-dialog { width: min(420px, calc(100vw - 32px)); padding: 1.25rem 1.25rem 1rem; }
.env-dialog h2 { margin: 0 0 .9rem; font-size: 1.15rem; font-weight: 650; }
.env-list { display: flex; flex-direction: column; gap: .5rem; max-height: 55vh; overflow: auto; }
.env-option {
  display: flex; align-items: center; gap: .7rem; min-height: 52px; padding: .65rem .85rem;
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  transition: border-color .12s, background-color .12s;
}
@media (hover: hover) { .env-option:hover { border-color: var(--accent); } }
.env-option:has(input:checked) {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
.env-option input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex: none; }
.env-name { flex: 1; font-weight: 600; }
.env-current {
  padding: .05rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 700;
  background: var(--surface-alt); color: var(--muted); border: 1px solid var(--border);
}
.env-dialog .notice { margin: .75rem 0 0; }
@media (max-width: 760px) {
  .env-dialog .actions .btn { flex: 1; justify-content: center; min-height: 46px; }
}

/* Tela de autorização do conector MCP (oauth/authorize). */
.login-body > .btn { justify-content: center; min-height: 44px; }
.login-body > .btn:not(.primary) { margin-top: -.4rem; }
.login .hint { margin: -.4rem 0 0; color: var(--muted); font-size: .85rem; }
.login-page { min-height: 100dvh; }
.login-foot a { color: inherit; }
#btnHelp span[aria-hidden] { font-weight: 700; }
@media (max-width: 380px) { .topbar h1 { display: none; } }
