/* Shared presentation layer, loaded after each module. Brand colors stay local. */
:root {
  --navy: #143653;
  --accent: #08796d;
  --ink: #20354b;
  --muted: #586b7d;
  --line: #dce5ec;
  --bg: #f4f7fa;
  --radius: 14px;
  --sidebar: 264px;
  --surface-shadow: 0 2px 6px #14365304, 0 8px 24px #14365303;
}
body { font-size: 15px; line-height: 1.65; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { color: var(--navy); text-wrap: balance; }
h1 { font-size: clamp(1.75rem, 2.8vw, 2.35rem); letter-spacing: -.035em; margin-bottom: 20px; }
h2 { letter-spacing: -.02em; }
h3 { line-height: 1.45; }
a { text-underline-offset: 3px; }
p, li, dd { overflow-wrap: anywhere; }
.eyebrow { font-weight: 700; letter-spacing: .11em; margin-bottom: 10px; }
::selection { background: #c7eee5; color: #143653; }
:focus-visible { scroll-margin-block: 110px 40px; }

/* Stable shell with a quieter, clearly selected navigation. */
.sidebar { background: #102f49; padding: 32px 18px; border-right: 1px solid #ffffff0d; }
.sidebar-brand { margin: 0 12px 34px; }
.nav-caption { margin: 0 14px 16px; font-size: .64rem; letter-spacing: .13em; color: #a8c0d2; }
.main-nav { gap: 5px; }
.main-nav a { position: relative; border: 1px solid transparent; border-radius: 10px; padding: 12px 14px; font-size: .85rem; line-height: 1.45; min-height: 46px; }
.main-nav a:hover { background: #ffffff0d; border-color: #ffffff12; }
.main-nav a[aria-current=page] { background: #214a61; border-color: #ffffff16; font-weight: 650; color: #fff; }
.main-nav a[aria-current=page]::before { content: ""; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: #83dfd1; }
.main-nav .icon { width: 19px; height: 19px; opacity: .9; }
.app-topbar { min-height: 82px; padding: 15px 36px; box-shadow: 0 1px 8px #14365303; }
.topbar-context { min-width: 0; }
.topbar-title { display: grid; gap: 2px; min-width: 0; }
.topbar-caption { color: var(--muted); font-size: .68rem; }
.topbar-title strong { font-size: .9rem; overflow-wrap: anywhere; line-height: 1.4; }
.topbar-actions { gap: 10px; flex-shrink: 0; }
.topbar-actions summary { padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fafcfd; font-size: .8rem; gap: 10px; }
.topbar-actions summary::after { content: "⌄"; color: var(--muted); }
.topbar-actions summary:hover, .topbar-actions details[open] summary { background: #edf5f5; border-color: #accbc6; }
.topbar-popover { top: calc(100% + 10px); z-index: 20; box-shadow: 0 12px 40px #1436531c; font-size: .88rem; }
.topbar-popover button { width: 100%; }
.content { padding: 36px; margin: 0 auto; }
.page-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 20px; margin-bottom: 26px; }
.page-heading h1 { margin-bottom: 8px; }
.page-heading p:last-child { margin-bottom: 0; }
.search-form { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.search-form > div { flex: 1; min-width: min(240px, 100%); }
.search-form button { margin: 0; }
.search-form { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.search-form > div { flex: 1; min-width: min(220px, 100%); }
.search-form button { margin: 0; }
footer { padding: 22px 36px; margin-top: auto; border-top: 1px solid var(--line); background: #ffffff60; }

/* Primary, secondary and destructive actions share dimensions and states. */
button, .button, .button-secondary, .report-actions a {
  min-height: 44px; padding: 10px 17px; border-radius: 9px;
  font-size: .85rem; font-weight: 650; line-height: 1.4; text-align: center;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
button:hover, .button:hover { background: #204d6d; border-color: #204d6d; }
button:active, .button:active { box-shadow: inset 0 2px 4px #00000018; }
.button-secondary { background: #fff; color: var(--navy); border-color: #bfceda; }
.button-secondary:hover { background: #edf4f8; color: var(--navy); border-color: #819eaf; }
button.button-danger { background: #fff; color: #a32232; border-color: #dcb5bd; }
button.button-danger:hover { background: #fff0f2; border-color: #a32232; }
button:disabled, .button[aria-disabled=true] { opacity: .55; cursor: not-allowed; box-shadow: none; }
button[aria-busy=true] { cursor: progress; }
.action-row, .platform-inline, .slate-actions, .aff-form-actions { gap: 10px; }
.action-row form, .platform-inline form { margin: 0; }
.action-row button, .platform-inline button, td form button { margin-top: 0; }
.platform-inline { align-items: end; margin-bottom: 24px; }
.platform-inline label { margin: 0; flex: 1; min-width: min(230px, 100%); }
td button, td .button, td .button-secondary { padding: 9px 12px; font-size: .78rem; }
td form + form { margin-top: 8px; }

/* Inputs, help text, required fields and validation. */
input, select, textarea { border-color: #b9c9d5; border-radius: 9px; padding: 11px 12px; font-size: .94rem; line-height: 1.5; }
input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select { min-height: 46px; }
textarea { min-height: 128px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #829eae; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 3px solid #08796d26; outline-offset: 1px; }
input:disabled, select:disabled, textarea:disabled { background: #edf1f5; color: #586b7d; cursor: not-allowed; }
input[readonly], textarea[readonly] { background: #f5f8fa; }
input[type=checkbox], input[type=radio] { width: auto; min-height: auto; accent-color: var(--accent); }
input[type=checkbox] { width: 18px; height: 18px; vertical-align: middle; }
input[type=file] { padding: 7px; font-size: .85rem; }
input::file-selector-button { border: 0; border-radius: 5px; padding: 7px 10px; margin-right: 12px; background: #eaf1f6; color: var(--navy); cursor: pointer; }
label { font-size: .85rem; line-height: 1.5; }
fieldset { min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
legend { padding: 0 8px; font-weight: 650; color: var(--navy); }
.form-group { margin: 24px 0; }
.field { position: relative; }
.field > label { display: inline-block; margin-right: 8px; }
.required-mark { display: inline-block; font-size: .64rem; font-weight: 500; color: var(--muted); margin-bottom: 7px; }
.helptext, .help-text { display: block; font-size: .78rem; line-height: 1.6; margin: 4px 0 8px; }
.helptext ul { padding-left: 20px; margin: 6px 0; }
.field-error input, .field-error select, .field-error textarea, [aria-invalid=true] { border-color: var(--error); }
.errorlist { font-size: .84rem; margin: 8px 0 0; }
.error-summary { background: #fff4f5; border: 1px solid #e9bbc2; border-left: 4px solid var(--error); border-radius: 10px; padding: 18px 20px; }
.error-summary h2 { font-size: 1rem; color: var(--error); margin: 0 0 8px; }
.error-summary a { color: var(--error); }
.checkbox-field label { display: block; }
.password-toggle { min-height: 36px; font-size: .73rem; padding: 6px 10px; }

/* Common surfaces keep the same rhythm across the operational modules. */
.card, .el-panel, .ca-panel, .el-filters, .ca-filters, .home-module, .aff-start-card { box-shadow: var(--surface-shadow); }
.card, .el-panel, .ca-panel { border-color: var(--line); border-radius: var(--radius); padding: 26px; }
.card > h2:first-child, .card > h3:first-child, .ca-panel > h2:first-child { margin-top: 0; }
.card > p, .platform-form > p { max-width: 85ch; }
.stat-card { box-shadow: var(--surface-shadow); padding: 24px; border-top: 3px solid var(--accent); color: var(--navy); }
a.stat-card:hover { border-color: #87b7ae; background: #fcfefd; }
.stat-card strong { font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.stat-card span { font-size: .84rem; color: var(--muted); }
.aff-metrics article, .org-metrics > *, .slate-metrics article, .ca-kpi, .el-kpi { box-shadow: var(--surface-shadow); min-width: 0; }
.aff-metrics strong, .org-metrics strong, .slate-metrics strong { font-size: clamp(1.8rem, 2.6vw, 2.45rem); font-variant-numeric: tabular-nums; line-height: 1.25; }
.aff-hero, .org-hero, .slate-hero, .ca-profile-hero, .el-candidate-hero { background: linear-gradient(115deg, #143653, #17575d); border-radius: 16px; }
.aff-hero h1, .org-hero h1, .slate-hero h1, .ca-profile-hero h1, .el-candidate-hero h2 { color: #fff; }
.aff-hero .button:hover, .slate-hero .button:hover { background: #e7f5ef; border-color: #e7f5ef; }
.home-welcome { background: linear-gradient(110deg, #eaf5f2, #fff 80%); border-color: #cfdfdf; border-radius: 16px; }
.home-module { border-radius: 14px; }
.home-module:hover { transform: none; box-shadow: 0 6px 24px #1436530c; }
.aff-filters, .org-filters { background: #fff; border: 1px solid var(--line); box-shadow: var(--surface-shadow); }
.aff-filters label, .org-filters label { margin-bottom: 0; }
.aff-filters button, .org-filters button { margin: 0; }
.notice { border: 1px solid #cce0df; border-left: 4px solid var(--accent); border-radius: 10px; background: #f0f8f6; font-size: .9rem; }
.notice-error { background: #fff3f5; border-color: #ecc1c8; border-left-color: var(--error); }
.notice-warning { background: #fff8e9; border-color: #e8d5ac; border-left-color: #a66c10; }
.notice-success { background: #edf8f1; border-color: #badbc7; border-left-color: #176c46; }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; border-radius: 6px; }

/* Scrollable tables remain tables on mobile, keeping column relationships. */
.table-scroll { border-radius: 11px; background: #fff; scrollbar-width: thin; }
.table-scroll:focus-visible { outline: 3px solid #08796d66; outline-offset: 3px; }
th { font-size: .74rem; font-weight: 700; color: #506779; background: #f3f7fa; line-height: 1.5; }
td { font-size: .85rem; line-height: 1.65; }
th, td { padding: 15px 17px; }
tbody tr:hover { background: #f7fbfc; }
td a:not(.button):not(.button-secondary) { font-weight: 600; }
td[colspan] { padding: 28px 20px; color: var(--muted); text-align: center; }
.pagination, .ca-pagination, .el-pagination { flex-wrap: wrap; gap: 12px; font-size: .82rem; }
.pagination a, .ca-pagination a, .el-pagination a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; text-decoration: none; }
.pagination a:hover, .ca-pagination a:hover, .el-pagination a:hover { background: #edf6f3; border-color: #a6c9bf; }

/* Module tabs share a visible current state and work without JavaScript. */
.aff-tabs, .slate-tabs, .el-navigation, .ca-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: #eaf0f5; margin-bottom: 26px; }
.aff-tabs a, .slate-tabs a, .el-navigation a, .ca-tabs a { display: inline-flex; align-items: center; min-height: 44px; padding: 10px 14px; border: 1px solid transparent; border-radius: 8px; font-size: .8rem; font-weight: 600; line-height: 1.4; color: #425d72; background: transparent; text-decoration: none; }
.aff-tabs a:hover, .slate-tabs a:hover, .el-navigation a:hover, .ca-tabs a:hover { background: #ffffff99; }
.aff-tabs a[aria-current=page], .slate-tabs a[aria-current=page], .el-navigation a[aria-current=page], .ca-tabs a[aria-current=page] { background: #fff; color: #08685e; border-color: #d2e1df; box-shadow: 0 2px 4px #14365308; }
summary { cursor: pointer; }
.content details:not(.topbar-actions details) > summary { padding-block: 10px; font-size: .88rem; font-weight: 600; }
.content details[open] > summary { margin-bottom: 12px; }
.organization-preview { border-bottom: 2px solid #b47a1b; }

/* General login/recovery and party portals retain their own brand identity. */
.auth-page { background: radial-gradient(ellipse at 15% 0, #e5f0ef, transparent 60%), #f3f6fa; }
.auth-brand { padding: 30px 36px; }
.auth-content > .card, .auth-content > .login { border-top: 3px solid var(--accent); padding: 34px; box-shadow: 0 12px 42px #1436530a; }
.auth-content h1 { font-size: 1.9rem; margin-bottom: 16px; }
.login > p:not(.eyebrow) { color: var(--muted); font-size: .9rem; }
.login-submit { min-height: 48px; }
.login form + p { margin-top: 20px; font-size: .85rem; }
.party-login { box-shadow: 0 16px 48px #1436530e; }
.party-login-identity h1 { color: var(--party-ink, #fff); }
.auth-frame footer { background: transparent; border: 0; }

@media (max-width: 1023px) {
  .slate-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-topbar { padding: 14px 24px; }
  .content { padding: 28px 24px; }
  .menu-toggle { padding: 9px 12px; background: #fff; color: var(--navy); border-color: var(--line); }
  .menu-toggle:hover { background: #edf4f8; }
}
@media (max-width: 600px) {
  .content, .auth-content { padding: 22px 16px; }
  .content :is(input, select, textarea), .auth-content :is(input, select, textarea) { font-size: 16px; }
  .app-topbar { padding: 12px 16px; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
  .topbar-context { flex: 1 1 100%; gap: 12px; }
  .topbar-actions { margin-left: auto; max-width: 100%; }
  .topbar-actions summary { font-size: .76rem; overflow-wrap: anywhere; }
  .topbar-title strong { font-size: .85rem; }
  .topbar-popover { width: 280px; }
  .card, .el-panel, .ca-panel { padding: 20px 18px; }
  .auth-content > .card, .auth-content > .login { padding: 28px 22px; margin-top: 6px; }
  .auth-brand { padding: 24px; }
  footer { padding: 20px; }
  .action-row { align-items: stretch; }
  .action-row > .button, .action-row > .button-secondary { flex: 1 1 auto; }
  .platform-inline { align-items: stretch; }
  .platform-inline > label { flex-basis: 100%; }
  .aff-filters label, .org-filters label { min-width: min(180px, 100%); }
  .aff-filters, .org-filters { padding: 18px; }
  .aff-tabs a, .slate-tabs a, .el-navigation a, .ca-tabs a { flex: 1 1 auto; justify-content: center; padding: 10px; font-size: .76rem; text-align: center; }
  .slate-columns { grid-template-columns: minmax(0, 1fr); }
  .aff-data { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .aff-data dd { margin-bottom: 14px; }
  .org-metrics strong { font-size: 1.85rem; }
  .pagination { justify-content: center; }
  th, td { padding: 13px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
  body { background: #fff; font-size: 11pt; }
  .card, .el-panel, .ca-panel { box-shadow: none; }
  .aff-tabs, .slate-tabs, .el-navigation, .ca-tabs, .topbar-caption { display: none !important; }
  .content { margin: 0; padding: 0; }
  .table-scroll { overflow: visible; border-radius: 0; }
  th, td { font-size: 9pt; }
}
