:root {
  --paper: #f3f0e8;
  --ink: #17181b;
  --card: #faf8f3;
  --muted: #5c6068;
  --line: #d4cfc4;
  --wash: #e6e1d4;
  --primary: #1c2128;
  --ok: #2f5d45;
  --warn: #6b4f2a;
  --bad: #8f2d20;
  --shadow: 0 0 0 1px rgba(23, 24, 27, 0.08), 0 1px 2px -1px rgba(23, 24, 27, 0.06), 0 2px 6px 0 rgba(23, 24, 27, 0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  line-height: 1.5;
}
a { color: inherit; }
h1, h2, .display {
  font-family: "Barlow Condensed", "IBM Plex Sans", sans-serif;
  letter-spacing: 0.04em;
  font-weight: 600;
  line-height: 0.95;
}
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; }
.kicker {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.wrap { max-width: 64rem; margin: 0 auto; padding: 0 1.25rem; }
header.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(243, 240, 232, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
header.top .bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
}
.mark {
  width: 2rem; height: 2rem; flex: none;
}
.brand { text-decoration: none; display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.brand strong { display: block; font-family: "Barlow Condensed", sans-serif; font-size: 1.25rem; letter-spacing: 0.14em; }
.brand span { display: none; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
@media (min-width: 640px) { .brand span { display: block; } }
nav.links { margin-left: auto; display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center; justify-content: flex-end; }
nav.links a, nav.links button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0 0.85rem;
  border-radius: 10px;
  border: 0;
  text-decoration: none;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
nav.links a:hover, .btn:hover { background: var(--wash); color: var(--ink); }
nav.links a.active { background: var(--primary); color: var(--paper); }
.btn-primary, button[type=submit].btn-primary {
  background: var(--primary);
  color: var(--paper);
}
a.btn.btn-primary:hover,
button.btn.btn-primary:hover {
    background: var(--primary);
    color: var(--paper);
    filter: brightness(1.12);
}

.fare .btn-primary {
    gap: 0.45rem;
}

    .fare .btn-primary::after {
        content: "";
        width: 0.45rem;
        height: 0.45rem;
        border-top: 2px solid currentColor;
        border-right: 2px solid currentColor;
        transform: rotate(45deg);
        flex: none;
    }
.btn-outline {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
.who { font-size: 0.85rem; max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { padding: 1.5rem 0 3rem; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.4rem); max-width: none; margin: 0.4rem 0 0.75rem; }
.hero p.lede { max-width: none; color: var(--muted); margin: 0 0 1.25rem; }
.hero {
    margin-top: 1.5rem;
}
.pair {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

    .pair .end {
        display: grid;
        grid-template-columns: auto auto;
        column-gap: 0.45rem;
        row-gap: 0.15rem;
        align-items: center;
        flex: none;
    }

        .pair .end .code {
            grid-column: 2;
        }

        .pair .end .place {
            grid-column: 1 / -1;
            font-family: "IBM Plex Sans", ui-sans-serif, sans-serif;
            font-size: 0.75rem;
            letter-spacing: 0;
            color: var(--muted);
        }

        .pair .end.dest {
            text-align: right;
        }

            .pair .end.dest .code {
                grid-column: 1;
            }

            .pair .end.dest .dot {
                grid-column: 2;
            }

    .pair .dot {
        width: 0.55rem;
        height: 0.55rem;
        border-radius: 999px;
        background: var(--ink);
    }

    .pair .track {
        position: relative;
        flex: 1;
        min-width: 3.5rem;
        height: 1px;
        background: var(--ink);
    }

        .pair .track .km {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            background: var(--card);
            padding: 0 0.45rem;
            white-space: nowrap;
        }
.page-center {
    min-height: calc(100vh - 120px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding-top: 1.5rem;
}
    .page-center.stack {
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        padding-top: 1.5rem;
    }

        .page-center.stack > .card {
            width: min(40rem, 100%);
            max-width: 40rem;
        }

.book-card {
    width: min(36rem, 100%);
    margin: 3rem auto 0;
    max-width: 36rem;
    min-width: 0;
}
.code { font-size: 1.4rem; }

.km { font-size: 0.8rem; color: var(--muted); letter-spacing: 0.16em; }

.stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem;
  margin: 1.25rem 0 1.5rem;
}
.stats-4 { grid-template-columns: 1fr 1fr; }
@media (min-width: 640px) {
  .stats, .stats-4 { grid-template-columns: repeat(4, 1fr); }
}
.stats div { background: var(--card); padding: 0.85rem 1rem; border-radius: 12px; box-shadow: var(--shadow); }
.stats dt { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.stats dd { margin: 0.2rem 0 0; font-size: 1.25rem; font-weight: 600; }
.filters {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    background: var(--card);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 1rem;
}

@media (min-width: 800px) {
  .filters {
    grid-template-columns: 1.4fr 1.6fr 1fr;
    align-items: start;
  }
  .equip-field, .sort-field { grid-column: 1 / -1; }
}




label.field {
  display: grid;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}


input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  min-height: 3.5rem;
  width: 100%;
}
textarea { min-height: 5rem; }
.seg {
  display: flex;
  align-items: stretch;
  min-height: 3.5rem;
  padding: 4px;
  background: var(--wash);
  border-radius: 10px;
}
.seg button, .seg a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(3.5rem - 8px);
  border: 0;
  background: transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
}
.seg .on {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.seg.wrap {
  flex-wrap: wrap;
  gap: 0.25rem;
  min-height: auto;
  width: 100%;
  justify-content: flex-start;
}
@media (max-width: 799px) {
  .seg.wrap a { flex: 1 1 100%; }
}
.equip-counts { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.75rem; }
.extra-presets { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.35rem 0 0.75rem; }
.extra-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 7rem auto;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

    .extra-row .extra-name,
    .extra-row .extra-rand {
        width: 100%;
        min-width: 0;
        min-height: 2.75rem;
    }

    .extra-row .extra-remove {
        width: 2.75rem;
        min-width: 2.75rem;
        height: 2.75rem;
        min-height: 2.75rem;
        padding: 0;
    }

.extra-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.extra-row input, .extra-row button { min-height: 2.75rem; }
.extra-pick {
  display: flex; align-items: center; gap: 0.75rem; min-height: 2.75rem;
  border: 1px solid var(--line); border-radius: 10px; padding: 0.55rem 0.75rem;
  margin: 0 0 0.5rem; background: var(--card); cursor: pointer;
}
.extra-pick.on { background: var(--wash); }
.extra-pick span:nth-of-type(1) { flex: 1; font-weight: 500; }
.terms { border: 1px solid var(--line); border-radius: 10px; background: var(--card); margin: 0.75rem 0 0.35rem; }
    .terms summary {
        min-height: 2.75rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0 0.85rem;
        cursor: pointer;
        font-weight: 600;
        list-style: none;
    }

        .terms summary::-webkit-details-marker {
            display: none;
        }

        .terms summary::after {
            content: "";
            flex: none;
            width: 0.45rem;
            height: 0.45rem;
            margin-right: 0.15rem;
            border-right: 2px solid currentColor;
            border-bottom: 2px solid currentColor;
            transform: rotate(45deg) translateY(-2px);
            transition: transform 0.15s ease;
        }

    .terms[open] summary::after {
        transform: rotate(225deg) translateY(-2px);
    }
.terms-body {
  white-space: pre-wrap; background: var(--wash); margin: 0 0.75rem 0.75rem;
  border-radius: 8px; padding: 0.75rem 0.9rem; max-height: 12rem; overflow: auto;
}

.ticket {
  display: grid;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1rem;
}
@media (min-width: 640px) {
  .ticket { grid-template-columns: 8.75rem minmax(0, 1fr) 10.5rem; }
}
.stub {
  background: var(--wash);
  color: var(--ink);
  padding: 0.9rem 0.75rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  overflow: hidden;
  border-bottom: 1px dashed var(--line);
}
@media (min-width: 640px) {
  .stub { border-bottom: 0; border-right: 1px dashed var(--line); }
}
.stub .svc {
  font-family: "Barlow Condensed", "IBM Plex Sans", sans-serif;
  font-size: 1.15rem;
  letter-spacing: 0.14em;
  margin: 0;
  font-weight: 600;
}
.stub .dir {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  overflow-wrap: anywhere;
  margin: 0.5rem 0 0;
}
.body { padding: 1rem 1.1rem; min-width: 0; }
.body h3 { margin: 0 0 0.35rem; font-size: 1.35rem; }
.ticket-top { display: flex; justify-content: space-between; gap: 0.75rem; align-items: flex-start; }
.fare {
  padding: 1rem 1.1rem;
  text-align: right;
  background: rgba(230, 225, 212, 0.55);
  border-top: 1px dashed var(--line);
}
@media (min-width: 640px) {
  .fare { border-top: 0; border-left: 1px dashed var(--line); }
}
.fare-amt {
  font-family: "Barlow Condensed", "IBM Plex Sans", sans-serif;
  font-size: 1.85rem;
  letter-spacing: 0.04em;
  margin: 0.2rem 0 0.15rem;
  font-weight: 600;
}
.fare-callout {
    background: var(--wash);
    border-radius: 20px;
    padding: 1.5rem;
    margin: 1rem 0 2rem;
}
    .fare-callout .fare-amt {
        font-size: 3rem;
    }
.mobile-only { margin-top: 0.85rem; }
.desktop-only { display: none; }
@media (min-width: 640px) {
  .mobile-only { display: none; }
  .desktop-only { display: flex; }
}
.price-modes {
  display: grid;
  gap: 0.5rem;
  margin: 0.4rem 0 1rem;
}
@media (min-width: 640px) {
  .price-modes { grid-template-columns: 1fr 1fr 1fr; }
}
.price-modes .mode {
  text-align: left;
  background: var(--wash);
  color: var(--ink);
  border: 0;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  cursor: pointer;
  font: inherit;
  box-shadow: var(--shadow);
}
.price-modes .mode span { display: block; margin-top: 0.25rem; font-size: 0.75rem; color: var(--muted); }
.price-modes .mode.on { background: var(--primary); color: var(--paper); }
.price-modes .mode.on span { color: rgba(243, 240, 232, 0.8); }
.meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1rem; font-size: 0.9rem; }
.meta dt { color: var(--muted); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; }
.meta dd { margin: 0.1rem 0 0; }
.open { color: var(--ok); font-weight: 600; }
.limited { color: var(--warn); font-weight: 600; }
.full { color: var(--bad); font-weight: 600; }
.actions { margin-top: 0.85rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }


input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
select,
textarea {
    /* existing text-field styles */
}


.extra-pick .extra-check {
    width: 1.15rem;
    height: 1.15rem;
    min-width: 1.15rem;
    min-height: 1.15rem;
    max-width: 1.15rem;
    flex: 0 0 1.15rem;
    margin: 0;
    padding: 0;
}

.extra-pick .extra-name {
    flex: 1;
    min-width: 0;
    font-weight: 500;
}

.extra-pick .extra-price {
    margin-left: auto;
    white-space: nowrap;
    font-weight: 600;
}


.card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.flash {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  background: var(--wash);
}
.flash.error { background: #f3e2de; color: var(--bad); }
.grid-2 { display: grid; gap: 0.85rem; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.tabs { display: flex; background: var(--wash); padding: 4px; border-radius: 10px; margin-bottom: 1rem; }
.tabs a { flex: 1; text-align: center; padding: 0.5rem; border-radius: 8px; text-decoration: none; color: var(--muted); }
.tabs a.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); padding: 0.5rem 0.5rem 0.5rem 0; border-bottom: 1px solid var(--line); }
td { padding: 0.7rem 0.5rem 0.7rem 0; border-bottom: 1px solid rgba(212, 207, 196, 0.7); }
.val-err { color: var(--bad); font-size: 0.85rem; margin: 0 0 0.75rem; }
.qr { width: 8.5rem; height: 8.5rem; background: var(--wash); padding: 0.5rem; border-radius: 10px; }
.qr img { width: 100%; height: 100%; display: block; }
.ref { font-size: 1.6rem; letter-spacing: 0.08em; margin: 0.2rem 0 0; }
.foot { color: var(--muted); font-size: 0.8rem; }
.banner {
  background: var(--wash);
  text-align: center;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--line);
}

@media print {
  header.top, .no-print, .banner { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid var(--line); }
}

.wagon-list-scroll {
  overflow-x: auto;
  overflow-y: scroll;
  max-height: 24rem;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #5c6068 #e6e1d4;
}
.wagon-list-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.wagon-list-scroll::-webkit-scrollbar-track { background: #e6e1d4; border-radius: 999px; }
.wagon-list-scroll::-webkit-scrollbar-thumb { background: #5c6068; border-radius: 999px; }
.wagon-list-scroll th { position: sticky; top: 0; background: var(--card); }
