:root {
    --bg: #f5f5f3; --surface: #fff; --text: #1c1d21; --muted: #6b6e76; --line: #e3e3df;
    --primary: #1f5f8b; --primary-text: #fff; --hover: #f0f3f6; --tag: #eef1f4; --danger: #b3261e;
    --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #16171a; --surface: #1f2024; --text: #e8e8ea; --muted: #9a9ca3; --line: #2e3035;
        --primary: #5aa0d6; --primary-text: #0d1117; --hover: #262a30; --tag: #2a2d33; --danger: #f2877f;
        --shadow: none;
    }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 0.9em ui-monospace, SFMono-Regular, Menlo, monospace; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
h2 { font-size: 1.15rem; margin: 0; }
h3 { font-size: 1rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.r { text-align: right; }

.top { display: flex; align-items: center; gap: 1rem; padding: .75rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { color: var(--text); font-size: 1rem; display: flex; align-items: center; gap: .5rem; }
.brand:hover { text-decoration: none; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--text); color: var(--bg); display: grid; place-items: center; font-weight: 700; }
.crumbs { display: flex; gap: .5rem; align-items: center; color: var(--muted); min-width: 0; overflow: hidden; white-space: nowrap; }
.crumbs b { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.logout { margin-left: auto; color: var(--muted); font-size: .9rem; }

main { max-width: 1240px; margin: 0 auto; padding: 1.75rem 1.5rem 4rem; }
.intro { margin-bottom: 1.5rem; }
.intro.row { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.section { margin: 2rem 0 .75rem; display: flex; gap: .75rem; align-items: baseline; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); margin-top: 2rem; }

.project { color: var(--text); display: flex; flex-direction: column; gap: .75rem; border-top: 3px solid var(--accent); transition: transform .12s, box-shadow .12s; }
.project:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.08); }
.project p { margin: 0; }
.project-head { display: flex; gap: .75rem; align-items: center; }
.project-head .badge { margin-left: auto; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent, var(--muted)); flex: none; }

.badge { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; padding: .15rem .5rem; border-radius: 99px; background: var(--tag); color: var(--muted); font-weight: 600; }
.tag { font-size: .8rem; padding: .1rem .5rem; border-radius: 6px; background: var(--tag); white-space: nowrap; }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .5rem 1rem; margin: 0; }
.kv dt { font-size: .75rem; color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.kv.wide { grid-template-columns: 1fr; gap: 0; }
.kv.wide > div { display: grid; grid-template-columns: 180px 1fr; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.kv.wide > div:last-child { border-bottom: 0; }
.kv.wide dt { font-size: .85rem; font-family: ui-monospace, Menlo, monospace; }
.kv.wide dd { font-weight: 400; word-break: break-word; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; overflow-x: auto; }
.tabs a { padding: .6rem 1rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { color: var(--text); border-color: var(--text); font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.stats span { display: block; font-size: .78rem; color: var(--muted); }
.stats b { font-size: 1.2rem; font-variant-numeric: tabular-nums; }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.filters input[type=search] { flex: 1 1 320px; }
input, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .75rem; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.btn { display: inline-flex; align-items: center; gap: .4rem; font: inherit; font-weight: 500; padding: .5rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; background: var(--hover); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.small { padding: .25rem .65rem; font-size: .85rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; font-size: .9rem; }
.list th { text-align: left; font-weight: 600; font-size: .78rem; color: var(--muted); padding: .65rem .85rem; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.list th a { color: inherit; }
.list td { padding: .65rem .85rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.list tbody tr:last-child td { border-bottom: 0; }
.list tbody tr[onclick] { cursor: pointer; }
.list tbody tr:hover { background: var(--hover); }
.list tbody tr.dim td { color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; color: var(--muted); white-space: nowrap; }
.check input { padding: 0; }
.list tfoot td { border-top: 1px solid var(--line); border-bottom: 0; }
.list.compact td, .list.compact th { padding: .45rem .75rem; }
.list.data td { white-space: nowrap; font-size: .82rem; font-variant-numeric: tabular-nums; }
.list td.r, .list th.r { text-align: right; font-variant-numeric: tabular-nums; }

.pager { display: flex; gap: 1rem; justify-content: center; align-items: center; margin-top: 1rem; color: var(--muted); }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty h3 { color: var(--text); }
.alert { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem; }

.raw { margin-top: 2rem; }
.raw summary { cursor: pointer; color: var(--muted); }
.raw pre { overflow: auto; font-size: .8rem; max-height: 480px; }

.login { max-width: 380px; margin: 8vh auto; display: flex; flex-direction: column; gap: 1rem; }
.login h1 { margin: 0; }
.login p { margin: 0; }
.login label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); }

@media (max-width: 640px) {
    main { padding: 1.25rem 1rem 3rem; }
    .top { padding: .65rem 1rem; }
    .crumbs { display: none; }
    .kv.wide > div { grid-template-columns: 1fr; gap: .1rem; }
    .grid { grid-template-columns: 1fr; }
}
