/* Ventilus · App de Produção — estilos partilhados */
:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --surface-2: #f7f8f5;
  --line: #dcdfd7;
  --line-strong: #b9beb2;
  --ink: #15191c;
  --ink-2: #4a5157;
  --ink-3: #737b82;
  --accent: #0b57a4;
  --accent-ink: #ffffff;
  --accent-soft: #e3eefa;
  --ok: #1d7a3e;
  --ok-soft: #e1f3e6;
  --warn: #a35c00;
  --warn-soft: #fdf0dc;
  --err: #b42318;
  --err-soft: #fde6e3;
  --steel: #5b6b78;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 25, 30, .06), 0 4px 16px rgba(20, 25, 30, .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111416; --surface: #1a1e21; --surface-2: #20252a; --line: #2e3439; --line-strong: #444c53;
    --ink: #eef1f3; --ink-2: #b8c0c6; --ink-3: #8a939a; --accent: #5ea4ee; --accent-ink: #08121c; --accent-soft: #1b2c3e;
    --ok: #5fcf86; --ok-soft: #173223; --warn: #f0b154; --warn-soft: #382a14; --err: #ff8a7d; --err-soft: #3d1c19; --steel: #9db0bf;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111416; --surface: #1a1e21; --surface-2: #20252a; --line: #2e3439; --line-strong: #444c53;
  --ink: #eef1f3; --ink-2: #b8c0c6; --ink-3: #8a939a; --accent: #5ea4ee; --accent-ink: #08121c; --accent-soft: #1b2c3e;
  --ok: #5fcf86; --ok-soft: #173223; --warn: #f0b154; --warn-soft: #382a14; --err: #ff8a7d; --err-soft: #3d1c19; --steel: #9db0bf;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.hide { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.big { min-height: 60px; padding: 0 26px; font-size: 18px; border-radius: var(--radius); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; font-size: 18px; color: var(--ink-2); }
.icon-btn:hover { background: var(--surface-2); }

/* campos */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=search], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* cartões */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }

/* barras de progresso */
.bar { display: inline-block; position: relative; width: 100%; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; vertical-align: middle; }
.bar > span { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 99px; transition: width .3s; }
.bar.ok > span { background: var(--ok); }
.bar.thick { height: 12px; }

/* estados */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.err { background: var(--err-soft); color: var(--err); border-color: transparent; }
.pill.acc { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.sync { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.sync i { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; }
.sync-busy i { background: var(--accent); animation: pulse 1s infinite; }
.sync-warn i { background: var(--warn); }
.sync-err i { background: var(--err); }
.sync-demo i { background: var(--steel); }
.sync-err { color: var(--err); }
@keyframes pulse { 50% { opacity: .3; } }

/* toasts */
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 1000; pointer-events: none; width: min(92vw, 460px); }
.toast { padding: 14px 18px; border-radius: var(--radius-sm); background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: var(--shadow); text-align: center; animation: tin .2s ease-out; }
.toast-err { background: var(--err); color: #fff; }
.toast-warn { background: var(--warn); color: #fff; }
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes tin { from { transform: translateY(10px); opacity: 0; } }

/* modais */
.modal-wrap { position: fixed; inset: 0; background: rgba(10, 14, 18, .5); display: grid; place-items: center; z-index: 900; padding: 16px; animation: fin .15s; }
@keyframes fin { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: var(--radius); width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal-wide { width: min(900px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 8px; }
.modal-body { padding: 8px 18px 16px; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* tabelas */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.t th, table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.t th { position: sticky; top: 0; background: var(--surface-2); font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: none; z-index: 1; white-space: nowrap; }
table.t td.r, table.t th.r { text-align: right; font-variant-numeric: tabular-nums; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: var(--surface-2); }
table.t tfoot td { font-weight: 700; background: var(--surface-2); position: sticky; bottom: 0; }
table.t tr.clickable { cursor: pointer; }
table.t tr.voided td { color: var(--ink-3); text-decoration: line-through; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(420px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; }
/* logótipo = ícone da app (o "V" no HTML fica escondido, só para leitores de ecrã) */
.brand-mark { width: 42px; height: 42px; border-radius: 10px; background: #0B1A3F url(icon.svg) center / cover no-repeat; color: transparent; font-size: 0; overflow: hidden; flex: none; }
.brand small { display: block; color: var(--ink-3); font-size: 12px; font-weight: 500; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pinpad button { min-height: 64px; font-size: 24px; font-weight: 600; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; }
.pinpad button:active { background: var(--accent-soft); }
.pin-dots { display: flex; justify-content: center; gap: 12px; min-height: 22px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); }
.pin-dots i.on { background: var(--accent); border-color: var(--accent); }
.err-text { color: var(--err); font-weight: 600; text-align: center; min-height: 20px; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 99px; overflow: hidden; background: var(--surface); max-width: 100%; overflow-x: auto; }
.seg button { min-height: 40px; padding: 0 16px; border: 0; background: transparent; font-weight: 600; cursor: pointer; color: var(--ink-2); white-space: nowrap; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

.upd-banner { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 950; display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 18px; border-radius: 99px; background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.upd-banner small { opacity: .7; font-weight: 500; }

.empty { padding: 36px 16px; text-align: center; color: var(--ink-3); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

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

/* meteo ao vivo (tablets e escritório) */
.wx-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.wx-card.wx-warn { border-color: var(--warn); }
.wx-card.wx-err { border-color: var(--err); }
.wx-empty { flex-direction: row; gap: 10px; align-items: center; }
.wx-now { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.wx-ico { font-size: 40px; line-height: 1; }
.wx-temp { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.wx-facts { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 200px; }
.wx-alert { font-weight: 700; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--warn-soft); }
.wx-alert.wx-t-err { background: var(--err-soft); }
.wx-t-warn { color: var(--warn); } .wx-t-err { color: var(--err); }
.wx-hours { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.wx-h { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 52px; padding: 6px 4px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 15px; }
.wx-rain { color: var(--accent); }
.wx-src { font-size: 11px; }

/* ordenar tabelas: clicar no título da coluna */
table.t:not(.no-sort) thead th { cursor: pointer; user-select: none; }
table.t:not(.no-sort) thead th:hover { color: var(--accent); }
table.t thead th.sort-asc::after { content: " ▲"; color: var(--accent); font-size: 10px; }
table.t thead th.sort-desc::after { content: " ▼"; color: var(--accent); font-size: 10px; }
