/* Kontrolo MZ v4.12 — indicador "Por enviar" e folha da fila offline. */
.km-off-pill {
    position: fixed; left: 50%; transform: translateX(-50%); z-index: 1100;
    bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 12px);
    display: inline-flex; align-items: center; gap: 8px; max-width: calc(100vw - 32px);
    padding: 8px 14px; border: 0; border-radius: 999px; cursor: pointer;
    background: #121614; color: #fff; font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    -webkit-tap-highlight-color: transparent;
}
.km-off-pill[hidden] { display: none; }
/* Ecrãs sem barra de separadores (formulários): em cima, para não tapar o botão Guardar. */
html.km-off-top .km-off-pill { bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 8px); }
.km-off-pill [data-off-text] { overflow: hidden; text-overflow: ellipsis; }
.km-off-dot { width: 8px; height: 8px; border-radius: 50%; background: #2fbf68; flex: 0 0 8px; }
.km-off-pill[data-state="offline"] .km-off-dot { background: #8a948f; }
.km-off-pill[data-state="waiting"] .km-off-dot { background: #f5a524; }
.km-off-pill[data-state="attention"] { background: #b42318; }
.km-off-pill[data-state="attention"] .km-off-dot { background: #fff; }
.km-off-pill.is-busy .km-off-dot { animation: km-off-blink 0.9s infinite alternate; }
@keyframes km-off-blink { from { opacity: 1; } to { opacity: 0.25; } }
@media (min-width: 900px) {
    .km-off-pill { bottom: 20px; left: auto; right: 20px; transform: none; }
}

.km-off-sheet { position: fixed; inset: 0; z-index: 1300; display: flex; align-items: flex-end; justify-content: center; }
.km-off-sheet[hidden] { display: none; }
.km-off-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.38); }
.km-off-panel {
    position: relative; width: 100%; max-width: 560px; max-height: 82vh; overflow: auto; -webkit-overflow-scrolling: touch;
    background: #fff; color: #121614; border-radius: 20px 20px 0 0;
    padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 900px) { .km-off-sheet { align-items: center; } .km-off-panel { border-radius: 20px; } }
.km-off-handle { width: 38px; height: 5px; border-radius: 3px; background: rgba(60, 67, 63, 0.25); margin: 0 auto 8px; }
.km-off-head { display: flex; align-items: center; justify-content: space-between; }
.km-off-head h2 { margin: 0; font-size: 1.15rem; }
.km-off-x { border: 0; background: transparent; font-size: 1.6rem; line-height: 1; color: #5f6763; cursor: pointer; padding: 4px 8px; }
.km-off-note { margin: 4px 0 12px; color: #5f6763; font-size: 0.92rem; }
.km-off-list { display: grid; gap: 8px; }
.km-off-row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: start;
    padding: 12px; border-radius: 14px; background: #f4f6f5;
}
.km-off-row.is-attention { background: #fef3f2; }
.km-off-main { display: grid; gap: 2px; min-width: 0; }
.km-off-main strong { font-size: 0.97rem; overflow-wrap: anywhere; }
.km-off-main small { color: #5f6763; font-size: 0.82rem; }
.km-off-error { font-style: normal; color: #b42318; font-size: 0.85rem; }
.km-off-amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.km-off-actions { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 6px; }
.km-off-btn {
    flex: 1 1 0; min-height: 40px; border-radius: 10px; border: 1px solid rgba(60, 67, 63, 0.18);
    background: #fff; color: #121614; font: inherit; font-size: 0.92rem; font-weight: 700; cursor: pointer;
}
.km-off-btn.is-danger { color: #b42318; }
.km-off-send {
    width: 100%; min-height: 48px; margin-top: 14px; border: 0; border-radius: 14px;
    background: #0f8f3d; color: #fff; font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer;
}
.km-off-send[hidden] { display: none; }
html.km-off-sheet-open, html.km-off-sheet-open body { overflow: hidden; }

[data-theme="escuro"] .km-off-panel { background: #141d1a; color: #e9efec; }
[data-theme="escuro"] .km-off-row { background: #0f1614; }
[data-theme="escuro"] .km-off-row.is-attention { background: #2a1513; }
[data-theme="escuro"] .km-off-btn { background: #141d1a; color: #e9efec; }
[data-theme="escuro"] .km-off-note, [data-theme="escuro"] .km-off-main small { color: #a7b3ad; }

/* A antiga caixa "Modo offline" deixou de existir. */
.offline-sync-toast { display: none !important; }

/* v4.13 · teste gratuito por movimentos */
.km-trial-mov{display:flex;align-items:center;gap:12px;margin:0 0 14px;padding:12px 14px;border-radius:14px;text-decoration:none;color:inherit;border:1px solid transparent;line-height:1.3}
.km-trial-mov--low{background:#fff7e6;border-color:#f5c26b;color:#5c3b00}
.km-trial-mov--out{background:#fdecec;border-color:#ef9a9a;color:#6b1414}
.km-trial-mov__icon{flex:0 0 auto;display:inline-flex;width:28px;height:28px;align-items:center;justify-content:center}
.km-trial-mov__icon svg{width:22px;height:22px;stroke:currentColor;fill:none;stroke-width:2}
.km-trial-mov__text{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:2px}
.km-trial-mov__text strong{font-size:15px}
.km-trial-mov__text small{font-size:13px;opacity:.85}
.km-trial-mov__cta{flex:0 0 auto;font-size:13px;font-weight:700;padding:8px 12px;border-radius:999px;background:rgba(0,0,0,.08)}
@media (prefers-color-scheme:dark){
  .km-trial-mov--low{background:#3a2a07;border-color:#8a6418;color:#ffe2a8}
  .km-trial-mov--out{background:#3b1414;border-color:#8c3030;color:#ffd0d0}
  .km-trial-mov__cta{background:rgba(255,255,255,.12)}
}

/* v4.15 — código automático do produto */
.field-hint { display: block; margin-top: 4px; font-size: 12px; font-weight: 400; color: #6b7570; }
.product-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; color: #0f8f3d; letter-spacing: 0.02em; }
[data-theme="escuro"] .field-hint { color: #a7b3ad; }

/* v4.16 — código de barras */
.code-scan-row { display: flex; gap: 6px; align-items: stretch; }
.code-scan-row input { flex: 1; min-width: 0; }
.code-scan-btn { flex: 0 0 auto; width: 44px; border-radius: 10px; border: 1px solid #cfe3d6; background: #eaf7ef; color: #0f8f3d; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.code-scan-btn:hover { background: #d9f1e2; }
.qs-search-wrap.qs-search-scan { display: flex; align-items: center; }
.qs-search-wrap.qs-search-scan input { flex: 1; min-width: 0; }
.qs-scan-btn { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px; height: 36px; margin: 0 4px 0 6px; padding: 0 12px; border-radius: 10px; border: 0; background: #0f8f3d; color: #fff; font-weight: 700; font-size: 13px; cursor: pointer; box-shadow: 0 2px 6px rgba(15, 143, 61, .25); }
.qs-scan-btn:active { transform: scale(.97); }
.qs-scan-msg { margin: 6px 0 0; padding: 8px 10px; border-radius: 10px; font-size: 13px; font-weight: 600; }
.qs-scan-msg.is-ok { background: #e7f8ee; color: #0b6b2f; }
.qs-scan-msg.is-bad { background: #fff4e5; color: #8a4b00; }
.qs-scan-msg a { margin-left: 8px; color: #0f8f3d; text-decoration: underline; font-weight: 700; }
.caixa-scan-bar { display: grid; grid-template-columns: auto 1fr; gap: 8px; margin-bottom: 12px; }
.caixa-scan-bar .qs-scan-msg { grid-column: 1 / -1; margin: 0; }
.caixa-scan-btn { display: inline-flex; align-items: center; gap: 6px; background: #0f8f3d; color: #fff; border: 0; }
.caixa-scan-input { min-width: 0; }
@media (max-width: 420px) { .caixa-scan-bar { grid-template-columns: 1fr; } }
[data-theme="escuro"] .code-scan-btn { background: #12301f; border-color: #1e4d33; color: #6ee7a0; }
[data-theme="escuro"] .qs-scan-msg.is-ok { background: #12301f; color: #9be8b9; }
[data-theme="escuro"] .qs-scan-msg.is-bad { background: #3a2a10; color: #fcd38d; }
