:root { --brand: #0f6e56; --ink: #163028; --paper: #f4f1ea; --card: #fffdf8; }
body { background: var(--paper); color: var(--ink); }
[data-bs-theme="dark"] body { --paper: #121816; --ink: #e7eee9; --card: #1b2420; background: var(--paper); color: var(--ink); }

.site-nav {
    background: #12382f;
    --bs-navbar-color: #d7ebe3;
    --bs-navbar-hover-color: #fff;
    --bs-navbar-brand-color: #fff;
    --bs-navbar-brand-hover-color: #fff;
    --bs-navbar-toggler-border-color: rgba(255,255,255,.35);
}
.site-nav .navbar-brand { color: #fff; font-weight: 650; letter-spacing: -.02em; }
.site-nav .nav-link { color: #d7ebe3; border-radius: 999px; padding-inline: .75rem; }
.site-nav .nav-link:hover, .site-nav .nav-link:focus { color: #fff; background: rgba(255,255,255,.08); }
.site-nav .navbar-toggler { border-color: rgba(255,255,255,.35); }
.site-nav .navbar-toggler-icon { filter: invert(1); }
.nav-link { min-height: 44px; display: flex; align-items: center; gap: .4rem; }

.page-head { margin-bottom: 1.25rem; }
.page-head h1, h1 { letter-spacing: -.03em; }
.page-head p { max-width: 40rem; }
.stat-card, .card-panel, .duplicate-item {
    background: var(--card);
    border: 1px solid rgba(18, 56, 47, .08);
    border-radius: 1.1rem;
    box-shadow: 0 10px 30px rgba(18, 56, 47, .06);
}
.stat-value { font-variant-numeric: tabular-nums; }
.line-badge { min-width: 2.5rem; }
.line-link { white-space: normal; line-height: 1.3; border-radius: .9rem; }
.duplicate-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; }
.duplicate-item { padding: .75rem .9rem; }
.sort-pills { flex: none; }
.sort-pills .btn { min-height: 44px; }
.btn, .form-control, .form-select { min-height: 44px; }
.table thead th { font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; color: var(--bs-secondary-color); white-space: nowrap; }
.table-scroll { overflow-x: auto; }
.fav-on { color: #d4a017; }

.site-footer { background: var(--card); border-top: 1px solid rgba(18, 56, 47, .08); }
.credit-stack { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .65rem; padding: .85rem 1rem 1rem; }
.credit-own {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    margin: 0;
    padding: .28rem .8rem .3rem .62rem;
    border-radius: 999px;
    background: #12382f;
    color: #fff;
    text-decoration: none;
    font-weight: 650;
    letter-spacing: -.02em;
    font-size: .95rem;
    line-height: 1.2;
    box-shadow: 0 8px 18px rgba(18, 56, 47, .16);
}
.credit-own:hover, .credit-own:focus { color: #fff; background: #0f6e56; }
.credit-own .credit-heart { color: #fb7185; font-size: .82em; }
.credit-legal {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .45rem;
    width: min(100%, 36rem);
    padding-top: .55rem;
    border-top: 1px solid rgba(18, 56, 47, .1);
}
.credit-copy { margin: 0; max-width: 34rem; font-size: .74rem; line-height: 1.45; color: #6d7c74; }
[data-bs-theme="dark"] .credit-legal { border-top-color: rgba(255,255,255,.1); }
[data-bs-theme="dark"] .credit-copy { color: #9aada4; }
.logo-pad { display: inline-flex; align-items: center; gap: .85rem; background: #111; border-radius: .9rem; padding: .4rem .75rem; }
.logo-pad img { width: auto; max-width: 132px; height: 32px; object-fit: contain; }

.map-screen { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; background: #d5e4dc; }
.map-screen .site-nav, .map-screen .site-footer { flex: none; position: relative; z-index: 700; }
.map-screen .map-main { flex: 1 1 auto; min-height: 0; display: flex; overflow: hidden; padding: 0; }
.map-screen .credit-stack { padding: .45rem .75rem .5rem; gap: .4rem; }
.map-screen .credit-own { font-size: .86rem; box-shadow: none; }
.map-screen .credit-legal { padding-top: .35rem; gap: .35rem; }
.map-layout { position: relative; flex: 1; min-height: 0; min-width: 0; }
#ctbus-map { position: absolute; inset: 0; }
.leaflet-container { height: 100%; width: 100%; background: #d5e4dc; font: inherit; }
.leaflet-control-attribution { max-width: calc(100% - 8px); white-space: normal; line-height: 1.35; }
.credit-heart { color: #e11d48; }
.map-side {
    position: absolute;
    z-index: 500;
    top: .75rem;
    left: .75rem;
    width: min(340px, calc(100% - 5.5rem));
    max-height: calc(100% - 1.5rem);
    overflow: auto;
    padding: .85rem .9rem .7rem;
    background: rgba(255, 253, 248, .94);
    color: var(--ink);
    border-radius: 1.15rem;
    box-shadow: 0 16px 40px rgba(16, 40, 32, .18);
    border: 1px solid rgba(255,255,255,.7);
}
[data-bs-theme="dark"] .map-side { background: rgba(22, 30, 27, .94); color: #e7eee9; border-color: rgba(255,255,255,.08); }
.bus-pin { width: 34px; height: 34px; border-radius: 999px; display: flex; align-items: center; justify-content: center; color: #fff; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); font-size: 14px; }
.heat { width: 18px; height: 18px; border-radius: 3px; display: inline-block; }
.heat-table { font-variant-numeric: tabular-nums; }
.heat-cell { min-width: 1.7rem; text-align: center; font-size: .68rem; font-weight: 650; border-radius: .25rem; padding: .2rem .1rem; }
.tone-ok { color: #0f6e56; }
.tone-warn { color: #b45309; }
.tone-bad { color: #b42318; }
.tone-early { color: #1d4ed8; }
.rank-top { background: rgba(180, 83, 9, .08); }
.table-panel { max-height: 28rem; }
.month-track { height: .45rem; border-radius: 999px; background: rgba(18, 56, 47, .08); overflow: hidden; }
.month-track > span { display: block; height: 100%; border-radius: 999px; background: #c2410c; }
.delay-stack { display: flex; height: .7rem; border-radius: 999px; overflow: hidden; background: rgba(18, 56, 47, .08); }
.stack-early { background: #0d6efd; }
.stack-ok { background: #1f8a4c; }
.stack-ok2 { background: #8fbf6a; }
.stack-warn { background: #f0ad00; }
.stack-bad { background: #dc3545; }
.stack-dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 999px; margin-right: .2rem; vertical-align: middle; }
[data-bs-theme="dark"] .tone-ok { color: #8dceb4; }
[data-bs-theme="dark"] .tone-warn { color: #f5c16c; }
[data-bs-theme="dark"] .tone-bad { color: #ff8b80; }
[data-bs-theme="dark"] .tone-early { color: #9ec1ff; }
[data-bs-theme="dark"] .rank-top { background: rgba(245, 193, 108, .08); }

.vehicle-sheet {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: var(--paper);
    color: var(--ink);
}
.vehicle-sheet::backdrop { background: rgba(18, 56, 47, .45); }
.vehicle-sheet-scroll {
    min-height: 100%;
    overflow: auto;
    padding: max(1rem, env(safe-area-inset-top)) 1.15rem max(1.4rem, env(safe-area-inset-bottom));
}
.vehicle-sheet-mark { width: 2.75rem; height: .35rem; border-radius: 999px; margin-bottom: .85rem; background: var(--brand); }
.vehicle-sheet-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.vehicle-sheet-type { margin: 0; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: #5c7268; }
.vehicle-sheet h2 { margin: .1rem 0 .45rem; font-size: 2rem; letter-spacing: -.03em; }
.vehicle-sheet-line, .vehicle-sheet-sign { margin: 0; }
.vehicle-sheet-line { font-size: 1.15rem; font-weight: 650; }
.vehicle-sheet-line a { color: var(--brand); text-decoration: none; }
.vehicle-sheet-sign { margin-top: .2rem; color: #3d5248; }
.vehicle-sheet-close {
    flex: none;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(18, 56, 47, .12);
    border-radius: 999px;
    background: var(--card);
    color: inherit;
    font-size: 1.15rem;
}
.vehicle-sheet-facts { list-style: none; margin: 1.2rem 0 0; padding: 0; display: grid; gap: .55rem; }
.vehicle-sheet-facts li {
    background: var(--card);
    border: 1px solid rgba(18, 56, 47, .08);
    border-radius: .95rem;
    padding: .85rem 1rem;
    font-size: 1.05rem;
}
.vehicle-sheet-actions { margin: 1.25rem 0 0; }
.vehicle-sheet-actions .btn { width: 100%; }
[data-bs-theme="dark"] .vehicle-sheet-type { color: #9aada4; }
[data-bs-theme="dark"] .vehicle-sheet-sign { color: #c5d5cc; }
[data-bs-theme="dark"] .vehicle-sheet-close,
[data-bs-theme="dark"] .vehicle-sheet-facts li { border-color: rgba(255,255,255,.1); }

@media (max-width: 991.98px) {
    .map-side { top: .5rem; left: .5rem; width: calc(100% - 1rem); max-height: none; }
    .map-side:not(.is-open) #map-tools-body { display: none; }
    .map-side.is-open { width: calc(100% - 4.6rem); max-height: calc(100% - 5.6rem); }
    .map-side .form-control, .map-side .form-select, .map-side .btn { min-height: 36px; }
    .leaflet-top.leaflet-right { top: auto; bottom: .45rem; right: .4rem; margin: 0; }
    .leaflet-bottom.leaflet-right { left: 0; right: auto; bottom: 0; max-width: calc(100% - 3.8rem); margin: 0; }
}
@media (max-width: 767.98px) {
    .sort-pills { display: flex; width: 100%; }
    .sort-pills .btn { flex: 1 1 auto; padding-left: .45rem; padding-right: .45rem; }
    .line-link { font-size: .92rem; }
}
