:root {
    --bg: #f2f3f1;
    --surface: #ffffff;
    --surface-2: #f7f7f4;
    --surface-3: #ecefea;
    --text: #171a1d;
    --muted: #5f676c;
    --border: #d6dbd2;
    --border-strong: #bfc7bd;
    --accent: #0d6155;
    --accent-dark: #073f38;
    --topbar: #151918;
    --topbar-muted: #bac3bf;
    --row-hover: #f8faf7;
    --danger: #b42318;
    --warning: #9a6700;
    --ok: #1a7f37;
    --shadow: 0 1px 2px rgba(22, 27, 29, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--accent-dark);
    text-decoration: none;
    text-underline-offset: 3px;
}

a:hover {
    text-decoration: underline;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 68px;
    padding: 0 max(28px, calc((100vw - 1280px) / 2 + 24px));
    background: var(--topbar);
    border-bottom: 1px solid #0b0e0d;
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    min-width: 0;
}

.brand {
    color: #fff;
    font-weight: 750;
    font-size: 19px;
    letter-spacing: 0;
}

.main-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.main-nav a {
    color: var(--topbar-muted);
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
}

.main-nav a[aria-current="page"],
.main-nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.09);
    text-decoration: none;
}

.language-switcher {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.07);
}

.language-switcher button {
    min-height: 30px;
    padding: 4px 8px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--topbar-muted);
    font-size: 13px;
    font-weight: 700;
}

.language-switcher button.active {
    background: #fff;
    color: var(--topbar);
}

.page {
    width: min(1280px, calc(100% - 48px));
    margin: 0 auto;
    padding: 30px 0 56px;
}

.intro,
.page-head,
.panel,
.form-panel,
.success {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow);
}

.intro {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    gap: 32px;
    padding: 34px;
    border-top: 3px solid var(--accent-dark);
}

.page-head {
    padding: 26px 30px;
    margin-bottom: 20px;
    border-top: 3px solid var(--accent-dark);
}

.page-head p:last-child,
.intro p:last-child {
    margin-bottom: 0;
}

.person-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 10px;
    font-size: clamp(30px, 4vw, 52px);
    line-height: 1.05;
    letter-spacing: 0;
    font-weight: 780;
}

h2 {
    margin-bottom: 8px;
    font-size: 18px;
    line-height: 1.25;
    letter-spacing: 0;
    font-weight: 740;
}

h3 {
    font-size: 16px;
    margin: 18px 0 6px;
    font-weight: 720;
}

p {
    color: var(--muted);
}

.intro > div > p:not(.notice) {
    max-width: 760px;
}

.notice {
    color: #35423f;
    background: #eef5f2;
    border: 1px solid #cddfd8;
    border-radius: 6px;
    padding: 10px 12px;
}

.actions,
.search-row,
.filters {
    display: flex;
    gap: 10px;
    align-items: end;
    flex-wrap: wrap;
}

.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 13px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 650;
    cursor: pointer;
}

.button.primary,
button[type="submit"] {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.button:hover,
button:hover {
    text-decoration: none;
    border-color: var(--border-strong);
}

.button.primary:hover,
button[type="submit"]:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.search-box,
.featured-group {
    align-self: end;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 18px;
}

.featured-group {
    display: grid;
    gap: 12px;
    border-left: 3px solid var(--accent);
}

.featured-group h2 {
    margin-bottom: 0;
}

.featured-group p {
    margin-bottom: 0;
}

.featured-group .button {
    justify-self: start;
}

label {
    display: grid;
    gap: 6px;
    color: #323b3f;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    min-height: 38px;
    border: 1px solid #c9d0c7;
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 8px 10px;
    font: inherit;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(13, 97, 85, 0.16);
    border-color: var(--accent);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin: 20px 0;
}

.metric-grid.compact {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.metric {
    min-height: 108px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow);
}

.metric-label,
.metric-note {
    color: var(--muted);
    font-size: 13px;
}

.metric-value {
    margin: 8px 0 4px;
    font-size: 23px;
    font-weight: 760;
    line-height: 1.2;
}

.split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.panel {
    padding: 22px;
    overflow: auto;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: -2px 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.section-heading h2 {
    margin-bottom: 0;
}

.section-heading a {
    font-size: 14px;
    font-weight: 650;
}

.chart-measure {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
    white-space: nowrap;
}

.chart-measure select {
    min-height: 32px;
    padding: 5px 28px 5px 9px;
    font-size: 13px;
}

.chart-help {
    margin: -6px 0 12px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.income-benchmark {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.income-benchmark > div {
    padding: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.income-benchmark span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.income-benchmark strong {
    display: block;
    margin-top: 8px;
    font-size: 22px;
    line-height: 1.2;
}

.benchmark-ratio {
    margin: 0 0 12px;
    color: var(--text);
    font-weight: 680;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
    font-size: 14px;
}

.party-members-table {
    table-layout: fixed;
    min-width: 0;
}

.party-members-table .col-name {
    width: 28%;
}

.party-members-table .col-role {
    width: 24%;
}

.party-members-table .col-income {
    width: 22%;
}

.party-members-table .col-public {
    width: 18%;
}

.party-members-table .col-signals {
    width: 12%;
}

.party-members-table th:nth-child(2),
.party-members-table td:nth-child(2) {
    overflow-wrap: anywhere;
    white-space: normal;
    word-break: normal;
}

.party-members-table .role-value {
    display: -webkit-box;
    line-height: 1.35;
    max-height: calc(1.35em * 2);
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.party-members-table th:nth-child(n+3),
.party-members-table td:nth-child(n+3) {
    overflow-wrap: normal;
    white-space: nowrap;
}

.markdown-table {
    margin: 12px 0 18px;
}

th,
td {
    padding: 11px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

th {
    color: #3d474b;
    font-size: 13px;
    font-weight: 740;
    background: #f4f5f2;
    border-bottom-color: var(--border-strong);
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover {
    background: var(--row-hover);
}

td a {
    font-weight: 650;
}

.filters,
.form-panel {
    padding: 18px;
    margin-bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow);
}

.filters label {
    min-width: 220px;
    flex: 1;
}

.form-panel {
    display: grid;
    gap: 14px;
    max-width: 760px;
}

.form-panel.wide {
    max-width: 920px;
}

.coming-soon {
    max-width: 760px;
    padding: 18px;
}

.coming-soon p:last-child {
    margin-bottom: 0;
}

.auth-panel {
    max-width: 420px;
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.form-panel label span,
.field-error {
    color: var(--danger);
    font-weight: 500;
}

.check {
    display: flex;
    grid-template-columns: none;
    flex-direction: row;
    align-items: center;
    font-weight: 500;
}

.check input {
    width: auto;
    min-height: auto;
}

.success {
    margin-bottom: 18px;
    padding: 14px 16px;
    color: var(--ok);
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #f3f5f1;
    color: #323b3f;
    font-size: 13px;
    font-weight: 650;
    white-space: nowrap;
}

.signal-list {
    display: grid;
    gap: 10px;
}

.signal {
    padding: 12px;
    border: 1px solid var(--border);
    border-left-width: 4px;
    border-radius: 6px;
    background: #fff;
}

.signal p {
    margin: 6px 0 0;
    font-size: 13px;
}

.signal.low {
    border-left-color: var(--ok);
}

.signal.medium {
    border-left-color: var(--warning);
}

.signal.high {
    border-left-color: var(--danger);
}

.analysis ul {
    margin-top: 0;
}

.network {
    height: 360px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fbfbf8;
}

.list-grid {
    display: grid;
    gap: 12px;
}

.row-card,
.admin-request {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow);
}

.row-card p,
.admin-request p {
    margin-bottom: 0;
}

.admin-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 18px;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow);
}

.admin-nav a {
    color: var(--muted);
    padding: 8px 10px;
    border-radius: 6px;
    font-weight: 600;
}

.admin-nav a:hover {
    color: var(--text);
    background: var(--surface-2);
    text-decoration: none;
}

.admin-request form {
    display: grid;
    gap: 8px;
    min-width: 280px;
}

.readable {
    max-width: 860px;
}

.chart {
    width: 100%;
    max-height: 320px;
}

.chart-note {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.dashboard-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.dashboard-head h1 {
    font-size: 34px;
}

.page-head:not(.dashboard-head) h1 {
    font-size: 36px;
    line-height: 1.08;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(96px, 1fr));
    gap: 1px;
    overflow: hidden;
    min-width: 480px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--border);
}

.dashboard-stats div {
    padding: 12px;
    background: var(--surface);
}

.dashboard-stats strong,
.dashboard-stats span {
    display: block;
}

.dashboard-stats strong {
    font-size: 18px;
    font-weight: 760;
    line-height: 1.2;
}

.dashboard-stats span {
    color: var(--muted);
    font-size: 13px;
}

.party-dashboard {
    display: grid;
    grid-template-columns: 276px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.dashboard-sidebar,
.dashboard-filter-block {
    display: grid;
    gap: 12px;
}

.dashboard-sidebar {
    position: sticky;
    top: 18px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow);
}

.dashboard-filter-block {
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.dashboard-filter-block:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.dashboard-filter-block h2 {
    margin-bottom: 0;
    font-size: 15px;
}

.dashboard-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.dashboard-actions button {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 13px;
}

.check-list,
.person-picker {
    display: grid;
    gap: 8px;
}

.person-picker {
    max-height: 360px;
    overflow: auto;
    padding-right: 4px;
}

.dashboard-check {
    align-items: flex-start;
    gap: 8px;
    color: var(--text);
    font-size: 13px;
    line-height: 1.3;
}

.dashboard-check span {
    min-width: 0;
}

.dashboard-check b {
    margin-right: 4px;
}

.dashboard-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    margin-top: 3px;
    margin-right: 6px;
    border: 1px solid rgba(31, 36, 41, 0.18);
    border-radius: 2px;
    vertical-align: -1px;
}

.dashboard-check em {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-style: normal;
    font-size: 12px;
}

.dashboard-main {
    display: grid;
    gap: 20px;
    min-width: 0;
}

.dashboard-chart-wrap {
    height: 430px;
}

.dashboard-chart-panel .section-heading span {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.dashboard-table-panel td span {
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 920px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 14px 20px;
    }

    .topbar-actions {
        align-items: flex-start;
        flex-direction: column;
        width: 100%;
    }

    .page {
        width: min(100% - 24px, 1240px);
        padding-top: 18px;
    }

    .intro,
    .split {
        grid-template-columns: 1fr;
    }

    .metric-grid,
    .metric-grid.compact {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .person-head,
    .dashboard-head,
    .row-card,
    .admin-request {
        flex-direction: column;
    }

    .dashboard-stats {
        width: 100%;
        min-width: 0;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .party-dashboard {
        grid-template-columns: 1fr;
    }

    .dashboard-sidebar {
        position: static;
    }

    h1 {
        font-size: 32px;
    }
}

@media (max-width: 560px) {
    .metric-grid,
    .metric-grid.compact {
        grid-template-columns: 1fr;
    }

    .intro,
    .page-head,
    .panel,
    .form-panel {
        padding: 16px;
    }

    .dashboard-chart-wrap {
        height: 320px;
    }

    .actions,
    .search-row {
        align-items: stretch;
        flex-direction: column;
    }

    .featured-group .button {
        justify-self: stretch;
    }
}
