:root {
  --bg: #f5f6f4; --card: #fff; --ink: #1c2420; --muted: #5d6a63; --line: #dfe4e0;
  --accent: #23533f; --accent-ink: #fff; --accent-soft: #e3efe8; --bar: #2f6b52;
  --ok-bg: #e4f3e9; --ok: #1d6537; --warn-bg: #fbf0d6; --warn: #775300; --bad-bg: #fbe3e1; --bad: #9a1f17;
  --test-bg: #fff0c4; --test: #634a00;
  --series-s: #2a78d6; --series-b: #eb6834;  /* chart: sessões, bulk (validated pair, as in the Sheets) */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111613; --card: #1a211d; --ink: #e5ebe7; --muted: #9aa8a0; --line: #2b3530;
    --accent: #7cc4a1; --accent-ink: #0d1612; --accent-soft: #1f3329; --bar: #6db592;
    --ok-bg: #163222; --ok: #8fd6a9; --warn-bg: #352b11; --warn: #f0cf78; --bad-bg: #3a1a17; --bad: #f2a49c;
    --test-bg: #352d10; --test: #f2d98b;
    --series-s: #3987e5; --series-b: #d95926;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
main { max-width: 860px; margin: 0 auto; padding: 12px 16px 48px; }
h1 { font-size: 1.45rem; margin: 8px 0 12px; } h2 { font-size: 1.05rem; margin: 0 0 8px; }
.test-banner { background: var(--test-bg); color: var(--test); text-align: center; padding: 6px 16px; font-size: .85rem; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; max-width: 860px; margin: 0 auto; padding: 12px 16px 6px; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); } .brand span { color: var(--accent); }
.who { display: flex; gap: 14px; align-items: center; font-size: .9rem; } .who .name { color: var(--muted); }
.who form { margin: 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; max-width: 860px; margin: 0 auto; padding: 4px 12px 8px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: .95rem; }
.tabs a.on { background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.tabs .sep { flex-basis: 0; width: 1px; background: var(--line); margin: 4px 6px; }
.switch { max-width: 860px; margin: 8px auto 0; padding: 0 16px; font-size: .88rem; }
.viewing { max-width: 828px; margin: 12px auto 0; padding: 10px 14px; background: var(--accent-soft); border-radius: 10px; font-size: .92rem; }
.viewing .links { margin-top: 4px; display: flex; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 0 0 14px; min-width: 0; }
.card.narrow { max-width: 520px; margin: 16px auto; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 14px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.monthbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.monthbar h1 { margin: 8px 0; text-align: center; }
.arrow { display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center; border-radius: 22px; font-size: 1.6rem; text-decoration: none; background: var(--card); border: 1px solid var(--line); color: var(--ink); }
.arrow.off { visibility: hidden; }
.total { text-align: center; }
.total .big { font-size: 2.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.total .big:has(.hint), .total .ects:has(.hint) { display: flex; justify-content: center; align-items: center; gap: 6px; }
.total .averages { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 16px; margin-top: 10px; }
.total .averages strong { font-variant-numeric: tabular-nums; }
.actions-main { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 14px; }
.actions-main form { margin: 0; display: grid; }
@media (max-width: 420px) { .actions-main { grid-template-columns: 1fr; } }
.button, button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; min-height: 44px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.timer.on { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
button.link { min-height: 0; padding: 0; border: 0; background: none; color: var(--accent); font-weight: 400; text-decoration: underline; }
button.small, .small button.link, a.small { font-size: .85rem; }
.danger, button.link.danger { color: var(--bad); }
.danger-bg { background: var(--bad); border-color: var(--bad); color: #fff; }
.wide { width: 100%; }
.row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.row form { margin: 0; }
.row .push { margin-left: auto; }
.row.end { align-items: flex-end; } .row.end label.field { flex: 1 1 200px; margin: 0; }
form.inline { display: inline; }
label.field { display: block; margin: 0 0 12px; font-size: .92rem; font-weight: 600; }
label.field[hidden] { display: none; }
label.field small { display: block; color: var(--muted); font-weight: 400; }
label.field small[hidden] { display: none; }
small.err, .err { color: var(--bad); }
input, select, textarea { display: block; width: 100%; margin-top: 4px; min-height: 44px; padding: 8px 10px; font: inherit; font-weight: 400; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
input[type=radio], input[type=checkbox] { display: inline; width: auto; min-height: 0; margin: 0; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); vertical-align: middle; }
label.bad input, label.bad select { border-color: var(--bad); }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--bg); border-radius: 10px; margin-bottom: 14px; }
.segmented label { position: relative; text-align: center; font-size: .88rem; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; padding: 8px 4px; border-radius: 8px; }
.segmented input:checked + span { background: var(--card); box-shadow: 0 0 0 1px var(--line); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }
fieldset.choices { border: 0; padding: 0; margin: 0 0 14px; } fieldset.choices legend { font-size: .92rem; font-weight: 600; padding: 0; margin: 0 0 6px; }
fieldset.choices label { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; margin: 0 0 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); cursor: pointer; }
fieldset.choices label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.preview { margin: -6px 0 12px; color: var(--accent); font-weight: 600; }
.preview:empty { display: none; }
select { height: 44px; }
details.repeat { margin: 0 0 14px; } details.repeat summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .92rem; padding: 4px 0; }
details.repeat[hidden] { display: none; } details.repeat label.field { margin: 8px 0 0; }
.day { margin: 0 0 14px; }
.day h2 { font-size: .9rem; color: var(--muted); font-weight: 600; margin: 0 0 6px; }
.entry { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 14px; margin: 0 0 6px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); }
.entry:hover { border-color: var(--accent); }
.entry .when { font-variant-numeric: tabular-nums; } .entry em { color: var(--muted); font-style: normal; font-size: .9rem; }
.entry .hours { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.entry .desc { grid-column: 1 / -1; color: var(--muted); font-size: .92rem; }
.pill { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.note { font-size: .9rem; color: var(--muted); margin: 0 0 12px; } .note.warn { color: var(--warn); }
.nudge { background: var(--warn-bg); border-color: transparent; } .nudge p { margin: 0 0 10px; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }
.msg { padding: 10px 14px; border-radius: 10px; margin: 0 0 12px; background: var(--accent-soft); }
.msg.success { background: var(--ok-bg); color: var(--ok); } .msg.warning { background: var(--warn-bg); color: var(--warn); } .msg.error { background: var(--bad-bg); color: var(--bad); }
.muted { color: var(--muted); font-size: .9rem; font-weight: 400; }
code.pw { font-size: 1.05rem; padding: 2px 6px; background: var(--card); border-radius: 4px; user-select: all; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; } th a { color: inherit; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.strong { font-weight: 700; } tfoot td { font-weight: 700; border-bottom: 0; }
td.late { color: var(--bad); font-weight: 700; }
.table-wrap { margin: 0 0 14px; overflow-x: auto; }
.bars td { border: 0; padding: 4px 6px; } .barcell { width: 50%; }
.bar { height: 12px; border-radius: 6px; background: var(--bg); overflow: hidden; } .bar i { display: block; height: 100%; background: var(--bar); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; }
.chips a { padding: 6px 12px; border-radius: 16px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: .9rem; background: var(--card); }
.chips a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.change { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .93rem; }
.change .meta { color: var(--muted); font-size: .85rem; }
.change .before { text-decoration: line-through; color: var(--muted); } .change .reason { font-style: italic; }
.personrow { display: flex; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line); }
.dim { opacity: .6; }
details.mail { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 0 0 8px; }
details.mail summary { cursor: pointer; }
details.mail pre { white-space: pre-wrap; font: inherit; font-size: .92rem; margin: 10px 0 0; }
@media (max-width: 640px) {
  table.team thead { display: none; }
  table.team, table.team tbody, table.team tfoot, table.team tr, table.team td { display: block; width: 100%; }
  table.team tr { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 0 0 8px; }
  table.team td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.team td:first-child { text-align: left; font-weight: 700; }
  table.team td[data-label]:not([data-label=""])::before { content: attr(data-label); color: var(--muted); font-size: .85rem; font-weight: 400; text-align: left; }
  table.team td:empty { display: none; }
}
.grid2.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 760px) { .grid2.even { grid-template-columns: minmax(0, 1fr); } }
.ects { margin-top: 8px; font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.money { display: grid; gap: 12px; align-content: start; }
.money .figure { display: grid; }
.money .figure .amount { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.money .figure strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.legend { display: flex; gap: 12px; font-size: .85rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.swatch.s { background: var(--series-s); } .swatch.b { background: var(--series-b); }
.cols { display: flex; align-items: stretch; gap: 3px; margin: 14px 0 6px; }
.col { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; text-decoration: none; color: var(--muted); border-radius: 6px; outline-offset: 2px; }
.col .plot { height: 150px; display: flex; flex-direction: column-reverse; border-bottom: 1px solid var(--line); }
.col .seg { display: block; width: 100%; }
.col .seg.s { background: var(--series-s); } .col .seg.b { background: var(--series-b); }
.col .seg + .seg { border-bottom: 2px solid var(--card); }
.col .seg:last-child { border-radius: 4px 4px 0 0; }
.col.future .seg { opacity: .55; }
.col .x { font-size: .72rem; text-align: center; padding-top: 4px; line-height: 1.2; }
.col .x small { font-size: .65rem; }
.col.now .x { color: var(--ink); font-weight: 700; }
.col:hover .plot, .col:focus-visible .plot { background: var(--bg); }
.col .tip { display: none; position: absolute; bottom: calc(100% - 20px); left: 50%; transform: translateX(-50%); z-index: 2; width: max-content; max-width: 220px; padding: 6px 10px; border-radius: 8px; background: var(--card); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0, 0, 0, .15); font-size: .82rem; line-height: 1.35; pointer-events: none; }
.col:nth-child(-n+3) .tip { left: 0; transform: none; } .col:nth-last-child(-n+3) .tip { left: auto; right: 0; transform: none; }
.col:hover .tip, .col:focus-visible .tip { display: block; }
.cols.years .col { max-width: 72px; }
.hint { position: relative; display: inline-block; vertical-align: middle; line-height: 1; }
.hint[hidden] { display: none; }
.q { width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 1px solid var(--muted); background: transparent; color: var(--muted); min-height: 0; font-family: inherit; font-size: .72rem; font-weight: 700; line-height: 1; cursor: help; }
.q:hover, .q:focus-visible { border-color: var(--accent); color: var(--accent); }
.hint-tip { display: none; position: absolute; bottom: calc(100% + 6px); left: -8px; z-index: 3; width: max-content; max-width: min(260px, 80vw); padding: 6px 10px; border-radius: 8px; background: var(--card); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0, 0, 0, .15); font-size: .82rem; font-weight: 400; line-height: 1.35; text-align: left; white-space: normal; }
.hint:hover .hint-tip, .hint:focus-within .hint-tip { display: block; }
.hint.end .hint-tip { left: auto; right: -8px; }
.table-view summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
.table-view table { margin-top: 8px; }
.segmented.units { grid-template-columns: repeat(4, 1fr); margin: 0 0 10px; }
.segmented.units a { display: block; padding: 8px 4px; border-radius: 8px; text-align: center; font-size: .88rem; color: var(--ink); text-decoration: none; }
.segmented.units a.on { background: var(--card); box-shadow: 0 0 0 1px var(--line); font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.stepper .jump { flex: 1; display: grid; justify-items: center; gap: 2px; min-width: 0; }
.stepper select { margin: 0; max-width: 100%; text-align: center; font-weight: 600; }
.pickers { margin: 0 0 8px; } .pickers label.field { flex: 1 1 140px; margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pick.all { margin: 8px 0; font-size: .92rem; font-weight: 600; }
.pick { display: inline-flex; align-items: center; gap: 10px; }
.checks { display: grid; gap: 2px; margin: 0 0 12px; }
.checks label { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.checks label small { margin-left: auto; flex: 0 1 60%; color: var(--muted); text-align: right; }
.selection { margin-top: 4px; } .selection .row + .row { margin-top: 12px; }
.selection label.field { flex: 0 1 180px; }
fieldset.plain { border: 0; padding: 0; margin: 0 0 4px; min-width: 0; }
.label-strong { font-size: .92rem; font-weight: 600; padding: 0; margin-bottom: 4px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.presets[hidden] { display: none; }
.chip { min-height: 36px; padding: 4px 12px; border-radius: 18px; font-size: .88rem; font-weight: 400; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.actions-more { margin: -4px 0 14px; font-size: .9rem; }

/* Programme costs: one colour per programme in the stacked chart (the last is "Outros") */
:root { --pc0: #2a78d6; --pc1: #eb6834; --pc2: #2f9e6b; --pc3: #8a5cc7; --pc4: #c9a227; --pc5: #d1478f; --pc6: #3aa7b8; --pc7: #8a8f98; }
@media (prefers-color-scheme: dark) { :root { --pc0: #3987e5; --pc1: #d95926; --pc2: #3fb37d; --pc3: #9d74d6; --pc4: #d6b23a; --pc5: #de5c9f; --pc6: #4cb8c9; --pc7: #9aa0a8; } }
.pc0 { background: var(--pc0); } .pc1 { background: var(--pc1); } .pc2 { background: var(--pc2); } .pc3 { background: var(--pc3); }
.pc4 { background: var(--pc4); } .pc5 { background: var(--pc5); } .pc6 { background: var(--pc6); } .pc7 { background: var(--pc7); }
.segmented.units.two { grid-template-columns: repeat(2, 1fr); }
.unit-h .u-eur, .unit-eur .u-h { display: none; }
.tiles .money { display: grid; gap: 10px; }
.section-gap { margin-top: 36px; }

/* Authorisations */
tr.part td { font-size: .88rem; padding-top: 4px; padding-bottom: 4px; border-top: 0; }
tr.part td:first-child { padding-left: 22px; }
.work-only { margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-weight: 600; }
.work-only[hidden], select[hidden] { display: none; }
div.field { display: block; margin: 0 0 14px; } div.field > label { display: block; font-size: .92rem; font-weight: 600; margin: 0 0 6px; } div.field .msg { margin: 6px 0 0; }
.authline { margin: 0 0 10px; }
.chips.people { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 12px; }
.row.fields { align-items: flex-start; } .row.fields .field { flex: 1 1 180px; margin: 0 0 12px; }
.row.between { justify-content: space-between; margin: 0 0 12px; }
details.act summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .9rem; }
details.act form { margin: 8px 0 0; } details.act .field { margin: 0; flex: 1 1 150px; }
tr.dim td { color: var(--muted); }
