/*
 * Pontak — estilos.
 * Telemóvel primeiro. Cores: amarelo de colete, aço e betão; contraste alto para ler ao sol.
 * Botões principais com pelo menos 56 px; letra dos campos com 16 px ou mais.
 * Modo escuro automático (segue o telemóvel/computador).
 */

/* ------------------------------------------------------------------ letras (guardadas no projeto, licença OFL em fonts/OFL.txt) */
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/barlow-400.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/barlow-500.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/barlow-600.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/barlow-700.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/barlow-condensed-600.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/barlow-condensed-700.woff2') format('woff2'); }

/* ------------------------------------------------------------------ cores e letras */
:root {
    --bg: #eceff2;
    --surface: #ffffff;
    --surface-2: #f4f6f8;
    --ink: #18202a;
    --muted: #46515d;
    --line: #d5dbe1;
    --accent: #f5c400;
    --accent-ink: #18202a;
    --steel: #243242;
    --steel-2: #2f4156;
    --steel-ink: #d4dce5;
    --ok: #1c7f46;
    --ok-bg: #e3f4ea;
    --warn: #a86400;
    --warn-bg: #fff1d6;
    --bad: #c0352a;
    --bad-bg: #fbe4e1;
    --radius: 12px;
    --font-display: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', sans-serif;
    --font-body: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --nav-h: 68px;
    --btn-line: #2f4156;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e1318;
        --surface: #182029;
        --surface-2: #212b36;
        --ink: #edf0f3;
        --muted: #b6c0cb;
        --line: #2f3a46;
        --steel: #101820;
        --steel-2: #1c2835;
        --ok: #4fc283;
        --ok-bg: #173a28;
        --warn: #f0b04a;
        --warn-bg: #41330f;
        --bad: #ff7a6b;
        --bad-bg: #47201c;
        --btn-line: #6b7c8f;
        color-scheme: dark;
    }
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
/* "hidden" ganha sempre (os estilos de botões e imagens não o podem desfazer). */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.45;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.2px; line-height: 1.05; }
h1 { font-size: 2rem; margin: 0 0 1rem; }
h2 { font-size: 1.4rem; margin: 0 0 0.75rem; }
p { margin: 0 0 0.75rem; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.optional { font-weight: 400; color: var(--muted); font-size: 0.9em; }
.num { font-variant-numeric: tabular-nums; }
svg.icon { width: 22px; height: 22px; flex: none; }

/* ------------------------------------------------------------------ estrutura (com sessão) */
.app { min-height: 100vh; min-height: 100dvh; }

/* Barra lateral (computador) / barra inferior (telemóvel) */
.side {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    display: flex;
    gap: 2px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--steel);
    color: var(--steel-ink);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.25);
}
.side__brand, .side__who, .side__spacer { display: none; }
.nav {
    flex: 1 1 0;
    min-width: 0;
    min-height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 2px;
    border-radius: 10px;
    color: var(--steel-ink);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}
.nav span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nav[aria-current="page"] { background: var(--steel-2); color: var(--accent); }
.nav--primary { color: var(--accent); }

.main { min-width: 0; }
.bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    padding-top: calc(10px + env(safe-area-inset-top));
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.bar__brand { display: flex; align-items: center; }
.bar__company { min-width: 0; flex: 1; font-weight: 700; line-height: 1.2; }
.bar__company strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar__company small { display: block; font-weight: 500; color: var(--muted); font-size: 13px; }
.bar__account { display: flex; gap: 8px; align-items: center; }
.bar__account .btn { min-width: 44px; padding: 0 10px; }
@media (max-width: 599px) { .bar__account .btn span { display: none; } }

.content {
    padding: 16px 14px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
    max-width: 1180px;
}

.logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: 9px;
    background: var(--accent);
    color: var(--accent-ink);
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    flex: none;
}

@media (min-width: 900px) {
    .app { display: grid; grid-template-columns: 240px minmax(0, 1fr); }
    .side {
        position: sticky;
        top: 0;
        height: 100vh;
        flex-direction: column;
        gap: 4px;
        padding: 18px 12px;
        box-shadow: none;
        overflow-y: auto;
    }
    .side__brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; color: #fff; text-decoration: none; }
    .side__brand b { font-family: var(--font-display); font-size: 26px; line-height: 1; }
    .side__spacer { display: block; flex: 1; }
    .side__who { display: block; padding: 12px 10px 0; border-top: 1px solid rgba(255, 255, 255, 0.12); font-size: 13px; color: #9fb0c2; }
    .side__who b { display: block; color: #fff; font-size: 15px; }
    .nav {
        flex: none;
        flex-direction: row;
        justify-content: flex-start;
        gap: 12px;
        min-height: 46px;
        padding: 10px 12px;
        font-size: 16px;
        position: relative;
    }
    .nav:hover { background: var(--steel-2); }
    .nav[aria-current="page"] { color: #fff; }
    .nav[aria-current="page"]::before {
        content: "";
        position: absolute;
        left: -12px; top: 8px; bottom: 8px;
        width: 4px;
        background: var(--accent);
        border-radius: 0 4px 4px 0;
    }
    .nav--primary { color: var(--accent); }
    .bar { padding: 12px 28px; }
    .bar__brand { display: none; }
    .content { padding: 26px 28px 48px; }
    h1 { font-size: 2.4rem; }
}

/* ------------------------------------------------------------------ estrutura (sem sessão: login) */
.guest {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    padding: 24px 16px;
    background: var(--steel);
}
.guest__brand { display: flex; align-items: center; gap: 12px; color: #fff; }
.guest__brand b { font-family: var(--font-display); font-size: 40px; line-height: 1; }
.guest__brand .logo { width: 48px; height: 48px; font-size: 32px; border-radius: 12px; }
.guest .card { width: 100%; max-width: 420px; }
.guest .notice, .guest .alert { width: 100%; max-width: 420px; }

/* ------------------------------------------------------------------ cabeçalho de página */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.page-head > .btn { width: 100%; }
@media (min-width: 700px) { .page-head > .btn { width: auto; } }

/* ------------------------------------------------------------------ cartões e grelhas */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
}
.card + .card, .card + .btn, .card + .menu, .list + .btn, .card + .list { margin-top: 14px; }
.card h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card h2 small { font-family: var(--font-body); font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.card--narrow { max-width: 30rem; }

.grid { display: grid; gap: 12px; }
.grid > .card { margin-top: 0; }
.grid--kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
.grid--two { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) {
    .grid--kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
    .grid--two { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; }
}

.kpi__label { font-size: 13.5px; font-weight: 600; color: var(--muted); }
.kpi__value { font-family: var(--font-display); font-size: 34px; font-weight: 700; line-height: 1.05; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi__sub { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.kpi--warn .kpi__value { color: var(--warn); }
.kpi--ok .kpi__value { color: var(--ok); }
@media (min-width: 900px) { .kpi__value { font-size: 40px; } }

/* ------------------------------------------------------------------ botões */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 56px;
    padding: 0 20px;
    font: inherit;
    font-size: 17px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    border-radius: var(--radius);
    border: 2px solid transparent;
    cursor: pointer;
    touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--primary:hover { filter: brightness(0.96); }
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--btn-line); }
.btn--secondary:hover { background: var(--surface-2); }
.btn--danger { background: var(--surface); color: var(--bad); border-color: var(--bad); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); min-height: 44px; padding: 0 14px; font-size: 15px; }
.btn--small { min-height: 44px; padding: 0 14px; font-size: 15px; }
.btn--block { width: 100%; }
.btn--block + .btn--block, .btn--block + form, form + .btn--block, .exports + .btn--block, .pager + .btn--block { margin-top: 10px; }
.btn--big { min-height: 64px; font-size: 19px; }

/* Botões grandes de ação (ecrã Hoje) */
.big-actions { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 16px; }
.big-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 4px;
    min-height: 96px;
    padding: 14px 18px;
    border-radius: 14px;
    background: var(--surface);
    border: 2px solid var(--line);
    color: var(--ink);
    text-decoration: none;
    font-size: 19px;
    font-weight: 700;
}
.big-btn small { font-size: 14px; font-weight: 600; color: var(--muted); }
.big-btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.big-btn--primary small { color: var(--accent-ink); opacity: 0.8; }
.big-btn:active { transform: scale(0.98); }
@media (min-width: 700px) { .big-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.menu { display: flex; flex-direction: column; gap: 10px; }

/* ------------------------------------------------------------------ campos */
.field { display: block; margin: 0 0 14px; }
.field > span, .field > legend { display: block; font-size: 15px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
    width: 100%;
    min-height: 56px;
    padding: 12px 14px;
    font: inherit;
    font-size: 18px; /* 16 px ou mais evita o zoom automático no iPhone */
    color: var(--ink);
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: 10px;
}
.field textarea { min-height: 80px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--steel-2); box-shadow: 0 0 0 3px var(--accent); }
.field small { display: block; margin-top: 5px; font-size: 14px; color: var(--muted); }
.field--quantity input { font-family: var(--font-display); font-size: 26px; font-weight: 700; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-pair > .field { min-width: 0; }
.field input[type="date"] { min-width: 0; }
.field-pair input[type="date"] { font-size: 16px; padding-left: 8px; padding-right: 8px; }

/* Escolha com opções grandes (perfil, encarregados) */
.choice { border: 0; padding: 0; margin: 0 0 14px; }
.choice legend { padding: 0; }
.choice__option {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 10px 14px;
    margin-bottom: 8px;
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
}
.choice__option input { width: 24px; height: 24px; flex: none; accent-color: var(--steel-2); }
.choice__option > span { display: flex; flex-direction: column; }
.choice__option small { color: var(--muted); font-size: 14px; }
.choice__option:has(input:checked) { border-color: var(--steel-2); background: var(--surface-2); box-shadow: inset 4px 0 0 var(--accent); }

/* Unidades: botões grandes em grelha */
.units { border: 0; padding: 0; margin: 0 0 14px; }
.units legend { padding: 0; }
.units__grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.units__option { position: relative; }
.units__option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.units__option span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    font-size: 18px;
    font-weight: 700;
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: 10px;
}
.units__option input:checked + span { background: var(--steel); color: var(--accent); border-color: var(--steel); }
.units__option input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ mensagens */
.notice, .alert {
    padding: 12px 14px;
    margin: 0 0 16px;
    border-radius: var(--radius);
    border: 2px solid;
    font-weight: 600;
}
.notice { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.notice--info { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.alert { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.alert p { margin: 0; }
.empty {
    padding: 16px;
    border: 2px dashed var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--muted);
}

/* ------------------------------------------------------------------ listas */
.list { list-style: none; margin: 0 0 14px; padding: 0; }
.list__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.list__item--off { opacity: 0.75; background: var(--surface-2); }
.list__main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.list__main .muted { font-size: 15px; overflow-wrap: anywhere; }
.list__link { color: inherit; text-decoration: none; }
.list__link strong { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 3px; text-underline-offset: 4px; }

/* Lista dentro de um cartão (painel) */
.rows { display: flex; flex-direction: column; }
.row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
    color: inherit;
    text-decoration: none;
    flex-wrap: wrap;
}
.row:last-child { border-bottom: 0; }
.row__text { flex: 1 1 180px; min-width: 0; }
.row__text b { display: block; }
.row__text span { font-size: 14.5px; color: var(--muted); }
.row__end { margin-left: auto; text-align: right; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot--warn { background: var(--warn); }
.dot--bad { background: var(--bad); }
.dot--ok { background: var(--ok); }

.badge, .pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--line);
}
.badge--off { background: var(--surface-2); color: var(--muted); }
.badge--warn, .pill--warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill--ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }

/* Separadores */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; border-bottom: 2px solid var(--line); }
.tabs__tab {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0 14px;
    margin-bottom: -2px;
    color: var(--muted);
    font-weight: 700;
    text-decoration: none;
    border-bottom: 4px solid transparent;
}
.tabs__tab--on { color: var(--ink); border-bottom-color: var(--accent); }

/* ------------------------------------------------------------------ material */
.entry__qty { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.entry__spec { font-weight: 400; }
.entry__who { font-size: 13.5px; color: var(--muted); }
.totals__value { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.scope { margin: 0 0 10px; font-size: 15px; color: var(--muted); }

.saved, .pager, .exports { display: flex; gap: 10px; margin: 0 0 14px; }
.saved .btn, .pager .btn, .exports .btn { flex: 1; }
.undo { margin-bottom: 14px; }

/* Filtros que abrem e fecham */
.filters { margin-bottom: 14px; }
.filters summary {
    display: flex;
    align-items: center;
    min-height: 44px;
    font-weight: 700;
    cursor: pointer;
}
.filters[open] summary { margin-bottom: 10px; }
.filters .btn + .btn { margin-top: 8px; }

/* Câmara */
.camera__shoot { position: relative; width: 100%; margin-bottom: 12px; cursor: pointer; min-height: 120px; }
.camera__shoot .icon { width: 30px; height: 30px; }
.camera__gallery { position: relative; cursor: pointer; }
.camera__input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.camera__status { margin: 14px 0 0; font-weight: 700; }
.camera__status--busy::before { content: "⏳ "; }
.camera__preview { display: block; max-width: 100%; max-height: 50vh; margin: 12px auto 0; border-radius: 10px; border: 1px solid var(--line); }
.camera .alert { margin-top: 14px; }

/* Ecrã de confirmação: foto ao lado dos dados (em cima, no telemóvel) */
.confirm { display: grid; gap: 14px; }
.confirm__photo { display: block; padding: 8px; text-decoration: none; text-align: center; }
.confirm__photo img { display: block; width: 100%; max-height: 60vh; object-fit: contain; border-radius: 8px; background: var(--surface-2); }
.confirm__photo small { display: block; margin-top: 6px; color: var(--muted); font-size: 14px; }
.confirm__data > * + * { margin-top: 14px; }
.confirm__delete { margin-top: 14px; }
@media (min-width: 900px) {
    .confirm { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
    .confirm__photo { position: sticky; top: 16px; }
    .confirm__photo img { max-height: calc(100vh - 80px); }
}
.units__grid--two { grid-template-columns: 1fr 1fr; }

/* Fila "por rever" */
.review-item { align-items: stretch; }
.review-item__thumb { flex: none; width: 72px; height: 72px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.review-item__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.review-item__reason { color: var(--warn); font-weight: 600; font-size: 15px; }

.big-btn--warn { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.big-btn--warn small { color: var(--warn); }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; width: 100%; }
.head-actions .btn { flex: 1; }
@media (min-width: 700px) { .head-actions { width: auto; } .head-actions .btn { flex: none; } }
.usage { margin-top: 16px; font-size: 14px; }

/* Fotos à espera de rede */
.queue {
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 2px solid var(--steel-2);
    background: var(--surface);
    font-weight: 600;
}
.queue p { margin: 0 0 6px; }
.queue--offline { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.queue__failed { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; color: var(--bad); }
.queue__failed p { flex: 1 1 200px; margin: 0; }

/* "Já tens esta?" */
.similar {
    margin: -6px 0 14px;
    padding: 10px 14px;
    background: var(--warn-bg);
    color: var(--warn);
    border: 2px solid var(--warn);
    border-radius: 10px;
}
.similar__list { margin: 6px 0 0; padding-left: 20px; color: var(--ink); }
.similar__list li { margin: 4px 0; }
.similar__list a { font-weight: 700; }
.similar__list small { color: var(--muted); }
.similar-confirm .choice__option { margin: 10px 0 0; color: var(--ink); }

/* Formulários largos no computador */
.form-card { max-width: 40rem; }

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