:root {
  --primary: #235789;
  --primary-dark: #1a4268;
  --link: #235789;
  --bg: #f3f5f8;
  --card: #fff;
  --surface: #fff;
  --surface-2: #f1f4f7;
  --hover: #eef2f6;
  --input-bg: #fff;
  --text: #1d2733;
  --muted: #6b7785;
  --border: #dde3ea;
  --border-strong: #b8c3cf;
  --focus: #9cc0e4;
  --danger: #c0392b;
  --danger-border: #f0c4be;
  --ok: #2e8b57;
  --warn: #c98a12;
  --ok-bg: #e8f6ee; --ok-border: #b6e2c7; --ok-text: #1f6b41;
  --err-bg: #fdecea; --err-border: #f5c2bc; --err-text: #8f2a1f;
  --warn-bg: #fff6e0; --warn-border: #f0d79a; --warn-text: #7a5609;
  --info-bg: #eaf2fa; --info-border: #c4d8ec; --info-text: #1a4268;
  --shadow: rgba(0, 0, 0, .06);
  --logo-filter: none;
  --t1: #235789; --t2: #2e8b57; --t3: #e07a1f; --t4: #8a6fb3;
  --radius: 10px;
}
/* modo escuro: escolhido pelo utilizador, ou automático (segue o sistema) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --primary: #3a7bbf;
  --primary-dark: #2f6aa6;
  --link: #7ab3ef;
  --bg: #0f141a;
  --card: #1a212b;
  --surface: #1a212b;
  --surface-2: #232c38;
  --hover: #26303d;
  --input-bg: #121820;
  --text: #e3e8ee;
  --muted: #98a5b4;
  --border: #2e3a48;
  --border-strong: #46556a;
  --focus: #2d5f91;
  --danger: #ec7063;
  --danger-border: #6b2a24;
  --ok: #4cc283;
  --warn: #e0a83a;
  --ok-bg: #12301f; --ok-border: #1f5a39; --ok-text: #8fd9ad;
  --err-bg: #3a1714; --err-border: #6b2a24; --err-text: #f2a69c;
  --warn-bg: #352a0e; --warn-border: #6b5418; --warn-text: #f0cf7a;
  --info-bg: #12263a; --info-border: #1f4467; --info-text: #9cc8f0;
  --shadow: rgba(0, 0, 0, .4);
  /* logótipo: letras pretas passam a brancas, o vermelho mantém-se */
  --logo-filter: invert(1) hue-rotate(180deg) brightness(1.15);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
  color-scheme: dark;
    --primary: #3a7bbf;
    --primary-dark: #2f6aa6;
    --link: #7ab3ef;
    --bg: #0f141a;
    --card: #1a212b;
    --surface: #1a212b;
    --surface-2: #232c38;
    --hover: #26303d;
    --input-bg: #121820;
    --text: #e3e8ee;
    --muted: #98a5b4;
    --border: #2e3a48;
    --border-strong: #46556a;
    --focus: #2d5f91;
    --danger: #ec7063;
    --danger-border: #6b2a24;
    --ok: #4cc283;
    --warn: #e0a83a;
    --ok-bg: #12301f; --ok-border: #1f5a39; --ok-text: #8fd9ad;
    --err-bg: #3a1714; --err-border: #6b2a24; --err-text: #f2a69c;
    --warn-bg: #352a0e; --warn-border: #6b5418; --warn-text: #f0cf7a;
    --info-bg: #12263a; --info-border: #1f4467; --info-text: #9cc8f0;
    --shadow: rgba(0, 0, 0, .4);
    /* logótipo: letras pretas passam a brancas, o vermelho mantém-se */
    --logo-filter: invert(1) hue-rotate(180deg) brightness(1.15);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.45; }
a { color: var(--link); }
h1 { font-size: 1.5rem; margin: .3rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .8rem; }
h3 { font-size: 1rem; margin: 1rem 0 .3rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

/* topo */
.topbar { background: var(--surface); color: var(--text); border-bottom: 3px solid var(--primary); box-shadow: 0 1px 4px var(--shadow); display: flex; align-items: center; flex-wrap: wrap;
  padding: .55rem 1rem; gap: .5rem; position: sticky; top: 0; z-index: 10; }
.brand { color: var(--muted); text-decoration: none; font-size: 1.05rem; margin-right: auto;
  display: flex; align-items: center; gap: .6rem; }
.brand img { height: 30px; width: auto; display: block; }
.brand span { border-left: 1px solid var(--border); padding-left: .6rem; }
.topbar nav { display: flex; gap: .2rem; flex-wrap: wrap; }
.topbar nav a { color: var(--text); text-decoration: none; padding: .4rem .7rem; border-radius: 6px; }
.topbar nav a:hover { background: var(--hover); }
.topbar nav a.active { background: var(--primary); color: #fff; }
.nav-toggle, .nav-burger { display: none; }

.container { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin-bottom: 1rem; }
.narrow { max-width: 560px; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; }

/* mensagens */
.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: .8rem; border: 1px solid; }
.flash-success { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }
.flash-error { background: var(--err-bg); border-color: var(--err-border); color: var(--err-text); }
.flash-warning, .flash-message { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }

/* botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; padding: .55rem .95rem;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; font-size: .95rem;
  cursor: pointer; text-decoration: none; font-family: inherit; white-space: nowrap; }
.btn:hover { border-color: var(--border-strong); background: var(--hover); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-small { padding: .3rem .6rem; font-size: .85rem; }
.btn-block { width: 100%; padding: .75rem; font-size: 1rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* formulários */
.form label, .login-card label { display: block; margin-bottom: .8rem; font-weight: 600; font-size: .9rem; }
input, select, textarea { display: block; width: 100%; margin-top: .25rem; padding: .6rem .7rem; font-size: 1rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--input-bg); font-family: inherit; color: var(--text); }
input[readonly], input[disabled] { background: var(--surface-2); color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); border-color: var(--primary); }
.form label.check, label.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
label.check input { width: auto; margin: 0; }
fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 .8rem; padding: .5rem .8rem .8rem; }
legend { font-weight: 600; font-size: .9rem; padding: 0 .3rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; align-items: end; }
.row2 select, .row2 input { margin-top: .25rem; }

/* login */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; padding: 1.8rem; }
.login-card { text-align: center; }
.login-card label { text-align: left; }
.login-logo { width: 190px; max-width: 70%; height: auto; display: block; margin: .3rem auto .8rem; }
.login-card h1 { color: var(--muted); font-weight: 400; font-size: 1.2rem; margin: 0; }
.logo-setting { margin-bottom: .8rem; }
.logo-setting .label { display: block; font-weight: 600; font-size: .9rem; }
.logo-setting img { background: #fff; height: 50px; width: auto; display: block; margin: .4rem 0 .6rem; padding: .3rem;
  border: 1px dashed var(--border); border-radius: 6px; }

/* dashboard */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem;
  display: flex; flex-direction: column; border-left: 4px solid var(--primary); }
.stat span { color: var(--muted); font-size: .85rem; }
.stat strong { font-size: 1.6rem; margin: .2rem 0; }
.stat small { color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.bars { display: flex; align-items: flex-end; gap: .6rem; height: 190px; padding-top: 1rem; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar { width: 100%; max-width: 46px; background: var(--primary); border-radius: 5px 5px 0 0; min-height: 2px; }
.bar-val { font-size: .72rem; color: var(--muted); margin-bottom: .2rem; }
.bar-lbl { font-size: .8rem; margin-top: .3rem; }
.hbar { display: grid; grid-template-columns: 90px 1fr 100px; align-items: center; gap: .6rem; margin-bottom: .7rem; }
.hbar-lbl { font-size: .9rem; }
.hbar-track { background: var(--surface-2); border-radius: 5px; height: 14px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 5px; }
.hbar-val { text-align: right; font-size: .9rem; font-weight: 600; }
.tipo-1 { background: var(--t1); } .tipo-2 { background: var(--t2); } .tipo-3 { background: var(--t3); } .tipo-4 { background: var(--t4); }

/* tabelas */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase;
  border-bottom: 2px solid var(--border); padding: .5rem; }
.table td { border-bottom: 1px solid var(--border); padding: .55rem .5rem; vertical-align: middle; }
.table tfoot td { font-weight: 700; border-bottom: none; border-top: 2px solid var(--border); font-size: 1rem; }
.table .num { text-align: right; white-space: nowrap; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--hover); }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form { display: inline; }
.thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); display: block; }
.tag { display: inline-block; padding: .1rem .5rem; border-radius: 99px; font-size: .8rem; font-weight: 600; color: #fff; }
.tag-1 { background: var(--t1); } .tag-2 { background: var(--t2); } .tag-3 { background: var(--t3); } .tag-4 { background: var(--t4); }
.total-line { text-align: right; margin-top: .8rem; font-size: 1.1rem; }

.filters { display: flex; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filters select { width: auto; min-width: 200px; margin: 0; }

/* detalhe */
.info-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.info-grid > div { display: flex; flex-direction: column; }
.info-grid span { color: var(--muted); font-size: .8rem; text-transform: uppercase; }
.info-grid strong { font-size: 1.05rem; }
.info-grid strong.big { font-size: 1.6rem; color: var(--primary); }
.inline-edit summary { font-size: .8rem; color: var(--primary); cursor: pointer; }
.inline-edit form { margin-top: .4rem; grid-template-columns: 1fr 1fr auto; }
.danger-zone { text-align: right; margin-bottom: 2rem; }

.photo-input { margin-bottom: 1rem; }
.photo-input .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.photo-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.photo-buttons .btn { padding: .8rem; font-weight: 600; margin: 0; display: inline-flex; }
.hidden-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.current-photo { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.current-photo img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

/* config */
.tabs { display: flex; gap: .3rem; margin-bottom: 1rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tabs a { padding: .55rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tipo-row { display: flex; align-items: center; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.tipo-row.inactive input[name=name] { color: var(--muted); text-decoration: line-through; }
.tipo-form { display: flex; align-items: center; gap: .5rem; flex: 1; flex-wrap: wrap; }
.tipo-form input { margin: 0; }
.tipo-form input[name=name] { flex: 1; min-width: 140px; }
.tipo-form input[type=color] { width: 44px; height: 40px; padding: 2px; flex: none; }
.tipo-move { display: flex; align-items: center; gap: .15rem; flex: none; }
.tipo-move form { margin: 0; }
.drag-handle { cursor: grab; color: var(--muted); font-size: 1.25rem; padding: .3rem .35rem; touch-action: none; user-select: none; line-height: 1; }
.move-btn { border: 1px solid var(--border); background: var(--card); color: var(--text); border-radius: 6px; width: 30px; height: 30px; padding: 0; font-size: .7rem; cursor: pointer; line-height: 1; }
.move-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.move-btn:disabled { opacity: .3; cursor: default; }
.tipo-row.dragging { opacity: .6; background: var(--bg); outline: 2px dashed var(--primary); outline-offset: -2px; border-radius: 6px; }
body.dragging-tipo, body.dragging-tipo * { cursor: grabbing !important; user-select: none; }
.tipo-row.moved { animation: tipo-flash .6s ease; }
@keyframes tipo-flash { from { background: color-mix(in srgb, var(--primary) 15%, transparent); } to { background: transparent; } }
.tipo-form .check { margin: 0; white-space: nowrap; }
.tipo-row > form:last-child { flex: none; }
.sig-thumb { height: 28px; width: auto; display: block; }

/* assinatura */
.signature-field .sig-current { display: flex; align-items: center; gap: 1rem; margin-bottom: .6rem; flex-wrap: wrap; }
.signature-field .sig-current img { height: 60px; width: auto; border: 1px dashed var(--border); border-radius: 6px; padding: .2rem; background: #fff; }
.sig-pad-wrap { position: relative; }
.sig-pad { width: 100%; height: auto; aspect-ratio: 3 / 1; display: block; background: #fff; touch-action: none;
  border: 1px solid var(--border); border-radius: 8px;
  background-image: linear-gradient(to top, transparent 24%, #c9d3de 24%, #c9d3de calc(24% + 1px), transparent calc(24% + 1px)); }
.sig-hint { position: absolute; left: 0; right: 0; top: 40%; text-align: center; color: #b0bac5; pointer-events: none; }
.sig-actions { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.sig-actions .btn { margin: 0; font-weight: 500; font-size: .85rem; display: inline-flex; }

/* foto: resultado e editor de cantos */
.photo-result, .photo-editor { margin-top: .7rem; }
.photo-preview-img { display: block; max-width: 100%; max-height: 50vh; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface-2); min-height: 60px; }
.photo-status { margin: .4rem 0; }
.photo-status.ok { color: var(--ok); font-weight: 600; }
.photo-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.editor-stage { position: relative; display: inline-block; max-width: 100%; line-height: 0; touch-action: none; user-select: none; }
.editor-img { display: block; max-width: 100%; max-height: 60vh; border-radius: 6px; }
.editor-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.editor-svg polygon { fill: rgba(255, 212, 0, .18); stroke: #ffd400; stroke-width: 2; vector-effect: non-scaling-stroke; }
.editor-stage .pt { position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%;
  background: rgba(255, 212, 0, .9); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5); touch-action: none; cursor: grab; }

/* estados / aprovações */
.status-badge { display: inline-block; padding: .15rem .6rem; border-radius: 99px; color: #fff; font-size: .8rem;
  font-weight: 600; vertical-align: middle; white-space: nowrap; }
.status-badge.small { font-size: .72rem; padding: .1rem .5rem; }
h1 .status-badge { font-size: .85rem; margin-left: .3rem; }
.status-panel { border-left: 5px solid var(--muted); }
.status-panel p { margin: .3rem 0 0; }
.refused-note { color: var(--danger); }
.status-actions { margin-top: .8rem; }
.status-actions .note-field { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .6rem; }
.btn-action { font-weight: 600; }
.act-aprovar { background: #235789; border-color: #235789; color: #fff; }
.act-pagar { background: #2e8b57; border-color: #2e8b57; color: #fff; }
.act-submeter { background: var(--primary); border-color: var(--primary); color: #fff; padding: .65rem 1.2rem; }
.act-recusar { color: var(--danger); border-color: var(--danger-border); }
.act-aprovar:hover, .act-pagar:hover, .act-submeter:hover { filter: brightness(1.1); color: #fff; }
.history { margin-top: .8rem; }
.history summary { cursor: pointer; color: var(--primary); font-size: .9rem; }
.history ul { list-style: none; padding: 0; margin: .5rem 0 0; }
.history li { padding: .35rem 0; border-bottom: 1px dashed var(--border); font-size: .9rem; }
.nav-badge { display: inline-block; min-width: 1.3rem; padding: 0 .35rem; border-radius: 99px; background: #e53935;
  color: #fff; font-size: .72rem; font-weight: 700; line-height: 1.3rem; text-align: center; margin-left: .2rem; }
.nav-badge.dot { min-width: 0; width: .6rem; height: .6rem; padding: 0; vertical-align: top; }
.topbar nav a.active .nav-badge { background: #fff; color: #e53935; }
.count-pill { display: inline-block; min-width: 1.4rem; padding: 0 .35rem; border-radius: 99px; color: #fff;
  font-size: .72rem; line-height: 1.3rem; text-align: center; margin-left: .2rem; }
.alert-card { display: flex; align-items: center; gap: .8rem; padding: .85rem 1rem; margin-bottom: .8rem;
  border-radius: var(--radius); background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-text); text-decoration: none; }
.alert-card.info { background: var(--info-bg); border-color: var(--info-border); color: var(--info-text); }
.alert-card.danger { background: var(--err-bg); border-color: var(--err-border); color: var(--err-text); }
.alert-card strong, .alert-card small { display: block; }
.alert-icon { font-size: 1.6rem; }

/* visualizador de fotos */
.viewer { position: fixed; inset: 0; z-index: 100; background: rgba(10, 14, 20, .94); display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; gap: .6rem; padding: .5rem .8rem; color: #fff; flex-wrap: wrap; background: #0a0e14; }
.viewer-caption { flex: 1; min-width: 150px; font-size: .9rem; }
.viewer-tabs { display: flex; gap: .3rem; flex-wrap: wrap; }
.viewer-body { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; padding: .5rem; }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; background: #fff; }
.viewer-body.zoomed { display: block; }
.viewer-body.zoomed img { max-width: none; max-height: none; cursor: zoom-out; }
body.no-scroll { overflow: hidden; }

/* notas internas (só admin) */
.private-field textarea { background: var(--warn-bg); border-color: var(--warn-border); }
.private-badge { display: inline-block; padding: .05rem .5rem; border-radius: 99px; font-size: .72rem; font-weight: 600;
  background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-border); }
.private-note { margin: .3rem 0 0 .2rem; padding: .35rem .6rem; border-left: 3px solid var(--warn); background: var(--warn-bg);
  color: var(--warn-text); border-radius: 0 6px 6px 0; font-size: .88rem; white-space: pre-wrap; }
.private-field label { display: block; margin-bottom: .25rem; }
.private-field textarea { margin-top: 0; }
.private-actions { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; margin-top: .35rem; }

/* comprovativo de pagamento */
.proof-box { display: flex; align-items: center; gap: .7rem; margin-top: .8rem; padding: .6rem .8rem;
  background: var(--ok-bg); border: 1px solid var(--ok-border); border-radius: 8px; flex-wrap: wrap; }
.proof-icon { font-size: 1.5rem; }
.proof-info { flex: 1; min-width: 140px; display: flex; flex-direction: column; }
.proof-manage { margin-top: .6rem; }
.proof-manage summary { cursor: pointer; color: var(--primary); font-size: .9rem; }
.proof-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
.proof-form input[type=file] { flex: 1; min-width: 180px; margin: 0; }
.page-head { margin-bottom: .6rem; }
.page-head h1, .page-head h2 { margin-bottom: .4rem; }

/* logótipo claro / escuro */
.logo-for-dark { display: none !important; }
.logo-filter { filter: var(--logo-filter); }
:root[data-theme="dark"] .logo-for-light { display: none !important; }
:root[data-theme="dark"] .logo-for-dark { display: block !important; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .logo-for-light { display: none !important; }
  :root[data-theme="auto"] .logo-for-dark { display: block !important; }
}

/* botão de tema */
.theme-form { display: inline-flex; margin: 0; }
.theme-toggle { background: none; border: none; cursor: pointer; font: inherit; color: var(--text);
  padding: .4rem .6rem; border-radius: 6px; }
.theme-toggle:hover { background: var(--hover); }
.theme-label { display: none; }
.theme-toggle .icon-light { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-light { display: inline; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .theme-toggle .icon-dark { display: none; }
  :root[data-theme="auto"] .theme-toggle .icon-light { display: inline; }
}

/* aviso de fim de sessão */
.session-warning { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 90;
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; justify-content: center;
  background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-border);
  border-radius: var(--radius); padding: .7rem 1rem; box-shadow: 0 4px 16px var(--shadow); max-width: calc(100% - 2rem); }

/* intervalo de datas */
.date-range { display: flex; align-items: flex-end; gap: .5rem; flex-wrap: wrap; flex-basis: 100%; }
.date-range select { width: auto; margin: 0; }
.date-range label { display: flex; align-items: center; gap: .35rem; font-size: .9rem; color: var(--muted); margin: 0; }
.date-range input[type=date] { width: auto; margin: 0; min-width: 9.5rem; }
.date-range .pt-date { margin: 0; }
.date-range .arrow { color: var(--muted); padding-bottom: .55rem; }

/* km */
.km-badge { display: inline-block; margin-left: .4rem; padding: .05rem .45rem; border-radius: 99px; font-size: .78rem;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.km-field input { font-variant-numeric: tabular-nums; }
.pay-badge { display: inline-block; margin-left: .4rem; padding: .05rem .45rem; border-radius: 99px; font-size: .78rem;
  white-space: nowrap; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }
.pay-badge.pay-pessoal { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.info-grid small.reimburse { display: block; margin-top: .2rem; font-size: .82rem; color: var(--warn-text); }

/* janela de confirmação */
.modal { position: fixed; inset: 0; z-index: 120; background: rgba(0, 0, 0, .45); display: flex;
  align-items: center; justify-content: center; padding: 1rem; }
.modal-box { background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.2rem; width: 100%; max-width: 380px; box-shadow: 0 10px 30px var(--shadow); }
.modal-text { margin: 0 0 1rem; font-size: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; }

/* seletor de ficheiros em português */
.pt-file { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-top: .3rem; font-weight: 400; }
.pt-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* calendário em português */
.pt-date { position: relative; display: inline-flex; align-items: center; }
.pt-date input[type=text] { width: 9.5rem; margin: 0; padding-right: 2.2rem; font-variant-numeric: tabular-nums; }
.pt-date-btn { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); background: none; border: none;
  cursor: pointer; font-size: 1rem; padding: .2rem; }
.pt-cal { position: absolute; top: calc(100% + 4px); left: 0; z-index: 60; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px var(--shadow); padding: .6rem;
  width: 17.5rem; }
.pt-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.pt-cal-head button, .pt-cal-foot button { background: none; border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; cursor: pointer; padding: .25rem .6rem; font: inherit; }
.pt-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.pt-cal-grid .dow { font-size: .72rem; color: var(--muted); padding: .2rem 0; }
.pt-cal-grid button { background: none; border: none; color: var(--text); border-radius: 6px; padding: .4rem 0;
  cursor: pointer; font: inherit; font-size: .9rem; }
.pt-cal-grid button:hover { background: var(--hover); }
.pt-cal-grid button.today { outline: 1px solid var(--primary); }
.pt-cal-grid button.sel { background: var(--primary); color: #fff; }
.pt-cal-foot { display: flex; justify-content: space-between; margin-top: .4rem; }

/* exportar listagem */
.list-export { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap;
  margin-bottom: .8rem; }
.list-export .check { margin: 0; }

/* telemóvel */
@media (max-width: 760px) {
  .nav-burger { display: block; font-size: 1.5rem; cursor: pointer; padding: 0 .3rem; }
  .topbar nav { display: none; width: 100%; flex-direction: column; }
  .nav-toggle:checked ~ nav { display: flex; }
  .stats, .grid2 { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 1.3rem; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .filters select { min-width: 0; flex: 1; }
  /* tabela de itens em cartões */
  .table.items thead { display: none; }
  .table.items, .table.items tbody, .table.items tr, .table.items td { display: block; width: 100%; }
  .table.items tr { border: 1px solid var(--border); border-radius: 8px; margin-bottom: .6rem; padding: .4rem .6rem;
    display: grid; grid-template-columns: auto 1fr auto; gap: .1rem .6rem; }
  .table.items tbody td { border: none; padding: .2rem 0; }
  .table.items tbody td:nth-child(1) { display: none; }
  .table.items tbody td:nth-child(2) { grid-column: 1 / 3; color: var(--muted); font-size: .85rem; }
  .table.items tbody td:nth-child(3) { grid-column: 1 / 2; }
  .table.items tbody td:nth-child(4) { grid-column: 1 / 4; }
  .table.items tbody td:nth-child(5) { grid-column: 3; grid-row: 1 / 3; }
  .table.items tbody td:nth-child(6) { grid-column: 2 / 3; grid-row: 2; text-align: left; font-size: 1.1rem; }
  .table.items tbody td:nth-child(7) { grid-column: 1 / 4; text-align: left; }
  .table.items tfoot tr { display: flex; justify-content: space-between; border: none; }
  .table.items tfoot td { width: auto; border: none; padding: .4rem 0; font-size: 1.15rem; }
  .hide-sm { display: none; }
  .theme-label { display: inline; }
  .theme-toggle { width: 100%; text-align: left; padding: .4rem .7rem; }
  .page-head { margin-bottom: 1rem; }
  .page-head > .btn { margin-top: .2rem; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
  .filters select { width: 100%; min-width: 0; }
  .filters > select:last-of-type:nth-of-type(odd) { grid-column: 1 / -1; }
  .date-range { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
  .date-range select, .date-range .btn { grid-column: span 1; }
  .date-range select { grid-column: 1 / -1; width: 100%; }
  .date-range label { flex-direction: column; align-items: stretch; gap: .15rem; }
  .date-range input[type=date], .date-range .pt-date, .date-range .pt-date input[type=text] { width: 100%; min-width: 0; }
  .date-range label:last-of-type .pt-cal { left: auto; right: 0; }
  .date-range .arrow { display: none; }
  /* lista de registos em cartões */
  .reports-table thead { display: none; }
  .reports-table, .reports-table tbody { display: block; width: 100%; }
  .reports-table tr { display: grid; grid-template-columns: auto 1fr auto; gap: .15rem .6rem; align-items: center;
    padding: .65rem .2rem; border-bottom: 1px solid var(--border); }
  .reports-table td { border: none; padding: 0; }
  .reports-table td:nth-child(1) { grid-column: 1; grid-row: 1; font-weight: 600; }
  .reports-table td:nth-child(2) { grid-column: 2; grid-row: 1; font-weight: 600; }
  .reports-table td:nth-child(3) { display: none; }
  .reports-table td:nth-child(4) { grid-column: 1 / 3; grid-row: 2; color: var(--muted); font-size: .9rem; }
  .reports-table td:nth-child(5) { grid-column: 3; grid-row: 1; text-align: right; }
  .reports-table td:nth-child(6) { display: none; }
  .reports-table td:nth-child(7) { grid-column: 3; grid-row: 2; text-align: right; font-size: 1.05rem; }
  .tipo-row { display: grid; grid-template-columns: 58px 1fr auto auto; gap: .45rem; align-items: center; }
  .tipo-row .tipo-form { display: contents; }
  .tipo-row input[type=color] { grid-column: 1; grid-row: 1; width: 58px; }
  .tipo-row input[name=name] { grid-column: 2 / 5; grid-row: 1; min-width: 0; }
  .tipo-row .tipo-move { grid-column: 1; grid-row: 2; }
  .tipo-row .tipo-move .drag-handle { display: none; }
  .tipo-row .check { grid-column: 2; grid-row: 2; }
  .tipo-row .count { display: none; }
  .tipo-row .btn-primary { grid-column: 3; grid-row: 2; }
  .tipo-row > form:last-child { grid-column: 4; grid-row: 2; }
  .tipo-row .km-check { grid-column: 2 / 4; grid-row: 3; }
  .table.items tfoot td:last-child { display: none; }
}
