html {
    height: 100%;
}

:root {
    /* Pełna szerokość przeglądarki; wewnętrzne bloki mają własne max-width */
    --shell-max-width: none;
    --board-inner-max: min(100%, 72rem);
    --fav-card-min: min(100%, 300px);
    --search-inner-max: min(100%, 64rem);
    --view-edge-pad: clamp(12px, 2.4vw, 24px);
    --primary: #ef4444;
    --bg: #0b0f1a;
    --app-gradient: radial-gradient(circle at 50% 0%, #172554 0%, #0b0f1a 100%);
    --surface: rgba(30, 41, 59, 0.4);
    --surface-active: rgba(51, 65, 85, 0.6);
    --glass: rgba(255, 255, 255, 0.06);
    --text-main: #f8fafc;
    --text-sec: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);
    --success: #10b981;
    --accent: #38bdf8;
    --live-bg: rgba(16, 185, 129, 0.1);
    --header-bg: rgba(11, 15, 26, 0.85);
    --overlay-bg: rgba(7, 10, 18, 0.97);
    --select-option-bg: #0b0f1a;
    --dep-detail-bg: rgba(30, 41, 59, 0.55);
    --skeleton-base: rgba(255, 255, 255, 0.05);
    --skeleton-shine: rgba(255, 255, 255, 0.08);
    color-scheme: dark;
}

/* Hide Scrollbars completely but keep functionality */
::-webkit-scrollbar {
    display: none;
}

* {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Inter', sans-serif;
}

body {
    background: var(--app-gradient);
    color: var(--text-main);
    margin: 0;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

header.app-header {
    background: var(--header-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    padding: max(1.2rem, env(safe-area-inset-top, 0px)) max(1.5rem, env(safe-area-inset-right, 0px)) 1.2rem max(1.5rem, env(safe-area-inset-left, 0px));
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    column-gap: clamp(8px, 2vw, 20px);
    row-gap: 10px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: clamp(10px, 2vw, 20px);
    min-width: 0;
    justify-self: start;
}

.header-search-wrap {
    justify-self: center;
    min-width: 0;
    width: max-content;
    max-width: min(420px, calc(100vw - 7rem));
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    justify-self: end;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.logo h1 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #ef4444, #f87171);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.city-picker {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-sec);
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
}

.city-picker:hover {
    border-color: var(--primary);
    color: var(--text-main);
}

.city-picker:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.city-picker option {
    background: var(--select-option-bg);
    color: var(--text-main);
}

.search-trigger {
    box-sizing: border-box;
    width: auto;
    max-width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 12px 20px;
    border-radius: 16px;
    color: var(--text-sec);
    cursor: pointer;
    font: inherit;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s ease;
}

.search-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-color: var(--primary);
}

.search-trigger:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (max-width: 900px) {
    header.app-header {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: clamp(6px, 1.5vw, 12px);
    }

    .header-brand {
        flex: 1 1 auto;
        min-width: 0;
        justify-self: unset;
    }

    .header-search-wrap {
        flex: 0 0 auto;
        margin-left: auto;
        justify-self: unset;
        width: max-content;
        max-width: min(420px, calc(100vw - 11rem));
    }

    .header-actions {
        flex: 0 0 auto;
        justify-self: unset;
    }
}

@media (max-width: 600px) {
    .city-picker--header {
        display: none;
    }

    .logo h1 {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: min(12.5rem, 52vw);
    }
}

@media (max-width: 380px) {
    header.app-header {
        padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
        padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
    }

    .header-brand {
        gap: 8px;
    }

    .header-actions {
        gap: 6px;
    }

    .search-trigger {
        padding: 10px 14px;
        font-size: 0.82rem;
    }
}

.delays-trigger {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    padding: 10px 14px;
    border-radius: 14px;
    color: #fbbf24;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    transition: all 0.2s ease;
}

.delays-trigger:hover {
    border-color: #f59e0b;
    color: #fde68a;
    background: rgba(245, 158, 11, 0.2);
}

.settings-trigger {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 10px 14px;
    border-radius: 14px;
    color: var(--text-sec);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    transition: all 0.2s ease;
}

.settings-trigger:hover {
    border-color: var(--accent);
    color: var(--text-main);
}

.settings-overlay {
    position: fixed;
    inset: 0;
    padding: max(32px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) max(32px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
    background: var(--overlay-bg);
    backdrop-filter: blur(40px);
    z-index: 1001;
    display: none;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
}

.settings-panel {
    max-width: 480px;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 28px 28px 24px;
}

.settings-panel h2 {
    margin: 0 0 8px;
    font-size: 1.35rem;
}

.settings-panel p {
    margin: 0 0 16px;
    color: var(--text-sec);
    font-size: 0.9rem;
    line-height: 1.5;
}

.settings-backend {
    font-size: 0.8rem;
    color: var(--accent);
    margin-bottom: 20px;
    padding: 12px 14px;
    background: rgba(56, 189, 248, 0.08);
    border-radius: 12px;
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.settings-field {
    margin-bottom: 22px;
}

.settings-label {
    display: block;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
}

.settings-panel .settings-hint {
    margin: 0 0 10px;
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--text-sec);
}

.city-picker--settings {
    width: 100%;
    max-width: 100%;
}

.settings-data-legend {
    margin: 0;
    padding-left: 1.15rem;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--text-sec);
}

.settings-data-legend li {
    margin-bottom: 0.65em;
}

.settings-data-legend li:last-child {
    margin-bottom: 0;
}

.settings-data-legend code {
    font-size: 0.92em;
    word-break: break-all;
}

.settings-theme-field {
    border: none;
    margin: 0 0 22px;
    padding: 0;
    min-width: 0;
}

.settings-theme-field legend {
    padding: 0;
}

.settings-theme-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-theme-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-main);
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    transition: border-color 0.2s, background 0.2s;
}

.settings-theme-option:hover {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(255, 255, 255, 0.06);
}

.settings-theme-option input {
    accent-color: var(--primary);
}

.settings-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.settings-action-btn {
    flex: 1;
    min-width: 120px;
    padding: 14px 18px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.settings-action-btn:hover {
    border-color: var(--primary);
    background: rgba(239, 68, 68, 0.12);
}

.settings-action-btn.secondary {
    border-color: rgba(56, 189, 248, 0.35);
}

.settings-action-btn.secondary:hover {
    border-color: var(--accent);
    background: rgba(56, 189, 248, 0.1);
}

.settings-close {
    margin-top: 20px;
    width: 100%;
    padding: 12px;
    border: none;
    background: transparent;
    color: var(--text-sec);
    cursor: pointer;
    font-size: 0.9rem;
}

.settings-toast {
    margin-top: 16px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    text-align: center;
    display: none;
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.settings-toast.err {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.35);
}

.settings-toast.visible {
    display: block;
}

#app-viewport {
    flex: 1;
    min-height: 0;
    position: relative;
    width: 100%;
    max-width: var(--shell-max-width);
    margin: 0 auto;
    overflow: hidden;
}

.view-container {
    position: absolute;
    inset: 0;
    padding: var(--view-edge-pad);
    padding-left: max(var(--view-edge-pad), env(safe-area-inset-left, 0px));
    padding-right: max(var(--view-edge-pad), env(safe-area-inset-right, 0px));
    padding-bottom: max(var(--view-edge-pad), env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    background: var(--app-gradient);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

.view-container.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* Tablica: nagłówek poza scroll — tylko lista się przewija (brak nachodzenia na .board-pin) */
#view-board.view-container {
    padding-top: 0;
}

#view-board.view-container.view-board--split-scroll {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* FAVORITES DASHBOARD */
.dashboard-header {
    margin-bottom: 32px;
}

.dashboard-header h2 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 800;
}

.favorites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--fav-card-min), 1fr));
    gap: clamp(12px, 2vw, 28px);
}

.fav-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.fav-card:hover {
    transform: translateY(-8px) scale(1.02);
    background: var(--surface-active);
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.card-info h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-main);
}

.card-info p {
    margin: 6px 0 0;
    font-size: 0.9rem;
    color: var(--text-sec);
}

.card-source {
    font-size: 0.65rem;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent);
    text-transform: uppercase;
}

.mini-deps {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    min-width: 0;
}

.mini-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.mini-line-block {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.mini-badge {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.8rem;
    min-width: 36px;
    flex-shrink: 0;
    text-align: center;
}

.mini-dest {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-sec);
}

.mini-time {
    font-weight: 800;
    color: var(--success);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.mini-time-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    flex-shrink: 0;
    max-width: 100%;
}

.mini-delay {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.mini-delay.late {
    color: #f59e0b;
}

.mini-delay.early {
    color: var(--accent);
}

.mini-delay.on-time {
    color: var(--text-sec);
}

/* SEARCH INTERFACE */
.search-overlay {
    position: fixed;
    inset: 0;
    padding: max(24px, env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px));
    background: var(--overlay-bg);
    backdrop-filter: blur(40px);
    z-index: 1000;
    display: none;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

@media (max-width: 400px) {
    .search-overlay {
        padding: max(10px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.search-header {
    max-width: var(--search-inner-max);
    width: 100%;
    margin: 40px auto;
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-input {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--border);
    padding: 20px 32px;
    border-radius: 28px;
    color: var(--text-main);
    font-size: clamp(0.9rem, 3.5vw, 1.3rem);
    outline: none;
    transition: all 0.3s ease;
}

.search-input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

.close-search {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-sec);
    font-size: clamp(1.6rem, 5vw, 2.5rem);
    cursor: pointer;
    transition: color 0.2s;
    padding: 0 4px;
}

.close-search:hover {
    color: var(--text-main);
}

.search-results {
    max-width: var(--search-inner-max);
    width: 100%;
    margin: 0 auto;
    overflow-y: auto;
    flex: 1;
    padding-bottom: 60px;
}

@media (max-width: 400px) {
    .search-header {
        margin: 16px auto 12px;
        gap: 8px;
    }

    .search-input {
        padding: 14px 16px;
        border-radius: 18px;
    }

    .search-results {
        padding-bottom: 24px;
    }
}

@media (max-width: 240px) {
    .search-header {
        margin: 8px auto 6px;
        gap: 6px;
    }

    .search-input {
        padding: 10px 10px;
        border-radius: 12px;
        border-width: 1px;
    }

    .close-search {
        padding: 0 2px;
    }
}

/* OPÓŹNIENIA — modal rankingu (serwer) */
.delays-overlay {
    position: fixed;
    inset: 0;
    padding: max(20px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) max(20px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
    background: var(--overlay-bg);
    backdrop-filter: blur(36px);
    z-index: 1002;
    display: none;
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.25s ease;
}

.delays-panel {
    width: 100%;
    max-width: min(960px, 100%);
    max-height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.delays-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.delays-head-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.delays-head h2 {
    margin: 0;
    font-size: clamp(1.05rem, 3.8vw, 1.35rem);
    font-weight: 800;
    color: var(--text-main);
    min-width: 0;
    line-height: 1.2;
}

.delays-meta-wrap {
    margin-bottom: 12px;
}

.delays-meta-wrap[hidden] {
    display: none !important;
}

.close-delays {
    background: none;
    border: none;
    color: var(--text-sec);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 10px;
    transition: color 0.2s, background 0.2s;
}

.close-delays:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.06);
}

.delays-meta {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--text-sec);
}

.delays-sample-hint {
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-sec);
    font-size: 0.72rem;
    font-weight: 800;
    font-style: italic;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.delays-sample-hint:hover {
    color: var(--accent);
    border-color: rgba(56, 189, 248, 0.45);
    background: rgba(56, 189, 248, 0.1);
}

.delays-sample-hint.delays-sample-hint--open {
    color: var(--accent);
    border-color: rgba(56, 189, 248, 0.55);
    background: rgba(56, 189, 248, 0.14);
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.2);
}

.delays-sample-hint:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

html[data-theme="light"] .delays-sample-hint {
    background: rgba(15, 23, 42, 0.05);
}

html[data-theme="light"] .delays-sample-hint:hover {
    background: rgba(3, 105, 161, 0.1);
}

html[data-theme="light"] .delays-sample-hint.delays-sample-hint--open {
    background: rgba(3, 105, 161, 0.14);
}

.delays-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

.delays-filter {
    flex: 1 1 200px;
    min-width: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: 14px;
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
}

.delays-filter:focus {
    border-color: #f59e0b;
}

.delays-min-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.delays-min-label {
    font-size: 0.8rem;
    color: var(--text-sec);
    white-space: nowrap;
}

.delays-toolbar select.city-picker.delays-min-select {
    min-width: 7rem;
    flex-shrink: 0;
}

.delays-refresh {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #fbbf24;
    padding: 10px 16px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}

.delays-refresh:hover {
    background: rgba(245, 158, 11, 0.28);
}

.delays-table-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.15);
}

html[data-theme="light"] .delays-table-wrap {
    background: rgba(255, 255, 255, 0.5);
}

.delays-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.delays-table th {
    text-align: left;
    padding: 12px 14px;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-sec);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--overlay-bg);
    z-index: 1;
}

.delays-th-sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s, background 0.15s;
}

.delays-th-sortable:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
}

.delays-th-sortable.delays-th--active {
    color: #fbbf24;
}

.delays-th-sortable::after {
    display: inline-block;
    margin-left: 5px;
    font-size: 0.55rem;
    opacity: 0;
    vertical-align: middle;
}

.delays-th-sortable.delays-th--asc::after {
    content: '▲';
    opacity: 1;
}

.delays-th-sortable.delays-th--desc::after {
    content: '▼';
    opacity: 1;
}

.delays-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.delays-table tr:last-child td {
    border-bottom: none;
}

.delays-line {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.4rem;
    padding: 6px 10px;
    border-radius: 10px;
    background: var(--primary);
    color: white;
    font-weight: 800;
    font-size: 0.85rem;
}

.delays-dest {
    color: var(--text-main);
    font-weight: 600;
    max-width: 220px;
}

.delays-delay {
    color: #f59e0b;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.delays-eta {
    font-variant-numeric: tabular-nums;
    color: var(--success);
    white-space: nowrap;
}

.delays-stop {
    color: var(--text-sec);
    font-size: 0.82rem;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.delays-stop--link {
    cursor: pointer;
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
    text-underline-offset: 2px;
}

.delays-stop--link:hover {
    color: color-mix(in srgb, var(--accent) 88%, var(--text-main));
    text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

.delays-stop--link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.delays-src {
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.delays-empty {
    text-align: center;
    padding: 36px 20px !important;
    color: var(--text-sec);
}

@media (max-width: 640px) {
    .delays-table th:nth-child(2),
    .delays-table td.delays-dest {
        max-width: 120px;
    }

    .delays-table th:nth-child(5),
    .delays-table td.delays-stop {
        max-width: 100px;
    }
}

.res-group {
    margin-bottom: 28px;
    animation: slideIn 0.3s ease forwards;
    opacity: 0;
}

@keyframes slideIn {
    from {
        transform: translateY(10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.res-group-title {
    font-size: clamp(0.78rem, 2.8vw, 0.95rem);
    font-weight: 800;
    color: var(--primary);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.res-group-title > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.res-item {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.res-item:hover {
    background: rgba(255, 255, 255, 0.05);
    padding-left: 36px;
}

.res-item-text {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    min-width: 0;
    flex: 1;
}

.history-stop-name {
    font-size: clamp(0.82rem, 2.8vw, 1.05rem);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0.01em;
    color: var(--text-main);
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-line2 {
    font-size: clamp(0.65rem, 2.2vw, 0.78rem);
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-sec);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.res-item .code-pill {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 10px;
    font-weight: 700;
    font-size: clamp(0.62rem, 2.2vw, 0.85rem);
    color: var(--accent);
    white-space: nowrap;
}

@media (max-width: 400px) {
    .res-group-title {
        padding: 12px 12px;
    }

    .res-item {
        padding: 14px 12px;
        gap: 8px;
    }

    .res-item:hover {
        padding-left: 18px;
    }

    .res-item .code-pill {
        padding: 4px 8px;
        border-radius: 8px;
    }
}

@media (max-width: 240px) {
    .res-group-title {
        padding: 8px 6px;
        flex-direction: column;
        gap: 2px;
    }

    .res-item {
        padding: 10px 6px;
        gap: 6px;
        flex-wrap: wrap;
    }

    .res-item:hover {
        padding-left: 10px;
    }

    .res-item .code-pill {
        padding: 2px 6px;
        font-size: 0.6rem;
    }

    .res-item-text {
        gap: 3px;
    }
}

/* BOARD VIEW — kolumna: pin statyczny, scroll tylko w .deps-list */
.board-view {
    max-width: var(--board-inner-max);
    margin: 0 auto;
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.board-pin {
    position: relative;
    flex-shrink: 0;
    margin-top: 0;
    margin-bottom: 24px;
    margin-left: calc(-1 * max(var(--view-edge-pad), env(safe-area-inset-left, 0px)));
    margin-right: calc(-1 * max(var(--view-edge-pad), env(safe-area-inset-right, 0px)));
    padding: 14px max(24px, var(--view-edge-pad)) 18px;
    background: transparent;
    border-bottom: none;
    box-shadow: none;
    overflow: visible;
    transition: padding 0.22s ease;
}

.board-view .deps-list {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
}

.board-view--scrolled .board-pin {
    padding: 8px max(24px, var(--view-edge-pad)) 10px;
}

.board-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    transition: margin-bottom 0.22s ease;
}

.board-view--scrolled .board-top {
    margin-bottom: 8px;
}

.btn-back {
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 12px 24px;
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    transition: padding 0.22s ease, border-radius 0.22s ease, font-size 0.22s ease;
}

.board-view--scrolled .btn-back {
    padding: 7px 14px;
    border-radius: 12px;
    font-size: 0.82rem;
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.board-main-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0;
    gap: 12px;
}

.board-main-header h1 {
    margin: 0;
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.1;
    transition: font-size 0.22s ease, line-height 0.22s ease;
}

.board-main-header > div > h1:first-of-type {
    transition: font-size 0.22s ease, margin 0.22s ease;
}

.board-main-header p {
    transition: max-height 0.24s ease, opacity 0.2s ease, margin 0.2s ease;
    max-height: 6rem;
    overflow: hidden;
}

.board-view--scrolled .board-main-header > div > h1:first-of-type {
    font-size: 0.62rem !important;
    margin-bottom: 2px !important;
}

.board-view--scrolled .board-main-header h1:nth-of-type(2) {
    font-size: 1.05rem !important;
    line-height: 1.2;
}

.board-view--scrolled .board-main-header h1:nth-of-type(2) small {
    font-size: 0.55em !important;
}

.board-view--scrolled .board-main-header p {
    max-height: 0;
    opacity: 0;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.fav-btn {
    font-size: 2.2rem;
    cursor: pointer;
    color: #fbbf24;
    user-select: none;
    transition: transform 0.2s, font-size 0.22s ease;
}

.board-view--scrolled .fav-btn {
    font-size: 1.35rem;
}

.fav-btn:hover {
    transform: scale(1.2);
}

.dep-card {
    display: grid;
    grid-template-columns: minmax(52px, 70px) minmax(0, 1fr) max-content;
    align-items: center;
    gap: 0 12px;
    background: var(--surface);
    padding: 24px;
    border-radius: 24px;
    margin-bottom: 14px;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.dep-card:hover {
    transform: translateX(5px);
    border-color: var(--border);
    background: var(--surface-active);
}

.dep-card.dep-tappable {
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.07);
}

.dep-card.dep-tappable:hover {
    transform: none;
    border-color: rgba(239, 68, 68, 0.28);
    background: var(--surface-active);
}

.dep-card.dep-tappable:focus {
    outline: none;
}

.dep-card.dep-tappable:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.dep-stack {
    margin-bottom: 14px;
}

.dep-stack.dep-expanded .dep-card.dep-tappable {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    margin-bottom: 0;
    border-color: rgba(239, 68, 68, 0.35);
}

.dep-detail {
    display: none;
    background: var(--dep-detail-bg);
    border: 1px solid var(--border);
    border-top: none;
    padding: 16px 20px 18px;
    border-radius: 0 0 24px 24px;
    font-size: 0.88rem;
}

.dep-detail-hint {
    display: none;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-sec);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
}

.dep-stack.dep-expanded .dep-detail {
    display: block;
}

.dep-stack.dep-expanded .dep-detail-hint {
    display: block;
}

.dep-detail-hint-more {
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text-sec);
    opacity: 0.92;
}

.dep-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.dep-detail-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.dep-detail-row[title] {
    cursor: help;
}

.dep-detail-k {
    color: var(--text-sec);
    flex-shrink: 0;
    max-width: 42%;
}

.dep-detail-v {
    color: var(--text-main);
    text-align: right;
    word-break: break-word;
    font-weight: 600;
}

.line-num {
    width: 56px;
    height: 56px;
    background: var(--primary);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.4rem;
    color: white;
    box-shadow: 0 8px 16px -4px rgba(239, 68, 68, 0.4);
}

.dep-content {
    padding: 0 12px;
    min-width: 0;
}

.head-dest {
    font-weight: 700;
    font-size: 1.25rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.head-meta {
    font-size: 0.85rem;
    color: var(--text-sec);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dep-eta {
    font-weight: 800;
    font-size: 1.6rem;
    color: var(--success);
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.dep-eta-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
    min-width: min-content;
}

.dep-eta[title],
.dep-delay[title] {
    cursor: help;
}

.dep-delay {
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.dep-delay.late {
    color: #f59e0b;
}

.dep-delay.early {
    color: var(--accent);
}

.dep-delay.on-time {
    color: var(--text-sec);
}

/* SKELETON LOADERS */
.skeleton {
    background: var(--skeleton-base);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, var(--skeleton-shine), transparent);
    animation: sweep 1.5s infinite;
}

@keyframes sweep {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(100%);
    }
}

.sk-header-p {
    height: 1.2rem;
    width: 40%;
    margin-bottom: 15px;
}

.sk-header-h {
    height: 2.5rem;
    width: 80%;
}

.sk-card {
    height: 100px;
    width: 100%;
    margin-bottom: 14px;
    border-radius: 24px;
}

@media (min-width: 1600px) {
    :root {
        --board-inner-max: min(100%, 84rem);
    }
}

@media (min-width: 2200px) {
    :root {
        --board-inner-max: min(100%, 100rem);
        --fav-card-min: min(100%, 360px);
    }
}

@media (max-width: 800px), (max-height: 500px) {
    .favorites-grid {
        grid-template-columns: 1fr;
    }

    .board-main-header h1 {
        font-size: 1.8rem;
    }

    .line-num {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }

    .dep-eta {
        font-size: 1.3rem;
    }

    .card-info h3 {
        font-size: 1.2rem;
    }

    .header-brand {
        gap: 10px;
    }

    .header-actions {
        gap: 8px;
    }

    .search-trigger span:last-child {
        display: none;
    }
}

@media (max-width: 400px) {
    :root {
        --fav-card-min: 100%;
        --view-edge-pad: 12px;
    }

    .dep-card {
        padding: 14px 10px;
        gap: 0 8px;
    }

    .dashboard-header h2 {
        font-size: 1.35rem;
    }

    .board-main-header h1:nth-of-type(2) {
        font-size: clamp(1.1rem, 6.2vw, 1.55rem);
    }
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* —— Motywy (domyślny = :root / data-theme="dark") —— */
html[data-theme="light"] {
    color-scheme: light;
    --primary: #dc2626;
    --bg: #f8fafc;
    --app-gradient: linear-gradient(165deg, #e2e8f0 0%, #f8fafc 50%, #f1f5f9 100%);
    --surface: rgba(255, 255, 255, 0.94);
    --surface-active: rgba(255, 255, 255, 1);
    --glass: rgba(15, 23, 42, 0.06);
    --text-main: #0f172a;
    --text-sec: #64748b;
    --border: rgba(15, 23, 42, 0.12);
    --success: #059669;
    --accent: #0369a1;
    --live-bg: rgba(5, 150, 105, 0.14);
    --header-bg: rgba(248, 250, 252, 0.92);
    --overlay-bg: rgba(248, 250, 252, 0.97);
    --select-option-bg: #f1f5f9;
    --dep-detail-bg: rgba(241, 245, 249, 0.95);
    --skeleton-base: rgba(15, 23, 42, 0.07);
    --skeleton-shine: rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .logo h1 {
    background: linear-gradient(135deg, #b91c1c, #ef4444);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

html[data-theme="light"] .search-input {
    background: rgba(15, 23, 42, 0.05);
}

html[data-theme="light"] .search-input:focus {
    background: rgba(15, 23, 42, 0.08);
}

html[data-theme="midnight"] {
    color-scheme: dark;
    --primary: #fb923c;
    --bg: #020617;
    --app-gradient: radial-gradient(ellipse 120% 80% at 50% -20%, #1c1917 0%, #020617 55%, #0c0a09 100%);
    --surface: rgba(41, 37, 36, 0.45);
    --surface-active: rgba(68, 64, 60, 0.55);
    --glass: rgba(255, 255, 255, 0.05);
    --text-main: #fafaf9;
    --text-sec: #a8a29e;
    --border: rgba(255, 255, 255, 0.09);
    --success: #34d399;
    --accent: #fdba74;
    --live-bg: rgba(52, 211, 153, 0.12);
    --header-bg: rgba(2, 6, 23, 0.9);
    --overlay-bg: rgba(2, 6, 23, 0.96);
    --select-option-bg: #0c0a09;
    --dep-detail-bg: rgba(28, 25, 23, 0.65);
    --skeleton-base: rgba(255, 255, 255, 0.06);
    --skeleton-shine: rgba(255, 255, 255, 0.1);
}

html[data-theme="midnight"] .logo h1 {
    background: linear-gradient(135deg, #fb923c, #fdba74);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
