:root { --bg: #f3f6f5; --card: #fff; --ink: #172b35; --muted: #61737b; --brand: #087f73; --ok: #0a7a3d; --warn: #9a5b00; --bad: #b3261e; --line: #dce6e3; --shadow: 0 10px 30px rgba(16, 40, 56, .06); }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
.top { display: flex; gap: .65rem; align-items: center; padding: .65rem max(1rem, calc((100vw - 1040px) / 2)); background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; backdrop-filter: blur(14px); }
.brand-mark { border-radius: 10px; box-shadow: 0 3px 12px rgba(16,40,56,.16); }
.brand-name { letter-spacing: -.035em; font-size: 1.1rem; color: #102838; }
.install-app { white-space: nowrap; }
.top #who { margin-left: auto; color: var(--muted); font-size: .9rem; }
main { max-width: 1040px; margin: 0 auto; padding: 1.2rem 1rem 3rem; display: grid; gap: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 1.2rem; display: grid; gap: .7rem; box-shadow: var(--shadow); }
.login-brand { padding: .4rem 0 .8rem; border-bottom: 1px solid var(--line); }
.login-brand .eyebrow { color: var(--brand); font-size: .7rem; font-weight: 750; letter-spacing: .15em; }
.login-brand h1 { margin: .5rem 0; color: #102838; font-size: clamp(1.8rem, 4vw, 2.55rem); line-height: 1.08; letter-spacing: -.055em; }
.login-brand p { max-width: 36ch; margin: .5rem 0 0; color: var(--muted); }
#login { width: min(100%, 510px); margin: clamp(1rem, 7vh, 4rem) auto; padding: clamp(1.2rem, 4vw, 2rem); gap: .85rem; }
h1, h2, h3 { margin: 0; }
h2 { font-size: 1.12rem; letter-spacing: -.02em; }
label { display: grid; gap: .25rem; font-size: .9rem; color: var(--muted); }
input, select, textarea { font: inherit; padding: .6rem; border: 1px solid var(--line); border-radius: 8px; min-height: 44px; }
button { font: inherit; font-weight: 620; min-height: 44px; padding: .5rem 1rem; border: 0; border-radius: 10px; background: var(--brand); color: #fff; cursor: pointer; transition: transform .15s ease, filter .15s ease, box-shadow .15s ease; }
button:hover { filter: brightness(1.06); box-shadow: 0 5px 12px rgba(8,127,115,.18); }
button:active { transform: translateY(1px); }
button.secondary { background: #e8f1ef; color: #164d48; }
button:disabled { background: #b8bfcc; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #7aa7ff; outline-offset: 2px; }
.ai-helper { border: 1px solid #c8e6dc; border-radius: 12px; background: linear-gradient(135deg,#f1faf6,#f7fbfa); overflow: hidden; }
.ai-helper summary { cursor: pointer; padding: .75rem .9rem; font-weight: 650; color: #14554c; list-style-position: inside; }
.ai-helper[open] summary { border-bottom: 1px solid #d5eae2; }
.ai-body { padding: .85rem .9rem; display: grid; gap: .45rem; }
.ai-body p { margin: 0; }
.ai-spark { color: #b98328; padding-right: .2rem; }
.ai-msg { flex: 1; }
.install-dialog { width: min(92vw, 520px); max-height: 90dvh; overflow: auto; border: 1px solid var(--line); border-radius: 20px; padding: 1.5rem; color: var(--ink); box-shadow: var(--shadow); }
.install-dialog[open] { display: grid; gap: .8rem; }
.install-dialog::backdrop { background: rgba(16,40,56,.55); }
.install-dialog p { margin: 0; line-height: 1.5; }
.install-dialog img { border-radius: 14px; }
.install-steps { margin: 0; padding-left: 1.4rem; line-height: 1.5; }
.install-steps li + li { margin-top: .65rem; }
.state { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 99px; background: #e8ecf5; color: var(--muted); }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.msg { margin: 0; min-height: 1.2em; }
.msg.bad { color: var(--bad); }
.msg.ok { color: var(--ok); }
.req { display: flex; justify-content: space-between; gap: .5rem; align-items: center; padding: .4rem 0; border-top: 1px dashed var(--line); }
.req .done { color: var(--ok); font-weight: 600; }
.req .todo { color: var(--warn); }
.muted { color: var(--muted); font-size: .9rem; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
td, th { text-align: left; padding: .3rem; border-bottom: 1px solid var(--line); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 600px) { .top { padding: .55rem .7rem; gap: .45rem; } .brand-mark { width: 30px; height: 30px; } .brand-name { font-size: 1rem; } .top #who { font-size: .78rem; } #logout, .install-app { min-height: 38px; padding: .35rem .6rem; font-size: .82rem; } main { padding: .8rem .65rem 2rem; gap: .75rem; } .card { padding: .9rem; border-radius: 13px; } table { font-size: .82rem; } td, th { padding: .35rem .25rem; } }
.timeline { margin: 0; padding-left: 1.2rem; font-size: .9rem; }
.timeline li { padding: .15rem 0; }
#agenda input[type=date] { margin-left: auto; }
fieldset.people { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .75rem; display: grid; gap: .25rem; }
label.check { display: flex; gap: .5rem; align-items: center; color: var(--ink); }
label.check input { min-height: auto; width: 1.2rem; height: 1.2rem; }
.offform { display: grid; gap: .5rem; border-top: 1px dashed var(--line); padding-top: .5rem; }
h3 { font-size: 1rem; margin: .25rem 0; }
.mats td, .mats th { vertical-align: middle; }
.econ td, .econ th { font-size: .85rem; } #projetos { overflow-x: auto; }
.checklist table td { vertical-align: top; }
tr.nc td { background: #fff4e5; }
.stepform { display: grid; gap: .3rem; min-width: 180px; }
.stepform input, .stepform select { min-height: 36px; padding: .3rem; }
.checklist ul { margin: .25rem 0; padding-left: 1.2rem; }
.incident { border-left: 4px solid var(--line); padding: .4rem .6rem; margin: .3rem 0; font-size: .9rem; }
.incident.inc-block { border-left-color: var(--bad); background: #fdecea; }
.incident.inc-open { border-left-color: var(--warn); }
.incphoto { max-width: 160px; display: block; margin: .3rem 0; border-radius: 6px; }
.evidence-preview { display: block; max-width: min(100%, 480px); max-height: 420px; border-radius: 8px; margin-top: .5rem; }
.messages { border-top: 1px solid var(--line); padding-top: .5rem; display: grid; gap: .4rem; }
.message { border-radius: 8px; padding: .4rem .6rem; font-size: .9rem; }
.m-int { background: #f3f0e6; border: 1px dashed #b9a66a; }
.m-cli { background: #e9f1ff; border: 1px solid #b7cdf5; }
.vis { font-size: .7rem; padding: .05rem .4rem; border-radius: 99px; }
.vis-int { background: #6b5b24; color: #fff; }
.vis-cli { background: var(--brand); color: #fff; }
.vis-note { margin: 0; font-size: .85rem; font-weight: 600; }
.vis-cli-note { color: var(--brand); }
.vis-int-note { color: #6b5b24; }
.compose { display: grid; gap: .4rem; }
button.linkish { min-height: 28px; padding: .1rem .5rem; font-size: .8rem; }
.decisions { border-top: 1px solid var(--line); padding-top: .4rem; }
.decisions summary { cursor: pointer; font-weight: 600; }
.decisions td { font-size: .82rem; vertical-align: top; }
tr.dec-reopen td, tr.dec-return td { background: #fff4e5; }
.inv-forms { align-items: flex-start; }
.inv-forms form { flex: 1 1 200px; }
.resv { font-size: .8rem; color: var(--muted); }
.resform input, .resform select { min-height: 32px; }
.cons { font-size: .8rem; color: var(--ink); border-left: 3px solid var(--line); padding-left: .4rem; margin-top: .2rem; }
tr.estornado td { text-decoration: line-through; color: var(--muted); }
tr.estornado td:nth-child(2) { text-decoration: none; }
details.hist summary { cursor: pointer; font-size: .8rem; }
.pdoc { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; margin: .3rem 0; font-size: .88rem; }
#compras h3 { margin-top: .6rem; }
.risk { margin: .2rem 0; }
/* WG-UX: no telemóvel nada pode alargar a página (a grelha crescia até à tabela mais larga); tabelas largas deslizam dentro do cartão */
main, .card { grid-template-columns: minmax(0, 1fr); }
.top { z-index: 3; }
.top #who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top #logout { flex: none; }
/* confirmação/erro após uma ação: fica visível no sítio onde o utilizador está */
#app > .msg:first-child { position: sticky; top: 4.25rem; z-index: 2; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .75rem; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
section.card:focus { outline: 3px solid #7aa7ff; outline-offset: 2px; }
nav.jump { display: flex; flex-wrap: wrap; gap: .4rem; }
nav.jump a { font-size: .85rem; padding: .35rem .7rem; min-height: 32px; display: inline-flex; align-items: center; border-radius: 99px; background: #e8ecf5; color: var(--ink); text-decoration: none; }
nav.jump a:focus-visible { outline: 3px solid #7aa7ff; outline-offset: 2px; }
.workspace { padding-top: 0; }
.workspace-nav { position: sticky; top: var(--top-height, 64px); z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .75rem 0; background: var(--bg); border-bottom: 1px solid var(--line); }
.workspace-quick { display: flex; gap: .35rem; }
.workspace-nav a, .open-order { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 10px; padding: .5rem .85rem; text-decoration: none; font-weight: 650; color: #164d48; background: #e5eeeb; white-space: nowrap; }
.workspace-nav a[aria-current], .workspace-nav .primary-link, .open-order { color: white; background: var(--brand); }
.workspace a:focus-visible, .workspace select:focus-visible, .workspace h1:focus-visible { outline: 3px solid #7aa7ff; outline-offset: 3px; }
.area-picker { font-size: .75rem; gap: .1rem; min-width: 160px; }
.area-picker select { background: white; min-height: 38px; padding: .35rem .5rem; max-width: 245px; }
.demo-notice { font-size: .75rem; color: var(--muted); margin: 0; }
.workspace-panel { display: grid; gap: 1rem; min-width: 0; }
.workspace-panel > h1 { font-size: clamp(1.55rem, 3vw, 2rem); letter-spacing: -.04em; line-height: 1.2; margin: .3rem 0 0; }
.workspace-intro { color: var(--muted); margin: 0; }
.module-heading { display: none; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
.kpi { display: flex; flex-direction: column; gap: .25rem; border: 1px solid var(--line); border-radius: 14px; padding: 1rem; background: white; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.kpi-value { font-size: 2rem; font-weight: 750; color: var(--brand); line-height: 1.15; }
.kpi span:last-child { font-size: .85rem; }
.attention-panel { display: grid; gap: .5rem; border: 1px solid #edc4aa; border-left: 4px solid #b14c18; border-radius: 12px; padding: 1rem; background: #fff7ee; }
.attention-panel a { color: #843b18; font-size: .9rem; text-underline-offset: 3px; }
.attention-label { margin: 0; font-size: .85rem; color: #a13b14; font-weight: 650; }
.next-action { display: grid; gap: .75rem; }
.order-summary { display: grid; gap: .5rem; padding: 1rem 1.1rem; background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.order-summary-top { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.order-summary p { margin: 0; }
.order-summary .open-order { justify-self: start; }
.action-paging { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.order-tools { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, .4fr); gap: .8rem; }
.order-list, .detail-body { display: grid; gap: .8rem; min-width: 0; }
.line-editor, .editor-rows { display: grid; gap: .8rem; min-width: 0; }
.line-editor > button { justify-self: start; }
.editor-line { margin: 0; min-width: 0; padding: .8rem; border: 1px solid var(--line); border-radius: 10px; }
.editor-line legend { padding: 0 .3rem; font-weight: 650; }
.editor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; margin-bottom: .65rem; }
.editor-grid input, .editor-grid select { width: 100%; }
.editor-grid label.check input { width: 1.2rem; }
.editor-totals { padding: .6rem; border-radius: 8px; background: #e8f1ef; font-weight: 650; }
.project-summary { border-top: 1px solid var(--line); padding-top: 1rem; }
.project-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; }
.project-metrics dt { font-size: .8rem; color: var(--muted); }
.project-metrics dd { margin: .25rem 0; font-size: 1.05rem; font-weight: 650; }
.workspace-feedback { position: static; border-left: 3px solid var(--ok); background: white; border-radius: 8px; padding: .6rem .8rem; }
.top { padding-top: max(.65rem, env(safe-area-inset-top)); }
@media (max-width: 640px) {
  .req { display: grid; grid-template-columns: minmax(0, 1fr); }
  .workspace-nav { flex-direction: column; align-items: stretch; gap: .45rem; padding: .5rem 0; }
  .workspace-quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .3rem; }
  .workspace-nav a { font-size: .78rem; padding: .4rem .2rem; }
  .area-picker { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
  .area-picker select { max-width: none; width: 72%; min-width: 0; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
  .kpi { padding: .8rem; }
  .kpi-value { font-size: 1.7rem; }
  .order-tools { grid-template-columns: minmax(0, 1fr); }
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .project-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace-panel { gap: .8rem; }
  .top { padding-top: max(.55rem, env(safe-area-inset-top)); }
}
[id] { scroll-margin-top: 4.5rem; }
/* campos e listas com textos longos (moradas, materiais) não podem forçar a largura do cartão */
input, select, textarea { max-width: 100%; min-width: 0; }
.stepform { min-width: min(180px, 100%); }
.row > *, .stepform > *, .inv-forms > * { min-width: 0; }
/* arquivo de concluídas (recolhido) e procura */
details.arquivo { display: grid; gap: 1rem; }
details.arquivo > summary { cursor: pointer; list-style-position: inside; padding: .6rem .8rem; border: 1px dashed var(--line); border-radius: 12px; background: var(--card); }
details.arquivo > summary h2 { display: inline; }
details.arquivo[open] > summary { margin-bottom: 1rem; }
details.arquivo > section.card { margin-bottom: 1rem; }
input.busca { width: 100%; }
/* D-UX-01: pedido do cliente no cartão da ordem */
p.pedido { margin: 0; padding: .4rem .6rem; border-left: 4px solid var(--brand); background: #eef3ff; border-radius: 6px; font-size: .9rem; }
@media (max-width: 640px) { table { display: block; overflow-x: auto; } nav.jump { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .25rem; } nav.jump a { white-space: nowrap; } }
