@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;600;700&display=swap');

/* INOVAWOOD Planeamento — app de chão de fábrica.
   Fundo branco e linhas finas como as apps de trabalho da HOMAG; azul só para o que se clica;
   o tom de madeira fica reservado à marca. */
:root {
  --ink: #1b2a38;
  --ink-2: #4a5b6b;
  --canvas: #eef1f4;
  --surface: #ffffff;
  --line: #d9dee4;
  --side: #15283a;
  --side-ink: #c4d0db;
  --accent: #0b84c6;
  --accent-weak: #e5f2fa;
  --wood: #b9772e;
  --ok: #1d7a46;
  --ok-weak: #e3f3ea;
  --warn: #9a5b00;
  --err: #d4183d;
  --err-weak: #f9e1e5;
  --radius: 6px;
  font-family: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- estrutura ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 24px; color: #fff; font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; }
.brand small { display: block; font-weight: 500; font-size: .85rem; color: var(--side-ink); letter-spacing: 0; }
.brand-mark { width: 30px; height: 30px; border-radius: 5px; background: repeating-linear-gradient(100deg, var(--wood) 0 5px, #a5671f 5px 7px, #c98b3e 7px 11px); box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border: 0; border-radius: var(--radius); background: transparent; color: var(--side-ink); font: inherit; font-weight: 500; text-align: left; cursor: pointer; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(11,132,198,.22); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.ico { display: inline-flex; }
.stage { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 20px; padding: 0 28px; height: 64px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.page-title { margin-right: auto; font-size: 1.35rem; font-weight: 600; }
.org { color: var(--ink-2); font-weight: 500; }
.content { padding: 24px 28px 48px; max-width: 1320px; width: 100%; }
main.center { max-width: 400px; margin: 12vh auto; padding: 0 16px; }

/* ---------- blocos ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; }
.card.flush { padding: 0; }
.card.flush > .scroll, .card.flush > .empty { border-top: 1px solid var(--line); }
.card-head { display: flex; align-items: center; gap: 16px; padding: 16px 22px; }
.card-head h2 { margin: 0 auto 0 0; }
h1 { font-size: 1.5rem; margin: 0 0 14px; font-weight: 600; }
h2 { font-size: 1.15rem; margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 1.05rem; margin: 0 0 8px; font-weight: 600; }
p { margin: 0 0 10px; max-width: 75ch; }
.muted { color: var(--ink-2); }
.empty { color: var(--ink-2); padding: 22px; margin: 0; }
.warn { color: var(--warn); } input.warn { border-color: var(--warn); }
.error { color: var(--err); } .card.error { border-color: var(--err); background: var(--err-weak); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.kpi { background: var(--surface); padding: 14px 20px; display: flex; flex-direction: column; gap: 2px; }
.kpi span { color: var(--ink-2); font-size: .92rem; }
.kpi strong { font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- controlos ---------- */
button { font: inherit; font-weight: 500; padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--accent); background: var(--surface); color: var(--accent); cursor: pointer; }
button:hover { background: var(--accent-weak); }
button.primary { background: var(--accent); color: #fff; }
button.primary:hover { background: #0a74ad; }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 6px; text-decoration: underline; text-underline-offset: 2px; }
button.link:hover { background: none; color: #075a87; }
button.danger { color: var(--err); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.big { font-size: 1.25rem; font-weight: 600; padding: 16px 32px; min-width: 220px; }
input, select { font: inherit; padding: 8px 10px; border: 1px solid #b9c2cc; border-radius: var(--radius); background: #fff; color: var(--ink); }
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-weak); }
input.big { font-size: 1.3rem; padding: 14px 16px; flex: 1; min-width: 260px; }
input.filter { min-width: 260px; padding-left: 34px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234a5b6b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 5h18M6 12h12M10 19h4'/%3E%3C/svg%3E") no-repeat 10px center; }
label { display: inline-flex; flex-direction: column; gap: 4px; font-size: .92rem; font-weight: 500; color: var(--ink-2); }
form label { display: flex; margin-bottom: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-top: 14px; }
.file input { display: none; }
.file { display: inline-flex; flex-direction: row; align-items: center; padding: 10px 18px; border: 1px dashed var(--accent); border-radius: var(--radius); color: var(--accent); font-weight: 600; cursor: pointer; background: var(--accent-weak); }
.previews { margin-top: 16px; }
.preview { border-left: 3px solid var(--accent); }
.stats { display: flex; flex-wrap: wrap; gap: 28px; margin: 10px 0; }
.stat { display: flex; flex-direction: column; } .stat span { font-size: .9rem; } .stat strong { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; align-items: center; }
.chip { flex-direction: row; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; background: #fff; color: var(--ink); font-weight: 500; }
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-weak); }
.chip input { accent-color: var(--accent); }
.chip-note { color: var(--ink-2); font-weight: 400; font-size: .88rem; }
.chip.late { border-color: var(--err); }
.chips-label { min-width: 84px; font-weight: 600; color: var(--ink-2); font-size: .92rem; }
.small { font-size: .85rem; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-weight: 600; padding: 8px 0; }
label.check input { width: 18px; height: 18px; accent-color: var(--err); }
.tag { font-size: .78rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px dashed #b9c2cc; color: var(--ink-2); background: transparent; vertical-align: middle; }
.tag:hover { background: var(--err-weak); }
.tag.urgent { border: 1px solid var(--err); background: var(--err); color: #fff; }
.lot-sub { color: var(--ink-2); font-size: .85rem; white-space: normal; max-width: 220px; margin-top: 2px; }
tr.row-urgent { box-shadow: inset 3px 0 0 var(--err); }
.warnings { color: var(--warn); margin: 8px 0; padding-left: 20px; }
details summary { cursor: pointer; color: var(--accent); font-weight: 500; }

.role-chip { font-size: .8rem; font-weight: 600; color: var(--ink-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
.pad { padding: 0 22px 14px; margin: 0; }
.grow { flex: 1; min-width: 220px; } .grow input, .grow select { width: 100%; }
.row.top { margin-top: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid2 > .card { margin-bottom: 20px; }
.formgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; margin-top: 10px; }
.formgrid.tight { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.formgrid input, .formgrid select { width: 100%; }
.ok-text { color: var(--ok); }
tr.row-muted td { color: var(--ink-2); background: #fafbfc; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tab { border: 0; border-radius: var(--radius) var(--radius) 0 0; background: transparent; color: var(--ink-2); padding: 10px 16px; font-weight: 600; box-shadow: inset 0 -2px 0 transparent; white-space: nowrap; }
.tab:hover { background: var(--accent-weak); color: var(--ink); }
.tab.active { color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
button.chip-btn { cursor: pointer; font: inherit; font-size: .9rem; }
button.chip-btn.active { border-color: var(--accent); background: var(--accent-weak); color: #075a87; }
.label-editor { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 20px; }
.label-stage { background: repeating-conic-gradient(#eef1f4 0 25%, #f7f8fa 0 50%) 0 0 / 16px 16px; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; overflow: auto; margin: 8px 0 12px; }
.label-preview { display: inline-block; line-height: 0; touch-action: none; cursor: move; }
.label-preview svg { box-shadow: 0 2px 10px rgba(21,40,58,.18); background: #fff; }
.el-props label { display: flex; margin-bottom: 10px; }
.el-props label.check { flex-direction: row; }
.el-list { max-height: 220px; overflow: auto; }

/* ---------- tabelas ---------- */
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: 10px 11px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { font-weight: 700; color: var(--ink); background: var(--surface); border-bottom: 2px solid var(--line); }
tbody tr:hover { background: #f6f8fa; }
tbody tr:last-child td { border-bottom: 0; }
tr.row-error, tr.row-error:hover { background: var(--err-weak); }
td.wrap { white-space: normal; min-width: 160px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td input[type=number] { width: 84px; }
td input[type=date] { padding: 6px 8px; }
td.actions { white-space: nowrap; text-align: right; }
select.status { font-weight: 600; border-radius: 999px; padding: 5px 12px; }
select.status.s-open { background: #eef1f4; border-color: #c7cfd7; }
select.status.s-busy { background: var(--accent-weak); border-color: var(--accent); color: #075a87; }
select.status.s-done { background: var(--ok-weak); border-color: var(--ok); color: var(--ok); }

/* ---------- registo de tempos: o ecrã do operador ---------- */
.timer h2 { font-size: 1.3rem; }
.timer .row label { min-width: 200px; }
.timer .row select, .timer .row input[type=text]:not(.big) { font-size: 1.1rem; padding: 10px 12px; }
.lot-now { border: 2px solid var(--accent); margin-top: 18px; }
.lot-now h3 { font-size: 1.4rem; }
.clock { font-size: 3.4rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .02em; color: var(--accent); line-height: 1.1; margin: 4px 0 6px; }
.lot-now label { margin: 6px 16px 14px 0; }
.lot-now label input { font-size: 1.2rem; width: 180px; }

/* ---------- mensagens ---------- */
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; z-index: 20; }
.toast { padding: 12px 16px; border-radius: var(--radius); background: var(--ok); color: #fff; max-width: 420px; font-weight: 500; box-shadow: 0 6px 20px rgba(21,40,58,.25); }
.toast.error { background: var(--err); }

/* ---------- entrar ---------- */
.login { border-top: 4px solid var(--wood); }
.login h1 { font-size: 1.4rem; }

/* ---------- impressão da folha do lote ---------- */
.print-sheet { display: none; }
@media print {
  body > *:not(.print-sheet) { display: none !important; }
  .print-sheet { display: block; padding: 0; font-size: 11pt; }
  .print-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
  .print-sheet table { margin-bottom: 14px; } .print-sheet table.small { font-size: 9pt; }
  .print-sheet th, .print-sheet td { padding: 4px 6px; }
  .print-sheet section { break-inside: avoid-page; }
  .print-sheet.labels { padding: 0; }
  .label-page { break-after: page; overflow: hidden; }
  .label-page:last-child { break-after: auto; }
  .label-page svg { display: block; width: 100%; height: 100%; }
}

/* ---------- telemóvel e tablet: menu em baixo, para o operador ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 10; flex-direction: row; }
  .brand { display: none; }
  .nav { flex-direction: row; width: 100%; padding: 6px; gap: 4px; overflow-x: auto; }
  .nav-item { flex-direction: column; gap: 3px; padding: 8px 4px; font-size: .78rem; text-align: center; justify-content: center; min-width: 76px; }
  .grid2, .label-editor { grid-template-columns: 1fr; }
  .role-chip { display: none; }
  .nav-item.active { box-shadow: inset 0 3px 0 var(--accent); }
  .top { padding: 0 16px; height: 56px; }
  .page-title { font-size: 1.15rem; }
  .content { padding: 16px 12px 96px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #toasts { bottom: 84px; }
  .clock { font-size: 2.8rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
