:root {
    --paper: #f3efe6;
    --panel: #fffdf8;
    --ink: #1c1915;
    --muted: #5f584e;
    --line: #e3d7c6;
    --accent: #8d3b2c;
    --accent-dark: #6e2c21;
    --pine: #1e3a34;
    --chip: #efe6d6;
    --be: #2b6cb0;
    --fr: #c53030;
    --selected: #1f7a4d;
    --shadow: 0 12px 30px rgba(48, 36, 22, 0.06);
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
h1, h2 { font-family: Palatino, "Iowan Old Style", Georgia, serif; font-weight: 600; }
h1 { margin: 0; font-size: 1.8rem; }
h2 { margin: 0; font-size: 1.15rem; }
a { color: var(--pine); }

.top {
    background: var(--pine);
    color: #f6f1e7;
    padding: 1.1rem 1.4rem;
}
.brand { display: flex; gap: 0.85rem; align-items: center; }
.mark {
    width: 2.4rem; height: 2.4rem; border-radius: 50%;
    border: 2px solid #f0d7a2; position: relative;
}
.mark::after {
    content: ""; position: absolute; inset: 0.72rem; border-radius: 50%; background: #e0b15a;
}
.eyebrow { margin: 0 0 0.15rem; letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.72rem; color: #d9c7a4; }

main { width: min(1440px, calc(100% - 1.5rem)); margin: 1rem auto 2rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.search-panel {
    display: grid;
    grid-template-columns: minmax(16rem, 1fr) auto auto;
    gap: 0.75rem 1.1rem;
    align-items: end;
    padding: 0.85rem 1rem 0.95rem;
}
.field { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }
.field label, .field legend { font-size: 0.92rem; font-weight: 650; }
fieldset { border: 0; margin: 0; padding: 0; }
input[type="text"], input[type="search"], input[type="number"], select {
    background: #fff; border: 1px solid #d9cdb8; border-radius: 10px; padding: 0.62rem 0.75rem;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.combo { position: relative; }
.suggestions {
    position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
    margin: 0; padding: 0.3rem; list-style: none; background: #fff; border: 1px solid var(--line);
    border-radius: 12px; box-shadow: var(--shadow); max-height: 280px; overflow: auto;
}
.suggestions button {
    width: 100%; text-align: left; background: transparent; border: 0; border-radius: 8px; padding: 0.5rem 0.6rem; cursor: pointer;
}
.suggestions button[aria-selected="true"], .suggestions button:hover { background: #f6ecdf; }
.origin-label { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 0.86rem; }
.origin-label:empty { display: none; }
.radius-line { display: flex; align-items: center; gap: 0.45rem; }
.radius-line input { width: 6.2rem; }
.tool-buttons button, .export-bar button, .pager button {
    background: var(--chip); border: 1px solid #e0d3bf; border-radius: 999px; padding: 0.28rem 0.62rem; cursor: pointer;
}
.actions { display: flex; gap: 0.5rem; align-items: center; }
#search-button {
    background: var(--accent); color: #fffaf6; border: 0; border-radius: 999px; padding: 0.75rem 1.2rem; cursor: pointer; font-weight: 700;
}
#search-button:hover { background: var(--accent-dark); }
#search-button:disabled, button:disabled { opacity: 0.55; cursor: not-allowed; }
#cancel-button { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 0.7rem 0.9rem; cursor: pointer; }

.alert { margin: 0.8rem 0 0; padding: 0.75rem 0.9rem; border-radius: 12px; background: #fde8e4; color: #6e2c21; }
.alert.info { background: #e7f0ea; color: #1e3a34; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.7rem; margin-top: 0.9rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 0.8rem 0.95rem; }
.stat strong { display: block; font-family: Palatino, Georgia, serif; font-size: 1.8rem; line-height: 1; }
.stat span { color: var(--muted); font-size: 0.88rem; }
.note, .timings, .distance-note, .muted, .action-status { color: var(--muted); }
.note, .timings { margin: 0.7rem 0 0; }
.map-panel, .table-panel { padding: 0.8rem; }
.map-panel { margin-top: 0.9rem; }
.summary, #routing-note, #timings, .table-panel { margin-top: 0.9rem; }
.panel-head { display: flex; justify-content: space-between; gap: 0.8rem; align-items: center; margin-bottom: 0.55rem; }
.legend { display: flex; flex-wrap: wrap; gap: 0.55rem 0.8rem; color: var(--muted); font-size: 0.82rem; }
.swatch { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; margin-right: 0.25rem; vertical-align: -1px; }
.swatch.origin { background: #e0b15a; box-shadow: 0 0 0 2px #1e3a34; }
.swatch.selected { background: var(--selected); }
.scope-box {
    display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center;
    background: #fff; border: 1px solid #d9cdb8; border-radius: 10px; padding: 0.35rem;
}
.scope-box input { border: 0; flex: 1 1 10rem; min-width: 8rem; padding: 0.35rem 0.4rem; }
.scope-box input:focus { outline: none; }
.scope-box:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.scope-heading { display: block; font-weight: 700; margin-bottom: 0.35rem; }
.scope-all { display: flex; align-items: center; gap: 0.45rem; }
.scope-all input { width: auto; }
#scope-restrict { margin-top: 0.55rem; }
.scope-tag {
    display: inline-flex; align-items: center; gap: 0.15rem; max-width: 100%;
    background: var(--chip); border-radius: 999px; padding: 0.12rem 0.2rem 0.12rem 0.6rem;
}
.scope-tag.scope-unavailable { background: #f3eee6; }
.scope-tag.scope-unavailable small { color: var(--muted); font-size: 0.75rem; padding-right: 0.25rem; }
.scope-tag span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scope-tag button, .text-button { background: transparent; border: 0; cursor: pointer; }
.scope-tag button { width: 1.4rem; height: 1.4rem; border-radius: 50%; }
.scope-tag button:hover { background: rgba(0, 0, 0, 0.06); }
.text-button { align-self: flex-start; color: var(--muted); padding: 0; text-decoration: underline; }
.scope-option small { display: block; color: var(--muted); font-size: 0.78rem; }
.field-scopes { position: relative; }
.field-scopes .suggestions { top: auto; }
#map { height: min(62vh, 640px); min-height: 360px; width: 100%; border-radius: 12px; background: #d9d3c7; }
.leaflet-container { font-family: inherit; }
.origin-pin span {
    display: block; width: 16px; height: 16px; border-radius: 50%; background: #e0b15a;
    border: 3px solid #1e3a34; box-shadow: 0 0 0 4px rgba(224, 177, 90, 0.25);
}
.distance-note { margin: 0 0 0.6rem; font-size: 0.86rem; }
.toolbar, .export-bar { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; margin-bottom: 0.55rem; }
.filter { flex: 1 1 180px; }
.filter input, #page-size { width: 100%; }
.tool-buttons, .export-bar { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.table-scroll { max-height: 640px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { padding: 0.45rem 0.55rem; text-align: left; border-bottom: 1px solid #efe6d8; white-space: nowrap; }
th { position: sticky; top: 0; background: #faf6ef; z-index: 1; }
.sort { background: transparent; border: 0; padding: 0; cursor: pointer; font-weight: 700; }
.sort[aria-sort="ascending"]::after { content: " ↑"; }
.sort[aria-sort="descending"]::after { content: " ↓"; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #fbf7f1; }
tbody tr.is-active { background: #f4e7cf; }
tbody tr.is-selected { box-shadow: inset 3px 0 0 var(--selected); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.check-col { width: 2rem; }
.empty td { color: var(--muted); white-space: normal; cursor: default; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; margin-top: 0.6rem; }
.pager label { display: flex; align-items: center; gap: 0.4rem; color: var(--muted); }
.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
footer { width: min(1440px, calc(100% - 1.5rem)); margin: 0 auto 1.5rem; color: var(--muted); font-size: 0.82rem; }
.popup p { margin: 0.15rem 0; }
.popup strong { font-size: 1rem; }

@media (max-width: 800px) {
    .search-panel { grid-template-columns: 1fr; }
    #map { height: 420px; min-height: 280px; }
    .table-scroll { max-height: none; }
}
