:root {
    --bg: #f5efe6;
    --card-bg: #ffffff;
    --sidebar-bg: #faf6f0;
    --border: #ece2d4;
    --border-strong: #e3d5c0;
    --text: #2b2420;
    --text-muted: #8a7f71;
    --text-faint: #b3a696;
    --accent: #dd4e26;
    --accent-dark: #b83e1c;
    --gradient: linear-gradient(135deg, #f4923d 0%, #dd4a24 100%);
    --badge-bg: #fbe3ce;
    --badge-text: #b8541f;
    --via-hub-bg: #fce8d6;
    --via-hub-border: #f4cda3;
    --radius-lg: 24px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --radius-pill: 999px;
    --shadow: 0 20px 45px -20px rgba(120, 72, 30, 0.25);
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 2rem 1rem;
}

.page-card {
    max-width: 1220px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.page-card > .page-card-body {
    padding: 1.75rem 2rem;
}

/* ---- Search + results page (single unified page) ---- */

.sidebar-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    row-gap: 0.3rem;
    margin-bottom: 0.9rem;
}

.sidebar-header span {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
}

.sidebar-header-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.6rem;
    align-items: baseline;
}

.sidebar-header-links .link-accent {
    font-size: 0.72rem;
}

.link-accent {
    color: var(--accent);
    font-size: 0.8rem;
    text-decoration: none;
    font-weight: 600;
}

.link-accent:hover {
    text-decoration: underline;
}

.checkbox-list {
    display: flex;
    flex-direction: column;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 0.2rem;
}

.checkbox-item {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    color: var(--text);
    padding: 0.35rem 0;
}

.checkbox-item .country-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.count-badge {
    background: var(--badge-bg);
    color: var(--badge-text);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-pill);
    flex-shrink: 0;
}

.app-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    background: var(--gradient);
    padding: 0.9rem 2rem;
    position: relative;
    overflow: hidden;
}

.app-header::before,
.app-header::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
}

.app-header::before {
    width: 150px;
    height: 150px;
    top: -75px;
    right: -40px;
}

.app-header::after {
    width: 95px;
    height: 95px;
    bottom: -62px;
    right: 65px;
}

.app-header-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.app-header-icon svg {
    width: 19px;
    height: 19px;
    stroke: #fff;
    fill: none;
}

.app-header-text {
    z-index: 1;
}

.app-header h1 {
    margin: 0;
    color: #fff;
    font-size: 1.35rem;
}

.app-header-text p {
    margin: 0.15rem 0 0;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
}

.top-search-fields label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-right: 0.6rem;
    font-size: 0.76rem;
    color: var(--text-muted);
    font-weight: 600;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.7rem;
    margin-bottom: 0.8rem;
}

.top-search-fields input, .top-search-fields select {
    padding: 0.45rem 0.55rem;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
}

.top-search-fields input:focus, .top-search-fields select:focus {
    outline: none;
    border-color: var(--accent);
}

.top-search-fields select {
    /* Fixed, not min - a <select> otherwise grows to fit its longest OPTION (e.g. some airport
       names run 30+ chars), blowing past any min-width and wrapping the row. */
    width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.via-hub-box {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.4rem;
    background: var(--via-hub-bg);
    border: 1px solid var(--via-hub-border);
    border-radius: var(--radius-md);
    padding: 0.45rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-dark);
    max-width: 240px;
}

.via-hub-box .hint {
    font-weight: 400;
    color: var(--text-muted);
}

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

/* ---- Results page: sidebar (country + filters) + main column (search fields + map + table) ---- */

.results-body {
    padding: 1.75rem 2rem;
}

.results-layout {
    display: flex;
    align-items: flex-start;
    gap: 1.75rem;
    margin-top: 1rem;
}

.filters-sidebar {
    flex-shrink: 0;
    width: 230px;
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.top-search-fields {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.form-footer-links {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
}

.filter-group h3 {
    margin: 0 0 0.6rem;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    font-weight: 700;
}

.price-range-inputs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.price-range-inputs input {
    width: 3.6rem;
    flex: 0 0 auto;
    padding: 0.5rem 0.5rem;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
}

/* Hide native number input spin buttons - just a plain text-like field, no increment stepper. */
.price-range-inputs input[type="number"] {
    -moz-appearance: textfield;
}

.price-range-inputs input[type="number"]::-webkit-outer-spin-button,
.price-range-inputs input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.price-range-inputs input:focus {
    outline: none;
    border-color: var(--accent);
}

.price-range-inputs span {
    color: var(--text-faint);
}

.time-range-values {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.time-range-slider {
    position: relative;
    height: 20px;
    margin-bottom: 0.2rem;
}

.time-range-track {
    position: absolute;
    top: 8px;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: var(--radius-pill);
    background: var(--border-strong);
}

.time-range-fill {
    position: absolute;
    top: 0;
    height: 4px;
    border-radius: var(--radius-pill);
    background: var(--gradient);
}

.time-range-slider input[type="range"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 20px;
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
}

.time-range-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    pointer-events: auto;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--accent);
    cursor: pointer;
    margin-top: 2px;
    box-shadow: 0 1px 3px rgba(43, 36, 32, 0.25);
}

.time-range-slider input[type="range"]::-moz-range-thumb {
    pointer-events: auto;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--accent);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(43, 36, 32, 0.25);
}

.time-range-slider input[type="range"]::-moz-range-track {
    background: transparent;
    border: none;
}

/* ---- Trends page (/trends) ---- */

.trends-section {
    margin-top: 2rem;
}

.trends-section h2 {
    font-size: 1.05rem;
    margin: 0 0 0.6rem;
}

.chart-box {
    position: relative;
    height: 340px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.9rem;
    margin: 0.75rem 0;
}

.chart-box-tall {
    height: 460px;
}

.trends-legend {
    display: flex;
    gap: 1.2rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0.4rem 0;
}

.trends-legend i {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 0.35rem;
    vertical-align: -1px;
}

.trends-matrix-header {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin: 1.75rem 0 0.75rem;
    padding: 0.9rem 1rem;
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.trends-matrix-staydays {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    padding-right: 0.9rem;
    border-right: 1px solid var(--border);
}

.trends-matrix-staydays #trends-stay-days {
    width: 160px;
    accent-color: var(--accent);
}

.trends-matrix-header h3 {
    margin: 0;
    font-size: 0.95rem;
}

.trends-matrix-agg-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.9rem;
}

.trends-matrix-price-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    padding-left: 0.9rem;
    border-left: 1px solid var(--border);
}

.trends-matrix-price-filter select {
    padding: 0.4rem 0.5rem;
    font-size: 0.82rem;
    font-family: inherit;
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
}

.trends-matrix-wrap {
    max-height: 480px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.trends-matrix {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.78rem;
    white-space: nowrap;
}

.trends-matrix th,
.trends-matrix td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border);
    text-align: right;
}

.trends-matrix thead th {
    position: sticky;
    top: 0;
    background: var(--sidebar-bg);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 700;
    z-index: 2;
}

.trends-matrix-month-header {
    cursor: pointer;
}

.trends-matrix-month-header:hover {
    background: var(--badge-bg);
    color: var(--accent-dark);
}

.trends-matrix-month-active {
    background: var(--badge-bg);
    color: var(--accent-dark);
}

.trends-matrix-city,
.trends-matrix-corner {
    position: sticky;
    left: 0;
    text-align: left;
    background: #fff;
    z-index: 1;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trends-matrix-corner {
    background: var(--sidebar-bg);
    z-index: 3;
}

.trends-matrix-current td {
    background: var(--badge-bg);
}

.trends-matrix-current .trends-matrix-city {
    background: var(--badge-bg);
}

.trends-route-form {
    align-items: end;
}

.swap-button {
    padding: 0.5rem;
    margin-bottom: 0;
    background: #fff;
    color: var(--accent);
    box-shadow: none;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.swap-button svg {
    width: 16px;
    height: 16px;
}

.swap-button:hover {
    background: var(--sidebar-bg);
    filter: none;
}

.trends-route-form label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.76rem;
    color: var(--text-muted);
    font-weight: 600;
}

.trends-route-form select,
.trends-route-form input {
    padding: 0.45rem 0.55rem;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
}

.trends-route-form label.trends-return-toggle,
.trends-route-form label#trends-stay-days-wrap {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.trends-return-toggle input[type="checkbox"] {
    margin: 0;
}

#trends-stay-days {
    width: 140px;
    accent-color: var(--accent);
}

.trends-route-form select {
    width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-submit {
    padding: 0.5rem 0.7rem;
    margin-top: 0;
    font-size: 0.8rem;
    flex-shrink: 0;
}

#airline-filter-list {
    max-height: none;
}

.sort-links {
    margin: 0;
    font-size: 0.85rem;
}

.results-main {
    flex: 1;
    min-width: 0;
}

#results-map {
    /* Taller box = more pixels available for the same geographic extent (Iceland to Turkey) =
       Leaflet's fitBounds picks a higher zoom while still fitting every marker, rendering country
       borders/labels with noticeably more detail instead of the washed-out low-zoom look. */
    height: 520px;
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: 0.75rem;
}

.leaflet-container {
    font-family: inherit;
    background: var(--sidebar-bg);
}

.map-price-legend {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.92);
    padding: 0.35rem 0.55rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 4px rgba(43, 36, 32, 0.25);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text);
}

.map-price-legend i {
    display: block;
    width: 110px;
    height: 9px;
    border-radius: var(--radius-pill);
}

.focus-more {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
    font-weight: 600;
}

#results-map .leaflet-interactive {
    cursor: pointer;
}

#results-count {
    margin: 0 0 0.5rem;
}

.row-highlight {
    animation: row-highlight-flash 1.6s ease-out;
}

@keyframes row-highlight-flash {
    0% { background: var(--badge-bg); }
    100% { background: transparent; }
}

.price-up {
    color: #b83e1c;
    font-weight: 600;
    white-space: nowrap;
}

.price-down {
    color: #2f9e44;
    font-weight: 600;
    white-space: nowrap;
}

.login-card {
    max-width: 380px;
    margin: 4rem auto;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
}

.login-form input {
    padding: 0.6rem 0.7rem;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.login-form button {
    margin-top: 0.4rem;
}

.login-error {
    background: #fbe3ce;
    color: var(--accent-dark);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
    margin: 0 0 1rem;
}

button {
    padding: 0.55rem 1.3rem;
    margin-top: 0;
    font-size: 0.88rem;
    font-weight: 700;
    color: #fff;
    background: var(--gradient);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    box-shadow: 0 12px 24px -12px rgba(221, 74, 36, 0.6);
}

button:hover {
    filter: brightness(1.05);
}

table {
    border-collapse: collapse;
    width: 100%;
    margin-top: 1rem;
    font-size: 0.8rem;
}

th, td {
    border-bottom: 1px solid var(--border);
    padding: 0.45rem 0.5rem;
    text-align: left;
}

td {
    /* Data cells (esp. dates) shouldn't squeeze/wrap onto two lines - the table already scrolls
       horizontally (.table-wrap) if it needs more room than that. Headers are exempt (below):
       letting a header like "Dni na miejscu" wrap keeps its column from being forced wider than
       the single-digit data it actually holds. */
    white-space: nowrap;
}

.city-cell {
    /* Open-jaw has two of these (outbound + return city) - an occasional long name like
       "Basel-Mulhouse-Freiburg" would otherwise force horizontal scroll on the whole table.
       Full name still available via the title tooltip on hover. */
    max-width: 135px;
    overflow: hidden;
    text-overflow: ellipsis;
}

th {
    background: var(--sidebar-bg);
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 700;
    white-space: normal;
}

tbody tr:hover {
    background: #fdfaf6;
}

td .time {
    color: var(--text-faint);
    font-size: 0.8rem;
}

a {
    color: var(--accent);
}

a.active {
    font-weight: bold;
    text-decoration: none;
    color: var(--text);
}

fieldset {
    display: inline-flex;
    gap: 0.9rem;
    align-items: center;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 0.6rem 0.9rem;
    margin: 0 0.7rem 0 0;
}

fieldset legend {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 0 0.4rem;
}

label.inline {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
}

.inline-toggle {
    font-size: 0.75rem;
    margin-top: 0.2rem;
}

.hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ---- Custom checkbox / radio ---- */

input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 2px solid var(--border-strong);
    border-radius: 6px;
    background: #fff;
    position: relative;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}

input[type="checkbox"]:checked {
    background: var(--gradient);
    border-color: transparent;
}

input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 19px;
    height: 19px;
    min-width: 19px;
    border: 2px solid var(--border-strong);
    border-radius: 50%;
    background: #fff;
    position: relative;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}

input[type="radio"]:checked {
    border-color: var(--accent);
}

input[type="radio"]:checked::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 3px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--gradient);
}
