/* Fuel Ledger 2.0 — интерфейс маршрутного журнала */
.fuel-ledger {
    --fc-ink: #172a3f;
    --fc-ink-soft: #52657a;
    --fc-paper: #ffffff;
    --fc-ground: #f4f7fb;
    --fc-line: #dbe5ef;
    --fc-line-strong: #c4d2df;
    --fc-blue: #1769d6;
    --fc-blue-dark: #0e4fa7;
    --fc-blue-wash: #e9f2ff;
    --fc-amber: #d88b17;
    --fc-amber-wash: #fff5df;
    --fc-green: #087a59;
    --fc-green-wash: #e5f7f0;
    --fc-red: #b64043;
    --fc-red-wash: #ffebeb;
    --fc-radius-xl: 24px;
    --fc-radius-lg: 16px;
    --fc-radius-md: 12px;
    --fc-shadow: 0 18px 46px rgba(23, 42, 63, 0.12);
    --fc-thumb-size: 28px;
    box-sizing: border-box;
    max-width: 1160px;
    margin: 32px auto;
    color: var(--fc-ink);
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

.fuel-ledger *,
.fuel-ledger *::before,
.fuel-ledger *::after {
    box-sizing: inherit;
}

.fuel-ledger button,
.fuel-ledger input,
.fuel-ledger textarea {
    font: inherit;
}

.fuel-ledger-notice {
    max-width: 760px;
    margin: 24px auto;
    padding: 16px 18px;
    border: 1px solid #f0bbbb;
    border-radius: 12px;
    color: #802b31;
    background: var(--fc-red-wash);
}

.fc-hero {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    overflow: hidden;
    padding: 30px clamp(22px, 4vw, 44px);
    border-radius: var(--fc-radius-xl) var(--fc-radius-xl) 0 0;
    color: #fff;
    background: #172a3f;
    isolation: isolate;
}

.fc-hero::before {
    position: absolute;
    z-index: -1;
    top: -130px;
    right: -55px;
    width: 330px;
    height: 330px;
    border: 44px solid rgba(96, 177, 255, 0.14);
    border-radius: 50%;
    content: "";
}

.fc-hero::after {
    position: absolute;
    z-index: -1;
    right: 154px;
    bottom: -65px;
    width: 220px;
    height: 220px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 50%;
    content: "";
}

.fc-kicker {
    margin: 0 0 5px;
    color: var(--fc-blue);
    font-size: 0.76rem;
    font-weight: 750;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.fc-hero .fc-kicker {
    color: #a6d2ff;
}

.fc-hero h2,
.fc-section h3,
.fc-live-results h3,
.fc-history h3 {
    margin: 0;
    font-weight: 720;
    letter-spacing: -0.025em;
}

.fc-hero h2 {
    max-width: 700px;
    font-size: clamp(1.65rem, 3vw, 2.35rem);
    line-height: 1.12;
}

.fc-hero__hint {
    max-width: 620px;
    margin: 10px 0 0;
    color: rgba(255, 255, 255, 0.73);
}

.fc-capacity {
    flex: 0 0 auto;
    min-width: 136px;
    padding: 13px 16px 12px;
    border: 1px solid rgba(255, 255, 255, 0.23);
    border-radius: var(--fc-radius-md);
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
}

.fc-capacity span {
    display: block;
    margin-bottom: 2px;
    color: rgba(255, 255, 255, 0.66);
    font-size: 0.76rem;
}

.fc-capacity strong {
    font-size: 1.45rem;
    letter-spacing: -0.04em;
}

.fc-capacity small {
    margin-left: 2px;
    color: #bcdcff;
    font-size: 0.84rem;
    font-weight: 650;
    letter-spacing: 0;
}

.fc-entry-form {
    padding: clamp(16px, 3.5vw, 40px);
    border: 1px solid var(--fc-line);
    border-top: 0;
    background: var(--fc-ground);
}

.fc-sections {
    display: grid;
    gap: 16px;
}

.fc-section {
    padding: clamp(19px, 3vw, 30px);
    border: 1px solid var(--fc-line);
    border-radius: var(--fc-radius-lg);
    background: var(--fc-paper);
    box-shadow: 0 2px 0 rgba(23, 42, 63, 0.015);
}

.fc-section--general {
    border-left: 4px solid var(--fc-blue);
}

.fc-section--departure {
    border-left: 4px solid #1ca47b;
}

.fc-section--arrival {
    border-left: 4px solid var(--fc-amber);
}

.fc-section__heading {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 21px;
}

.fc-section__step {
    display: grid;
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: var(--fc-ink);
    font-size: 0.82rem;
    font-weight: 800;
}

.fc-section--departure .fc-section__step {
    background: #087a59;
}

.fc-section--arrival .fc-section__step {
    color: #563400;
    background: #ffc55f;
}

.fc-section h3 {
    font-size: 1.13rem;
    line-height: 1.15;
}

.fc-section__heading p {
    margin: 3px 0 0;
    color: var(--fc-ink-soft);
    font-size: 0.875rem;
}

.fc-fields {
    display: grid;
    gap: 18px;
}

.fc-fields--two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.fc-field {
    min-width: 0;
}

.fc-field > label,
.fc-value-input > label {
    display: block;
    margin-bottom: 7px;
    color: var(--fc-ink);
    font-size: 0.9rem;
    font-weight: 680;
}

.fc-field > label span {
    color: var(--fc-ink-soft);
    font-weight: 500;
}

.fc-field input:not([type="range"]),
.fc-field textarea {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid var(--fc-line-strong);
    border-radius: 10px;
    color: var(--fc-ink);
    background: #fff;
    box-shadow: 0 1px 1px rgba(23, 42, 63, 0.02);
    transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.fc-field textarea {
    min-height: 70px;
    resize: vertical;
}

.fc-field input[readonly] {
    color: #52657a;
    background: #eef3f8;
    cursor: not-allowed;
}

.fc-field input:not([type="range"]):focus,
.fc-field textarea:focus,
.fc-record-delete:focus-visible,
.fc-save-button:focus-visible,
.fc-table-wrap:focus-visible {
    outline: none;
    border-color: var(--fc-blue);
    box-shadow: 0 0 0 4px rgba(23, 105, 214, 0.16);
}

.fc-field input:invalid:not(:placeholder-shown) {
    border-color: var(--fc-red);
}

.fc-field--gauge {
    grid-row: span 2;
}

.fc-gauge {
    position: relative;
    padding-top: 3px;
}

.fc-gauge__range {
    display: block;
    width: 100%;
    height: var(--fc-thumb-size);
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    outline: none;
    background: linear-gradient(to right, var(--fc-blue) 0%, var(--fc-blue) var(--fc-range-progress, 0%), #d9e4ed var(--fc-range-progress, 0%), #d9e4ed 100%);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.fc-gauge__range:disabled {
    opacity: 0.72;
    cursor: not-allowed;
}

.fc-gauge__range::-webkit-slider-runnable-track {
    height: 8px;
    border-radius: 999px;
    background: transparent;
}

.fc-gauge__range::-webkit-slider-thumb {
    width: var(--fc-thumb-size);
    height: var(--fc-thumb-size);
    margin-top: -10px;
    border: 4px solid #fff;
    border-radius: 50%;
    background: var(--fc-ink);
    box-shadow: 0 2px 7px rgba(23, 42, 63, 0.25);
    cursor: grab;
    appearance: none;
    -webkit-appearance: none;
}

.fc-gauge__range:active::-webkit-slider-thumb {
    cursor: grabbing;
}

.fc-gauge__range::-moz-range-track {
    height: 8px;
    border: 0;
    border-radius: 999px;
    background: transparent;
}

.fc-gauge__range::-moz-range-thumb {
    width: calc(var(--fc-thumb-size) - 8px);
    height: calc(var(--fc-thumb-size) - 8px);
    border: 4px solid #fff;
    border-radius: 50%;
    background: var(--fc-ink);
    box-shadow: 0 2px 7px rgba(23, 42, 63, 0.25);
    cursor: grab;
}

.fc-gauge__range:focus-visible::-webkit-slider-thumb {
    outline: 3px solid rgba(23, 105, 214, 0.35);
    outline-offset: 3px;
}

.fc-gauge__range:focus-visible::-moz-range-thumb {
    outline: 3px solid rgba(23, 105, 214, 0.35);
    outline-offset: 3px;
}

.fc-gauge__labels {
    position: relative;
    height: 26px;
    margin: 7px calc(var(--fc-thumb-size) / 2) 0;
    color: #64788b;
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
}

.fc-gauge__labels span {
    position: absolute;
    top: 6px;
    left: calc(var(--fc-mark) * 12.5%);
    min-width: max-content;
    transform: translateX(-50%);
    text-align: center;
}

.fc-gauge__labels span::before {
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    width: 1px;
    height: 5px;
    background: #9dafbd;
    content: "";
}

.fc-value-input {
    display: inline-flex;
    align-items: stretch;
    width: min(100%, 150px);
    margin-top: 3px;
}

.fc-value-input input {
    min-width: 0;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.fc-value-input span {
    display: grid;
    min-width: 38px;
    place-items: center;
    border: 1px solid var(--fc-line-strong);
    border-left: 0;
    border-radius: 0 10px 10px 0;
    color: var(--fc-ink-soft);
    background: #eef3f8;
    font-size: 0.86rem;
    font-weight: 700;
}

.fc-field--notes {
    grid-column: span 2;
}

.fc-live-results {
    position: relative;
    overflow: hidden;
    margin-top: 16px;
    padding: clamp(20px, 3vw, 30px);
    border: 1px solid #bccce0;
    border-radius: var(--fc-radius-lg);
    background: #e9f2ff;
}

.fc-live-results::before {
    position: absolute;
    right: -36px;
    bottom: -65px;
    width: 190px;
    height: 190px;
    border: 26px solid rgba(23, 105, 214, 0.08);
    border-radius: 50%;
    content: "";
}

.fc-live-results__heading,
.fc-history__heading {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.fc-live-results h3,
.fc-history h3 {
    font-size: 1.25rem;
    line-height: 1.15;
}

.fc-live-status {
    max-width: 300px;
    margin: 3px 0 0;
    color: var(--fc-ink-soft);
    font-size: 0.84rem;
    text-align: right;
}

.fc-result-grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.fc-result-card {
    min-height: 112px;
    padding: 16px;
    border: 1px solid rgba(23, 105, 214, 0.17);
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.76);
}

.fc-result-card > span {
    display: block;
    min-height: 39px;
    color: var(--fc-ink-soft);
    font-size: 0.82rem;
    font-weight: 640;
}

.fc-result-card output {
    color: var(--fc-ink);
    font-size: clamp(1.4rem, 3.2vw, 2rem);
    font-weight: 760;
    letter-spacing: -0.045em;
    font-variant-numeric: tabular-nums;
}

.fc-result-card small {
    margin-left: 3px;
    color: var(--fc-ink-soft);
    font-size: 0.8rem;
    font-weight: 700;
}

.fc-result-card--balance.is-saving {
    border-color: rgba(8, 122, 89, 0.28);
    background: var(--fc-green-wash);
}

.fc-result-card--balance.is-saving output,
.fc-result-card--balance.is-saving > span {
    color: var(--fc-green);
}

.fc-result-card--balance.is-overuse {
    border-color: rgba(182, 64, 67, 0.28);
    background: var(--fc-red-wash);
}

.fc-result-card--balance.is-overuse output,
.fc-result-card--balance.is-overuse > span {
    color: var(--fc-red);
}

.fc-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 18px;
    padding-top: 22px;
}

.fc-save-button {
    min-height: 46px;
    padding: 11px 22px;
    border: 0;
    border-radius: 10px;
    color: #fff;
    background: var(--fc-blue);
    box-shadow: 0 7px 14px rgba(23, 105, 214, 0.23);
    cursor: pointer;
    font-weight: 720;
    transition: transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.fc-save-button:hover:not(:disabled) {
    background: var(--fc-blue-dark);
    box-shadow: 0 10px 19px rgba(23, 105, 214, 0.28);
    transform: translateY(-1px);
}

.fc-save-button:disabled {
    cursor: wait;
    opacity: 0.68;
}

.fc-form-message {
    min-height: 1.35em;
    margin: 0;
    color: var(--fc-ink-soft);
    font-size: 0.88rem;
    text-align: right;
}

.fc-form-message.is-success {
    color: var(--fc-green);
}

.fc-form-message.is-error {
    color: var(--fc-red);
}

.fc-history {
    padding: clamp(21px, 3.5vw, 40px);
    border: 1px solid var(--fc-line);
    border-top: 0;
    border-radius: 0 0 var(--fc-radius-xl) var(--fc-radius-xl);
    background: var(--fc-paper);
    box-shadow: var(--fc-shadow);
}

.fc-history__heading > span {
    margin-top: 3px;
    color: var(--fc-ink-soft);
    font-size: 0.82rem;
}

.fc-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--fc-line);
    border-radius: 12px;
}

.fc-history-table {
    width: 100%;
    min-width: 960px;
    border-collapse: collapse;
    color: var(--fc-ink);
    font-size: 0.84rem;
}

.fc-history-table th,
.fc-history-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--fc-line);
    text-align: left;
    vertical-align: middle;
}

.fc-history-table th {
    color: #4d6278;
    background: #f5f8fb;
    font-size: 0.72rem;
    font-weight: 760;
    letter-spacing: 0.035em;
    text-transform: uppercase;
    white-space: nowrap;
}

.fc-history-table tbody tr:last-child td {
    border-bottom: 0;
}

.fc-history-table tbody tr:hover {
    background: #f8fbfe;
}

.fc-empty-row td {
    padding: 28px;
    color: var(--fc-ink-soft);
    text-align: center;
}

.fc-notes-cell {
    max-width: 230px;
}

.fc-balance {
    display: inline-block;
    font-weight: 750;
    white-space: nowrap;
}

.fc-balance.is-saving {
    color: var(--fc-green);
}

.fc-balance.is-overuse {
    color: var(--fc-red);
}

.fc-record-delete {
    min-height: 34px;
    padding: 5px 10px;
    border: 1px solid #e4b9ba;
    border-radius: 7px;
    color: var(--fc-red);
    background: #fff;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 690;
    transition: background-color 160ms ease, color 160ms ease;
}

.fc-record-delete:hover {
    color: #fff;
    background: var(--fc-red);
}

.screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 760px) {
    .fuel-ledger {
        margin: 18px 0;
    }

    .fc-hero {
        align-items: stretch;
        flex-direction: column;
        padding: 25px 20px;
        border-radius: 18px 18px 0 0;
    }

    .fc-capacity {
        width: fit-content;
    }

    .fc-entry-form,
    .fc-history {
        padding: 15px;
    }

    .fc-section,
    .fc-live-results {
        padding: 18px;
        border-radius: 14px;
    }

    .fc-fields--two,
    .fc-result-grid {
        grid-template-columns: 1fr;
    }

    .fc-field--gauge,
    .fc-field--notes {
        grid-row: auto;
        grid-column: auto;
    }

    .fc-live-results__heading,
    .fc-history__heading {
        display: block;
    }

    .fc-live-status {
        max-width: none;
        margin-top: 8px;
        text-align: left;
    }

    .fc-result-card {
        display: grid;
        min-height: 0;
        grid-template-columns: 1fr auto auto;
        align-items: baseline;
        gap: 5px;
        padding: 14px;
    }

    .fc-result-card > span {
        min-height: 0;
    }

    .fc-actions {
        align-items: stretch;
        flex-direction: column-reverse;
        gap: 10px;
    }

    .fc-save-button {
        width: 100%;
    }

    .fc-form-message {
        text-align: left;
    }

    .fc-history {
        border-radius: 0 0 18px 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fuel-ledger *,
    .fuel-ledger *::before,
    .fuel-ledger *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
