:root {
    color-scheme: dark;
    --bg: #0d1117;
    --panel: #151b23;
    --panel-soft: #10161d;
    --ink: #e6edf3;
    --muted: #8b949e;
    --line: #30363d;
    --accent: #2fbc9f;
    --accent-dark: #23947d;
    --error: #ff7b72;
    --success: #7ee787;
    --focus: #58a6ff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
}

.topbar {
    align-items: center;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 24px;
    min-height: 64px;
    padding: 0 28px;
}

.brand {
    color: var(--ink);
    font-size: 22px;
    font-weight: 750;
}

.version {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
    margin-left: 6px;
    vertical-align: middle;
}

.nav {
    display: flex;
    gap: 8px;
}

.nav a,
.logout button {
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--muted);
    font: inherit;
    padding: 8px 12px;
}

.nav a.active,
.nav a:hover {
    background: #1d2b2b;
    color: var(--accent);
}

.logout {
    margin-left: auto;
}

.logout button {
    background: transparent;
    cursor: pointer;
}

.logout button:hover {
    border-color: var(--line);
    color: var(--ink);
}

.page {
    margin: 0 auto;
    max-width: 1160px;
    padding: 32px 24px 56px;
}

.headline {
    margin-bottom: 24px;
}

h1,
h2 {
    line-height: 1.15;
    margin: 0 0 8px;
}

h1 {
    font-size: 34px;
}

h2 {
    font-size: 20px;
}

.muted,
.empty {
    color: var(--muted);
}

.auth-panel,
.panel,
.content-block,
.metrics article {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.auth-panel {
    margin: 8vh auto;
    max-width: 430px;
    padding: 28px;
}

.form {
    display: grid;
    gap: 16px;
}

.form label {
    color: var(--muted);
    display: grid;
    font-size: 14px;
    gap: 6px;
}

input,
select,
textarea {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    font: inherit;
    min-height: 42px;
    padding: 9px 10px;
    width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--focus);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
    outline: none;
}

textarea {
    resize: vertical;
}

button,
.primary {
    background: var(--accent);
    border: 0;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    min-height: 42px;
    padding: 10px 16px;
}

button:hover,
.primary:hover {
    background: var(--accent-dark);
}

.danger {
    background: #a8323a;
}

.danger:hover {
    background: #84262d;
}

.danger-zone {
    border-top: 1px solid var(--line);
    margin-top: 24px;
    padding-top: 18px;
}

.alert {
    border-radius: 6px;
    margin: 0 0 18px;
    padding: 12px 14px;
}

.alert.error {
    background: rgba(248, 81, 73, 0.14);
    color: var(--error);
}

.alert.success {
    background: rgba(63, 185, 80, 0.14);
    color: var(--success);
}

.metrics {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 24px;
}

.metrics article {
    padding: 22px;
}

.metrics strong {
    display: block;
    font-size: 36px;
}

.metrics span {
    color: var(--muted);
}

.content-block,
.panel {
    padding: 22px;
}

.narrow {
    max-width: 520px;
}

.section-title {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.inline-filter {
    align-items: end;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(180px, 240px) auto auto;
    justify-content: start;
    margin: 0 0 18px;
}

.inline-filter label {
    color: var(--muted);
    display: grid;
    font-size: 14px;
    gap: 6px;
}

.button-link {
    align-items: center;
    background: #1f2937;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    display: inline-flex;
    font-weight: 700;
    min-height: 42px;
    padding: 10px 14px;
}

.split {
    align-items: start;
    display: grid;
    gap: 22px;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
}

.table-wrap {
    overflow-x: auto;
}

table {
    border-collapse: collapse;
    min-width: 680px;
    width: 100%;
}

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

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.file-link {
    background: #1f2937;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--accent);
    display: inline-block;
    margin: 0 6px 6px 0;
    max-width: 220px;
    overflow: hidden;
    padding: 5px 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

input[type="file"] {
    padding: 8px;
}

.lab-preview {
    display: grid;
    gap: 8px;
}

.lab-chip {
    align-items: center;
    background: #101820;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    display: flex;
    font-size: 14px;
    gap: 10px;
    padding: 8px 10px;
}

.lab-chip input {
    min-height: auto;
    width: auto;
}

.filters {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 22px;
}

.filters label {
    color: var(--muted);
    display: grid;
    font-size: 14px;
    gap: 6px;
}

.chart {
    color: var(--accent);
    margin: 12px 0 18px;
}

.chart svg {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: block;
    height: auto;
    width: 100%;
}

.chart circle {
    fill: var(--accent);
}

@media (max-width: 760px) {
    .topbar {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 12px;
        padding: 14px 18px;
    }

    .logout {
        margin-left: 0;
    }

    .page {
        padding: 24px 16px 40px;
    }

    .metrics,
    .split,
    .filters,
    .inline-filter {
        grid-template-columns: 1fr;
    }
}

.compact-table {
    min-width: 560px;
}

.study-summary {
    border-top: 1px solid var(--line);
    margin-top: 24px;
    padding-top: 18px;
}
