/* App shell: top navigation, one shared date and filter row, a dense grid and a drill panel */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 16px; padding: 10px 24px 6px; }
.company { padding-left: 16px; border-left: 1px solid var(--line-2); color: var(--ink-2); font-size: 14px; }
.user { position: relative; margin-left: auto; }
.user-btn { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 3px 8px 3px 4px; border: 1px solid transparent; border-radius: var(--radius); background: none; text-align: left; cursor: pointer; }
.user-btn:hover { border-color: var(--line-2); }
.user-btn strong, .user-btn small { display: block; line-height: 1.25; }
.user-btn strong { font-size: 14px; } .user-btn small { font-size: 12.5px; color: var(--ink-2); }
.avatar { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 99px; background: var(--accent-tint); color: var(--accent-dark); font: 700 12.5px/1 var(--head); text-decoration: none; }
.popover { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; display: grid; min-width: 220px; padding: 6px; border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: var(--surface); box-shadow: 0 22px 44px -22px rgba(30, 35, 40, .5); }
.popover :is(a, button) { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 10px; border: 0; border-radius: 6px; background: none; color: var(--ink); font-weight: 500; text-decoration: none; text-align: left; cursor: pointer; }
.popover :is(a, button):hover { background: var(--soft); }
.topnav { padding: 0 24px; }
.topnav ul { display: flex; flex-wrap: wrap; column-gap: 8px; }
.topnav a { position: relative; display: flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 11px; border-bottom: 3px solid transparent; color: var(--ink-2); font-weight: 600; font-size: 14.5px; text-decoration: none; white-space: nowrap; }
.topnav a:hover { color: var(--ink); border-bottom-color: var(--line-2); }
.topnav a.is-active { color: var(--accent-dark); border-bottom-color: var(--accent); }
.topnav .icon { width: 17px; height: 17px; }
.count { min-width: 19px; padding: 0 5px; border-radius: 99px; background: var(--sand); color: #fff; font-size: 12px; line-height: 19px; text-align: center; }
@media (max-width: 1180px) { .topnav .icon { display: none; } .topnav a { padding: 0 8px; } }
@media (max-width: 900px) { .company { display: none; } }

.filterbar { position: sticky; top: 0; z-index: 15; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 24px; border-bottom: 1px solid var(--line); background: var(--accent-tint); }
.fsel { display: inline-flex; align-items: center; gap: 7px; }
.fsel select, .inline-select select, .custom-dates input { min-height: 36px; max-width: 100%; padding: 0 28px 0 10px; border: 1px solid #c2cbd3; border-radius: var(--radius); background-color: var(--surface); font-size: 14px; font-weight: 500; }
.custom-dates input { padding-right: 8px; }
.fsel.is-set select { border-color: var(--accent); background-color: var(--accent); color: #fff; }
.fsel.is-set option { color: var(--ink); background: #fff; }
.fsel-date > .icon { color: var(--accent); }
.fsel-date select { font-weight: 700; }
.range-text { font-size: 14px; color: #36434e; font-variant-numeric: tabular-nums; }
.custom-dates { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.custom-dates label { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; }
.custom-dates .error { color: var(--danger); font-size: 13.5px; font-weight: 600; }
[aria-invalid="true"] { border-color: var(--danger) !important; box-shadow: 0 0 0 1px var(--danger); }
.f-sep { width: 1px; height: 24px; margin: 0 4px; background: #bcc6cf; }
.f-end { display: flex; gap: 6px; margin-left: auto; }
.filterbar .btn-quiet { color: var(--accent-dark); }
.filterbar .btn-quiet:hover { background: var(--surface); }

.content { display: block; max-width: 1560px; margin: 0 auto; padding: 18px 24px 48px; }
.content > * + * { margin-top: 14px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 20px; }
.page-head h1 { font: 700 24px/1.25 var(--head); letter-spacing: -.02em; }
.page-head p { color: var(--ink-2); font-size: 14px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Headline figures share one ruled strip */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--line); }
.kpis li { background: var(--surface); }
.kpis li > * { display: block; height: 100%; padding: 13px 16px; color: inherit; text-decoration: none; }
.kpis a:hover { background: #f4f6f7; }
.k-name { display: block; color: var(--ink-2); font-size: 13.5px; font-weight: 600; }
.k-value { display: block; margin: 3px 0 2px; font: 600 25px/1.2 var(--head); letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.k-sub { display: block; color: var(--ink-2); font-size: 13px; line-height: 1.35; }
.delta { font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.delta.good { color: var(--ok); } .delta.bad { color: var(--danger); }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid > .wide { grid-column: span 2; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-2 > .wide { grid-column: auto; }
@media (max-width: 1140px) { .grid, .grid-2 { grid-template-columns: minmax(0, 1fr); } .grid > .wide { grid-column: auto; } }
.card { display: flex; flex-direction: column; min-width: 0; padding: 14px 16px 12px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 6px 12px; margin-bottom: 10px; }
.card-head > div:first-child { flex: 1 1 180px; min-width: 0; }
.card h2 { font: 600 16px/1.35 var(--head); letter-spacing: -.01em; }
.card-head p { color: var(--ink-2); font-size: 13px; line-height: 1.4; }
.card-tools { display: flex; align-items: center; gap: 10px; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-head { margin: 0; padding: 14px 16px 10px; }
.more-link { font-size: 13.5px; font-weight: 700; }
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--soft); }
.seg button { min-height: 28px; padding: 0 10px; border: 0; border-radius: 6px; background: none; color: var(--ink-2); font-size: 12.5px; font-weight: 700; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(30, 35, 40, .2); }
.chart-table { max-height: 330px; overflow: auto; }

.table-wrap { max-width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { position: sticky; top: 0; border-top: 0; border-bottom: 1px solid var(--line-2); background: #f8f6f0; color: var(--ink-2); font-size: 13px; font-weight: 700; white-space: nowrap; }
th:first-child, td:first-child { padding-left: 16px; } th:last-child, td:last-child { padding-right: 16px; }
.chart-table :is(th, td):first-child { padding-left: 8px; }
td small { display: block; color: var(--ink-2); font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { white-space: nowrap; }
tbody tr[data-href] { cursor: pointer; }
tbody tr:hover { background: #f5f3ec; }
tfoot :is(th, td) { border-top: 2px solid var(--line-2); font-weight: 700; }
th button { display: inline-flex; align-items: center; gap: 5px; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
th button i { width: 0; height: 0; border: 4px solid transparent; opacity: .35; border-top-color: currentColor; transform: translateY(2px); }
th button i.up { opacity: 1; border-top-color: transparent; border-bottom-color: currentColor; transform: translateY(-2px); }
th button i.down { opacity: 1; }
.cell-link { font-weight: 700; text-underline-offset: 3px; }
.amt-in { color: var(--ok); font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12.5px; font-weight: 700; line-height: 1.45; white-space: nowrap; }
.tone-ok { background: var(--ok-tint); color: var(--ok); } .tone-neutral { background: var(--soft); color: #4a463f; } .tone-warn { background: var(--warn-tint); color: var(--warn); } .tone-danger { background: var(--danger-tint); color: var(--danger); } .tone-info { background: var(--info-tint); color: var(--info); }

.listbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 0 16px 10px; }
.searchfield { display: flex; flex: 0 1 340px; align-items: center; gap: 8px; min-height: 38px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--radius); background: #fff; }
.searchfield:focus-within { outline: 2px solid #2f74c0; }
.searchfield input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; }
.tabs { display: flex; gap: 6px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.tab { flex: none; min-height: 34px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 99px; background: var(--surface); font-size: 13.5px; font-weight: 600; cursor: pointer; }
.tab span { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tab.is-active { border-color: var(--accent); background: var(--accent); color: #fff; }
.tab.is-active span { color: #d5dde3; }
.inline-select { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; }
.list-count { padding: 0 16px 8px; color: var(--ink-2); font-size: 13.5px; }
.list-more { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: 13.5px; }
.empty { padding: 28px 16px; text-align: center; }
.empty h3 { font: 600 15.5px/1.4 var(--head); }
.empty p { color: var(--ink-2); font-size: 14px; }
.empty .btn { margin-top: 12px; }

.checks li + li, .mini li + li, .views li + li, .access li + li, .pays li + li { border-top: 1px solid var(--line); }
.checks a { display: grid; grid-template-columns: 10px minmax(0, 1fr) 16px; align-items: center; gap: 11px; padding: 10px 2px; color: inherit; text-decoration: none; }
.checks a:hover strong, .mini a:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.checks strong, .checks small, .mini strong, .mini small { display: block; line-height: 1.35; }
.checks strong { font-size: 14.5px; }
.checks small, .mini small { color: var(--ink-2); font-size: 13px; }
.checks .icon { color: var(--ink-2); width: 16px; }
.dot { width: 10px; height: 10px; border-radius: 3px; }
.dot.tone-danger { background: var(--danger); } .dot.tone-warn { background: #c68a3e; }
.mini a { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; color: inherit; text-decoration: none; }
.mini a > span:first-child { min-width: 0; }
.mini strong { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.mini-end { display: grid; flex: none; justify-items: end; gap: 3px; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px 16px; }
.facts dt { color: var(--ink-2); font-size: 13px; }
.facts dd { font-weight: 600; overflow-wrap: anywhere; }
.facts dd small { font-weight: 400; color: var(--ink-2); }
.views li, .access li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px; padding: 12px 16px; }
.views li:first-child, .access li:first-child { border-top: 1px solid var(--line); }
.views strong, .views small, .access strong, .access small { display: block; }
.views small, .access small { color: var(--ink-2); font-size: 13.5px; }
.r-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.access li { display: grid; grid-template-columns: 34px minmax(150px, 220px) minmax(0, 1fr) auto; justify-content: stretch; }
.a-what { color: var(--ink-2); font-size: 14px; }
.a-level { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
@media (max-width: 900px) { .access li { grid-template-columns: 34px minmax(0, 1fr); } .a-what, .a-level { grid-column: 2; justify-content: flex-start; flex-wrap: wrap; } }

/* Drill panel */
.has-panel { overflow: hidden; }
.scrim { position: fixed; inset: 0; z-index: 24; border: 0; background: rgba(24, 30, 36, .42); cursor: default; }
.drawer { position: fixed; z-index: 25; top: 0; right: 0; bottom: 0; display: flex; flex-direction: column; width: min(580px, calc(100vw - 48px)); background: var(--surface); box-shadow: -30px 0 60px -30px rgba(24, 30, 36, .55); }
@media (prefers-reduced-motion: no-preference) { .drawer { animation: drawer-in .22s cubic-bezier(.22, 1, .36, 1); } }
@keyframes drawer-in { from { transform: translateX(28px); opacity: .4; } }
.p-bar { display: flex; flex: none; align-items: center; justify-content: space-between; min-height: 52px; padding: 6px 14px 6px 20px; border-bottom: 1px solid var(--line); background: var(--accent-tint); font-weight: 700; font-size: 13.5px; }
.p-bar .btn { margin-left: -10px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: var(--radius); background: none; color: inherit; cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: rgba(52, 66, 78, .1); }
.p-body { flex: 1; min-height: 0; padding: 18px 20px 40px; overflow-y: auto; overscroll-behavior: contain; }
.p-body > * + *, .m-detail > * + * { margin-top: 16px; }
.p-title :is(h1, h2) { font: 700 20px/1.3 var(--head); letter-spacing: -.015em; }
.p-title p { color: var(--ink-2); font-size: 14px; }
.p-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.p-body > .facts, .m-detail > .facts { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: #f8f6f0; }
.p-sec h3 { margin-bottom: 6px; font: 600 14.5px/1.4 var(--head); }
.p-sec > .mini, .pays { border-block: 1px solid var(--line); }
.p-note { color: var(--ink-2); font-size: 14px; }
.lines :is(th, td) { padding: 7px 6px; }
.lines :is(th, td):first-child { padding-left: 0; } .lines :is(th, td):last-child { padding-right: 0; }
.lines thead th { position: static; background: none; }
.pays li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; }
.pays small { display: block; color: var(--ink-2); }
.p-body .chart-card { padding: 12px; --xc-h: 170px; }

.locked { max-width: 520px; margin: 60px auto; padding: 0 16px; text-align: center; }
.locked > .icon { width: 36px; height: 36px; margin: 0 auto 10px; color: var(--accent); }
.locked :is(h1, h2) { font: 700 22px/1.3 var(--head); }
.locked p { margin: 8px 0 18px; color: var(--ink-2); }

.signin { max-width: 1000px; margin: 0 auto; padding: 44px 20px 64px; text-align: center; }
.signin h1 { margin-top: 30px; font: 700 clamp(25px, 3.4vw, 32px)/1.25 var(--head); letter-spacing: -.02em; }
.signin-sub { max-width: 56ch; margin: 8px auto 0; color: var(--ink-2); }
.roles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 30px; }
.role { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 22px; border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: var(--surface); text-align: left; cursor: pointer; }
.role:hover { border-color: var(--accent); box-shadow: 0 18px 34px -24px rgba(30, 35, 40, .55); }
.role-icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 8px; border-radius: var(--radius); background: var(--accent-tint); color: var(--accent); }
.role-title { font: 700 19px/1.3 var(--head); }
.role-name { color: var(--ink-2); }
.role-short { display: none; }
.role-points { display: grid; gap: 7px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; }
.role-points > span { display: flex; gap: 8px; }
.role-points .icon { width: 16px; margin-top: 2px; color: var(--accent); }
.noscript { padding: 40px 20px; text-align: center; }

dialog { width: min(540px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); overflow: hidden; box-shadow: 0 30px 70px -20px rgba(30, 35, 40, .6); }
dialog::backdrop { background: rgba(24, 30, 36, .55); }
dialog form { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); margin: 0; }
.modal-head { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 10px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font: 700 17px/1.3 var(--head); }
.modal-body { min-height: 0; padding: 16px 20px; overflow-y: auto; overscroll-behavior: contain; }
.modal-body > * + * { margin-top: 12px; }
.modal-foot { display: flex; flex: none; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }
.modal-note { color: var(--ink-2); font-size: 14.5px; }
.modal-note strong { color: var(--ink); }
.field { display: grid; align-content: start; gap: 5px; }
.field label { font-weight: 700; font-size: 14px; }
.field :is(input, select, textarea) { width: 100%; min-width: 0; min-height: 42px; padding: 8px 11px; border: 1px solid var(--line-2); border-radius: var(--radius); background: #fff; }
.field small { color: var(--ink-2); font-size: 13px; }
.field .error:empty { display: none; }
.error, .form-error { color: var(--danger); font-size: 13.5px; font-weight: 600; }
.form-error { padding: 9px 12px; border-radius: var(--radius); background: var(--danger-tint); }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
@media (max-width: 480px) { .field-row { grid-template-columns: minmax(0, 1fr); } }
.linked { display: flex; gap: 8px; padding: 9px 12px; border-radius: var(--radius); background: var(--accent-tint); font-size: 14px; font-weight: 600; }
.linked .icon { margin-top: 2px; }
.sheet-links { display: flex; gap: 8px; }

.toasts { position: fixed; z-index: 60; right: 16px; bottom: 16px; display: grid; gap: 8px; max-width: min(400px, calc(100vw - 32px)); pointer-events: none; }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 15px; border-radius: var(--radius); background: #1e262d; color: #fff; box-shadow: 0 12px 28px -12px rgba(30, 35, 40, .6); }
.toast .icon { margin-top: 2px; color: #a5d8b4; }
.toast-warn .icon { color: #f2c274; }
/* Loading placeholder shown while a screen opens */
.page-skel { display: grid; grid-column: 1 / -1; align-content: start; gap: 14px; width: 100%; min-width: 0; padding: 2px; }
.page-skel i { display: block; height: 96px; border-radius: var(--radius-lg, 8px); background: linear-gradient(90deg, rgba(100, 112, 128, .13) 25%, rgba(100, 112, 128, .05) 50%, rgba(100, 112, 128, .13) 75%); background-size: 200% 100%; animation: skel-shimmer 1s linear infinite; }
.page-skel .sk-title { width: min(280px, 70%); height: 30px; }
.page-skel .sk-line { width: min(420px, 90%); height: 14px; }
.page-skel > div { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.page-skel .sk-block { height: 280px; }
@keyframes skel-shimmer { to { background-position: -200% 0; } }
@media (max-width: 760px) { .page-skel > div { grid-template-columns: minmax(0, 1fr); } .page-skel > div i { height: 68px; } }
.page-in > * { animation: page-in .3s ease-out both; }
@keyframes page-in { from { opacity: 0; } }
.page-skel.is-flush { box-sizing: border-box; padding: 22px 24px; }

/* One card left in a row takes the whole width */
.grid > .span-all { grid-column: 1 / -1; }
