:root {
    color-scheme: light dark;
    --bg: #f6f8fa;
    --surface: #ffffff;
    --border: #d0d7de;
    --text: #1f2328;
    --muted: #59636e;
    --accent: #0969da;
    --accent-text: #ffffff;
    --hover: #f3f4f6;
    --input-bg: #ffffff;
    --error-bg: #ffebe9;
    --error-border: #ff8182;
    --error-text: #82071e;
    --warn-bg: #fff8c5;
    --warn-border: #d4a72c;
    --warn-text: #633c01;
    --draft: #6e7781;
    --ok: #1a7f37;
    --bad: #cf222e;
    --radius: 8px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1117;
        --surface: #161b22;
        --border: #30363d;
        --text: #e6edf3;
        --muted: #9198a1;
        --accent: #4493f8;
        --accent-text: #0d1117;
        --hover: #1c2129;
        --input-bg: #0d1117;
        --error-bg: #3c1618;
        --error-border: #8e1519;
        --error-text: #ffdcd7;
        --warn-bg: #3b2e00;
        --warn-border: #7d4e00;
        --warn-text: #f8e3a1;
        --draft: #9198a1;
        --ok: #3fb950;
        --bad: #f85149;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

body.centered {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 16px;
}

h1 {
    font-size: 20px;
    margin: 0;
}

a {
    color: var(--accent);
}

.muted {
    color: var(--muted);
    margin: 0;
}

.small {
    font-size: 12px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: min(420px, 100%);
    text-align: center;
}

.card h1 {
    margin-bottom: 8px;
}

.card p {
    margin: 12px 0;
}

.button {
    display: inline-block;
    background: var(--accent);
    color: var(--accent-text);
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 6px 14px;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.button.secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
    font-weight: 500;
}

.button:hover {
    filter: brightness(1.05);
}

.button.refresh {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
}

.refresh-age {
    font-size: 0.75em;
    font-weight: 400;
    opacity: 0.75;
}

.button.secondary.refresh.stale {
    background: var(--ok);
    border-color: var(--ok);
    color: #fff;
}

.button:disabled {
    opacity: 0.6;
    cursor: default;
}

.card .button {
    padding: 10px 20px;
    margin-top: 8px;
}

.banner {
    border: 1px solid;
    border-radius: 6px;
    padding: 10px 14px;
    margin: 12px 0;
    text-align: left;
}

.banner.error {
    background: var(--error-bg);
    border-color: var(--error-border);
    color: var(--error-text);
}

.banner.warn {
    background: var(--warn-bg);
    border-color: var(--warn-border);
    color: var(--warn-text);
}

.banner ul {
    margin: 6px 0 0;
    padding-left: 18px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

main {
    padding: 16px 24px 32px;
}

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border);
}

.tab {
    font: inherit;
    font-weight: 500;
    color: var(--muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 10px 14px;
    cursor: pointer;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--text);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-radius: 4px;
}

.tab-count {
    display: inline-block;
    min-width: 20px;
    padding: 0 6px;
    margin-left: 4px;
    border-radius: 999px;
    background: var(--hover);
    color: var(--muted);
    font-size: 12px;
    line-height: 18px;
    text-align: center;
}

.layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    align-items: start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
}

.filters {
    position: sticky;
    top: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    border-right: 1px solid var(--border);
    background: var(--surface);
    border-radius: 0 0 0 var(--radius);
}

.filters-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.filters-section > .button {
    align-self: flex-start;
}

.filters-footer {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.filters label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filters input, .filters select {
    font: inherit;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
}

.filters select, .repo-filter summary {
    width: 100%;
    box-sizing: border-box;
}

.filters .checkbox-filter input {
    width: auto;
}

.content {
    min-width: 0;
    padding: 16px;
}

.content .table-wrap {
    border: none;
    border-radius: 0;
    background: none;
}

@media (max-width: 860px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
    }
    .filters {
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.6);
}

.modal-backdrop[hidden] {
    display: none;
}

.modal {
    display: flex;
    flex-direction: column;
    width: min(560px, 100%);
    max-height: calc(100vh - 32px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.modal-header {
    padding: 16px 20px 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px 20px;
    overflow-y: auto;
}

.modal-body label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-body input, .modal-body select, .modal-body textarea {
    font: inherit;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
}

.modal-body textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.modal-body .banner[hidden] {
    display: none;
}

.modal-body .banner {
    margin: 0;
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

.modal-footer-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.repo-filter {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
}

.repo-filter summary {
    list-style: none;
    cursor: pointer;
    font: inherit;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    min-width: 200px;
    user-select: none;
}

.repo-filter summary::-webkit-details-marker {
    display: none;
}

.repo-filter summary::after {
    content: " ▾";
    color: var(--muted);
}

.repo-options {
    position: absolute;
    top: 100%;
    margin-top: 4px;
    z-index: 10;
    min-width: 100%;
    max-height: 320px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.repo-options .repo-option {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 6px 6px;
    white-space: nowrap;
    cursor: pointer;
}

.repo-options .repo-option input {
    margin: 0;
    flex: none;
}

.repo-option:hover {
    background: var(--hover);
}

.count {
    margin-left: auto;
    align-self: center;
}

.filters-footer .count {
    margin-left: 0;
    align-self: flex-start;
}

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    white-space: nowrap;
}

th[data-sort] {
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

th[data-sort]:hover {
    color: var(--text);
}

th[aria-sort]::after {
    content: " ▲";
}

th[aria-sort="descending"]::after {
    content: " ▼";
}

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

tbody tr:last-child td {
  border-bottom: none;
}
tbody tr.hidden-pr { opacity: 0.55; }
.small-btn { padding: 2px 10px; font-size: 12px; }
.checkbox-filter { flex-direction: row !important; align-items: center; gap: 6px !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

td.title {
    white-space: normal;
    min-width: 260px;
}

td.title a {
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}

td.title a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.review-badge {
    display: inline-block;
    font-weight: 700;
    margin-right: 6px;
    width: 1.2em;
    text-align: center;
}
.review-badge.approved { color: var(--ok); }
.review-badge.changes { color: var(--bad); }

.draft-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: var(--draft);
    border: 1px solid var(--draft);
    border-radius: 999px;
    padding: 0 6px;
    margin-right: 6px;
}

.labels {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.label {
    font-size: 11px;
    border-radius: 999px;
    padding: 0 8px;
    border: 1px solid var(--border);
    white-space: nowrap;
}

.author {
    display: flex;
    align-items: center;
    gap: 6px;
}

.avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.reviewers {
    white-space: normal;
    max-width: 220px;
    color: var(--muted);
}

.empty {
    padding: 24px;
    text-align: center;
    margin: 0;
}

[hidden] {
    display: none !important;
}

.admin-form-wrap {
    margin-top: 16px;
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px 20px;
    max-width: 640px;
}

.admin-form h2 {
    font-size: 16px;
    margin: 0;
}

.admin-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-form input, .admin-form textarea {
    font: inherit;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
}

.admin-form textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.admin-form .banner {
    margin: 0;
}

.admin-form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.admin-form-actions[hidden] {
    display: none;
}

td.repos {
    white-space: normal;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
}
