/* VeloDB — design system
   Light: Drafting (cool blue-grey paper, indigo ink, drafting-red accent)
   Dark : Carbon   (graphite, hi-vis amber, follows prefers-color-scheme)
*/
:root {
    --bg: #dde3e6;
    --bg-2: #d2d9dd;
    --surface: #e7ecee;
    --surface-2: #f2f5f6;
    --line: #a9b3b8;
    --line-soft: #bdc5c9;
    --ink: #14202b;
    --ink-2: #2e3d4a;
    --sub: #5e6c76;
    --sub-2: #87929a;
    --link: #1f3f66;
    --link-hover: #c8552b;
    --accent: #c8552b;
    --accent-fg: #f2f5f6;
    --accent-2: #2e6f58;
    --accent-3: #1f3f66;
    --accent-4: #6f4a8e;
    --warn: #c8552b;
    --good: #2e6f58;
    --row: rgba(0, 0, 0, 0);
    --row-alt: rgba(20, 32, 43, 0.03);
    --row-hover: rgba(200, 85, 43, 0.08);
    --shadow: 0 1px 0 rgba(20, 32, 43, 0.05);
    --shadow-elev:
        0 12px 28px -10px rgba(20, 32, 43, 0.42), 0 2px 0 rgba(20, 32, 43, 0.06);
    --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --sans:
        "IBM Plex Sans", -apple-system, BlinkMacSystemFont, system-ui,
        sans-serif;
    --serif: "IBM Plex Serif", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #16181a;
        --bg-2: #1b1e21;
        --surface: #1f2326;
        --surface-2: #262b2f;
        --line: #353b40;
        --line-soft: #2c3236;
        --ink: #e8e6df;
        --ink-2: #c5c2b8;
        --sub: #8a8678;
        --sub-2: #6b6759;
        --link: #e8a848;
        --link-hover: #ffc675;
        --accent: #e8a848;
        --accent-fg: #16181a;
        --accent-2: #7bb661;
        --accent-3: #5ab3d6;
        --accent-4: #c77bb6;
        --warn: #e8a848;
        --good: #7bb661;
        --row-alt: rgba(255, 255, 255, 0.025);
        --row-hover: rgba(232, 168, 72, 0.1);
        --shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
        --shadow-elev:
            0 14px 32px -8px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(0, 0, 0, 0.4);
    }
}

* {
    box-sizing: border-box;
}
html,
body {
    margin: 0;
    padding: 0;
}
body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--ink);
    font-size: 13.5px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    letter-spacing: 0.005em;
}

a {
    color: var(--link);
    text-decoration: none;
    border-bottom: 1px dotted color-mix(in oklab, var(--link) 35%, transparent);
}
a:hover {
    color: var(--link-hover);
    border-bottom-color: var(--link-hover);
}
a.plain {
    border-bottom: none;
}

/* Top bar */
.topbar {
    background: var(--bg-2);
    border-bottom: 1px solid var(--line);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow);
}
.topbar-inner {
    max-width: 1500px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 28px;
    padding: 0 28px;
    height: 52px;
}
.brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
    border: none;
}
.brand-mark {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 19px;
    letter-spacing: -0.01em;
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.brand-dot {
    width: 10px;
    height: 10px;
    background: var(--accent);
    border-radius: 50%;
    display: inline-block;
}
.brand-meta {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--sub);
    letter-spacing: 0.02em;
}
.nav {
    display: flex;
    gap: 2px;
    align-items: center;
}
.nav a {
    padding: 6px 14px;
    font-size: 13px;
    color: var(--ink-2);
    border-bottom: 2px solid transparent;
    border-radius: 0;
    text-decoration: none;
    letter-spacing: 0.01em;
    transition:
        color 0.12s,
        border-color 0.12s;
}
.nav a:hover {
    color: var(--accent);
    border-bottom-color: transparent;
}
.nav a.active {
    color: var(--ink);
    border-bottom: 2px solid var(--accent);
}
.nav .nav-add {
    color: var(--accent);
    font-weight: 500;
    cursor: pointer;
}
.nav .nav-add::before {
    content: "+ ";
    font-family: var(--mono);
}
.tools {
    display: flex;
    gap: 8px;
    align-items: center;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--sub);
}
.search {
    font-family: var(--mono);
    font-size: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    padding: 5px 10px;
    width: 200px;
    color: var(--ink);
    border-radius: 2px;
}
.search::placeholder {
    color: var(--sub-2);
}
.search:focus {
    outline: none;
    border-color: var(--accent);
}
.kbd {
    font-family: var(--mono);
    font-size: 10px;
    border: 1px solid var(--line);
    padding: 1px 5px;
    background: var(--surface-2);
    color: var(--sub);
    border-radius: 2px;
}

/* Page */
.page {
    max-width: 1500px;
    margin: 0 auto;
    padding: 22px 28px 80px;
}
.page-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}
.page-title {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 26px;
    letter-spacing: -0.015em;
    margin: 0;
    color: var(--ink);
}
.page-title small {
    font-family: var(--mono);
    font-weight: 400;
    font-size: 12px;
    color: var(--sub);
    margin-left: 12px;
    letter-spacing: 0.02em;
}
.crumbs {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--sub);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.crumbs a {
    color: var(--sub);
}
.page-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Buttons */
.btn {
    font-family: var(--sans);
    font-size: 12px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--ink-2);
    padding: 5px 11px;
    border-radius: 2px;
    cursor: pointer;
    letter-spacing: 0.01em;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}
.btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.btn.primary {
    background: var(--accent);
    color: var(--accent-fg);
    border-color: var(--accent);
}
.btn.primary:hover {
    background: var(--link-hover);
    border-color: var(--link-hover);
    color: var(--accent-fg);
}
.btn.ghost {
    background: transparent;
}
.btn.sm {
    font-size: 11px;
    padding: 3px 8px;
}
.btn.danger {
    color: var(--accent);
    border-color: color-mix(in oklab, var(--accent) 55%, var(--line));
}
.btn.danger:hover {
    background: var(--accent);
    color: var(--accent-fg);
    border-color: var(--accent);
}

/* Filter bar */
.filterbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 2px;
    margin-bottom: 0;
}

.filterbar > .filters {
    display: grid;
    grid-template-columns: max-content 1fr;
    align-items: center;
    column-gap: 10px;
    row-gap: 6px;
    flex: 1;
    min-width: 0;
}

.filter {
    display: contents;
}

.filter-label {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--sub);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.filter-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.filter-row-break {
    flex-basis: 100%;
    height: 0;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 3px 9px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--ink-2);
    border-radius: 2px;
    cursor: pointer;
    font-family: var(--sans);
    text-decoration: none;
}
.chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.chip.on {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);
}
.chip .count {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--sub);
    margin-left: 2px;
}
.chip.on .count {
    color: color-mix(in oklab, var(--bg) 70%, transparent);
}
.chip-x {
    font-family: var(--mono);
    color: var(--sub-2);
    margin-left: 2px;
}
.chip:hover .chip-x {
    color: var(--accent);
}

/* Table */
.tbl-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: none;
    border-radius: 0 0 2px 2px;
    overflow: hidden;
}
.tbl-wrap.standalone {
    border-top: 1px solid var(--line);
    border-radius: 2px;
}
table.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.tbl thead th {
    font-family: var(--mono);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sub);
    font-weight: 500;
    text-align: left;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    white-space: nowrap;
    position: sticky;
    top: 0;
}
table.tbl thead th.sort {
    cursor: pointer;
}
table.tbl thead th.sort a {
    color: inherit;
    border: none;
    text-decoration: none;
    display: inline-block;
}
table.tbl thead th.sort:hover,
table.tbl thead th.sort:hover a {
    color: var(--accent);
}
table.tbl thead th.sort.active {
    color: var(--ink);
}
table.tbl thead th.sort.active a {
    color: var(--ink);
}
table.tbl thead th.sort.active.asc::after,
table.tbl thead th.sort.active.desc::after {
    margin-left: 4px;
    color: var(--accent);
    font-family: var(--mono);
}
table.tbl thead th.sort.active.asc::after {
    content: "▴";
}
table.tbl thead th.sort.active.desc::after {
    content: "▾";
}
table.tbl thead th.num,
table.tbl tbody td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: var(--mono);
}

.quantity {
    white-space: nowrap;
}
.quantity .unit {
    color: var(--sub-2);
}

table.tbl tbody td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: top;
    color: var(--ink-2);
}
table.tbl tbody tr {
    background: var(--row);
}
table.tbl tbody tr:nth-child(even) {
    background: var(--row-alt);
}
table.tbl tbody tr:hover {
    background: var(--row-hover);
}
table.tbl tbody tr:last-child td {
    border-bottom: none;
}
table.tbl td.id {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--link);
    width: 1%;
    white-space: nowrap;
}
table.tbl td.id a {
    color: var(--link);
    border-bottom: none;
}
table.tbl td.id a:hover {
    color: var(--accent);
}
table.tbl td.date {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--sub);
    white-space: nowrap;
    width: 1%;
}
table.tbl td.title {
    color: var(--ink);
    font-weight: 400;
}
table.tbl td.title a {
    color: var(--ink);
    border-bottom: none;
}
table.tbl td.title a:hover {
    color: var(--accent);
}
table.tbl td.collection {
    font-size: 12px;
    color: var(--sub);
    white-space: nowrap;
}
table.tbl td.collection a {
    color: var(--sub);
    border-bottom: none;
}
table.tbl td.collection a:hover {
    color: var(--accent);
}
.cb {
    accent-color: var(--accent);
}
.muted {
    color: var(--sub-2);
}

/* Designed-but-unwired elements (see placeholders in DESIGN todo) */
.nonfunctional {
    opacity: 0.5;
    cursor: not-allowed;
}
.nonfunctional .stat-k,
.nonfunctional .panel-head > span:first-child {
    text-decoration: line-through;
    text-decoration-style: dashed;
    text-decoration-color: var(--sub-2);
}

/* Tags */
.tag {
    display: inline-block;
    font-family: var(--mono);
    font-size: 10.5px;
    padding: 1px 6px;
    border: 1px solid var(--line);
    border-radius: 2px;
    color: var(--sub);
    margin-right: 3px;
    margin-bottom: 2px;
    background: var(--surface-2);
    letter-spacing: 0.02em;
    text-decoration: none;
}
.tag:hover {
    color: var(--accent);
    border-color: var(--accent);
}
.tag.brevet {
    color: var(--accent);
    border-color: color-mix(in oklab, var(--accent) 40%, transparent);
    background: color-mix(in oklab, var(--accent) 8%, transparent);
}
.tag.gravel {
    color: var(--accent-2);
    border-color: color-mix(in oklab, var(--accent-2) 40%, transparent);
    background: color-mix(in oklab, var(--accent-2) 8%, transparent);
}
.tag.road {
    color: var(--accent-3);
    border-color: color-mix(in oklab, var(--accent-3) 40%, transparent);
    background: color-mix(in oklab, var(--accent-3) 8%, transparent);
}
.tag.dsd {
    color: var(--accent-4);
    border-color: color-mix(in oklab, var(--accent-4) 40%, transparent);
    background: color-mix(in oklab, var(--accent-4) 8%, transparent);
}
.tag.eifel {
    color: var(--accent-4);
    border-color: color-mix(in oklab, var(--accent-4) 40%, transparent);
    background: color-mix(in oklab, var(--accent-4) 8%, transparent);
}
.tag.bikerouter {
    color: var(--sub);
}
.tag.overnighter {
    color: var(--ink-2);
    border-color: color-mix(in oklab, var(--ink-2) 30%, transparent);
    background: color-mix(in oklab, var(--ink-2) 5%, transparent);
}
.tag.belgien {
    color: var(--accent);
    border-color: color-mix(in oklab, var(--accent) 40%, transparent);
    background: color-mix(in oklab, var(--accent) 8%, transparent);
}
.tag.dgr {
    color: var(--accent-3);
}

/* Sport pill (text only, mono) */
.sport {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--sub);
    text-transform: lowercase;
    letter-spacing: 0.04em;
}
.sport::before {
    content: "● ";
    color: var(--accent-2);
    font-size: 9px;
}
.sport.cycling::before {
    color: var(--accent-3);
}
.sport.gravel::before {
    color: var(--accent-2);
}
.sport.cyclocross::before {
    color: var(--accent);
}
.sport.virtual::before {
    color: var(--sub-2);
}

/* Tiny inline checkbox marker for boolean cell */
.bool {
    width: 14px;
    height: 14px;
    border: 1px solid var(--line);
    display: inline-block;
    background: var(--surface-2);
    border-radius: 2px;
    vertical-align: middle;
    position: relative;
}
.bool.on {
    background: var(--accent);
    border-color: var(--accent);
}
.bool.on::after {
    content: "✓";
    color: var(--accent-fg);
    font-size: 10px;
    position: absolute;
    top: -2px;
    left: 2px;
    font-family: var(--mono);
}

/* Stats strip */
.stats {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0;
    border: 1px solid var(--line);
    background: var(--surface);
    margin-bottom: 14px;
    border-radius: 2px;
}
.stat {
    padding: 10px 14px;
    border-right: 1px solid var(--line-soft);
}
.stat:last-child {
    border-right: none;
}
.stat-k {
    font-family: var(--mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sub);
}
.stat-v {
    font-family: var(--serif);
    font-size: 22px;
    color: var(--ink);
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}
.stat-v small,
.stat-v .quantity .unit {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--sub);
    margin-left: 3px;
    letter-spacing: 0.02em;
}
.stat-sub {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--sub-2);
    margin-top: 2px;
}

/* Collections grid */
.coll-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.coll-card {
    border: 1px solid var(--line);
    background: var(--surface);
    padding: 12px 14px;
    border-radius: 2px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-decoration: none;
    color: var(--ink);
    transition:
        border-color 0.12s,
        background 0.12s;
    position: relative;
    min-height: 92px;
}
.coll-card:hover {
    border-color: var(--accent);
    background: var(--surface-2);
}
.coll-card.featured {
    background: var(--surface-2);
    color: var(--ink);
    border-color: var(--accent);
    box-shadow: inset 3px 0 0 var(--accent);
}
.coll-card.featured:hover {
    background: color-mix(in oklab, var(--accent) 8%, var(--surface-2));
    border-color: var(--accent);
}
.coll-card.featured .coll-name {
    color: var(--ink);
}
.coll-card.featured .coll-count {
    color: var(--accent);
}
.coll-card.featured .coll-meta {
    color: var(--sub);
}
.coll-name {
    font-family: var(--sans);
    font-weight: 500;
    font-size: 14.5px;
    color: var(--ink);
    letter-spacing: -0.005em;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}
.coll-count {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--sub);
    font-weight: 400;
}
.coll-meta {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--sub);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.coll-bar {
    height: 3px;
    background: var(--line-soft);
    position: relative;
    margin-top: auto;
    border-radius: 1px;
    overflow: hidden;
}
.coll-bar > span {
    display: block;
    height: 100%;
    background: var(--accent);
}
.coll-card.featured .coll-bar {
    background: var(--bg-2);
}
.coll-card.featured .coll-bar > span {
    background: var(--accent);
}

/* Detail page */
.detail {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 22px;
}
.dl {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 0;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 2px;
}
.dl dt,
.dl dd {
    margin: 0;
    padding: 9px 14px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 13px;
}
.dl dt {
    font-family: var(--mono);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sub);
    background: var(--surface);
    border-right: 1px solid var(--line-soft);
}
.dl dd {
    color: var(--ink-2);
    background: var(--surface-2);
}
.dl > *:nth-last-child(1),
.dl > *:nth-last-child(2) {
    border-bottom: none;
}

.panel {
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 2px;
}
.panel-head {
    padding: 9px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    font-family: var(--mono);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sub);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.panel-head .panel-meta {
    font-family: var(--mono);
    text-transform: none;
    font-size: 11px;
    color: var(--sub);
}
.panel-body {
    padding: 14px;
    background: var(--surface-2);
}

/* Map placeholder fallback (real maps replace this entirely) */
.map {
    height: 320px;
    background:
        linear-gradient(
                135deg,
                transparent 49%,
                color-mix(in oklab, var(--ink) 8%, transparent) 49%,
                color-mix(in oklab, var(--ink) 8%, transparent) 51%,
                transparent 51%
            )
            0 0/14px 14px,
        repeating-linear-gradient(
            45deg,
            color-mix(in oklab, var(--ink) 4%, transparent) 0 1px,
            transparent 1px 8px
        ),
        var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

.profile {
    height: 90px;
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

/* Sections */
h2.sec {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 18px;
    letter-spacing: -0.01em;
    margin: 24px 0 10px;
    color: var(--ink);
    display: flex;
    align-items: baseline;
    gap: 10px;
}
h2.sec small {
    font-family: var(--mono);
    font-weight: 400;
    font-size: 11px;
    color: var(--sub);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Code block */
.code {
    font-family: var(--mono);
    font-size: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    padding: 10px 12px;
    border-radius: 2px;
    color: var(--ink-2);
    overflow-x: auto;
    white-space: pre;
    word-break: break-all;
    line-height: 1.55;
}
.code .k {
    color: var(--accent);
}
.code .s {
    color: var(--accent-2);
}
.code .n {
    color: var(--accent-3);
}
.code .c {
    color: var(--sub-2);
}

.input-mono {
    font-family: var(--mono);
    font-size: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    padding: 8px 10px;
    border-radius: 2px;
    color: var(--ink-2);
    width: 100%;
    display: block;
}
.copy-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0;
    border: 1px solid var(--line);
    border-radius: 2px;
    overflow: hidden;
}
.copy-row .input-mono {
    border: none;
    border-right: 1px solid var(--line);
    border-radius: 0;
}
.copy-row .btn {
    border: none;
    border-radius: 0;
    padding: 0 14px;
    background: var(--surface);
}
.copy-row .btn:hover {
    background: var(--accent);
    color: var(--accent-fg);
}

.kv {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 6px 18px;
    font-size: 12.5px;
    margin-bottom: 4px;
}
.kv dt {
    color: var(--sub);
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-top: 2px;
}
.kv dd {
    margin: 0;
    color: var(--ink-2);
}

/* Footer / debug */
.foot {
    margin-top: 30px;
    border-top: 1px solid var(--line);
    padding-top: 12px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--sub);
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.foot a {
    color: var(--sub);
}

/* Pagination */
.pager {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--sub);
    margin-top: 10px;
    padding: 0 4px;
}
.pager .pg-btn {
    padding: 3px 9px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--ink-2);
    border-radius: 2px;
    cursor: pointer;
    text-decoration: none;
}
.pager .pg-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.pager .pg-btn.cur {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);
}
.pager .spacer {
    flex: 1;
}

/* Two-col integrations layout */
.int-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 1100px) {
    .int-grid,
    .detail {
        grid-template-columns: 1fr;
    }
    .stats {
        grid-template-columns: repeat(3, 1fr);
    }
    .coll-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .stats.stats-7 {
        grid-template-columns: repeat(3, 1fr);
    }
    .detail.detail-side {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 900px) {
    .topbar-inner {
        grid-template-columns: auto 1fr;
        gap: 16px;
        padding: 0 16px;
        height: auto;
        padding-top: 8px;
        padding-bottom: 8px;
        row-gap: 6px;
    }
    .topbar-inner .nav {
        grid-column: 1 / -1;
        flex-wrap: wrap;
        order: 3;
    }
    .topbar-inner .tools {
        justify-self: end;
    }
    .brand-meta {
        display: none;
    }
    .search {
        width: 140px;
    }
    .page {
        padding: 18px 16px 60px;
    }
    .page-head {
        flex-wrap: wrap;
        gap: 10px;
    }
    .page-actions {
        flex-wrap: wrap;
    }
    .tbl-wrap {
        overflow-x: auto;
    }
}
@media (max-width: 680px) {
    .stats {
        grid-template-columns: 1fr;
    }
    .coll-grid {
        grid-template-columns: 1fr;
    }
    .stats.stats-7 {
        grid-template-columns: repeat(2, 1fr);
    }
    .topbar-inner {
        grid-template-columns: 1fr auto;
    }
    .tools .kbd {
        display: none;
    }
    .search {
        width: 100%;
        min-width: 0;
    }
    .filterbar {
        padding: 8px;
    }
}
.stats.stats-7 {
    grid-template-columns: repeat(7, 1fr);
}
.stats.stats-5 {
    grid-template-columns: repeat(5, 1fr);
}
.stats.stats-4 {
    grid-template-columns: repeat(4, 1fr);
}
.stats.stats-3 {
    grid-template-columns: repeat(3, 1fr);
}
.detail.detail-side {
    grid-template-columns: 1fr 380px;
}

/* Status / heatmap dot */
.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.dot.live {
    background: var(--good);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--good) 22%, transparent);
}
.dot.idle {
    background: var(--sub-2);
}
.dot.warn {
    background: var(--warn);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--warn) 22%, transparent);
}

/* Chip dropdown popovers — used for "More …" overflow */
.chip-dropdown {
    position: relative;
    display: inline-flex;
}
.dropdown-toggle {
    font-family: var(--sans);
    cursor: pointer;
}
.dropdown-toggle .caret {
    font-size: 9px;
    margin-left: 2px;
    display: inline-block;
    transition: transform 120ms ease;
    color: color-mix(in oklab, currentColor 55%, transparent);
}
.dropdown-toggle.open {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);
}
.dropdown-toggle.open .count {
    color: color-mix(in oklab, var(--bg) 70%, transparent);
}
.dropdown-toggle.open .caret {
    transform: rotate(180deg);
    color: var(--bg);
}

.chip-popover {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 30;
    width: 320px;
    max-width: 90vw;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 2px;
    box-shadow: var(--shadow-elev);
    display: flex;
    flex-direction: column;
    font-family: var(--sans);
    animation: popover-in 100ms ease-out;
}
.chip-popover[hidden] {
    display: none;
}
@keyframes popover-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.popover-head {
    padding: 8px 8px 6px;
    border-bottom: 1px solid var(--line);
}
.popover-search {
    width: 100%;
    padding: 5px 8px;
    font-size: 11px;
    font-family: var(--mono);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 2px;
    color: var(--ink);
    box-sizing: border-box;
}
.popover-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent) 18%, transparent);
}
.popover-list {
    display: flex;
    flex-direction: column;
    max-height: 320px;
    overflow-y: auto;
    padding: 4px 0;
}
.popover-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    column-gap: 10px;
    row-gap: 0;
    padding: 5px 12px;
    text-decoration: none;
    color: var(--ink);
    font-size: 12.5px;
    border-left: 2px solid transparent;
    cursor: pointer;
}
.popover-item:hover {
    background: color-mix(in oklab, var(--accent) 8%, transparent);
    border-left-color: var(--accent);
}
.popover-item.on {
    background: color-mix(in oklab, var(--accent) 12%, transparent);
    border-left-color: var(--accent);
}
.popover-item input[type="checkbox"] {
    accent-color: var(--accent);
    margin: 0;
}
.popover-item-name {
    font-weight: 500;
}
.popover-item-count {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--sub-2);
    font-variant-numeric: tabular-nums;
}
.popover-item:hover .popover-item-count,
.popover-item.on .popover-item-count {
    color: var(--accent);
}
.popover-empty {
    padding: 18px 12px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--sub-2);
    text-align: center;
}
.popover-foot {
    padding: 7px 12px;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--sub-2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-top: 1px dashed var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.popover-foot a {
    color: var(--sub);
    text-decoration: none;
    border-bottom: 1px dotted var(--sub-2);
}
.popover-foot a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Bulk edit bar — appears between filterbar and table when rows are selected */
.filter-slot {
    position: relative;
}
.bulkbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 11px;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--accent);
    box-shadow: inset 0 0 0 1px
        color-mix(in oklab, var(--accent) 18%, transparent);
    font-size: 12px;
    font-family: var(--sans);
    flex-wrap: nowrap;
    position: absolute;
    inset: 0;
    z-index: 4;
    border-radius: 2px;
}
.bulkbar[hidden] {
    display: none;
}
.bulkbar .bulk-count {
    font-family: var(--mono);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sub);
    margin-right: 4px;
    padding: 0 4px;
}
.bulkbar .bulk-count b {
    color: var(--accent);
    font-weight: 500;
    font-size: 12px;
    margin-right: 4px;
}
.bulkbar .btn {
    background: var(--bg);
    color: var(--ink);
    border-color: var(--line);
}
.bulkbar .btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: color-mix(in oklab, var(--accent) 8%, var(--surface));
}
.bulkbar .bulk-sep {
    width: 1px;
    height: 16px;
    background: var(--line);
    margin: 0 4px;
}
.bulkbar .bulk-clear {
    color: var(--sub);
    font-family: var(--mono);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border: none;
    padding: 0 4px;
    cursor: pointer;
    text-decoration: none;
    background: transparent;
}
.bulkbar .bulk-clear:hover {
    color: var(--accent);
    border: none;
}

/* htmx loading */
.htmx-indicator {
    opacity: 0;
    transition: opacity 0.15s;
}
.htmx-request .htmx-indicator {
    opacity: 1;
}
#htmx-progress {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    display: none;
    border: none;
    background: transparent;
    color: var(--accent);
    z-index: 100;
}
#htmx-progress::-webkit-progress-bar {
    background: transparent;
}
#htmx-progress::-webkit-progress-value {
    background: var(--accent);
}
#htmx-progress::-moz-progress-bar {
    background: var(--accent);
}
.htmx-request#htmx-progress,
.htmx-request #htmx-progress {
    display: block;
}

/* Editable in-place fields */
.editable {
    cursor: text;
    border-bottom: 1px dotted transparent;
}
.editable:hover {
    border-bottom-color: color-mix(in oklab, var(--accent) 50%, transparent);
}
.editable input,
.editable textarea,
.editable select {
    font: inherit;
    color: inherit;
    background: var(--surface-2);
    border: 1px solid var(--accent);
    border-radius: 2px;
    padding: 2px 6px;
}

/* Tag-list (edit field) */
.tag-list {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 3px;
    align-items: center;
    cursor: text;
    min-width: 80px;
}
.tag-list chip,
.tag-list .tag-chip {
    display: inline-block;
    font-family: var(--mono);
    font-size: 10.5px;
    padding: 1px 6px;
    border: 1px solid var(--line);
    border-radius: 2px;
    color: var(--sub);
    background: var(--surface-2);
    letter-spacing: 0.02em;
}
.tag-list input {
    font-family: var(--mono);
    font-size: 11px;
    padding: 2px 6px;
    background: var(--surface-2);
    border: 1px solid var(--accent);
    color: var(--ink);
    border-radius: 2px;
    min-width: 120px;
}

/* Forms / dialog */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: color-mix(in oklab, var(--ink) 50%, transparent);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dialog {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 2px;
    width: min(560px, 92vw);
    box-shadow: var(--shadow-elev);
}
.dialog-head {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.dialog-head h2 {
    margin: 0;
    font-family: var(--serif);
    font-size: 18px;
    font-weight: 600;
}
.dialog-body {
    padding: 16px;
}
.dialog-foot {
    padding: 10px 16px;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.dialog-body label {
    display: block;
    font-family: var(--mono);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sub);
    margin-bottom: 4px;
    margin-top: 12px;
}
.dialog-body label:first-child {
    margin-top: 0;
}
.dialog-body input[type="text"],
.dialog-body input[type="url"],
.dialog-body input[type="file"],
.dialog-body select,
.dialog-body textarea {
    width: 100%;
    font-family: var(--mono);
    font-size: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 2px;
    color: var(--ink);
    padding: 6px 8px;
}
.dialog-body input:focus,
.dialog-body select:focus,
.dialog-body textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* Login layout */
.login-shell {
    min-height: calc(100vh - 52px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
}
.login-card {
    width: min(420px, 100%);
    text-align: center;
}
.login-card .panel-body {
    padding: 28px 22px;
}
.login-card h1 {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 22px;
    margin: 0 0 6px;
    color: var(--ink);
}
.login-card p {
    color: var(--sub);
    margin: 0 0 18px;
    font-size: 12.5px;
}

/* Activity bar chart placeholder (Sessions index) */
.activity-bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 96px;
    padding: 14px 18px;
    background: var(--surface-2);
}
.activity-bars > span {
    flex: 1;
    display: block;
    background: var(--accent-2);
    min-height: 1px;
    border-radius: 1px 1px 0 0;
}
