/* ─────────────────────────────────────────────────────────────
   nvllst PG-meta UI

   Bare-essentials ops UI — no theming switcher, no brand accents,
   no audio bar. Stays on the Stone-Parchment side of the nvllst
   palette so it visually announces "this is admin tooling, not
   reader chrome." IBM Plex stack matches the rest of nvllst.
   ───────────────────────────────────────────────────────────── */

:root {
    /* Stone-Parchment surface scale (subset of tokens.css). */
    --bg:           #f7f5f1;
    --surface:      #ffffff;
    --surface-2:    #ece8df;
    --ink:          #1d1c1a;
    --ink-2:        #545148;
    --ink-3:        #8b8678;
    --rule:         #d8d2c4;
    --rule-2:       #e8e3d7;
    /* States */
    --ok:           #2d6a4f;
    --error:        #9d2933;
    --warn:         #b45309;
    --info:         #1f4e7a;
    /* Type */
    --font-sans:    "IBM Plex Sans", system-ui, -apple-system,
                    "Segoe UI", Helvetica, Arial, sans-serif;
    /* Condensed sans is the default for dense display text (tables,
       chips, progress readouts) — it reads cleanly while reclaiming
       horizontal space vs. mono. Mono is now reserved for content
       where character alignment genuinely matters: inline <code>,
       structured ID inputs, and preformatted log output. */
    --font-condensed: "IBM Plex Sans Condensed", "IBM Plex Sans",
                    system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono:    "IBM Plex Mono", ui-monospace,
                    "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

main {
    max-width: 880px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

header.app {
    border-bottom: 1px solid var(--rule);
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}
header.app h1 {
    font-family: var(--font-sans);
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--ink);
}
header.app .sub {
    color: var(--ink-3);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

section.card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

section.card h2 {
    margin: 0 0 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-3);
}

/* Status chip — the prominent "what's happening right now" row. */
.status-chip {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-family: var(--font-condensed);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: var(--surface-2);
    color: var(--ink-2);
}
.status-chip.running        { background: #d9eddf; color: var(--ok); }
.status-chip.stop_requested { background: #fcefd6; color: var(--warn); }
.status-chip.done           { background: #e6e2d6; color: var(--ink-2); }
.status-chip.paused         { background: #f3eada; color: var(--warn); }
.status-chip.error          { background: #f8d7d7; color: var(--error); }
.status-chip.idle           { background: var(--surface-2); color: var(--ink-3); }

/* Button bar. Buttons are visually equal weight — let the
   enable/disable state communicate which one to press. */
.button-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}
.button-bar button {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border: 1px solid var(--rule);
    border-radius: 4px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    transition: background 80ms, border-color 80ms;
    min-width: 5.5rem;
}
.button-bar button:hover:not(:disabled) {
    background: var(--surface-2);
    border-color: var(--ink-3);
}
.button-bar button:disabled {
    color: var(--ink-3);
    background: var(--surface);
    border-color: var(--rule-2);
    cursor: not-allowed;
}
.button-bar button.danger:not(:disabled) {
    color: var(--error);
    border-color: #e9c0c0;
}
.button-bar button.danger:not(:disabled):hover {
    background: #f8eeee;
}

/* Per-ID filter explanation surfaced under Progress when a run
   was given an explicit pg_ids spec. */
.run-notes {
    margin: 1rem 0 0;
    padding: 0.75rem 1rem;
    background: var(--surface-2);
    border-radius: 4px;
    border: 1px solid var(--rule-2);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--ink-2);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 240px;
    overflow-y: auto;
}

/* Importer's ID spec input. */
.ids-field {
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--rule-2);
}
.ids-field label {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin-bottom: 0.35rem;
}
.ids-field label .muted {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}
.ids-field input {
    width: 100%;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--rule);
    border-radius: 4px;
    background: var(--surface);
    color: var(--ink);
}
.ids-field input:focus {
    outline: none;
    border-color: var(--ink-3);
}
#ids-help {
    margin-top: 0.4rem;
    font-size: 0.75rem;
}
#ids-help code {
    font-family: var(--font-mono);
    background: var(--surface-2);
    padding: 0 0.2rem;
    border-radius: 2px;
}

/* Live progress display. */
.progress-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 1.5rem;
    font-family: var(--font-condensed);
    font-variant-numeric: tabular-nums;
    font-size: 0.9rem;
    margin-top: 0.75rem;
}
.progress-grid .label { color: var(--ink-3); }
.progress-grid .value { color: var(--ink); }

.progress-bar {
    height: 6px;
    background: var(--surface-2);
    border-radius: 3px;
    overflow: hidden;
    margin: 0.5rem 0 1rem;
}
.progress-bar > .fill {
    height: 100%;
    background: var(--ok);
    transition: width 200ms;
}
.progress-bar > .fill.error    { background: var(--error); }
.progress-bar > .fill.paused   { background: var(--warn); }

/* Catalog status (parsed/error/pending counts). */
.catalog-row {
    display: grid;
    grid-template-columns: 80px 1fr 80px 100px;
    column-gap: 1rem;
    align-items: baseline;
    font-family: var(--font-condensed);
    font-variant-numeric: tabular-nums;
    font-size: 0.9rem;
    padding: 0.2rem 0;
    border-bottom: 1px solid var(--rule-2);
}
.catalog-row:last-child { border-bottom: none; }
.catalog-row .num       { text-align: right; }
.catalog-row .label     { color: var(--ink-3); }

/* Error list */
.errors {
    margin: 0;
    padding: 0;
    list-style: none;
    font-family: var(--font-condensed);
    font-size: 0.85rem;
}
.errors li {
    padding: 0.2rem 0;
    border-bottom: 1px solid var(--rule-2);
}
.errors .pgid    { color: var(--ink-3); margin-right: 0.5rem; }
.errors .err     { color: var(--error); }

/* History table */
.history {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-condensed);
    font-variant-numeric: tabular-nums;
    font-size: 0.875rem;
}
.history th, .history td {
    text-align: left;
    padding: 0.4rem 0.75rem 0.4rem 0;
    border-bottom: 1px solid var(--rule-2);
}
.history th {
    color: var(--ink-3);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.7rem;
}
.history td.num { text-align: right; }

.muted { color: var(--ink-3); }

footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--rule);
    font-size: 0.75rem;
    color: var(--ink-3);
    text-align: center;
}
footer code {
    font-family: var(--font-mono);
    background: var(--surface-2);
    padding: 0 0.25rem;
    border-radius: 2px;
}
footer a {
    color: var(--ink-2);
    text-decoration: none;
}
footer a:hover { color: var(--ink); }

/* Breadcrumb above page headings */
.crumbs {
    font-family: var(--font-condensed);
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}
.crumbs a {
    color: var(--ink-3);
    text-decoration: none;
}
.crumbs a:hover { color: var(--ink-2); }

/* Landing page tool list */
.tool-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.tool-list li {
    border-bottom: 1px solid var(--rule-2);
}
.tool-list li:last-child { border-bottom: none; }
.tool-list a {
    display: block;
    padding: 0.85rem 0;
    text-decoration: none;
    color: var(--ink);
}
.tool-list a:hover {
    background: var(--surface-2);
    margin: 0 -1.5rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}
.tool-name {
    display: block;
    font-weight: 500;
    font-size: 1rem;
    margin-bottom: 0.15rem;
}
.tool-desc {
    display: block;
    color: var(--ink-3);
    font-size: 0.875rem;
}
