/* Design system do Portal ACDL — mobile-first. Cores a partir do emblema oficial. */
:root {
    --blue-900: #1b1b4b; --blue-800: #23235f; --blue-600: #34348c; --blue-100: #e8e8f6;
    --yellow: #f5c800; --yellow-100: #fff6cc;
    --red: #b4141c; --red-100: #fde8e9;
    --green: #146c43; --green-100: #e3f3ea;
    --ink: #1c1d26; --muted: #585b6b; --line: #dcdee8; --bg: #f5f6fa; --surface: #fff;
    --radius: 14px; --tap: 48px;
    --shadow: 0 1px 2px rgb(27 27 75 / .07), 0 4px 16px rgb(27 27 75 / .06);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 1rem; line-height: 1.5; color: var(--ink); background: var(--bg); overflow-wrap: anywhere; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 1rem; color: var(--blue-900); }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; color: var(--blue-900); }
p { margin: 0 0 1rem; }
a { color: var(--blue-600); }
main > p > a:only-child, .details dd > a:only-child { display: inline-flex; align-items: center; min-height: var(--tap); }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.icon { width: 1.35rem; height: 1.35rem; flex: none; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: .5rem; top: .5rem; z-index: 20; background: var(--surface); padding: .5rem 1rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Estrutura */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .5rem 1rem; background: var(--blue-800); color: #fff; border-bottom: 3px solid var(--yellow); }
.brand { display: flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; min-height: var(--tap); }
.brand span { display: flex; flex-direction: column; line-height: 1.15; }
.brand small { opacity: .8; }
.topbar-action { display: grid; place-items: center; width: var(--tap); height: var(--tap); color: #fff; border-radius: 50%; }
.sidebar { display: none; }
.content { width: 100%; max-width: 60rem; margin: 0 auto; padding: 1.25rem 1rem calc(6rem + env(safe-area-inset-bottom)); }
.tabbar { position: fixed; inset: auto 0 0 0; z-index: 10; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; min-height: 60px; font-size: .8rem; color: var(--muted); text-decoration: none; border-top: 3px solid transparent; }
.tabbar a[aria-current=page] { color: var(--blue-800); font-weight: 600; border-top-color: var(--red); }
@media (min-width: 62rem) {
    .app { display: grid; grid-template-columns: 15rem 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
    .topbar { grid-column: 1 / -1; }
    .sidebar { display: flex; flex-direction: column; gap: .25rem; padding: 1rem .75rem; background: var(--surface); border-right: 1px solid var(--line); }
    .sidebar a, .sidebar button { display: flex; align-items: center; gap: .75rem; width: 100%; min-height: var(--tap); padding: 0 .75rem; border: 0; border-radius: 10px; background: none; color: var(--ink); font: inherit; text-decoration: none; cursor: pointer; }
    .sidebar a:hover, .sidebar button:hover { background: var(--bg); }
    .sidebar a[aria-current=page] { background: var(--blue-100); color: var(--blue-900); font-weight: 600; }
    .content { padding: 2rem; }
    .tabbar { display: none; }
}

/* Componentes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; margin-bottom: 1rem; }
.grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); margin-bottom: 1rem; }
.grid > .card { margin: 0; }
.stat { text-decoration: none; color: inherit; }
.stat strong { display: block; font-size: 1.75rem; line-height: 1.2; color: var(--blue-900); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .9rem; }
.list { list-style: none; margin: 0 0 1rem; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; min-height: 60px; color: inherit; text-decoration: none; }
a.row:hover { background: var(--bg); }
.row-main { flex: 1; min-width: 0; }
.row-main strong { display: block; }
.row-main small { display: block; color: var(--muted); }
.number { min-width: 3rem; padding: .25rem .4rem; border-radius: 10px; background: var(--blue-100); color: var(--blue-900); font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--blue-100); color: var(--blue-900); white-space: nowrap; }
.badge-ok { background: var(--green-100); color: var(--green); }
.badge-warn { background: var(--yellow-100); color: #6b5200; }
.badge-bad { background: var(--red-100); color: var(--red); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: var(--tap); padding: .6rem 1.2rem; border: 2px solid var(--blue-800); border-radius: 12px; background: var(--blue-800); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--blue-900); }
.btn-secondary { background: var(--surface); color: var(--blue-800); }
.btn-secondary:hover { background: var(--blue-100); }
.btn-danger { background: var(--surface); border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-100); }
.btn-block { width: 100%; }
.btn.is-busy { opacity: .65; cursor: progress; }
.btn.is-busy::after { content: " …"; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1rem 0; }
.actions form { margin: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.field { margin-bottom: 1rem; }
.field label, fieldset legend { display: block; font-weight: 600; margin-bottom: .3rem; }
.field input:not([type=checkbox]), .field select, .field textarea { width: 100%; min-height: var(--tap); padding: .6rem .75rem; border: 1px solid #a9adc0; border-radius: 10px; background: var(--surface); font: inherit; color: inherit; }
.field .hint { display: block; color: var(--muted); font-size: .875rem; margin-top: .25rem; }
.field-validation-error { display: block; color: var(--red); font-size: .9rem; margin-top: .25rem; }
.input-validation-error { border-color: var(--red) !important; }
fieldset { border: 0; margin: 0 0 1rem; padding: 0; }
.check { display: flex; align-items: center; gap: .6rem; min-height: var(--tap); }
.check input { width: 1.35rem; height: 1.35rem; }
.row-check { cursor: pointer; }
.row-check input { width: 1.35rem; height: 1.35rem; flex: none; }
.input-code { font-size: 1.5rem !important; letter-spacing: .3em; text-align: center; }
.search { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.search input, .search select { min-height: var(--tap); padding: .6rem .75rem; border: 1px solid #a9adc0; border-radius: 12px; font: inherit; background: var(--surface); }
.search input { flex: 1 1 12rem; min-width: 0; }
.search select { flex: 1 1 8rem; }
.details { display: grid; gap: .6rem; margin: 0; }
.details div { display: grid; gap: .1rem; }
.details dt { color: var(--muted); font-size: .85rem; }
.details dd { margin: 0; }
.alert { padding: .8rem 1rem; border-radius: 12px; border: 1px solid transparent; }
.alert-success { background: var(--green-100); color: var(--green); border-color: #bfe0cd; }
.alert-error, .validation-summary-errors { background: var(--red-100); color: var(--red); border-radius: 12px; padding: .8rem 1rem; margin-bottom: 1rem; }
.alert-warn { background: var(--yellow-100); color: #5c4700; }
.validation-summary-errors ul { margin: 0; padding-left: 1.1rem; }
.validation-summary-valid { display: none; }
.codes { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .5rem; padding: 0; list-style: none; font-family: ui-monospace, Consolas, monospace; }
.codes li { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .5rem; text-align: center; }
.key { font-family: ui-monospace, Consolas, monospace; background: var(--bg); padding: .5rem; border-radius: 8px; display: block; }
.qr { display: block; width: 12rem; height: 12rem; margin: 0 auto 1rem; image-rendering: pixelated; }

/* Autenticação */
.auth { min-height: 100vh; display: grid; place-items: start center; align-content: start; padding: 1.5rem 1rem; background: linear-gradient(var(--blue-800) 0 14rem, var(--bg) 14rem) no-repeat var(--bg); }
.auth-card { width: 100%; max-width: 25rem; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 1.5rem; border-top: 5px solid var(--yellow); }
.auth-brand { text-align: center; color: var(--muted); font-size: .9rem; }
.auth h1 { text-align: center; font-size: 1.3rem; }
.center { text-align: center; }
@media (prefers-reduced-motion: no-preference) { .btn, a.row { transition: background-color .15s; } }
/* Quotas e pagamentos */
.btn-big { min-height: 60px; font-size: 1.15rem; margin-bottom: 1rem; }
.amount { font-size: 2rem; font-weight: 700; margin: 0; color: var(--blue-900); font-variant-numeric: tabular-nums; }
.lines { margin: 0 0 .75rem; }
.lines div { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.lines dt { margin: 0; }
.lines dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.lines dt a { display: inline-flex; align-items: center; min-height: 44px; }
.lines .total { font-weight: 700; font-size: 1.15rem; border-bottom: 0; }
li.row .btn { flex: none; }
.options summary { display: flex; align-items: center; min-height: var(--tap); cursor: pointer; font-weight: 600; color: var(--blue-800); }
.period .field { flex: 1 1 9rem; margin: 0; }
.period .btn { align-self: flex-end; }
.table-scroll { overflow-x: auto; max-width: 100%; margin-bottom: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.map { border-collapse: collapse; width: 100%; font-size: .9rem; }
.map th, .map td { padding: .35rem .5rem; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.map th[scope=row] { position: sticky; left: 0; background: var(--surface); text-align: left; font-weight: 400; }
.map th[scope=row] a { display: flex; align-items: center; gap: .4rem; min-height: 44px; color: inherit; text-decoration: none; }
.map .number { min-width: 2.5rem; }
.map-name { max-width: 7rem; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 40rem) { .map-name { max-width: 20rem; } }
/* Comunicações */
.message { white-space: pre-line; }
.field textarea { resize: vertical; }
label.row { cursor: pointer; }
.pick { width: 1.5rem; height: 1.5rem; flex: none; }
.preview summary { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; min-height: 60px; cursor: pointer; }
.preview p { margin: 0 1rem .75rem; }
/* Pagamentos eletrónicos */
.pay-card h2 { margin-top: .5rem; }
.reference dd { font-size: 1.25rem; font-weight: 700; white-space: nowrap; }
@media print { .topbar, .sidebar, .tabbar, .btn, .search, .actions { display: none !important; } .app { display: block; } body { background: #fff; } }
