:root {
    color-scheme: light;
    --ink: #172a4a;
    --muted: #465b7b;
    --accent: #3459a3;
    --accent-hover: #264581;
    --navy: #132853;
    --focus: #315eb9;
    --ground: #f3f7fd;
    --surface: #fff;
    --border: #d3def0;
    --field-border: #7588a5;
    --subtle: #edf3fc;
    --radius: 16px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.5;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); }
[hidden] { display: none !important; }
h1, h2, h3, p, dl, dd { margin: 0; }
a { color: var(--accent); text-underline-offset: .17em; }
button, input, select, textarea { font: inherit; }
input, select, textarea { min-width: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.shell { width: min(100% - 3rem, 76rem); margin-inline: auto; }
.skip-link { position: absolute; z-index: 3; left: 1rem; top: .7rem; padding: .6rem 1rem; background: var(--surface); transform: translateY(-200%); }
.skip-link:focus { transform: none; }
.top { color: #fff; background: var(--navy); }
.top :focus-visible { outline-color: #b6d0ff; }
.top__bar { min-height: 4.4rem; display: flex; justify-content: space-between; align-items: center; gap: .75rem 1.6rem; padding-block: .65rem; }
.top__brand { color: #fff; font-weight: 720; text-decoration: none; max-width: 29rem; }
.top__account { display: flex; align-items: center; gap: .85rem; }
.top__identity { color: #e1eaff; font-size: .87rem; text-wrap: pretty; overflow-wrap: anywhere; }

.page { display: grid; gap: 1rem; padding-block: 2rem 3rem; }
.page__intro { padding-block: .15rem .35rem; }
h1 { font-size: clamp(2rem, 1.65rem + 1.6vw, 3.2rem); font-weight: 730; letter-spacing: -.05em; line-height: 1.04; }
h2 { font-size: 1.2rem; font-weight: 720; letter-spacing: -.018em; line-height: 1.2; }
h3 { font-size: 1.02rem; line-height: 1.25; }
.message { padding: .7rem .95rem; border: 1px solid; border-radius: .55rem; overflow-wrap: anywhere; }
.message--success { background: #e5f4e7; color: #1d5b31; border-color: #b7d8bd; }
.message--error { background: #fae9e5; color: #872d27; border-color: #ebc2bb; }
.message--warning { background: #f6ecd5; color: #65491a; border-color: #dcc69c; margin-bottom: .85rem; font-size: .88rem; }

.overview { display: grid; grid-template-columns: minmax(0, 3fr) minmax(15rem, 1.2fr); gap: .8rem; }
.overview__counts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .65rem; }
.metric { display: grid; align-content: center; gap: .14rem; min-height: 6rem; padding: .8rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.metric strong { font-size: clamp(1.35rem, 1.05rem + 1vw, 2rem); line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }
.metric span, .funds__head span, .funds__target { font-size: .82rem; }
.metric span { color: var(--muted); line-height: 1.22; }
.overview__funds { min-width: 0; border-radius: var(--radius); background: #e8f0fc; padding: .8rem 1rem; }
.funds__head { display: flex; gap: .35rem 1rem; align-items: baseline; justify-content: space-between; }
.funds__head h2 { font-size: .94rem; }
.funds__amount { font-size: 1.55rem; font-weight: 750; line-height: 1.2; font-variant-numeric: tabular-nums; }
progress { display: block; width: 100%; height: .55rem; margin-block: .4rem .3rem; border: none; border-radius: 1rem; background: #c8d6ed; accent-color: var(--accent); }
progress::-webkit-progress-bar { background: #c8d6ed; border-radius: 1rem; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 1rem; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 1rem; }
.traffic { display: flex; flex-wrap: wrap; gap: .25rem 1rem; padding: .5rem .85rem; background: var(--subtle); border-radius: .55rem; font-size: .88rem; }
.traffic span { color: var(--muted); }

.panel { min-width: 0; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); }
.panel__heading { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: 1rem 1.2rem; }
.disclosure > summary { cursor: pointer; color: var(--ink); padding: .85rem 1.2rem; font-weight: 680; }
.disclosure > summary:hover, .disclosure > summary:focus-visible { color: var(--accent); }
.disclosure__body { padding: 0 1.2rem 1rem; }
.disclosure__body > p { font-size: .9rem; color: var(--muted); }
.disclosure__body > p + form { margin-top: .5rem; }
.stack { display: grid; gap: .65rem; }

.button { display: inline-flex; min-height: 2.45rem; justify-content: center; align-items: center; padding: .43rem .82rem; border: 1px solid transparent; border-radius: .47rem; background: var(--accent); color: #fff; font-size: .87rem; font-weight: 665; line-height: 1.22; text-decoration: none; text-align: center; cursor: pointer; }
.button:hover { background: var(--accent-hover); }
.button--secondary { color: var(--accent); border-color: var(--field-border); background: #fff; }
.button--secondary:hover { background: var(--subtle); }
.button--header { color: #fff; border-color: #93a9d0; background: transparent; }
.button--header:hover { background: #294675; }
.button--danger { color: #87302a; border-color: #d9acaa; background: #fff7f4; }
.button--danger:hover { background: #f9eae7; }
.text-action { font-size: .88rem; font-weight: 670; }
.line-actions { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }

.field { display: grid; gap: .25rem; align-content: start; color: var(--ink); font-size: .85rem; font-weight: 650; min-width: 0; }
.field input, .field select, .field textarea { min-width: 0; max-width: 100%; width: 100%; min-height: 2.45rem; padding: .46rem .58rem; border: 1px solid var(--field-border); border-radius: .4rem; background: #fff; color: var(--ink); font-size: .95rem; font-weight: 400; }
.field input::placeholder { color: var(--muted); opacity: 1; }
.field textarea { resize: vertical; line-height: 1.45; }
.field input[readonly], .field textarea[readonly] { background: var(--ground); }
.field input[type='date'] { max-inline-size: 100%; min-inline-size: 0; }
.field select { padding-right: 1.15rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.field--wide { grid-column: 1 / -1; }
.filters { display: grid; grid-template-columns: minmax(11rem, 1.55fr) minmax(8.5rem, 1fr) minmax(6.6rem, .7fr) minmax(5rem, .54fr) minmax(9.25rem, .85fr) auto; gap: .6rem; align-items: end; padding: 0 1.2rem 1rem; }
.filters__actions { display: flex; align-items: center; gap: .6rem; }

.table-scroll { overflow-x: auto; }
.table-scroll:focus-visible { outline-offset: -3px; }
table { border-collapse: collapse; width: 100%; min-width: 39rem; font-size: .88rem; }
th, td { padding: .65rem .65rem; border-bottom: 1px solid #e0e7f2; text-align: left; vertical-align: middle; }
thead { color: var(--ink); background: var(--subtle); }
thead th { font-size: .82rem; white-space: nowrap; }
thead th:first-child, tbody th { padding-left: 1.2rem; }
th:last-child, td:last-child { padding-right: 1.2rem; }
tbody tr.is-selected { background: #e8f0fc; }
tbody tr:hover { background: var(--ground); }
tbody tr:last-child > * { border-bottom-color: transparent; }
tbody th a { display: inline-block; padding-block: .12rem; font-weight: 720; overflow-wrap: anywhere; }
.badge { display: inline-block; border-radius: 1rem; padding: .2rem .52rem; color: #39495e; background: #eef1f6; font-size: .795rem; font-weight: 660; line-height: 1.24; }
.state-pending, .state-clarification { color: #65491a; background: #f6ecd5; }
.state-approved { color: #284f6d; background: #e3eff7; }
.state-active { color: #195035; background: #e1f1e2; }
.state-rejected, .state-withdrawn { color: #793b39; background: #faebe8; }
.record-warning { display: block; margin-top: .12rem; color: #65491a; }
.empty { padding: .3rem 1.2rem 1.1rem; color: var(--muted); font-size: .92rem; }
.registry { overflow: hidden; }

.profile { scroll-margin-block-start: 1rem; }
.profile__heading { border-bottom: 1px solid var(--border); }
.profile__heading h2 { overflow-wrap: anywhere; font-size: 1.38rem; }
.profile__heading p { color: var(--muted); font-size: .88rem; margin-top: .23rem; }
.profile__layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 1.05rem; padding: 1.2rem; }
.profile__primary > h3 { margin-bottom: .8rem; }
.profile__side { display: grid; align-content: start; gap: .85rem; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem .8rem; }
.facts dt { color: var(--muted); font-size: .82rem; font-weight: 650; }
.facts dd { font-size: .94rem; overflow-wrap: anywhere; }
.fact__version { color: var(--muted); display: block; }
.facts--secondary { border-top: 1px solid var(--border); padding-top: .8rem; margin-top: 1rem; }
.multiline { white-space: pre-wrap; overflow-wrap: anywhere; }
.profile__management { border: 1px solid var(--border); border-radius: .62rem; margin-top: .9rem; }
.profile__management > summary { padding: .7rem .8rem; font-size: .88rem; }
.profile__management .disclosure__body { padding: 0 .8rem .8rem; }

.subpanel { min-width: 0; border: 1px solid var(--border); border-radius: .7rem; background: #f7f9fd; }
.subpanel__head { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; padding: .78rem .9rem .62rem; }
.subpanel__head > span { color: var(--muted); font-size: .82rem; }
.subpanel__empty { padding: 0 .9rem .7rem; color: var(--muted); font-size: .87rem; }
.subpanel__address { padding: 0 .9rem .7rem; }
.subpanel__details { border-top: 1px solid var(--border); }
.subpanel__details > summary { padding: .7rem .9rem; font-size: .88rem; }
.subpanel__details .disclosure__body { padding: 0 .9rem .9rem; }
.subpanel__link { padding: .6rem .9rem .7rem; border-top: 1px solid var(--border); }
.events { list-style: none; margin: 0; padding: 0 .9rem; }
.events > li { padding: .58rem 0; border-top: 1px solid var(--border); }
.events > li p { color: var(--muted); font-size: .85rem; }
.event__main { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .13rem .5rem; }
.event__main span { color: var(--muted); font-size: .82rem; }
.events--history { padding: 0 1.2rem .48rem; }
.copy-action { justify-self: start; }
.clipboard-status { position: fixed; right: 1rem; bottom: 1rem; z-index: 2; max-width: min(25rem, calc(100% - 2rem)); background: var(--navy); color: #fff; padding: .65rem .9rem; box-shadow: 0 4px 16px #13285330; border-radius: .5rem; font-size: .88rem; }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 1.25rem; }
.login-box { display: grid; width: min(100%, 28rem); gap: 1rem; padding: clamp(1.3rem, 3vw, 2rem); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.login-box h1 { font-size: clamp(1.8rem, 1.4rem + 2.2vw, 2.55rem); }
.login-box p { color: var(--muted); font-size: .9rem; }
.login-box p[role='alert'] { padding: .65rem .8rem; color: #872d27; background: #fae9e5; border-radius: .45rem; }
.login-box form { display: grid; gap: .8rem; }
.login-box label { display: grid; gap: .25rem; color: var(--ink); font-size: .87rem; font-weight: 650; }
.login-box input:not([type='hidden']) { width: 100%; min-height: 2.65rem; padding: .5rem .62rem; border: 1px solid var(--field-border); border-radius: .44rem; color: var(--ink); background: #fff; font-size: .98rem; font-weight: 400; }
.login-box button { justify-self: start; min-height: 2.6rem; padding: .48rem .93rem; border: 0; border-radius: .44rem; background: var(--accent); color: #fff; font-weight: 675; cursor: pointer; }
.login-box button:hover { background: var(--accent-hover); }

@media (max-width: 60rem) {
    .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .overview { grid-template-columns: minmax(0, 2.3fr) minmax(12rem, 1fr); }
    .metric { padding-inline: .65rem; }
}

@media (max-width: 48rem) {
    .shell { width: calc(100% - 1.65rem); }
    .page { padding-top: 1.5rem; }
    .overview { grid-template-columns: 1fr; }
    .profile__layout { grid-template-columns: 1fr; }
}

@media (max-width: 34rem) {
    .top__bar { flex-wrap: wrap; gap: .5rem; }
    .top__brand { width: 100%; font-size: .93rem; }
    .top__account { width: 100%; justify-content: space-between; }
    .top__identity { font-size: .8rem; }
    .overview__counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .metric { min-height: 4.5rem; padding: .65rem .8rem; }
    .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .field--search, .filters__actions { grid-column: 1 / -1; }
    .panel__heading, .disclosure > summary { padding-inline: .85rem; }
    .filters, .profile__layout, .disclosure__body { padding-inline: .85rem; }
    .profile__heading { align-items: flex-start; }
}
