:root {
    --ink: #17202a;
    --muted: #5b6b7c;
    --line: #dde3ea;
    --bg: #f6f8fa;
    --accent: #1f6feb;
    --ok: #1a7f37;
    --warn: #9a6700;
    --bad: #b42318;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main { flex: 1 0 auto; }

/* ---- header ---- */

.site-header {
    background: #10203a;
    color: #fff;
    padding: .75rem 0;
}

.site-header a { color: #d7e3f4; text-decoration: none; }
.site-header a:hover { color: #fff; }
.site-header .brand { font-size: 1.15rem; font-weight: 600; color: #fff; }
.site-header .brand span { color: #7db1ff; font-weight: 400; }
.site-header .muted { color: #8ba3c0; font-size: .9rem; }
.site-header .divider { width: 1px; height: 20px; background: #2b4266; }

.site-footer {
    border-top: 1px solid var(--line);
    padding: 1rem 0;
    color: var(--muted);
    font-size: .85rem;
    background: #fff;
}

/* ---- cards and tables ---- */

.card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    margin-bottom: 1.25rem;
}

.card > h2, .card > h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--line);
    background: #fbfcfd;
    border-radius: 8px 8px 0 0;
}

.card-body { padding: 1rem; }

table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td { padding: .5rem .75rem; border-bottom: 1px solid var(--line); text-align: left; }
table.data th { font-weight: 600; color: var(--muted); background: #fbfcfd; }
table.data tr:last-child td { border-bottom: none; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- status pills ---- */

.pill {
    display: inline-block;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.pill-queued    { background: #eef2f6; color: var(--muted); border-color: var(--line); }
.pill-running   { background: #e7f0ff; color: var(--accent); border-color: #bcd4ff; }
.pill-succeeded { background: #e6f4ea; color: var(--ok); border-color: #b7dfc3; }
.pill-failed    { background: #fdeceb; color: var(--bad); border-color: #f5c2c0; }
.pill-cancelled { background: #f3f0ff; color: #6941c6; border-color: #d9d0f7; }
.pill-inactive  { background: #eef2f6; color: var(--muted); border-color: var(--line); }

/* ---- run log ---- */

.log { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .84rem; }
.log .row-entry { display: flex; gap: .75rem; padding: .3rem .5rem; border-bottom: 1px solid #eef1f5; }
.log .ts { color: var(--muted); white-space: nowrap; }
.log .lvl { width: 5.5rem; flex: 0 0 5.5rem; white-space: nowrap; font-weight: 600; }
.log .lvl-Error { color: var(--bad); }
.log .lvl-Warning { color: var(--warn); }
.log .lvl-Information { color: var(--muted); }
.log .lvl-Debug { color: #9aa7b4; }
.log .msg { flex: 1; white-space: pre-wrap; word-break: break-word; }

pre.detail {
    background: #f6f8fa;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: .6rem;
    font-size: .8rem;
    max-height: 18rem;
    overflow: auto;
    margin: .4rem 0 0;
}

/* ---- sql editor ---- */

textarea.sql {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: .88rem;
    min-height: 22rem;
    tab-size: 4;
}

.muted { color: var(--muted); }
.small-muted { color: var(--muted); font-size: .85rem; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem 1.25rem; }

/* ---- schema browser ---- */

.table-picker { position: sticky; top: 1rem; }

.picker-list {
    max-height: 26rem;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.picker-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .28rem .5rem;
    border-bottom: 1px solid #eef1f5;
    cursor: pointer;
    font-size: .85rem;
}

.picker-row:last-child { border-bottom: none; }
.picker-row:hover { background: #f4f8ff; }
.picker-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-meta { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }

.no-pk {
    display: inline-block;
    margin-left: .25rem;
    width: 1rem;
    text-align: center;
    border-radius: 3px;
    background: #fdeceb;
    color: var(--bad);
    font-weight: 700;
}

.table-tags { display: inline-flex; gap: .35rem; font-weight: 400; }

table.schema-columns td, table.schema-columns th { padding: .35rem .75rem; }

.trait {
    display: inline-block;
    margin-right: .25rem;
    padding: .02rem .35rem;
    border-radius: 3px;
    font-size: .72rem;
    font-weight: 600;
    border: 1px solid var(--line);
    background: #eef2f6;
    color: var(--muted);
}

.trait-pk { background: #e6f4ea; color: var(--ok); border-color: #b7dfc3; }
.trait-fk { background: #e7f0ff; color: var(--accent); border-color: #bcd4ff; }
.trait-identity { background: #f3f0ff; color: #6941c6; border-color: #d9d0f7; }

.fk-target { font-size: .78rem; text-decoration: none; }
.fk-target:hover { text-decoration: underline; }

.schema-extras {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    padding: .75rem 1rem;
    border-top: 1px solid var(--line);
    background: #fbfcfd;
    font-size: .85rem;
}

.extras-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    margin-bottom: .25rem;
}

/* ---- SQL runner, diff and sample inserts ---- */

textarea.sql-compact { min-height: 9rem; }

.diff { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .84rem; }

.diff-row {
    display: flex;
    gap: .6rem;
    align-items: baseline;
    padding: .25rem .5rem;
    border-bottom: 1px solid #eef1f5;
}

.diff-row:last-child { border-bottom: none; }
.diff-mark { width: 1rem; font-weight: 700; text-align: center; }
.diff-add { background: #f2fbf5; }
.diff-add .diff-mark { color: var(--ok); }
.diff-remove { background: #fdf4f3; }
.diff-remove .diff-mark { color: var(--bad); }
.diff-alter { background: #fffaf0; }
.diff-alter .diff-mark { color: var(--warn); }

.btn-xs {
    padding: .05rem .4rem;
    font-size: .74rem;
    line-height: 1.4;
}

pre.sample-sql {
    max-height: 60vh;
    font-size: .82rem;
    margin: 0;
}

details summary { cursor: pointer; }

/* ---- deployment trackers and timeline ---- */

.tracker-actions { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400; }
.tracker-divider { width: 1px; height: 22px; background: var(--line); margin: 0 .2rem; }

.count-badge {
    display: inline-block;
    min-width: 1.35rem;
    padding: 0 .3rem;
    border-radius: 999px;
    background: #eef2f6;
    color: var(--muted);
    font-size: .74rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.count-badge.count-due { background: #fdeceb; color: var(--bad); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 1.25rem; position: relative; }

.timeline::before {
    content: "";
    position: absolute;
    left: .32rem;
    top: .4rem;
    bottom: .4rem;
    width: 2px;
    background: var(--line);
}

.tl-item { position: relative; padding: 0 0 1rem .9rem; }
.tl-item:last-child { padding-bottom: 0; }

.tl-dot {
    position: absolute;
    left: -1.02rem;
    top: .35rem;
    width: .62rem;
    height: .62rem;
    border-radius: 50%;
    background: var(--muted);
    box-shadow: 0 0 0 3px #fff;
}

.tl-change .tl-dot  { background: var(--accent); }
.tl-failed .tl-dot  { background: var(--bad); }
.tl-dev .tl-dot     { background: #6941c6; }
.tl-prod .tl-dot    { background: var(--ok); }
.tl-undo .tl-dot    { background: #fff; box-shadow: 0 0 0 2px var(--muted), 0 0 0 5px #fff; }
.tl-undo .tl-title  { color: var(--muted); }

.tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .8rem; }
.tl-when { color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-who { color: var(--muted); }
.tl-title { font-size: .92rem; margin-top: .1rem; }

.tl-trackers { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .45rem; }

.tracker {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .12rem .5rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    font-size: .78rem;
    cursor: pointer;
    user-select: none;
}

.tracker:hover { border-color: var(--accent); }
.tracker input { margin: 0; cursor: pointer; }
.tracker-on { background: #e6f4ea; border-color: #b7dfc3; color: var(--ok); font-weight: 600; }
.tracker-meta { color: var(--muted); font-weight: 400; font-size: .74rem; }
