:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --panel: #ffffff;
    --line: #d9dee7;
    --line-strong: #b9c2cf;
    --text: #20242c;
    --muted: #657080;
    --muted-strong: #4f5b6a;
    --accent: #0083c3;
    --accent-strong: #00659c;
    --danger: #a83232;
    --danger-bg: #fff1f1;
    --warning: #7a4c00;
    --warning-bg: #fff7df;
    --attention-high-bg: #fff5f5;
    --attention-medium-bg: #fff9e8;
    --attention-low-bg: #fffdf1;
    --ok: #1f7a3f;
    --skip: #7a5a12;
}

* {
    box-sizing: border-box;
}

::selection {
    background: var(--accent);
    color: #fff;
}

.terminal-caret::after {
    animation: caret-blink 1.2s steps(1) infinite;
    color: var(--accent);
    content: "▍";
    font-weight: 400;
    margin-left: 2px;
}

@keyframes caret-blink {
    50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .terminal-caret::after { animation: none; }
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
}

.topbar {
    align-items: center;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    min-height: 76px;
    padding: 16px 28px;
}

.topbar form {
    align-items: center;
    display: flex;
    gap: 10px;
}

.brand {
    align-items: center;
    display: flex;
    gap: 12px;
}

.brand-logo {
    border-radius: 6px;
    display: block;
    height: 36px;
    width: 36px;
}

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

.eyebrow {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    margin: 0 0 2px;
    text-transform: uppercase;
}

h1 {
    font-size: 24px;
    line-height: 1.2;
    margin: 0;
}

main {
    margin: 0 auto;
    max-width: 1280px;
    padding: 24px 28px 40px;
}

.button {
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    min-height: 40px;
    padding: 8px 14px;
}

.button:disabled {
    cursor: not-allowed;
    opacity: .48;
}

.primary {
    background: var(--accent-strong);
    color: #fff;
}

.primary:hover:not(:disabled) {
    background: #00547f;
}

.secondary {
    background: #fff;
    border-color: var(--line-strong);
    color: var(--text);
}

.notice {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
    padding: 12px 14px;
}

.notice.error {
    background: var(--danger-bg);
    border-color: #efb5b5;
    color: var(--danger);
}

.notice.warning {
    background: var(--warning-bg);
    border-color: #e6c36f;
    color: var(--warning);
}

.snapshot-status {
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    margin-bottom: 18px;
    padding: 12px 14px;
}

.snapshot-fresh {
    border-left-color: var(--ok);
}

.snapshot-stale {
    border-left-color: var(--warning);
}

.snapshot-seriously-stale {
    background: var(--danger-bg);
    border-left-color: var(--danger);
    color: var(--danger);
}

.import-form {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    display: grid;
    gap: 10px;
    padding: 18px;
}

.import-form label {
    font-weight: 800;
}

.import-form textarea {
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    min-height: 320px;
    padding: 12px;
    resize: vertical;
    width: 100%;
}

.field-validation-error {
    color: var(--danger);
}

.metrics {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 18px;
}

.metrics div {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 14px 16px;
}

.metrics span {
    display: block;
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
}

.metrics label {
    color: var(--muted);
    display: block;
    margin-top: 6px;
}

.results {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
}

.result {
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: 6px;
    display: grid;
    gap: 10px;
    grid-template-columns: 92px minmax(120px, 1fr) minmax(160px, 2fr);
    padding: 10px 12px;
}

.result.created {
    border-left-color: var(--ok);
}

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

.result.skipped {
    border-left-color: var(--skip);
}

.result.failed {
    border-left-color: var(--danger);
}

.result span {
    color: var(--muted);
    font-weight: 800;
}

.result em {
    color: var(--muted);
    font-style: normal;
}

.attention-list {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
    padding: 12px 14px;
}

.attention-list h2 {
    font-size: 15px;
    line-height: 1.2;
    margin: 0 0 2px;
}

.attention-list div {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: 78px minmax(180px, 1fr) minmax(220px, 2fr);
}

.attention-list span:last-child {
    color: var(--muted);
}

.badge-high,
.badge-medium,
.badge-low {
    border-radius: 999px;
    display: inline-block;
    font-size: 12px;
    font-weight: 800;
    padding: 3px 8px;
    text-align: center;
}

.badge-high {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-medium {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-low {
    background: #fffce8;
    color: var(--skip);
}

.table-shell {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow-x: auto;
}

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

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

th {
    background: #eef2f5;
    color: #3c4654;
    font-size: 13px;
    font-weight: 800;
}

:where(#claims-table) td span {
    color: var(--muted);
    display: block;
    margin-top: 3px;
}

:where(#claims-table) .claim-link {
    color: var(--accent);
    text-decoration: none;
}

:where(#claims-table) .claim-link:hover {
    text-decoration: underline;
}

.attention-high td {
    background: var(--attention-high-bg);
}

.attention-medium td {
    background: var(--attention-medium-bg);
}

.attention-low td {
    background: var(--attention-low-bg);
}

.attention-note {
    color: var(--warning);
    font-size: 13px;
    font-weight: 700;
}

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

.select-col {
    text-align: center;
    width: 86px;
}

input[type="checkbox"] {
    height: 18px;
    width: 18px;
}

input[type="date"],
input[type="search"] {
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    min-height: 40px;
    padding: 7px 10px;
}

.empty {
    color: var(--muted);
    height: 92px;
    text-align: center;
}

.actions {
    display: flex;
    justify-content: flex-end;
    padding: 16px 0 0;
}

.table-toolbar {
    margin-bottom: 12px;
}

.table-toolbar .input-wrap {
    max-width: 320px;
}

.table-toolbar input[type="search"] {
    width: 100%;
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable::after {
    content: "";
    display: inline-block;
    margin-left: 6px;
    opacity: .35;
}

th.sortable[aria-sort="ascending"]::after {
    content: "▲";
    opacity: 1;
}

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

.loading-shell {
    align-items: center;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 64px 0;
    text-align: center;
}

.spinner {
    animation: spin .8s linear infinite;
    border: 3px solid var(--line);
    border-radius: 50%;
    border-top-color: var(--accent);
    height: 36px;
    width: 36px;
}

.loading-shell .loading-quip {
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    margin: 0;
}

.input-wrap {
    position: relative;
}

.kbd-hint {
    background: #eef2f5;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    line-height: 1;
    padding: 3px 6px;
    pointer-events: none;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.input-wrap:focus-within .kbd-hint {
    opacity: 0;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.login-page {
    align-items: center;
    background: var(--bg);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .06);
    max-width: 380px;
    padding: 40px 36px;
    text-align: center;
    width: 100%;
}

.login-logo {
    border-radius: 12px;
    height: 64px;
    margin: 0 auto 16px;
    width: 64px;
}

.login-card .eyebrow {
    text-align: center;
}

.login-card h1 {
    margin-bottom: 12px;
}

.login-tagline {
    color: var(--accent-strong);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    margin: 0 0 10px;
}

.login-copy {
    color: var(--muted);
    margin: 0 0 24px;
}

.login-button {
    display: inline-flex;
    justify-content: center;
    text-decoration: none;
    width: 100%;
}

@media (max-width: 720px) {
    .topbar {
        align-items: flex-start;
        gap: 14px;
        padding: 16px;
    }

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

    .metrics {
        grid-template-columns: 1fr;
    }

    .result {
        grid-template-columns: 1fr;
    }

    .attention-list div {
        align-items: flex-start;
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 32px 24px;
    }
}

.preview-item {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    margin: 16px 0;
    overflow: hidden;
}

.preview-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.preview-head strong {
    font-size: 15px;
}

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

.pdf-frame {
    width: 100%;
    height: 820px;
    border: 0;
    display: block;
    background: #525659;
}
