:root {
    --page-bg: #f5f7fb;
    --panel-bg: #ffffff;
    --text: #172033;
    --muted: #5c667a;
    --line: #dfe5ef;
    --brand: #0b4e8a;
    --brand-dark: #07365f;
    --shadow: 0 8px 24px rgba(23, 32, 51, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--page-bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
}

.app-shell {
    min-height: 100vh;
}

.top-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
    height: 42px;
    padding: 0 0.75rem;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 8px rgba(23, 32, 51, 0.05);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
    color: var(--brand-dark);
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.brand img {
    display: block;
    height: 24px;
    width: auto;
}

.page-title {
    overflow: hidden;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-nav {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}


.top-guid-loader {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0 0.15rem 0 0;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.top-guid-loader input {
    width: 13rem;
    height: 1.55rem;
    min-height: 1.55rem;
    padding: 0.12rem 0.35rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 0.74rem;
}

@media (max-width: 900px) {
    .top-guid-loader span { display: none; }
    .top-guid-loader input { width: 8rem; }
}

.top-nav a {
    border-radius: 999px;
    padding: 0.25rem 0.6rem;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
}

.top-nav a.active,
.top-nav a:hover {
    background: #eaf2fb;
    color: var(--brand-dark);
}

.page-content {
    width: min(1180px, calc(100% - 2rem));
    margin: 1rem auto 2rem;
}

h1 {
    margin: 0 0 0.75rem;
    font-size: 1.45rem;
}

h2 {
    margin: 0 0 0.45rem;
    font-size: 1rem;
}

p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel-bg);
    box-shadow: var(--shadow);
    padding: 1rem;
}

.hero-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.two-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.login-card {
    width: 420px;
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel-bg);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.login-logo {
    display: block;
    width: min(230px, 80%);
    height: auto;
    margin: 0 auto 1.2rem;
}

.login-heading {
    display: grid;
    gap: 0.35rem;
    margin-bottom: 1rem;
    text-align: center;
}

.login-heading h1 {
    margin: 0;
}

.login-form {
    display: grid;
    gap: 0.85rem;
}

label {
    display: grid;
    gap: 0.3rem;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
}

input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
    color: var(--text);
    font: inherit;
}

input:focus {
    border-color: var(--brand);
    outline: 3px solid rgba(11, 78, 138, 0.15);
}

.button-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 10px;
    background: var(--brand);
    color: white;
    cursor: pointer;
    font-weight: 700;
    padding: 0.55rem 0.85rem;
    text-decoration: none;
}

.button-primary:hover {
    background: var(--brand-dark);
}

.form-message {
    border-radius: 10px;
    background: #eef5ff;
    color: var(--brand-dark);
    padding: 0.65rem 0.75rem;
}

@media (max-width: 720px) {
    .top-bar {
        grid-template-columns: auto 1fr;
        height: auto;
        min-height: 42px;
        padding-block: 0.35rem;
    }

    .top-nav {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }

    .hero-panel,
    .two-column {
        display: grid;
        grid-template-columns: 1fr;
    }
}

.form-message.success {
    color: #146c2e;
}

.form-message.error {
    color: #b42318;
}

.token-pill {
    display: inline-flex;
    align-items: center;
    min-height: 1.35rem;
    padding: 0 0.45rem;
    border: 1px solid #d4d4d8;
    border-radius: 999px;
    font-size: 0.72rem;
    color: #374151;
    background: #f8fafc;
    white-space: nowrap;
}

.status-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.45rem 1rem;
    margin: 0;
}

.status-list dt {
    font-weight: 700;
    color: #374151;
}

.status-list dd {
    margin: 0;
    color: #111827;
    word-break: break-word;
}

.phase-list {
    margin: 0;
    padding-left: 1.1rem;
}

.phase-list li + li {
    margin-top: 0.65rem;
}

.compact-card {
    text-align: center;
}

button:disabled,
input:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.button-row,
.panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.button-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: white;
    color: var(--brand-dark);
    cursor: pointer;
    font-weight: 700;
    padding: 0.55rem 0.85rem;
    text-decoration: none;
}

.button-secondary:hover {
    background: #eef5ff;
}

.phase-panel {
    margin-top: 1rem;
}

/* Phase 5 search form */
.compact-hero {
    margin-bottom: 1rem;
}

.warning-panel {
    margin-bottom: 1rem;
    background: #fff7ed;
}

.search-layout {
    grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
    align-items: start;
}

.search-form-panel,
.json-preview-panel {
    display: grid;
    gap: 0.9rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.dense-form-grid {
    gap: 0.55rem 0.75rem;
}

.form-control,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.5rem 0.65rem;
    color: var(--text);
    background: #fff;
    font: inherit;
}

.form-control:focus,
select:focus,
textarea:focus {
    border-color: var(--brand);
    outline: 3px solid rgba(11, 78, 138, 0.15);
}

label small,
.muted {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 500;
}

details {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.7rem;
    background: #fbfdff;
}

summary {
    cursor: pointer;
    font-weight: 800;
    color: var(--brand-dark);
}

details[open] summary {
    margin-bottom: 0.75rem;
}

.full-width-field {
    margin-top: 0.7rem;
}

.mono-textarea,
.json-preview {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.82rem;
}

.json-preview {
    min-height: 42rem;
    resize: vertical;
    white-space: pre;
}

@media (max-width: 980px) {
    .search-layout,
    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* Wider-screen responsive layout refinements */
@media (min-width: 1200px) {
    .page-content {
        width: calc(100% - 3rem);
        max-width: none;
    }

    .search-layout {
        grid-template-columns: minmax(760px, 1fr) minmax(420px, 32vw);
        gap: 1rem;
    }

    .form-grid {
        grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    }

    .json-preview-panel {
        position: sticky;
        top: 58px;
    }

    .json-preview {
        min-height: calc(100vh - 260px);
    }
}

@media (min-width: 1600px) {
    .page-content {
        width: calc(100% - 4rem);
    }

    .search-layout {
        grid-template-columns: minmax(980px, 1fr) minmax(520px, 30vw);
        gap: 1.25rem;
    }

    .form-grid {
        grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
    }

    .panel {
        padding: 1.15rem;
    }
}

@media (min-width: 2100px) {
    .search-layout {
        grid-template-columns: minmax(1300px, 1fr) minmax(640px, 28vw);
    }

    .form-grid {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    }
}

/* Phase 5 compact aligned form refinements */
.page-content {
    width: calc(100% - 1.5rem);
    margin: 0.6rem auto 1rem;
}

h1 {
    margin-bottom: 0.45rem;
    font-size: 1.35rem;
}

.panel {
    border-radius: 12px;
    padding: 0.75rem;
}

.hero-panel {
    margin-bottom: 0.7rem;
}

.search-layout {
    gap: 0.7rem;
}

.search-form-panel,
.json-preview-panel {
    gap: 0.6rem;
}

.form-grid {
    gap: 0.45rem 0.6rem;
}

.core-journey-grid {
    grid-template-columns: repeat(6, minmax(130px, 1fr));
    align-items: start;
}

.core-journey-grid > label {
    grid-template-rows: 1rem 2.05rem 0.8rem;
    gap: 0.18rem;
    min-width: 0;
}

.dense-form-grid > label {
    gap: 0.18rem;
}

label {
    font-size: 0.78rem;
}

label small,
.muted {
    font-size: 0.68rem;
    line-height: 1.15;
}

.form-control,
select,
textarea,
input {
    min-height: 2.05rem;
    border-radius: 7px;
    padding: 0.34rem 0.45rem;
    font-size: 0.82rem;
}

.button-primary,
.button-secondary {
    border-radius: 7px;
    padding: 0.42rem 0.7rem;
    font-size: 0.82rem;
}

details {
    border-radius: 9px;
    padding: 0.45rem;
}

details[open] summary {
    margin-bottom: 0.5rem;
}

.full-width-field {
    margin-top: 0.45rem;
}

.mono-textarea,
.json-preview {
    font-size: 0.74rem;
}

@media (min-width: 1200px) {
    .page-content {
        width: calc(100% - 1.5rem);
    }

    .search-layout {
        grid-template-columns: minmax(760px, 1fr) minmax(360px, 30vw);
        gap: 0.7rem;
    }

    .form-grid {
        grid-template-columns: repeat(4, minmax(165px, 1fr));
    }

    .core-journey-grid {
        grid-template-columns: repeat(6, minmax(130px, 1fr));
    }

    .panel {
        padding: 0.75rem;
    }
}

@media (min-width: 1600px) {
    .page-content {
        width: calc(100% - 2rem);
    }

    .search-layout {
        grid-template-columns: minmax(980px, 1fr) minmax(350px, 20vw);
        gap: 0.8rem;
    }

    .form-grid {
        grid-template-columns: repeat(4, minmax(210px, 1fr));
    }

    .core-journey-grid {
        grid-template-columns: repeat(6, minmax(160px, 1fr));
    }
}

@media (max-width: 1199px) {
    .core-journey-grid {
        grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    }
}

.station-autocomplete {
    position: relative;
    width: 100%;
}

.station-suggestion-list {
    position: absolute;
    z-index: 50;
    left: 0;
    right: 0;
    top: calc(100% + 2px);
    max-height: 260px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #cfd8e3;
    border-radius: 0.45rem;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
    padding: 0.2rem;
}

.station-suggestion {
    display: block;
    box-sizing: border-box;
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    padding: 0.35rem 0.45rem;
    border-radius: 0.3rem;
    cursor: pointer;
    font: inherit;
    line-height: 1.2;
}

.station-suggestion:hover,
.station-suggestion.is-selected {
    background: #dbeafe;
}

.station-suggestion.is-selected {
    outline: 1px solid #2563eb;
}

.station-suggestion-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.station-suggestion-meta {
    color: #52627a;
    font-size: 0.8rem;
    white-space: nowrap;
}

.core-journey-grid .station-autocomplete {
    height: 2.05rem;
}

/* Compact core journey cleanup */
.core-journey-grid {
    gap: 0.32rem 0.6rem;
}

.core-journey-grid > label {
    grid-template-rows: 1rem 2.05rem;
    gap: 0.12rem;
}

.return-journey-heading {
    margin: 0.05rem 0 0;
    padding: 0;
    font-size: 0.78rem;
    line-height: 1;
    font-weight: 800;
    color: var(--text);
}

.return-journey-grid {
    margin-top: -0.05rem;
}

.search-page-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin: 0 0 0.45rem;
}

/* Compact passenger/fare controls */
.compact-control-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    align-content: flex-start;
    gap: 0.28rem 0.42rem;
    width: 100%;
    max-width: 100%;
}

.compact-control-grid > label {
    display: grid;
    grid-template-rows: 0.9rem 1.75rem;
    gap: 0.08rem;
    align-items: end;
    flex: 0 0 auto;
    min-width: 0;
    margin: 0;
}

.compact-control-grid .form-control,
.compact-control-grid select,
.compact-control-grid input {
    min-height: 1.75rem;
    height: 1.75rem;
    padding: 0.18rem 0.32rem;
    border-radius: 5px;
    font-size: 0.78rem;
}

.compact-control-grid .field-numeric-small { width: 3.3rem; }
.compact-control-grid .field-numeric-searchtype { width: 4.4rem; }
.compact-control-grid .field-numeric-layover { width: 5.6rem; }
.compact-control-grid .field-numeric-commission { width: 5.1rem; }
.compact-control-grid .field-wide { width: 15rem; }
.compact-control-grid .field-dropdown-advance { width: 10.8rem; }
.compact-control-grid .field-dropdown-availability { width: 13.2rem; }

.compact-number {
    text-align: right;
}

.checkbox-field {
    display: grid;
    grid-template-rows: 0.9rem 1.75rem;
    gap: 0.08rem;
    align-items: end;
    width: 5.6rem;
    white-space: nowrap;
    min-height: 0;
    padding: 0;
    margin: 0;
    flex: 0 0 auto;
}

.checkbox-field span {
    line-height: 0.9rem;
}

.checkbox-field .compact-checkbox,
.checkbox-field input[type="checkbox"] {
    width: 0.95rem;
    height: 0.95rem;
    min-height: 0;
    margin: 0.35rem 0 0.15rem 0;
    padding: 0;
    justify-self: start;
    accent-color: #075a9c;
}


/* Dense non-Bootstrap layout for passengers/fares block.
   Uses fixed intrinsic widths and flex-wrap to minimise vertical space. */
.passenger-flex-section {
    display: flex !important;
    flex-flow: row wrap !important;
    align-items: flex-end !important;
    align-content: flex-start !important;
    gap: 0.28rem 0.45rem !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.passenger-flex-section .pf-field {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.08rem !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
    min-width: 0 !important;
    margin: 0 !important;
}

.passenger-flex-section label,
.passenger-flex-section .pf-field > label {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1rem !important;
    font-size: 0.74rem !important;
    font-weight: 700 !important;
    color: var(--text) !important;
    white-space: nowrap !important;
}

.passenger-flex-section .pf-control,
.passenger-flex-section input,
.passenger-flex-section select {
    box-sizing: border-box !important;
    width: 100% !important;
    height: 1.75rem !important;
    min-height: 1.75rem !important;
    max-height: 1.75rem !important;
    margin: 0 !important;
    padding: 0.18rem 0.32rem !important;
    border: 1px solid var(--line) !important;
    border-radius: 5px !important;
    background: #fff !important;
    color: var(--text) !important;
    font: inherit !important;
    font-size: 0.78rem !important;
}

.passenger-flex-section .pf-number {
    text-align: right !important;
}

.passenger-flex-section .pf-num1 { width: 3.2rem !important; }
.passenger-flex-section .pf-railcard { width: 13rem !important; }
.passenger-flex-section .pf-advload { width: 8rem !important; }
.passenger-flex-section .pf-advavail { width: 8rem !important; }
.passenger-flex-section .pf-searchtype { width: 4.5rem !important; }
.passenger-flex-section .pf-layover { width: 5.8rem !important; }
.passenger-flex-section .pf-commission { width: 5.4rem !important; }

.passenger-flex-section .pf-checkbox {
    display: inline-flex !important;
    flex: 0 0 auto !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.25rem !important;
    width: auto !important;
    min-width: 5.2rem !important;
    height: 1.75rem !important;
    margin: 1rem 0 0 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
}

.passenger-flex-section .pf-checkbox input[type="checkbox"] {
    width: 0.95rem !important;
    height: 0.95rem !important;
    min-width: 0.95rem !important;
    min-height: 0.95rem !important;
    max-width: 0.95rem !important;
    max-height: 0.95rem !important;
    margin: 0 !important;
    padding: 0 !important;
    accent-color: #075a9c !important;
}

.passenger-flex-section .pf-checkbox span {
    font-size: 0.74rem !important;
    font-weight: 700 !important;
}


/* Cache-busted dense passenger/fare layout override.
   Keep this at the end of the file so it wins over generic label/input rules. */
.passenger-flex-section {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: flex-end !important;
    align-content: flex-start !important;
    gap: 0.25rem 0.45rem !important;
    width: 100% !important;
    max-width: 100% !important;
}

.passenger-flex-section > .pf-field,
.passenger-flex-section > .pf-checkbox {
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    margin: 0 !important;
}

.passenger-flex-section > .pf-field {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.08rem !important;
}

.passenger-flex-section > .pf-num1 { flex: 0 0 3.4rem !important; width: 3.4rem !important; max-width: 3.4rem !important; }
.passenger-flex-section > .pf-railcard { flex: 0 0 13rem !important; width: 13rem !important; max-width: 13rem !important; }
.passenger-flex-section > .pf-advload { flex: 0 0 8rem !important; width: 8rem !important; max-width: 8rem !important; }
.passenger-flex-section > .pf-advavail { flex: 0 0 8rem !important; width: 8rem !important; max-width: 8rem !important; }
.passenger-flex-section > .pf-searchtype { flex: 0 0 7.2rem !important; width: 7.2rem !important; max-width: 7.2rem !important; }
.passenger-flex-section > .pf-searchcustom { flex: 0 0 6.2rem !important; width: 6.2rem !important; max-width: 6.2rem !important; }
.passenger-flex-section > .pf-layover { flex: 0 0 5.9rem !important; width: 5.9rem !important; max-width: 5.9rem !important; }
.passenger-flex-section > .pf-commission { flex: 0 0 5.6rem !important; width: 5.6rem !important; max-width: 5.6rem !important; }

.passenger-flex-section > .pf-field > label {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 0.74rem !important;
    line-height: 0.95rem !important;
    white-space: nowrap !important;
}

.passenger-flex-section .pf-control,
.passenger-flex-section > .pf-field > input,
.passenger-flex-section > .pf-field > select {
    width: 100% !important;
    min-width: 0 !important;
    height: 1.75rem !important;
    min-height: 1.75rem !important;
    max-height: 1.75rem !important;
    padding: 0.18rem 0.32rem !important;
    border-radius: 5px !important;
    font-size: 0.78rem !important;
}

.passenger-flex-section > .pf-checkbox {
    display: inline-flex !important;
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
    min-width: 6.2rem !important;
    height: 1.75rem !important;
    align-items: center !important;
    gap: 0.3rem !important;
    padding: 0 !important;
    white-space: nowrap !important;
}

.passenger-flex-section > .pf-checkbox input[type=checkbox] {
    width: 0.95rem !important;
    height: 0.95rem !important;
    min-width: 0.95rem !important;
    min-height: 0.95rem !important;
    max-width: 0.95rem !important;
    max-height: 0.95rem !important;
    margin: 0 !important;
    padding: 0 !important;
}

.passenger-flex-section > .pf-checkbox span {
    display: inline !important;
    font-size: 0.74rem !important;
    line-height: 1 !important;
}


/* Dense flex layout for outbound/return advanced journey filter panels.
   Deliberately avoids Bootstrap/grid sizing so controls use only the space they need. */
.journey-filter-flex-section {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: flex-end !important;
    align-content: flex-start !important;
    gap: 0.25rem 0.45rem !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.journey-filter-flex-section > .jf-field {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.08rem !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.journey-filter-flex-section > .jf-field > label {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 0.74rem !important;
    font-weight: 700 !important;
    line-height: 0.95rem !important;
    color: var(--text) !important;
    white-space: nowrap !important;
}

.journey-filter-flex-section .jf-control {
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 1.75rem !important;
    min-height: 1.75rem !important;
    max-height: 1.75rem !important;
    margin: 0 !important;
    padding: 0.18rem 0.32rem !important;
    border: 1px solid var(--line) !important;
    border-radius: 5px !important;
    background: #fff !important;
    color: var(--text) !important;
    font: inherit !important;
    font-size: 0.78rem !important;
}

.journey-filter-flex-section > .jf-small { flex: 0 0 5.5rem !important; width: 5.5rem !important; max-width: 5.5rem !important; }
.journey-filter-flex-section > .jf-tocs { flex: 0 0 8rem !important; width: 8rem !important; max-width: 8rem !important; }
.journey-filter-flex-section > .jf-uics { flex: 0 0 12rem !important; width: 12rem !important; max-width: 12rem !important; }
.journey-filter-flex-section > .jf-process-order { flex: 0 0 6.5rem !important; width: 6.5rem !important; max-width: 6.5rem !important; }
.journey-filter-flex-section > .jf-uic-single { flex: 0 0 8rem !important; width: 8rem !important; max-width: 8rem !important; }
.journey-filter-flex-section > .jf-medium { flex: 0 0 12rem !important; width: 12rem !important; max-width: 12rem !important; }
.journey-filter-flex-section > .jf-trainuids { flex: 0 0 14rem !important; width: 14rem !important; max-width: 14rem !important; }
.journey-filter-flex-section > .jf-mode { flex: 0 0 7rem !important; width: 7rem !important; max-width: 7rem !important; }

/* Typed controls for outbound/return advanced journey filters. */
.journey-filter-flex-section > .jf-extra-time {
    flex: 0 0 6.7rem !important;
    width: 6.7rem !important;
    max-width: 6.7rem !important;
}

.journey-filter-flex-section > .jf-maxchanges {
    flex: 0 0 5.2rem !important;
    width: 5.2rem !important;
    max-width: 5.2rem !important;
}

.journey-filter-flex-section > .jf-checkbox {
    display: flex !important;
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
    flex-direction: row !important;
    align-items: center !important;
    align-self: flex-end !important;
    gap: 0.25rem !important;
    height: 1.75rem !important;
    min-height: 1.75rem !important;
    margin: 0 !important;
    padding: 0 !important;
    white-space: nowrap !important;
    font-size: 0.74rem !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    color: var(--text) !important;
}

.journey-filter-flex-section > .jf-checkbox input[type=checkbox] {
    width: 0.95rem !important;
    height: 0.95rem !important;
    min-width: 0.95rem !important;
    min-height: 0.95rem !important;
    max-width: 0.95rem !important;
    max-height: 0.95rem !important;
    margin: 0 !important;
    padding: 0 !important;
}

.journey-filter-flex-section > .jf-checkbox span {
    display: inline !important;
    font-size: 0.74rem !important;
    line-height: 1 !important;
}

.journey-filter-flex-section > .jf-mode {
    flex: 0 0 5.2rem !important;
    width: 5.2rem !important;
    max-width: 5.2rem !important;
}


.travel-mode-subtitle {
    display: block !important;
    font-size: 0.82rem !important;
    font-weight: 600 !important;
    line-height: 1.1 !important;
    margin: 0.15rem 0 0.05rem 0 !important;
    padding: 0 !important;
    color: #0f2742 !important;
}

/* Dense travel-mode checkbox layout. Keep this separate from Bootstrap/grid helpers so the test form stays compact. */
.travel-mode-flex-section {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 0.35rem 0.75rem !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 0 0.25rem 0 !important;
}

.travel-mode-flex-section > .tm-checkbox {
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.25rem !important;
    min-height: 1.35rem !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 0.82rem !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    color: #0f2742 !important;
}

.travel-mode-flex-section > .tm-checkbox input[type=checkbox] {
    width: 0.95rem !important;
    height: 0.95rem !important;
    min-width: 0.95rem !important;
    margin: 0 !important;
    padding: 0 !important;
    accent-color: #0f5ca8;
}

.travel-mode-flex-section > .tm-checkbox span {
    display: inline-block !important;
    line-height: 1.1 !important;
}

.travel-mode-flex-section > .tm-wide {
    flex: 0 0 auto !important;
}

/* Dense flex layout for top-level advanced parameters. */
.top-advanced-flex-section {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: flex-end !important;
    align-content: flex-start !important;
    gap: 0.25rem 0.45rem !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.top-advanced-flex-section > .ta-field {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.08rem !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.top-advanced-flex-section > .ta-field > label {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 0.74rem !important;
    font-weight: 700 !important;
    line-height: 0.95rem !important;
    color: var(--text) !important;
    white-space: nowrap !important;
}

.top-advanced-flex-section .ta-control {
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 1.75rem !important;
    min-height: 1.75rem !important;
    max-height: 1.75rem !important;
    margin: 0 !important;
    padding: 0.18rem 0.32rem !important;
    border: 1px solid var(--line) !important;
    border-radius: 5px !important;
    background: #fff !important;
    color: var(--text) !important;
    font: inherit !important;
    font-size: 0.78rem !important;
}

.top-advanced-flex-section > .ta-checkbox {
    display: flex !important;
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
    flex-direction: row !important;
    align-items: center !important;
    align-self: flex-end !important;
    gap: 0.25rem !important;
    height: 1.75rem !important;
    min-height: 1.75rem !important;
    margin: 0 !important;
    padding: 0 !important;
    white-space: nowrap !important;
    font-size: 0.74rem !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    color: var(--text) !important;
}

.top-advanced-flex-section > .ta-checkbox input[type=checkbox] {
    width: 0.95rem !important;
    height: 0.95rem !important;
    min-width: 0.95rem !important;
    min-height: 0.95rem !important;
    max-width: 0.95rem !important;
    max-height: 0.95rem !important;
    margin: 0 !important;
    padding: 0 !important;
}

.top-advanced-flex-section > .ta-checkbox span {
    display: inline !important;
    font-size: 0.74rem !important;
    line-height: 1 !important;
}

.top-advanced-flex-section > .ta-merge { flex: 0 0 14rem !important; width: 14rem !important; max-width: 14rem !important; }
.top-advanced-flex-section > .ta-zone { flex: 0 0 4.5rem !important; width: 4.5rem !important; max-width: 4.5rem !important; }
.top-advanced-flex-section > .ta-travelcard { flex: 0 0 11.5rem !important; width: 11.5rem !important; max-width: 11.5rem !important; }
.top-advanced-flex-section > .ta-int { flex: 0 0 6.5rem !important; width: 6.5rem !important; max-width: 6.5rem !important; }
.top-advanced-flex-section > .ta-mandatory { flex: 0 0 11rem !important; width: 11rem !important; max-width: 11rem !important; }
.top-advanced-flex-section > .ta-datetime { flex: 0 0 12rem !important; width: 12rem !important; max-width: 12rem !important; }
.top-advanced-flex-section > .ta-guid { flex: 0 0 12rem !important; width: 12rem !important; max-width: 12rem !important; }
.top-advanced-flex-section > .ta-percent { flex: 0 0 6.7rem !important; width: 6.7rem !important; max-width: 6.7rem !important; }
.top-advanced-flex-section > .ta-customfare { flex: 0 0 12rem !important; width: 12rem !important; max-width: 12rem !important; }
.top-advanced-flex-section > .ta-plannerrefs { flex: 0 0 18rem !important; width: 18rem !important; max-width: 18rem !important; }

/* Availability-card controls moved out of passengers/fares. */
.top-advanced-flex-section > .ta-advload { flex: 0 0 8rem !important; width: 8rem !important; max-width: 8rem !important; }
.top-advanced-flex-section > .ta-advavail { flex: 0 0 8rem !important; width: 8rem !important; max-width: 8rem !important; }


.dismissible-panel{
    display:flex;
    justify-content:space-between;
    align-items:center;
}
.dismiss-button{
    border:none;
    background:transparent;
    cursor:pointer;
    font-size:1.2rem;
    line-height:1;
    padding:0 .25rem;
    color:inherit;
}

.json-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.json-preview-header h2 {
    margin: 0;
}

.json-preview-header .button-primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.journey-planner-result-box {
    display: grid;
    gap: 0.6rem;
    margin-top: 0.4rem;
}

.journey-planner-result-preview {
    min-height: 52rem;
}

.existing-search-panel {
    margin-bottom: 1rem;
}

.existing-search-row {
    display: flex;
    align-items: end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.existing-search-guid {
    flex: 1 1 24rem;
    max-width: 42rem;
}

.result-summary-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.85rem;
    background: #fbfdff;
    display: grid;
    gap: 0.75rem;
}

.result-summary-card h2 {
    margin: 0;
    font-size: 1rem;
    color: var(--brand-dark);
}

.result-count-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.result-count-tile {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.8rem;
    background: #fff;
    display: grid;
    gap: 0.25rem;
}

.result-count-label {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.result-count-tile strong {
    font-size: 1.6rem;
    line-height: 1;
    color: var(--brand-dark);
}

.result-summary-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.result-guid-link {
    font-size: 0.85rem;
    font-weight: 700;
}

.result-meta-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem 0.9rem;
    font-size: 0.85rem;
    color: var(--text);
}

.result-meta-wide {
    grid-column: span 2;
}

.journey-results-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.journey-results-table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.journey-results-table th,
.journey-results-table td {
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    text-align: left;
}

.journey-results-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f6f9fd;
    color: var(--brand-dark);
    font-weight: 800;
    white-space: nowrap;
}

.journey-result-row:hover {
    background: #f8fbff;
}

.journey-flags {
    white-space: nowrap;
    font-weight: 800;
    color: var(--brand-dark);
}

.fare-cell {
    min-width: 4.75rem;
    text-align: right;
    white-space: nowrap;
    border-left: 1px solid #edf2f7;
    font-weight: 800;
}

.fare-none {
    color: var(--muted);
    background: #f8fafc;
}

.fare-best {
    background: #d8f5d2;
}

.fare-good {
    background: #ebf8d9;
}

.fare-mid {
    background: #fff1c7;
}

.fare-high {
    background: #ffe0d6;
}

.journey-itinerary {
    min-width: 34rem;
    line-height: 1.35;
}

.journey-itinerary a {
    text-decoration: none;
}

.journey-itinerary a:hover {
    text-decoration: underline;
}

.journey-direction {
    font-weight: 800;
    color: var(--brand-dark);
}

.journey-leg-mode {
    color: var(--muted);
    font-weight: 700;
}

.journey-leg-separator {
    color: var(--muted);
}

.live-status {
    font-weight: 800;
}

.live-status-green {
    color: #087f23;
}

.live-status-amber {
    color: #9a5a00;
}

.live-status-red {
    color: #d60000;
}

@media (max-width: 900px) {
    .result-meta-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .result-meta-wide {
        grid-column: span 2;
    }
}

.journey-detail-placeholder {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 0.4rem 1rem;
}

.journey-detail-placeholder dt {
    font-weight: 800;
    color: var(--brand-dark);
}

.journey-detail-placeholder dd {
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* UIC include/exclude builder */
.journey-filter-flex-section > .jf-uic-builder {
    flex: 0 1 auto !important;
    width: fit-content !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

.journey-filter-flex-section > .jf-uic-builder:has(.uic-mode-select) {
    flex-basis: auto !important;
}

.uic-builder-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.uic-mode-select,
.uic-activity-select,
.uic-minutes-input {
    border: 1px solid #cfd8e3;
    border-radius: 6px;
    padding: 0.25rem 0.4rem;
    background: #fff;
    font-size: 0.85rem;
}

.uic-mode-select {
    flex: 0 0 auto;
    width: auto;
    min-width: 6.4rem;
    min-height: 2rem;
    margin-left: 0.25rem;
    white-space: nowrap;
}

.uic-builder-add-row {
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    flex-wrap: nowrap;
}

.uic-station-picker {
    flex: 0 0 18rem;
    min-width: 18rem;
}

.uic-station-picker .station-autocomplete input {
    min-height: 2rem;
}

.uic-activity-select {
    flex: 0 0 82px;
    min-height: 2rem;
}

.uic-minutes-input {
    flex: 0 0 64px;
    min-height: 2rem;
}

.small-action-button {
    min-height: 2rem;
    border: 1px solid #0b5a99;
    background: #0b5a99;
    color: #fff;
    border-radius: 6px;
    padding: 0.25rem 0.65rem;
    font-weight: 700;
    cursor: pointer;
}

.small-action-button:hover {
    background: #084b80;
}

.uic-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.4rem;
}

.uic-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid #c9d8e8;
    background: #f7fbff;
    border-radius: 999px;
    padding: 0.18rem 0.25rem 0.18rem 0.55rem;
    font-size: 0.82rem;
}

.uic-chip-main {
    font-weight: 600;
}

.uic-chip-code {
    color: #0b5a99;
    font-weight: 700;
}

.uic-chip-delete {
    width: 1.25rem;
    height: 1.25rem;
    border: none;
    background: transparent;
    color: #a00000;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
}

.uic-chip-delete:hover {
    background: #ffe4e4;
}

.uic-empty-hint {
    margin-top: 0.3rem;
    color: #64748b;
    font-size: 0.82rem;
}

.json-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.json-copy-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.25rem;
}

/* Journey detail page */
.journey-detail-page {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.journey-detail-header,
.journey-direction-heading,
.leg-title-row,
.leg-service-meta,
.leg-raw-ids,
.journey-detail-meta,
.journey-direction-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.8rem;
}

.journey-detail-header {
    justify-content: space-between;
}

.journey-detail-header h1 {
    margin: 0;
}

.journey-detail-subtitle {
    color: #334155;
    font-size: 0.95rem;
    margin-top: 0.2rem;
}

.journey-detail-meta {
    border: 1px solid #d9e4f2;
    border-radius: 0.65rem;
    padding: 0.55rem 0.7rem;
    background: #f8fbff;
    font-size: 0.9rem;
}

.journey-detail-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    border-bottom: 1px solid #d9e4f2;
}

.journey-detail-tab {
    border: 1px solid #d9e4f2;
    border-bottom: none;
    border-radius: 0.5rem 0.5rem 0 0;
    padding: 0.45rem 0.7rem;
    background: #f3f7fc;
    font-weight: 700;
    color: #003b71;
}

.journey-detail-tab.active {
    background: #fff;
}

.journey-detail-tab:disabled {
    opacity: 0.55;
}

.journey-detail-tab-panel,
.journey-direction-card,
.leg-detail-card {
    border: 1px solid #d9e4f2;
    border-radius: 0.65rem;
    background: #fff;
}

.journey-detail-tab-panel {
    padding: 0.75rem;
}

.journey-detail-panel-heading h2,
.journey-direction-heading h3,
.leg-title-row h4 {
    margin: 0;
}

.journey-direction-card {
    margin-top: 0.8rem;
    overflow: hidden;
}

.journey-direction-heading {
    justify-content: space-between;
    padding: 0.7rem 0.85rem;
    background: #f8fbff;
    border-bottom: 1px solid #d9e4f2;
}

.detail-flag {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: #e8f2ff;
    color: #003b71;
    padding: 0.1rem 0.45rem;
    font-size: 0.78rem;
    font-weight: 800;
}

.detail-flag-warning {
    background: #fff3cd;
    color: #7a4b00;
}

.leg-detail-list {
    display: flex;
    flex-direction: column;
}

.leg-detail-card {
    border-width: 0 0 1px 0;
    border-radius: 0;
    padding: 0.85rem;
}

.leg-detail-card:last-child {
    border-bottom: none;
}

.leg-main {
    display: grid;
    grid-template-columns: 5.5rem minmax(0, 1fr);
    gap: 0.8rem;
}

.leg-time-block {
    text-align: right;
    color: #002b52;
}

.leg-line {
    width: 2px;
    min-height: 1.4rem;
    background: #bfd0e4;
    margin: 0.25rem 0 0.25rem auto;
}

.leg-body {
    min-width: 0;
}

.leg-mode,
.leg-operator {
    border-radius: 0.35rem;
    padding: 0.12rem 0.4rem;
    background: #eef4fb;
    font-weight: 700;
    font-size: 0.82rem;
}

.leg-operator {
    background: #f5f7fb;
    color: #334155;
}

.leg-service-meta,
.leg-raw-ids,
.raw-id-list {
    color: #475569;
    font-size: 0.83rem;
}

.leg-service-meta {
    margin-top: 0.35rem;
}

.leg-notes {
    margin: 0.5rem 0 0;
    padding: 0.45rem 0.55rem;
    background: #fff8e6;
    border-radius: 0.45rem;
}

.leg-raw-ids {
    margin-top: 0.65rem;
    padding-top: 0.5rem;
    border-top: 1px dashed #d9e4f2;
}

.live-status {
    border-radius: 0.35rem;
    padding: 0.1rem 0.35rem;
    font-weight: 800;
    font-size: 0.82rem;
}

.live-status-green {
    color: #0f7a2a;
    background: #e9f8ed;
}

.live-status-amber {
    color: #8a5b00;
    background: #fff1cc;
}

.live-status-red {
    color: #b00000;
    background: #ffe8e8;
}

.stops-detail {
    margin-top: 0.65rem;
}

.stops-detail summary {
    cursor: pointer;
    font-weight: 700;
    color: #003b71;
}

.stops-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.4rem;
    font-size: 0.84rem;
}

.stops-table th,
.stops-table td {
    border: 1px solid #d9e4f2;
    padding: 0.25rem 0.35rem;
    text-align: left;
}

.stops-table th {
    background: #f3f7fc;
}

.endpoint-stop td {
    font-weight: 800;
    background: #f8fbff;
}

.small-link-button {
    display: inline-flex;
    align-items: center;
    border: 1px solid #b8cce3;
    border-radius: 0.45rem;
    background: #f8fbff;
    padding: 0.3rem 0.55rem;
    font-weight: 700;
    color: #003b71;
    text-decoration: none;
}

@media (max-width: 700px) {
    .leg-main {
        grid-template-columns: 1fr;
    }

    .leg-time-block {
        display: flex;
        gap: 0.45rem;
        text-align: left;
    }

    .leg-line {
        display: none;
    }
}

/* Journey detail itinerary compact layout */
.journey-detail-page {
    gap: 0.65rem;
}

.journey-detail-header {
    gap: 0.5rem 1rem;
}

.journey-detail-subtitle {
    margin-top: 0.1rem;
}

.journey-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    padding: 0.45rem 0.65rem;
}

.journey-detail-tabs {
    margin-top: -0.15rem;
}

.journey-detail-tab-panel {
    padding: 0.65rem;
}

.journey-detail-panel-heading {
    display: flex;
    align-items: baseline;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.journey-detail-panel-heading p {
    margin: 0;
}

.journey-direction-heading {
    padding: 0.55rem 0.75rem;
}

.journey-direction-heading > div:first-child {
    display: flex;
    align-items: baseline;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.journey-direction-summary {
    gap: 0.3rem 0.55rem;
}

.leg-detail-card {
    padding: 0.65rem 0.75rem;
}

.leg-summary-grid {
    display: grid;
    grid-template-columns: minmax(6.5rem, 0.7fr) 1.5rem minmax(6.5rem, 0.7fr) minmax(18rem, 2.6fr);
    gap: 0.45rem 0.75rem;
    align-items: center;
}

.leg-station-block {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.05rem 0.4rem;
    align-items: baseline;
    min-width: 0;
}

.leg-station-label {
    color: #64748b;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
}

.leg-station-block strong {
    font-size: 1.02rem;
    color: #002b52;
}

.leg-time {
    font-weight: 800;
    font-size: 1.02rem;
}

.leg-station-block .muted {
    font-size: 0.78rem;
}

.leg-arrow {
    color: #64748b;
    font-size: 1.3rem;
    font-weight: 800;
    text-align: center;
}

.leg-service-block {
    min-width: 0;
}

.leg-title-row {
    gap: 0.25rem 0.45rem;
}

.leg-service-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.7rem;
    margin-top: 0.25rem;
}

.leg-raw-ids {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.85rem;
    margin-top: 0.45rem;
    padding-top: 0.4rem;
}

.stops-detail {
    margin-top: 0.45rem;
}

.stops-detail summary {
    display: inline-flex;
    padding: 0.15rem 0.35rem;
    border-radius: 0.35rem;
    background: #f3f7fc;
}

@media (max-width: 1000px) {
    .leg-summary-grid {
        grid-template-columns: minmax(6.5rem, 1fr) 1.5rem minmax(6.5rem, 1fr);
    }

    .leg-service-block {
        grid-column: 1 / -1;
    }
}

@media (max-width: 650px) {
    .leg-summary-grid {
        grid-template-columns: 1fr;
    }

    .leg-arrow {
        display: none;
    }

    .leg-station-block {
        grid-template-columns: 3.5rem 1fr 4rem 1fr;
    }
}

.endpoint-warning {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    align-items: center;
    margin: 0.45rem 0;
    padding: 0.45rem 0.6rem;
    border: 2px solid #b00020;
    border-radius: 0.45rem;
    background: #ffebee;
    color: #b00020;
    font-weight: 800;
}

.timetable-history-link {
    display: inline-flex;
    align-items: center;
    border: 1px solid #b8cce3;
    border-radius: 999px;
    background: #f8fbff;
    padding: 0.1rem 0.4rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: #003b71;
    text-decoration: none;
}

.timetable-history-link:hover {
    background: #eaf3ff;
    text-decoration: none;
}

/* Journey detail best fares tab */
.best-fares-tab {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.best-fares-overview,
.best-fare-card-meta,
.fare-record-meta,
.journey-segment-list,
.ticket-group-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.85rem;
}

.best-fares-overview {
    padding: 0.45rem 0.65rem;
    border: 1px solid #d9e4f2;
    border-radius: 0.55rem;
    background: #f8fbff;
    font-size: 0.88rem;
}

.best-fare-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
    gap: 0.75rem;
}

.best-fare-card,
.fare-record-card,
.ticket-group-card {
    border: 1px solid #d9e4f2;
    border-radius: 0.65rem;
    background: #fff;
}

.best-fare-card {
    overflow: hidden;
}

.best-fare-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    background: #f8fbff;
    border-bottom: 1px solid #d9e4f2;
}

.best-fare-card-header h3 {
    margin: 0;
    font-size: 1rem;
}

.best-fare-price {
    margin-top: 0.15rem;
    font-size: 1.25rem;
    font-weight: 800;
    color: #002b52;
}

.best-fare-card-meta,
.fare-record-meta {
    padding: 0.45rem 0.75rem;
    color: #475569;
    font-size: 0.83rem;
}

.fare-record-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.65rem;
}

.fare-record-card {
    padding: 0.6rem;
    background: #fcfdff;
}

.fare-record-heading {
    display: grid;
    grid-template-columns: minmax(9rem, 1fr) minmax(12rem, 2fr) auto;
    gap: 0.45rem 0.75rem;
    align-items: baseline;
}

.fare-record-price {
    font-weight: 800;
    color: #002b52;
    white-space: nowrap;
}

.journey-segment-list {
    padding: 0.25rem 0;
}

.journey-segment-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border-radius: 999px;
    background: #eef4fb;
    padding: 0.15rem 0.45rem;
    font-size: 0.82rem;
}

.ticket-group-card {
    padding: 0.45rem;
    background: #fff;
}

.fare-mini-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.35rem;
    font-size: 0.82rem;
}

.fare-mini-table th,
.fare-mini-table td {
    border: 1px solid #d9e4f2;
    padding: 0.2rem 0.35rem;
    text-align: left;
}

.fare-mini-table th {
    background: #f3f7fc;
}

.fare-notes-detail,
.raw-json-detail {
    margin-top: 0.45rem;
}

.fare-notes-detail summary,
.raw-json-detail summary {
    cursor: pointer;
    font-weight: 700;
    color: #003b71;
}

@media (max-width: 700px) {
    .fare-record-heading {
        grid-template-columns: 1fr;
    }
}

.leg-service-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    gap: 0.35rem 1rem;
    margin-top: 0.45rem;
    color: #334155;
    font-size: 0.84rem;
}

.detail-flag-sleeper {
    background: #efe8ff;
    color: #4c1d95;
}

/* Supplement fare chains in Journey Detail best fares */
.supplement-fare-box {
    margin: 0.55rem 0 0.25rem 0.75rem;
    padding: 0.55rem 0.65rem;
    border-left: 4px solid #8b5cf6;
    border-radius: 0.55rem;
    background: #faf7ff;
}

.supplement-fare-title {
    margin-bottom: 0.35rem;
    font-size: 0.82rem;
    font-weight: 800;
    color: #4c1d95;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.supplement-fare-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.35rem;
    padding: 0.4rem 0;
    border-top: 1px solid #e9d5ff;
}

.supplement-fare-row:first-of-type {
    border-top: 0;
    padding-top: 0;
}

.supplement-fare-indent {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    color: #6d28d9;
    white-space: pre;
}

.supplement-fare-content {
    min-width: 0;
}

.supplement-fare-heading {
    display: grid;
    grid-template-columns: minmax(8rem, auto) minmax(12rem, 1fr) auto;
    gap: 0.45rem 0.75rem;
    align-items: baseline;
}

.supplement-fare-meta {
    padding: 0.25rem 0 0;
}

.supplement-fare-warning {
    color: #991b1b;
    font-weight: 700;
}

/* Journey detail through fares tab */
.through-fares-tab {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.through-fulfilment-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.through-fulfilment-group {
    border: 1px solid #d9e4f2;
    border-radius: 0.75rem;
    background: #fff;
    overflow: hidden;
}

.through-fulfilment-group > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0.85rem;
    cursor: pointer;
    background: #f8fbff;
    border-bottom: 1px solid #d9e4f2;
}

.through-fulfilment-title {
    font-weight: 800;
    color: #002b52;
}

.through-fulfilment-summary {
    color: #64748b;
    font-size: 0.85rem;
}

.through-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(24rem, 1fr));
    gap: 0.75rem;
    padding: 0.75rem;
}

.through-category-card {
    border: 1px solid #d9e4f2;
    border-radius: 0.65rem;
    background: #fff;
    overflow: hidden;
}

.through-category-empty {
    background: #fbfcfe;
}

.through-category-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    background: #f8fbff;
    border-bottom: 1px solid #d9e4f2;
}

.through-category-header h3 {
    margin: 0;
    font-size: 1rem;
}

.through-fare-detail-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.65rem;
}

.through-fare-detail-card {
    background: #fcfdff;
}

.missing-fare-warning {
    color: #991b1b;
    font-weight: 800;
}

/* Journey detail all valid fares tab */
.all-fares-tab {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.all-fares-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
    gap: 0.75rem;
}

.all-fares-column {
    border: 1px solid #d9e4f2;
    border-radius: 0.75rem;
    background: #fff;
    overflow: hidden;
}

.all-fares-column-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    background: #f8fbff;
    border-bottom: 1px solid #d9e4f2;
}

.all-fares-column-header h3 {
    margin: 0;
    font-size: 1rem;
}

.all-fares-column-header span {
    color: #64748b;
    font-size: 0.83rem;
    white-space: nowrap;
}

.all-fares-list {
    display: flex;
    flex-direction: column;
}

.all-fares-row {
    display: grid;
    grid-template-columns: minmax(4.5rem, 0.75fr) minmax(10rem, 1.8fr) auto;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-top: 1px solid #e5edf7;
    font-size: 0.86rem;
    cursor: help;
}

.all-fares-row:first-child {
    border-top: 0;
}

.all-fares-row:hover {
    background: #f8fbff;
}

.all-fares-type {
    font-weight: 800;
    color: #002b52;
}

.all-fares-route {
    color: #334155;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.all-fares-price {
    font-weight: 800;
    color: #002b52;
    white-space: nowrap;
}

.all-fares-row-missing {
    background: #fff1f2;
    color: #991b1b;
}

.all-fares-empty {
    padding: 0.75rem;
    margin: 0;
}

@media (max-width: 700px) {
    .all-fares-row {
        grid-template-columns: 1fr auto;
    }

    .all-fares-route {
        grid-column: 1 / -1;
    }
}

/* Journey detail all valid fares tab */
.all-fares-tab {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.all-fares-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
    gap: 0.75rem;
}

.all-fares-column {
    border: 1px solid #d9e4f2;
    border-radius: 0.75rem;
    background: #fff;
    overflow: hidden;
}

.all-fares-column-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    background: #f8fbff;
    border-bottom: 1px solid #d9e4f2;
}

.all-fares-column-header h3 {
    margin: 0;
    font-size: 1rem;
}

.all-fares-column-header span {
    color: #64748b;
    font-size: 0.83rem;
    white-space: nowrap;
}

.all-fares-list {
    display: flex;
    flex-direction: column;
}

.all-fares-row {
    display: grid;
    grid-template-columns: minmax(4.5rem, 0.75fr) minmax(10rem, 1.8fr) auto;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-top: 1px solid #e5edf7;
    font-size: 0.86rem;
    cursor: help;
}

.all-fares-row:first-child {
    border-top: 0;
}

.all-fares-row:hover {
    background: #f8fbff;
}

.all-fares-type {
    font-weight: 800;
    color: #002b52;
}

.all-fares-route {
    color: #334155;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.all-fares-price {
    font-weight: 800;
    color: #002b52;
    white-space: nowrap;
}

.all-fares-row-missing {
    background: #fff1f2;
    color: #991b1b;
}

.all-fares-empty {
    padding: 0.75rem;
    margin: 0;
}

@media (max-width: 700px) {
    .all-fares-row {
        grid-template-columns: 1fr auto;
    }

    .all-fares-route {
        grid-column: 1 / -1;
    }
}

/* All valid fares supplement display */
.all-fares-item {
    border-top: 1px solid #e5edf7;
}

.all-fares-item:first-child {
    border-top: 0;
}

.all-fares-item > .all-fares-row {
    border-top: 0;
}

.all-fares-supplements {
    margin: 0 0.6rem 0.45rem 1.15rem;
    padding: 0.45rem 0.55rem;
    border-left: 3px solid #7c3aed;
    border-radius: 0.45rem;
    background: #f7f3ff;
    font-size: 0.82rem;
}

.all-fares-supplement-heading {
    font-weight: 800;
    color: #4c1d95;
    margin-bottom: 0.3rem;
}

.all-fares-supplement-row {
    display: grid;
    grid-template-columns: minmax(4.5rem, 0.75fr) minmax(10rem, 1.8fr) auto;
    gap: 0.5rem;
    padding: 0.22rem 0;
}

.all-fares-supplement-type {
    font-weight: 800;
    color: #4c1d95;
}

.all-fares-supplement-route {
    color: #334155;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.all-fares-supplement-price {
    font-weight: 800;
    color: #4c1d95;
    white-space: nowrap;
}

.all-fares-supplement-warning {
    color: #991b1b;
}

.all-fares-supplement-warning .all-fares-supplement-type,
.all-fares-supplement-warning .all-fares-supplement-price {
    color: #991b1b;
}

@media (max-width: 700px) {
    .all-fares-supplement-row {
        grid-template-columns: 1fr auto;
    }

    .all-fares-supplement-route {
        grid-column: 1 / -1;
        white-space: normal;
    }
}

/* FareDetails diagnostics display */
.fare-diagnostics {
    margin-top: 0.45rem;
    border: 1px solid #bfd7f3;
    border-radius: 0.5rem;
    background: #f8fbff;
    overflow: hidden;
}

.fare-diagnostics > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.42rem 0.6rem;
    cursor: pointer;
    font-weight: 800;
    color: #003b6f;
}

.fare-diagnostics-body {
    padding: 0.65rem 0.8rem;
    border-top: 1px solid #d7e6f7;
    background: #ffffff;
    color: #172554;
    font-size: 0.86rem;
    line-height: 1.45;
}

.fare-diagnostics-body ul {
    margin: 0.35rem 0 0.35rem 1.25rem;
}

.fare-diagnostics-body hr {
    border: 0;
    border-top: 1px solid #d7e6f7;
    margin: 0.55rem 0;
}

.supplement-fare-diagnostics {
    margin: 0.45rem 0 0;
    border-color: #d8c7ff;
    background: #fbf8ff;
}

.all-fares-diagnostics {
    margin: 0 0.65rem 0.45rem 0.65rem;
    font-size: 0.82rem;
}

.all-fares-supplement-diagnostics {
    margin-left: 1.2rem;
    border-color: #d8c7ff;
    background: #fbf8ff;
}

.mini-copy-button {
    border: 1px solid #b8cce7;
    border-radius: 0.35rem;
    background: #ffffff;
    color: #003b6f;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 0.12rem 0.45rem;
    cursor: pointer;
}

.mini-copy-button:hover {
    background: #eef6ff;
}

/* Journey detail RCS_R_T tab */
.rcs-rt-tab {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.rcs-rt-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 0.9rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid #d9e4f2;
    border-radius: 0.65rem;
    background: #f8fbff;
}

.rcs-rt-groups {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.rcs-rt-group {
    border: 1px solid #d9e4f2;
    border-radius: 0.75rem;
    background: #fff;
    overflow: hidden;
}

.rcs-rt-group > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0.85rem;
    cursor: pointer;
    background: #f8fbff;
    border-bottom: 1px solid #d9e4f2;
}

.rcs-rt-title {
    font-weight: 800;
    color: #002b52;
}

.rcs-rt-summary {
    color: #64748b;
    font-size: 0.85rem;
}

.rcs-product-ref-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid #e5edf6;
    background: #fcfdff;
}

.rcs-product-ref-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: #eef6ff;
    color: #002b52;
    font-size: 0.82rem;
    font-weight: 700;
}

.rcs-table-wrap {
    overflow-x: auto;
}

.rcs-rt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.rcs-rt-table th,
.rcs-rt-table td {
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid #e5edf6;
    text-align: left;
    vertical-align: top;
}

.rcs-rt-table th {
    background: #f3f8ff;
    color: #002b52;
    font-weight: 800;
}

.rcs-rt-table code {
    white-space: nowrap;
    font-size: 0.78rem;
}

.warning-text {
    color: #991b1b;
    font-weight: 800;
}

/* POP/PAP detail tab */
.poppap-tab {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.poppap-groups {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.poppap-group {
    border: 1px solid var(--border-color, #d7dce2);
    border-radius: 0.75rem;
    background: #fff;
    overflow: hidden;
}

.poppap-group > summary {
    cursor: pointer;
    padding: 0.7rem 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: #f8fafc;
}

.poppap-group-title {
    font-weight: 700;
}

.poppap-group-summary {
    color: #53606d;
    font-size: 0.9rem;
    text-align: right;
}

.poppap-group-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    padding: 0.75rem 0.85rem;
    border-top: 1px solid #eef1f4;
    color: #334155;
    font-size: 0.9rem;
}

.poppap-fare-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.75rem;
    padding: 0.85rem;
    border-top: 1px solid #eef1f4;
}

.poppap-fare-card {
    border: 1px solid #d9e0e7;
    border-radius: 0.65rem;
    padding: 0.75rem;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.poppap-fare-main {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: flex-start;
}

.poppap-ticket-code {
    font-weight: 800;
    font-size: 1rem;
}

.poppap-ticket-name {
    color: #334155;
    font-size: 0.9rem;
}

.poppap-fare-price-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
    white-space: nowrap;
}

.poppap-adult-price {
    font-weight: 800;
}

.poppap-child-price {
    color: #64748b;
    font-size: 0.9rem;
}

.poppap-fare-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.35rem 0.75rem;
    font-size: 0.86rem;
    color: #475569;
}

/* Search posting overlay */
.posting-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.58);
    backdrop-filter: blur(1.5px);
}

.posting-overlay-card {
    min-width: 220px;
    padding: 1.1rem 1.35rem;
    border-radius: 14px;
    border: 1px solid rgba(20, 30, 50, 0.18);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 45px rgba(20, 30, 50, 0.22);
    text-align: center;
}

.posting-spinner {
    width: 44px;
    height: 44px;
    margin: 0 auto 0.7rem;
    border-radius: 50%;
    border: 4px solid rgba(0, 0, 0, 0.13);
    border-top-color: rgba(0, 0, 0, 0.62);
    animation: posting-spin 0.8s linear infinite;
}

.posting-overlay-title {
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.posting-overlay-time {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 1.35rem;
    font-weight: 700;
}

.core-passengers-fares-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(15, 23, 42, 0.12);
}

.core-passengers-fares-section h3 {
    margin: 0 0 0.65rem;
}

.journey-travel-modes {
    grid-column: 1 / -1;
    margin-top: 0.45rem;
    padding-top: 0.65rem;
    border-top: 1px dashed rgba(15, 23, 42, 0.16);
}

@keyframes posting-spin {
    to { transform: rotate(360deg); }
}


/* Core journey + passenger/fare unified flex layout. */
.core-journey-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: flex-end !important;
    gap: 0.35rem 0.55rem !important;
}

.core-journey-grid > label {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.12rem !important;
    min-width: 0 !important;
    flex: 1 1 14rem !important;
}

.core-journey-grid > label:nth-child(1),
.core-journey-grid > label:nth-child(2) {
    flex-basis: 16rem !important;
}

.core-journey-grid > label:nth-child(3) {
    flex-basis: 15rem !important;
}

.core-journey-grid > label:nth-child(4) {
    flex-basis: 14rem !important;
}

.core-journey-grid > label:nth-child(5) {
    flex: 0 1 9rem !important;
}

.core-journey-grid > label:nth-child(6) {
    flex-basis: 13rem !important;
}

.core-passengers-fares-section {
    margin-top: 0.55rem !important;
    padding-top: 0 !important;
    border-top: 0 !important;
}

.core-passengers-fares-section .full-width-field {
    margin-top: 0.45rem !important;
}

@media (max-width: 760px) {
    .core-journey-grid > label,
    .core-journey-grid > label:nth-child(n) {
        flex: 1 1 100% !important;
    }

    .passenger-flex-section > .pf-field,
    .passenger-flex-section > .pf-checkbox,
    .passenger-flex-section > .pf-num1,
    .passenger-flex-section > .pf-railcard,
    .passenger-flex-section > .pf-searchtype,
    .passenger-flex-section > .pf-searchcustom,
    .passenger-flex-section > .pf-layover,
    .passenger-flex-section > .pf-commission {
        flex: 1 1 10rem !important;
        width: auto !important;
        max-width: none !important;
    }
}

/* Journey detail diagnostics tab */
.diagnostics-tab {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.json-preview-card {
    border: 1px solid #d9e4f2;
    border-radius: 0.75rem;
    background: #ffffff;
    overflow: hidden;
}

.json-preview-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid #e5edf7;
    background: #f8fbff;
}

.json-preview-heading h3 {
    margin: 0;
    font-size: 1rem;
}

.json-preview-heading p {
    margin: 0.15rem 0 0;
}

.json-preview-box {
    margin: 0;
    max-height: 28rem;
    overflow: auto;
    padding: 0.85rem;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 0.78rem;
    line-height: 1.45;
    white-space: pre;
}

.json-preview-empty {
    padding: 0.85rem;
    color: #64748b;
    font-size: 0.9rem;
}

.posting-overlay-label {
    font-weight: 700;
}
