:root {
    color-scheme: light;
    --ink: #17202a;
    --muted: #5a6573;
    --line: #d7dde5;
    --panel: #ffffff;
    --paper: #f4f7fb;
    --blue: #1664d9;
    --blue-dark: #0d47a1;
    --green: #138a52;
    --amber: #a45f00;
    --red: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    background:
        linear-gradient(135deg, rgba(22, 100, 217, 0.08), rgba(19, 138, 82, 0.08)),
        var(--paper);
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0;
}

.workspace {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.workspace.narrow {
    width: min(900px, 100%);
    margin: 0 auto;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 0;
}

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

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

h1 {
    margin-bottom: 2px;
    font-size: 2rem;
}

h2 {
    margin-bottom: 10px;
    font-size: 1.25rem;
}

h3 {
    margin: 24px 0 10px;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0;
}

.brand p,
.fine-print,
.db-status {
    margin-bottom: 0;
    color: var(--muted);
}

.ledger-link,
.primary-link {
    color: var(--blue);
    font-weight: 700;
    text-decoration: none;
}

.ledger-link:hover,
.primary-link:hover {
    text-decoration: underline;
}

.grid {
    display: grid;
    grid-template-columns: minmax(320px, 0.9fr) minmax(340px, 1.1fr);
    gap: 20px;
    align-items: start;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 18px 40px rgba(23, 32, 42, 0.07);
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

textarea,
input,
select {
    width: 100%;
    margin-bottom: 16px;
    border: 1px solid #b7c2d0;
    border-radius: 6px;
    padding: 12px;
    font: inherit;
    background: #fff;
    color: var(--ink);
}

textarea {
    min-height: 260px;
    resize: vertical;
}

.field-row {
    display: grid;
    grid-template-columns: minmax(160px, 220px) 1fr;
    gap: 16px;
    align-items: end;
}

.checkline {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    margin-bottom: 16px;
    font-weight: 400;
}

.checkline input {
    width: 18px;
    height: 18px;
    margin: 0;
    flex: 0 0 auto;
}

.primary-button {
    width: 100%;
    min-height: 48px;
    border: 0;
    border-radius: 6px;
    background: var(--blue);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
}

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

.empty-state,
.loading-state,
.error-state {
    min-height: 420px;
    display: grid;
    place-content: center;
    text-align: center;
}

.meter {
    width: 128px;
    height: 128px;
    margin: 0 auto 18px;
    border-radius: 50%;
    border: 12px solid #dce5ef;
    display: grid;
    place-items: center;
}

.meter span {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--blue);
    display: block;
}

.spinner {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    border-radius: 50%;
    border: 5px solid #dce5ef;
    border-top-color: var(--blue);
    animation: spin 0.8s linear infinite;
}

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

.hidden {
    display: none !important;
}

.scoreline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.scoreline strong {
    font-size: 2.2rem;
}

.eyebrow {
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.risk-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 92px;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    color: #fff;
    font-weight: 800;
    background: var(--muted);
}

.risk-pill.lower {
    background: var(--green);
}

.risk-pill.caution {
    background: var(--amber);
}

.risk-pill.high {
    background: var(--red);
}

.bar {
    width: 100%;
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: #e3e9f1;
    margin-bottom: 22px;
}

.bar span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--amber), var(--red));
    transition: width 0.25s ease;
}

ul {
    padding-left: 20px;
}

li {
    margin-bottom: 10px;
    line-height: 1.45;
}

.plain-list {
    margin-bottom: 20px;
}

.setup-form {
    margin-top: 22px;
}

.error-text {
    color: var(--red);
    font-weight: 700;
}

.ledger-summary {
    justify-content: flex-start;
}

.ledger-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

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

.ledger-table th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

@media (max-width: 820px) {
    .grid,
    .field-row {
        grid-template-columns: 1fr;
    }

    .topbar,
    .scoreline {
        align-items: flex-start;
        flex-direction: column;
    }

    .shell {
        width: min(100% - 20px, 1180px);
        padding: 18px 0;
    }
}
