:root {
    --radius: 18px;
    --spacing: 14px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;

    background:
        var(--tg-theme-bg-color, #f2f2f7);

    color:
        var(--tg-theme-text-color, #111111);
}

body {
    padding-bottom: 30px;
}

button,
input {
    font-family: inherit;
}

button {
    cursor: pointer;
}

.app {
    width: 100%;
    max-width: 620px;

    margin: 0 auto;

    padding:
        18px
        16px
        40px;
}


/* =========================
   HEADER
========================= */

.header {
    display: flex;

    justify-content: space-between;
    align-items: center;

    margin-bottom: 20px;
}

.logo {
    font-size: 25px;
    font-weight: 800;

    letter-spacing: -0.5px;
}

.subtitle {
    margin-top: 3px;

    font-size: 13px;

    color:
        var(--tg-theme-hint-color, #888);
}

.icon-button {
    width: 42px;
    height: 42px;

    border: none;
    border-radius: 14px;

    background:
        var(--tg-theme-secondary-bg-color, #ffffff);

    font-size: 20px;
}


/* =========================
   HERO
========================= */

.hero-card {
    position: relative;

    overflow: visible;

    padding: 28px 20px;

    border-radius: 24px;

    text-align: center;

    background:
        var(--tg-theme-button-color, #2481cc);

    color:
        var(--tg-theme-button-text-color, #ffffff);

    box-shadow:
        0 8px 25px rgba(0, 0, 0, 0.08);
}

.hero-card::after {
    content: "";
    pointer-events: none;

    position: absolute;

    width: 150px;
    height: 150px;

    right: -60px;
    bottom: -70px;

    border-radius: 50%;

    background:
        rgba(255, 255, 255, 0.08);
}

.hero-label {
    position: relative;

    z-index: 1;

    font-size: 14px;

    opacity: .85;
}


.info-button:active {
    transform: scale(.94);

    background:
        rgba(255, 255, 255, .22);
}

.hero-value {
    position: relative;

    z-index: 1;

    margin-top: 7px;

    font-size: 48px;

    font-weight: 800;

    letter-spacing: -2px;
}

.hero-unit {
    position: relative;

    z-index: 1;

    font-size: 14px;

    opacity: .8;
}


/* =========================
   STAT CARDS
========================= */

.stats-grid {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 12px;

    margin-top: 12px;
}

.stat-card {
    padding: 17px;

    border-radius: var(--radius);

    background:
        var(--tg-theme-secondary-bg-color, #ffffff);
}

.stat-icon {
    font-size: 20px;

    margin-bottom: 12px;
}

.stat-label {
    font-size: 12px;

    color:
        var(--tg-theme-hint-color, #888);
}

.stat-value {
    margin-top: 4px;

    font-size: 22px;

    font-weight: 750;
}

.stat-unit {
    font-size: 12px;

    color:
        var(--tg-theme-hint-color, #888);
}


/* =========================
   BUTTONS
========================= */

.primary-button {
    width: 100%;

    margin-top: 14px;

    padding: 16px 18px;

    border: none;

    border-radius: 17px;

    background:
        var(--tg-theme-button-color, #2481cc);

    color:
        var(--tg-theme-button-text-color, #ffffff);

    font-size: 16px;

    font-weight: 750;

    transition:
        transform .1s ease,
        opacity .1s ease;
}

.primary-button:active {
    transform: scale(.98);

    opacity: .85;
}


.menu-grid {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 12px;

    margin-top: 12px;
}

.menu-button {
    display: flex;

    align-items: center;
    justify-content: center;

    gap: 8px;

    padding: 16px;

    border: none;

    border-radius: 17px;

    background:
        var(--tg-theme-secondary-bg-color, #ffffff);

    color:
        var(--tg-theme-text-color, #111);

    font-size: 14px;

    font-weight: 650;
}

.menu-icon {
    font-size: 18px;
}


/* =========================
   LAST FUEL
========================= */

.last-fuel-card {
    margin-top: 12px;

    padding: 18px;

    border-radius: var(--radius);

    background:
        var(--tg-theme-secondary-bg-color, #ffffff);
}

.section-title {
    margin-bottom: 12px;

    font-size: 15px;

    font-weight: 750;
}

.last-fuel-row {
    display: flex;

    justify-content: space-between;

    align-items: center;

    padding: 7px 0;

    font-size: 14px;
}

.last-fuel-row span:last-child {
    font-weight: 650;
}


/* =========================
   PAGE
========================= */

.page {
    animation:
        pageIn .18s ease;
}

@keyframes pageIn {

    from {
        opacity: 0;
        transform: translateY(5px);
    }

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

}

.page-header {
    display: flex;

    align-items: center;

    gap: 12px;

    margin-bottom: 18px;
}

.back-button {
    width: 42px;
    height: 42px;

    border: none;

    border-radius: 13px;

    background:
        var(--tg-theme-secondary-bg-color, #ffffff);

    color:
        var(--tg-theme-text-color, #111);

    font-size: 22px;
}

.page-title {
    font-size: 24px;

    font-weight: 800;

    letter-spacing: -.4px;
}

.page-subtitle {
    margin-top: 2px;

    font-size: 13px;

    color:
        var(--tg-theme-hint-color, #888);
}


/* =========================
   FORM
========================= */

.form-card {
    padding: 18px;

    border-radius: var(--radius);

    background:
        var(--tg-theme-secondary-bg-color, #ffffff);
}

.input-label {
    display: block;

    margin-bottom: 17px;

    font-size: 13px;

    font-weight: 650;
}

.input-wrapper {
    display: flex;

    align-items: center;

    margin-top: 7px;

    padding-right: 14px;

    border-radius: 13px;

    background:
        var(--tg-theme-bg-color, #f2f2f7);
}

.input-wrapper input {
    flex: 1;

    min-width: 0;

    border: none;

    outline: none;

    padding: 14px;

    background: transparent;

    color:
        var(--tg-theme-text-color, #111);

    font-size: 17px;
}

.input-wrapper span {
    font-size: 13px;

    color:
        var(--tg-theme-hint-color, #888);
}

.input-label > input {
    width: 100%;

    margin-top: 7px;

    padding: 14px;

    border: none;

    outline: none;

    border-radius: 13px;

    background:
        var(--tg-theme-bg-color, #f2f2f7);

    color:
        var(--tg-theme-text-color, #111);

    font-size: 17px;
}


/* =========================
   CHECKBOX
========================= */

.checkbox-row {
    position: relative;

    display: flex;

    align-items: center;

    gap: 11px;

    margin: 20px 0;

    cursor: pointer;
}

.checkbox-row input {
    position: absolute;

    opacity: 0;

    pointer-events: none;
}

.custom-checkbox {
    width: 24px;
    height: 24px;

    flex-shrink: 0;

    border-radius: 7px;

    background:
        var(--tg-theme-bg-color, #f2f2f7);

    border:
        2px solid
        var(--tg-theme-hint-color, #aaa);
}

.checkbox-row input:checked
~ .custom-checkbox {

    background:
        var(--tg-theme-button-color, #2481cc);

    border-color:
        var(--tg-theme-button-color, #2481cc);
}

.checkbox-row input:checked
~ .custom-checkbox::after {

    content: "✓";

    display: flex;

    align-items: center;

    justify-content: center;

    height: 100%;

    color: white;

    font-size: 15px;

    font-weight: 800;
}

.checkbox-text {
    display: flex;

    flex-direction: column;

    gap: 2px;
}

.checkbox-text strong {
    font-size: 14px;
}

.checkbox-text small {
    font-size: 12px;

    color:
        var(--tg-theme-hint-color, #888);
}


/* =========================
   CALCULATION
========================= */

.calculation-preview {
    margin: 12px 0;

    padding: 14px;

    border-radius: 13px;

    background:
        var(--tg-theme-bg-color, #f2f2f7);

    font-size: 14px;

    line-height: 1.5;
}


/* =========================
   HISTORY
========================= */

.history-item {
    margin-bottom: 10px;

    padding: 17px;

    border-radius: var(--radius);

    background:
        var(--tg-theme-secondary-bg-color, #ffffff);
}

.history-top {
    display: flex;

    justify-content: space-between;

    gap: 10px;
}

.history-date {
    font-size: 12px;

    color:
        var(--tg-theme-hint-color, #888);
}

.history-mileage {
    margin-top: 5px;

    font-size: 18px;

    font-weight: 750;
}

.history-data {
    display: flex;

    flex-wrap: wrap;

    gap: 8px;

    margin-top: 10px;

    font-size: 13px;

    color:
        var(--tg-theme-hint-color, #888);
}

.history-actions {
    display: flex;

    gap: 8px;

    margin-top: 13px;
}

.small-button {
    flex: 1;

    padding: 9px;

    border: none;

    border-radius: 10px;

    background:
        var(--tg-theme-bg-color, #f2f2f7);

    color:
        var(--tg-theme-text-color, #111);

    font-size: 12px;
}

.delete-button {
    color: #e53935;
}


/* =========================
   STATS
========================= */

.stat-row {
    display: flex;

    justify-content: space-between;

    gap: 15px;

    padding: 15px 0;

    border-bottom:
        1px solid
        rgba(128, 128, 128, .15);

    font-size: 14px;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row strong {
    text-align: right;
}


/* =========================
   DANGER
========================= */

.danger-button {
    width: 100%;

    margin-top: 12px;

    padding: 15px;

    border: none;

    border-radius: 15px;

    background:
        rgba(229, 57, 53, .12);

    color: #e53935;

    font-size: 14px;

    font-weight: 700;
}


/* =========================
   EMPTY
========================= */

.empty {
    padding: 35px 15px;

    text-align: center;

    color:
        var(--tg-theme-hint-color, #888);
}

.empty-icon {
    font-size: 42px;

    margin-bottom: 10px;
}

.empty-title {
    font-size: 17px;

    font-weight: 700;

    color:
        var(--tg-theme-text-color, #111);
}

.empty-text {
    margin-top: 6px;

    font-size: 13px;
}


/* =========================
   UTILITY
========================= */

.hidden {
    display: none !important;
}


/* =========================
   MOBILE
========================= */

@media (max-width: 380px) {

    .app {
        padding-left: 12px;
        padding-right: 12px;
    }

    .hero-value {
        font-size: 42px;
    }

    .stat-value {
        font-size: 19px;
    }

}
/* =========================
   CONSUMPTION INFO MODAL
========================= */

.modal-overlay {
    position: fixed;

    inset: 0;

    z-index: 1000;

    display: flex;

    align-items: flex-end;

    justify-content: center;

    padding: 16px;

    background:
        rgba(0, 0, 0, .35);

    backdrop-filter:
        blur(4px);
}

.modal-card {
    width: 100%;

    max-width: 620px;

    padding: 20px;

    border-radius: 22px;

    background:
        var(
            --tg-theme-secondary-bg-color,
            #ffffff
        );

    color:
        var(
            --tg-theme-text-color,
            #111111
        );

    box-shadow:
        0 12px 40px
        rgba(0, 0, 0, .18);

    animation:
        modalIn .18s ease;
}

@keyframes modalIn {

    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

}

.modal-header {
    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 12px;

    margin-bottom: 14px;
}

.modal-title {
    font-size: 18px;

    font-weight: 800;
}

.modal-close {
    width: 32px;
    height: 32px;

    flex-shrink: 0;

    padding: 0;

    border: none;

    border-radius: 50%;

    background:
        var(
            --tg-theme-bg-color,
            #f2f2f7
        );

    color:
        var(
            --tg-theme-text-color,
            #111
        );

    font-size: 22px;

    line-height: 30px;
}

.modal-content {
    font-size: 14px;

    line-height: 1.55;

    color:
        var(
            --tg-theme-text-color,
            #111111
        );
}

.modal-content p {
    margin: 0 0 12px;
}

.modal-content p:last-child {
    margin-bottom: 0;
}
/* =========================
   CONSUMPTION INFO
========================= */

.hero-label-row {
    position: relative;

    z-index: 5;

    display: flex;

    align-items: center;

    justify-content: center;

    gap: 7px;
}


.consumption-info {
    position: relative;

    z-index: 20;
}


.info-button {
    width: 24px;
    height: 24px;

    display: flex;

    align-items: center;
    justify-content: center;

    padding: 0;

    border: none;

    border-radius: 50%;

    background:
        rgba(255, 255, 255, .14);

    color:
        rgba(255, 255, 255, .95);

    font-size: 15px;

    line-height: 1;

    cursor: pointer;

    list-style: none;
}


.info-button::-webkit-details-marker {
    display: none;
}


.info-button:active {
    transform: scale(.94);
}


.info-popover {
    position: absolute;

    top: 36px;

    left: 50%;

    right: auto;

    transform: translateX(-50%);

    width: 300px;

    max-width: calc(100vw - 32px);

    padding: 17px;

    border-radius: 16px;

    background:
        var(
            --tg-theme-secondary-bg-color,
            #ffffff
        );

    color:
        var(
            --tg-theme-text-color,
            #111111
        );

    text-align: left;

    box-shadow:
        0 10px 30px
        rgba(0, 0, 0, .20);

    font-size: 13px;

    line-height: 1.5;
}


.info-popover-title {
    margin-bottom: 9px;

    font-size: 15px;

    font-weight: 800;
}


.info-popover p {
    margin: 0 0 10px;
}


.info-popover p:last-child {
    margin-bottom: 0;
}


.consumption-method {
    position: relative;

    z-index: 1;

    margin-top: 9px;

    font-size: 13px;

    font-weight: 650;

    opacity: .95;
}


.consumption-hint {
    position: relative;

    z-index: 1;

    margin-top: 4px;

    font-size: 11px;

    line-height: 1.35;

    opacity: .72;
}
/* =========================
   HISTORY CONSUMPTION
========================= */

.history-consumption {
    margin-top: 13px;

    padding: 12px 13px;

    border-radius: 13px;

    background:
        var(
            --tg-theme-bg-color,
            #f2f2f7
        );
}


.history-consumption-row {
    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 10px;

    padding: 3px 0;

    font-size: 14px;
}


.history-consumption-row strong {
    font-size: 14px;
}


.history-consumption-label {
    margin-top: 5px;

    font-size: 11px;

    color:
        var(
            --tg-theme-hint-color,
            #888
        );
}


.history-first {
    margin-top: 13px;

    padding: 10px 12px;

    border-radius: 11px;

    background:
        var(
            --tg-theme-bg-color,
            #f2f2f7
        );

    color:
        var(
            --tg-theme-hint-color,
            #888
        );

    font-size: 12px;
}
/* =========================
   LAST TRIP
========================= */

.last-trip-main {
    text-align: center;

    padding: 4px 0 16px;
}


.last-trip-distance {
    font-size: 34px;

    font-weight: 800;

    letter-spacing: -1px;
}


.last-trip-distance span {
    font-size: 15px;

    font-weight: 600;

    color:
        var(
            --tg-theme-hint-color,
            #888
        );
}


.last-trip-label {
    margin-top: 3px;

    font-size: 12px;

    color:
        var(
            --tg-theme-hint-color,
            #888
        );
}


.last-trip-stats {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 10px;
}


.last-trip-stat {
    display: flex;

    align-items: center;

    gap: 9px;

    padding: 12px;

    border-radius: 13px;

    background:
        var(
            --tg-theme-bg-color,
            #f2f2f7
        );
}


.last-trip-stat-icon {
    font-size: 19px;
}


.last-trip-stat-value {
    font-size: 16px;

    font-weight: 750;
}


.last-trip-stat-label {
    margin-top: 2px;

    font-size: 11px;

    color:
        var(
            --tg-theme-hint-color,
            #888
        );
}
/* =========================
   STATS PERIODS
========================= */

.stats-period-tabs {
    display: flex;

    gap: 7px;

    margin-bottom: 12px;

    overflow-x: auto;

    padding-bottom: 2px;

    scrollbar-width: none;
}


.stats-period-tabs::-webkit-scrollbar {
    display: none;
}


.stats-period-button {
    flex: 0 0 auto;

    padding: 10px 13px;

    border: none;

    border-radius: 12px;

    background:
        var(
            --tg-theme-secondary-bg-color,
            #ffffff
        );

    color:
        var(
            --tg-theme-hint-color,
            #888
        );

    font-size: 12px;

    font-weight: 650;

    white-space: nowrap;
}


.stats-period-button.active {
    background:
        var(
            --tg-theme-button-color,
            #2481cc
        );

    color:
        var(
            --tg-theme-button-text-color,
            #ffffff
        );
}