@media screen and (max-width: 1300px) {
  html {
    font-size: 56.25%;
  }

  .header:not(.hidden) {
    /* Säilytetään keskitetty sijainti */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
  }

  .app.active {
    /* top: 60%; */
    grid-template-columns: 1.5fr 1fr;
  }
}
/* Tablet Landscape (1024px and below) */
@media screen and (max-width: 1024px) {
  html {
    font-size: 56.25%; /* 9px */
  }

  .app.active {
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: auto auto auto auto auto auto !important;
    gap: 2rem !important;
    padding: 2rem !important;
    position: relative !important;
    left: 50% !important; /* Asetetaan vasemmalta 50% */
    transform: translateX(-50%) !important; /* Keskitetään X-akselilla */
    margin-top: 4rem !important;
    margin-bottom: 4rem !important;
    width: min(90%, 140rem) !important;
    height: auto !important;
    min-height: 80vh !important;
  }

  /* Aseta grid-alueet lapsielementeille */
  .search-container {
    grid-column: 1 / -1;
    grid-row: 1;
    gap: 2rem;
  }

  .balance {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .movements {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .operations-column {
    grid-column: 1 / -1;
    grid-row: 4;
  }

  .expense-summary {
    grid-column: 1 / -1;
    grid-row: 5;
  }

  .user-controls {
    grid-column: 1 / -1;
    grid-row: 7;
    padding: 0 0.3rem;
    /* margin-top: 1.9rem; */
    text-align: left;
    font-size: 1.25rem;
  }

  /* .header:not(.hidden) {
    top: 35%;
    width: 80%; 
  }

  .header__title {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
    gap: 2rem;
  }

  .header__img {
    grid-column: 1;
    grid-row: 1;
    transform: none;
    max-width: 50%; 
    margin-bottom: 2rem; 
  } */

  h1 {
    font-size: 4rem;
  }
  /* Operations */
  .operation {
    border-radius: 1rem;
    padding: 2rem 3rem;
    color: #333;
  }

  .form__inputs {
    display: grid;
    grid-template-columns: 2.5fr 2.5fr 1.5fr; /* Changed column sizes */
    gap: 1rem;
    width: 100%;
  }

  .form__input {
    font-size: 1.6rem;
    padding: 0.5rem 1rem;
  }

  .form__btn {
    width: 15rem; /* Napit ovat saman kokoisia */
  }

  .form__btn:nth-child(2) {
    margin-left: auto; /* Siirtää toisen napin oikealle */
  }

  /* search */
  .search-container {
    margin-right: 1rem;
    gap: 0.8rem;
  }

  .search-input {
    width: 20rem;
    font-size: 1.3rem;
  }

  .search-date-from,
  .search-date-to {
    width: 11rem;
    font-size: 1.3rem;
  }

  .movements__row {
    grid-template-columns: 120px 1fr auto;
    gap: 1rem;
    padding: 0.8rem 1rem;
  }

  .grid--footer {
    gap: 2rem;
    padding: 0 1rem;
  }

  .capten-container {
    width: 6rem;
    height: 6rem;
  }

  .expense-summary__filters {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: 1fr 1fr;
    grid-row-gap: 1rem;
    grid-column-gap: 0.5rem;
    align-items: center;
  }

  .expense-summary__filters label {
    margin-right: 0;
  }

  .expense-summary__filters label:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
  }

  .expense-summary__filters select:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
  }

  .expense-summary__filters label:nth-child(3) {
    grid-column: 1;
    grid-row: 2;
  }

  .expense-summary__filters select:nth-child(4) {
    grid-column: 2;
    grid-row: 2;
  }
}

/* Tablet Portrait (768px and below) */
@media screen and (max-width: 780px) {
  html {
    font-size: 50%;
  }

  nav {
    min-height: 10rem;
  }

  .welcome {
    display: none;
  }

  .header:not(.hidden) {
    /* Keskitetty sijainti tablet-koossa */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 90rem;
  }

  .form__btn {
    width: 12rem; /* Napit ovat saman kokoisia */
  }

  .form--close .form__column {
    width: 60%;
  }

  .form--close .form__btn--close {
    width: 30%;
    margin-top: 1rem;
  }

  /* Movements */
  .movements__row {
    grid-template-columns: 90px 1fr auto;
    gap: 0.8rem;
  }

  .movements__value {
    font-size: 1.6rem;
  }

  /* Footer optimointi pienemmille näytöille */
  .footer {
    padding: 1.5rem 2rem;
  }

  .expense-summary__header {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .summary-totals {
    min-width: 20rem;
  }
}

@media screen and (max-width: 680px) {
  .expense-summary__header {
    display: grid;
    grid-template-columns: 1fr;
  }

  nav {
    padding: 0 2rem; /* Vähennä paddingia */
  }

  /* Siirrä welcome oikealle */
  .welcome {
    font-size: 1.6rem; /* Pienempi fonttikoko mobiililla */
  }

  .login__input {
    width: auto; /* Anna inputien mukautua koon mukaan */
  }

  .login__input--user {
    width: 20rem; /* Pienempi koko mobiililla */
  }

  .login__input--pin {
    width: 12rem;
  }
}

/* Mobile (480px and below) */
@media screen and (max-width: 480px) {
  html {
    font-size: 35%;
  }

  .welcome {
    font-size: 1.4rem;
    margin-right: 1rem;
  }

  .app.active {
    margin-top: 2rem; /* Pienempi margin pienillä näytöillä */
    margin-bottom: 3rem;
    padding: 1.5rem; /* Pienempi padding enemmän tilaa sisällölle */
  }

  .header:not(.hidden) {
    /* Keskitetty sijainti pienemmille näytöille */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 75%;
    max-width: 70rem;
  }

  /* Navigation optimointi */
  nav {
    padding: 0 1rem;
    min-height: 7rem;
  }

  /* Login input optimointi */
  .login__input {
    padding: 0.6rem 1rem;
  }

  /* Operations container optimointi */
  .operations {
    padding: 1rem;
  }

  .form__inputs {
    grid-template-columns: 1fr; /* Muuta syötekentät allekkain mobiilinäkymässä */
    gap: 0.8rem;
    /* Mobile korjaukset */
    min-width: 0;
    overflow: visible; /* Salli elementtien näkyminen */
  }

  .form__input {
    /* Mobile korjaukset */
    min-width: 0;
    width: 100%;
    /* iOS korjaukset */
    font-size: max(16px, 1.4rem); /* Estä zoom iOS:ssä */
    -webkit-text-size-adjust: 100%;
  }

  .form__btn {
    width: 100%; /* Napit täyteen leveyteen */
    margin-top: 0.8rem;
  }

  /* Movements */
  .movements__date {
    font-size: 1.3rem; /* Suurennettu 1.2rem -> 1.3rem */
  }

  .movements__description {
    font-size: 1.4rem; /* Suurennettu 1.3rem -> 1.4rem */
  }

  .movements__value {
    font-size: 1.5rem; /* Suurennettu 1.4rem -> 1.5rem */
  }

  /* Expense summary optimointi */
  .expense-summary__box {
    min-height: 70px;
    padding: 1rem;
  }

  .expense-summary__filters {
    grid-row-gap: 0.8rem;
  }

  /* Footer optimointi pienemmille näytöille */
  .footer {
    padding: 1rem 1.5rem;
  }

  .footerItems {
    gap: 1rem;
  }

  /* Modal optimointi */
  .modal-header {
    padding: 1.2rem 1.5rem;
  }

  .modal-header h2 {
    font-size: 2rem;
  }

  .close-button {
    font-size: 24px;
  }

  .modal-close-btn {
    padding: 6px 12px;
    font-size: 1.8rem;
  }

  .modal-body {
    max-height: 35rem; /* Pienemmät näytöt saavat pienemmän korkeuden */
    padding: 1.2rem;
  }

  .modal-body li {
    padding: 1rem;
    grid-template-columns: 80px 1fr 80px;
    font-size: 1.6rem;
  }

  /* Expense modal perusasetukset */
  .expense-modal {
    min-width: 30rem; /* Pienempi minimi leveys pienemmillä näytöillä */
    width: 90%;
    max-width: 50rem;
  }
}

@media screen and (max-width: 380px) {
  html {
    font-size: 30%;
  }

  /* Navigaation parannukset */
  nav {
    padding: 0 0.8rem;
    min-height: 6rem;
  }

  .login__input--user {
    width: 18rem;
  }

  .login__input--pin {
    width: 10rem;
  }

  /* App-näkymän parannukset */
  .app.active {
    padding: 1rem;
    margin-top: 1.5rem;
    margin-bottom: 2rem;
  }

  /* Operations alueen optimointi */
  .operation {
    padding: 1.5rem 1rem;
  }

  .form__input {
    padding: 0.4rem 0.8rem;
    /* Mobile korjaukset */
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    /* iOS korjaukset */
    font-size: max(16px, 1.2rem); /* Estä zoom iOS:ssä */
    -webkit-text-size-adjust: 100%;
    min-height: 44px; /* iOS suositus */
  }

  /* Movements optimointi */
  .movements__row {
    grid-template-columns: 60px 1fr auto;
    gap: 1rem;
    padding: 0.8rem 1rem;
  }

  .movements__date {
    font-size: 1.1rem;
  }

  /* search */
  .search-container {
    padding: 0 0.5rem;
    gap: 0.6rem;
  }

  .search-input,
  .search-date-from,
  .search-date-to {
    font-size: 1.1rem;
    padding: 0.4rem 0.8rem;
  }

  .search-button {
    width: 2.8rem;
    height: 2.8rem;
  }

  .search-button i {
    font-size: 1.4rem;
  }

  /* Modal optimointi 380px näytöille */
  .expense-modal {
    min-width: 28rem;
    width: 95%;
  }

  .modal-header {
    padding: 1rem 1.2rem;
  }

  .modal-header h2 {
    font-size: 1.8rem;
  }

  .close-button {
    font-size: 22px;
  }

  .modal-body {
    max-height: 30rem;
    padding: 1rem;
  }

  .modal-body li {
    padding: 0.8rem;
    grid-template-columns: 70px 1fr 70px;
    font-size: 1.5rem;
  }

  /* Expense summary box optimization for small screens */
  .expense-summary__container {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.8rem;
    padding: 0.8rem;
  }

  .expense-summary__box {
    padding: 1rem;
  }

  .expense-summary__box h3 {
    font-size: 1.6rem;
    margin-bottom: 0.6rem;
  }

  .expense-summary__box p {
    font-size: 1.6rem;
  }

  .expense-summary__box .expense-summary__amount {
    font-size: 2.4rem;
    padding-top: 0.8rem;
  }
}

/* Small Mobile (320px and below) */
@media screen and (max-width: 320px) {
  html {
    font-size: 25%;
  }

  /* Navigaation parannukset */
  nav {
    padding: 0 0.6rem;
    min-height: 5.5rem;
  }

  .login__input--user {
    width: 16rem;
  }

  .login__input--pin {
    width: 9rem;
  }

  /* App-näkymän parannukset */
  .app.active {
    padding: 0.8rem;
    margin-top: 1rem;
    margin-bottom: 1.5rem;
  }

  /* Expense summary box optimization for very small screens */
  .expense-summary__container {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.6rem;
    padding: 0.6rem;
  }

  .expense-summary__box {
    padding: 0.8rem;
  }

  .expense-summary__box h3 {
    font-size: 1.2rem;
    margin-bottom: 0.4rem;
  }

  .expense-summary__box p {
    font-size: 1.4rem;
  }

  .expense-summary__box .expense-summary__amount {
    font-size: 1.6rem;
    padding-top: 0.6rem;
  }

  /* App-näkymän parannukset */
  .app.active {
    padding: 0.8rem;
    margin-top: 1rem;
    margin-bottom: 1.5rem;
  }

  /* Operations alueen optimointi */
  .operation {
    padding: 1.2rem 0.8rem;
  }

  /* Movements optimointi */
  .movements__row {
    grid-template-columns: 50px 1fr auto;
    gap: 0.8rem;
    padding: 0.6rem 0.8rem;
  }

  /* search */
  .search-container {
    padding: 0 0.4rem;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .search-input,
  .search-date-from,
  .search-date-to {
    font-size: 1.1rem;
    padding: 0.4rem 0.8rem;
  }

  .search-button {
    width: 2.8rem;
    height: 2.8rem;
  }

  .search-button i {
    font-size: 1.4rem;
  }

  /* Modal optimointi pienimmille näytöille */
  .expense-modal {
    min-width: 26rem;
    width: 98%;
  }

  .modal-header {
    padding: 1.2rem 1rem;
  }

  .modal-header h2 {
    font-size: 2rem;
  }

  .close-button {
    font-size: 20px;
  }

  .modal-body {
    max-height: 25rem;
    padding: 0.8rem;
  }

  .modal-body li {
    padding: 0.5rem;
    grid-template-columns: 60px 1fr 60px;
    font-size: 1.6rem;
  }
}

/* iPad pro landscape */
@media (max-width: 1370px) and (max-height: 1024px) {
  html {
    font-size: 50%;
  }

  .header:not(.hidden) {
    width: 75%;
  }
}

/* iPad Air landscape */
@media (max-width: 1200px) and (max-height: 850px) {
  html {
    font-size: 45%;
  }
}

/* iPad mini landscape */
@media (max-width: 1024px) and (max-height: 800px) {
  html {
    font-size: 45%;
  }
}

@media (max-width: 940px) and (max-height: 450px) {
  html {
    font-size: 35%;
  }

  .header:not(.hidden) {
    width: 55%;
    /* padding: 1rem;
    display: flex;
    flex-direction: row;
    height: 100vh;
  }

  .header__title {
    flex: 1;
    max-width: 100rem;
    display: grid;
    grid-template-columns: 3fr 2fr;
    row-gap: 2rem;
    align-content: center;
    justify-content: center;
    align-items: center;
    justify-items: center;
    position: relative;
    overflow-y: auto;
  }

  .header__img {
    grid-column: 2 / 3;
    grid-row: 1 / span 4;
    width: 100%;
    transform: translateY(0);
    margin-bottom: 2rem;
  } */
  }
}
@media (max-width: 750px) and (max-height: 550px) {
  html {
    font-size: 35%;
  }

  .header:not(.hidden) {
    width: 60%;
  }
}

@media screen and (orientation: portrait) and (max-width: 1180px) {
  html {
    font-size: 50%;
  }

  .header:not(.hidden) {
    width: 75%;
  }

  .header__title {
    grid-template-columns: 1fr;
    gap: 4rem;
    text-align: center;
    justify-items: center;
  }

  .header__img {
    grid-column: 1;
    grid-row: 1;
    transform: none;
    max-width: 75%;
  }
}

@media screen and (orientation: portrait) and (max-width: 768px) {
  html {
    font-size: 45%;
  }

  .header:not(.hidden) {
    top: 20%;
    width: 80%;
  }

  .header__title {
    grid-template-columns: 1fr;
    gap: 4rem;
    text-align: center;
    justify-items: center;
  }

  .header__img {
    grid-column: 1;
    grid-row: 1;
    transform: none;
    max-width: 75%;
  }
}

@media screen and (orientation: portrait) and (max-width: 550px) {
  html {
    font-size: 35%;
  }

  .header:not(.hidden) {
    top: 15%;
    width: 85%;
  }
}

@media screen and (orientation: portrait) and (max-width: 550px) and (max-height: 720px) {
  html {
    font-size: 35%;
  }

  .header:not(.hidden) {
    top: 18%;
    width: 85%;
  }

  .header__title {
    grid-template-columns: 1fr;
    gap: 4rem;
    text-align: center;
    justify-items: center;
  }

  .header__img {
    grid-column: 1;
    grid-row: 1;
    transform: none;
    max-width: 50%;
  }

  .login__input--user {
    width: 25rem;
  }

  .login__input--pin {
    width: 15rem;
  }
}

@media screen and (orientation: portrait) and (max-width: 450px) {
  html {
    font-size: 38%;
  }

  .header:not(.hidden) {
    top: 25%;
    width: 85%;
  }

  .header__title {
    grid-template-columns: 1fr;
    gap: 4rem;
    text-align: center;
    justify-items: center;
  }

  .header__img {
    grid-column: 1;
    grid-row: 1;
    transform: none;
    max-width: 70%;
  }

  .login__input--user {
    width: 20rem;
  }

  .login__input--pin {
    width: 12rem;
  }
}

@media screen and (orientation: portrait) and (max-width: 400px) {
  html {
    font-size: 35%;
  }

  .header:not(.hidden) {
    top: 30%;
    width: 85%;
  }

  .header__title {
    grid-template-columns: 1fr;
    gap: 4rem;
    text-align: center;
    justify-items: center;
  }

  .header__img {
    grid-column: 1;
    grid-row: 1;
    transform: none;
    max-width: 60%;
  }

  .login__input--user {
    width: 20rem;
  }

  .login__input--pin {
    width: 12rem;
  }
}

@media screen and (orientation: portrait) and (max-width: 375px) {
  html {
    font-size: 30%;
  }

  .header:not(.hidden) {
    top: 22%;
    width: 85%;
  }

  .header__title {
    grid-template-columns: 1fr;
    gap: 4rem;
    text-align: center;
    justify-items: center;
  }

  .header__img {
    grid-column: 1;
    grid-row: 1;
    transform: none;
    max-width: 60%;
  }

  /* Movements optimointi iPhone 6/7/8 */
  .movements__content {
    gap: 0.3rem;
  }

  .movements__date {
    font-size: 1.3rem !important;
    line-height: 1.4;
  }

  .movements__description {
    font-size: 1.5rem !important;
    line-height: 1.4;
    font-weight: 500;
  }

  .movements__value {
    font-size: 1.5rem !important;
    line-height: 1.4;
    font-weight: 600;
  }
}

@media screen and (orientation: portrait) and (max-width: 350px) {
  html {
    font-size: 30%;
  }

  .header:not(.hidden) {
    top: 30%;
    width: 90%;
  }

  .header__title {
    grid-template-columns: 1fr;
    gap: 4rem;
    text-align: center;
    justify-items: center;
  }

  .header__img {
    grid-column: 1;
    grid-row: 1;
    transform: none;
    max-width: 60%;
  }

  .login__input--user {
    width: 18rem;
  }

  .login__input--pin {
    width: 12rem;
  }
}

/* Lisää mobile-specific korjaukset */
@media screen and (max-width: 768px) {
  /* Varmista että kaikki input-kentät käyttäytyvät samalla tavalla */
  .form__input,
  .form__input select,
  select.form__input {
    /* Pakota samat koot kaikille */
    height: 44px !important;
    min-height: 44px !important;
    line-height: 1.2;

    /* Varmista että padding on konsistentti */
    padding: 0.8rem 1rem !important;

    /* Estä iOS:n automaattinen zoom */
    font-size: 16px !important;

    /* Varmista että border-box on käytössä */
    box-sizing: border-box !important;
    -webkit-box-sizing: border-box !important;

    /* Keskitä teksti kaikissa kentissä, myös select */
    text-align: center !important;
    text-align-last: center !important;
    -moz-text-align-last: center !important;
  }

  /* Select-elementtien erityiskäsittely mobiililla */
  select.form__input {
    padding-right: 2.5rem !important; /* Tilaa dropdown-nuolelle */
  }

  /* Grid korjaus mobiilille */
  .form__inputs {
    grid-template-columns: 1fr !important;
    gap: 1rem;
    width: 100%;
  }
}

/* iOS iPad/iPhone spesifiset korjaukset */
@media screen and (max-width: 1024px) and (-webkit-min-device-pixel-ratio: 1) {
  /* Tunnistaa iOS laitteet */
  select.form__input,
  .form__input--to,
  .form__input--recurrence {
    /* Erittäin aggressiivinen keskitys iOS:lle */
    text-align: center !important;
    text-align-last: center !important;
    -webkit-text-align-last: center !important;

    /* Poista kaikki iOS default styles */
    -webkit-appearance: none !important;
    appearance: none !important;

    /* Pakota sisältö keskelle */
    padding: 0.8rem 2.5rem 0.8rem 1rem !important;
    text-indent: 0 !important;

    /* Background korjaus */
    background-position: right 0.7rem center !important;

    /* Font korjaus iOS:lle */
    font-family: inherit !important;
    font-size: 16px !important;

    /* Estä iOS:n automaattiset muotoilut */
    -webkit-text-size-adjust: 100% !important;
    -webkit-font-smoothing: antialiased !important;
  }

  /* Placeholder ja option keskitys iOS:lle */
  select.form__input option,
  .form__input--to option,
  .form__input--recurrence option {
    text-align: center !important;
    font-size: 16px !important;
  }
}

/* iPhone spesifiset korjaukset (pienemmät näytöt) */
@media screen and (max-width: 768px) and (-webkit-min-device-pixel-ratio: 2) {
  select.form__input,
  .form__input--to,
  .form__input--recurrence {
    /* Vieläkin aggressiivisempi keskitys iPhonelle */
    text-align: center !important;
    text-align-last: center !important;
    -webkit-text-align-last: center !important;

    /* Padding säätö pienemmille näytöille */
    padding: 1rem 2.5rem 1rem 1rem !important;

    /* Text direction pakotus */
    direction: ltr !important;
    unicode-bidi: embed !important;

    /* Font rendering optimointi */
    -webkit-font-feature-settings: 'kern' !important;
    font-feature-settings: 'kern' !important;
  }
}

/* iPhone specific movements layout fixes (iPhone SE ja pienemmät) */
@media screen and (max-width: 390px) {
  .movements {
    padding: 1rem 0.5rem;
    height: auto; /* Poista kiinteä korkeus iPhonella */
    min-height: 40rem;
  }

  .movements__content {
    gap: 0.3rem;
  }

  .movements__row {
    grid-template-columns: 50px 1fr 75px; /* Suurennettu value kolumni 70px -> 75px */
    gap: 0.5rem;
    padding: 0.5rem 0.3rem;
    height: auto; /* Poista kiinteä korkeus */
    min-height: 3.8rem; /* Hieman suurempi minimum korkeus */
  }

  .movements__date {
    font-size: 1.4rem !important; /* Suurennettu 1.3rem -> 1.4rem */
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
  }

  .movements__description {
    font-size: 1.7rem !important; /* Suurennettu 1.5rem -> 1.7rem */
    line-height: 1.4;
    max-width: none; /* Poista leveyden rajoitus */
    padding: 0.3rem 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
  }

  .movements__value {
    font-size: 1.7rem !important; /* Suurennettu 1.5rem -> 1.7rem */
    line-height: 1.4;
    text-align: right;
    white-space: nowrap;
    min-width: 65px; /* Hieman suurempi tila */
    font-weight: 600;
  }

  .movements__pagination {
    padding: 1rem 0.5rem;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .movements__pagination button {
    font-size: 1.4rem; /* Suurennettu 1.2rem -> 1.4rem */
    padding: 0.6rem 1.2rem; /* Suurempi padding */
    min-width: 90px; /* Suurempi minimum leveys */
  }

  .movements__pagination--current {
    font-size: 1.4rem; /* Suurennettu 1.2rem -> 1.4rem */
    min-width: 70px; /* Suurempi minimum leveys */
    text-align: center;
  }
}

/* Very small iPhone screens (iPhone SE, etc.) */
@media screen and (max-width: 320px) {
  .movements {
    padding: 0.8rem 0.3rem;
  }

  .movements__row {
    grid-template-columns: 45px 1fr 70px; /* Hieman suurempi value kolumni */
    gap: 0.3rem;
    padding: 0.4rem 0.2rem;
    min-height: 3.3rem; /* Hieman suurempi minimum korkeus */
  }

  .movements__date {
    font-size: 1rem !important; /* Suurennettu 0.8rem -> 1.0rem */
  }

  .movements__description {
    font-size: 1.2rem !important; /* Suurennettu 1.0rem -> 1.2rem */
    padding: 0.2rem 0.3rem;
  }

  .movements__value {
    font-size: 1.3rem !important; /* Suurennettu 1.1rem -> 1.3rem */
    min-width: 60px; /* Hieman suurempi tila */
  }

  .movements__pagination {
    padding: 0.8rem 0.3rem;
  }

  .movements__pagination button {
    font-size: 1.3rem; /* Suurennettu 1.1rem -> 1.3rem */
    padding: 0.5rem 1rem; /* Hieman suurempi padding */
    min-width: 80px; /* Suurempi minimum leveys */
  }
}

/* iPhone safe-area korjaukset */
/* iPhone 14 Pro Max, 15 Pro Max (932x430 landscape, 430x932 portrait) */
@media screen and (max-width: 430px) and (orientation: portrait) {
  .movements__content {
    gap: 0.4rem;
  }

  .movements__date {
    font-size: 1.4rem !important;
    line-height: 1.4;
  }

  .movements__description {
    font-size: 1.6rem !important;
    line-height: 1.4;
    font-weight: 500;
  }

  .movements__value {
    font-size: 1.6rem !important;
    line-height: 1.4;
    font-weight: 600;
  }
}

/* iPhone 13, 14, 15 series (428x926 portrait) */
@media screen and (max-width: 428px) and (orientation: portrait) {
  .movements {
    /* Safe area padding iPhone X+ laitteille */
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .movements__content {
    /* Varmista että sisältö ei mene safe-areen */
    padding: 0 0.5rem;
    gap: 0.4rem;
  }

  .movements__date {
    font-size: 1.4rem !important;
    line-height: 1.4;
  }

  .movements__description {
    font-size: 1.6rem !important;
    line-height: 1.4;
    font-weight: 500;
  }

  .movements__value {
    font-size: 1.6rem !important;
    line-height: 1.4;
    font-weight: 600;
  }
}

@media screen and (max-width: 926px) and (orientation: landscape) {
  .movements {
    /* Landscape safe area */
    padding-left: max(2rem, env(safe-area-inset-left));
    padding-right: max(2rem, env(safe-area-inset-right));
    height: auto;
    min-height: 25rem;
  }

  .movements__content {
    gap: 0.2rem;
  }

  .movements__row {
    height: auto;
    min-height: 3rem;
    padding: 0.5rem 1rem;
    grid-template-columns: 40px 1fr 60px;
    gap: 0.5rem;
  }

  .movements__date {
    font-size: 1.2rem !important;
    line-height: 1.3;
  }

  .movements__description {
    font-size: 1.4rem !important;
    line-height: 1.3;
    font-weight: 500;
  }

  .movements__value {
    font-size: 1.4rem !important;
    line-height: 1.3;
    font-weight: 600;
  }
}

/* iPad Portrait specific header fixes */
@media screen and (max-width: 768px) and (orientation: portrait) {
  .header:not(.hidden) {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    max-width: 60rem;
    max-height: 85vh;
    padding: 1.5rem;
    z-index: 1;
  }

  .header__title {
    display: grid;
    grid-template-columns: 1fr; /* Yksi sarake iPad:lle */
    gap: 2rem;
    text-align: center;
    justify-items: center;
    align-items: center;
  }

  .header__img {
    grid-column: 1;
    grid-row: 1; /* Kuva ylimmäksi */
    max-width: 60%;
    width: auto;
    height: auto;
    transform: none;
    margin-bottom: 1rem;
    border-radius: 15px;
  }

  h1 {
    grid-row: 2; /* Otsikko kuvan alle */
    font-size: 3.5rem;
    line-height: 1.2;
    text-align: center;
    margin: 1rem 0;
  }

  h4 {
    grid-row: 3; /* Alaotsikko viimeiseksi */
    font-size: 2rem;
    text-align: center;
    margin: 0.5rem 0;
  }
}

/* iPhone specific header fixes */
@media screen and (max-width: 428px) and (orientation: portrait) {
  .header:not(.hidden) {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 40rem;
    max-height: 80vh;
    padding: 1rem;
    overflow-y: auto;
  }

  .header__title {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    text-align: center;
  }

  .header__img {
    order: 1; /* Kuva ensimmäiseksi */
    max-width: 70%;
    width: auto;
    height: auto;
    transform: none;
    margin: 0;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  }

  h1 {
    order: 2; /* Otsikko toiseksi */
    font-size: 2.8rem;
    line-height: 1.1;
    text-align: center;
    margin: 0.8rem 0;
  }

  h4 {
    order: 3; /* Alaotsikko viimeiseksi */
    font-size: 1.6rem;
    text-align: center;
    margin: 0;
    padding: 0 1rem;
  }
}

/* Landscape orientation fixes for mobile */
@media screen and (max-height: 500px) and (orientation: landscape) {
  .header:not(.hidden) {
    position: fixed;
    top: 55%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* width: 90%;
    max-width: 80rem;
    max-height: 90vh;
    padding: 1rem;
    overflow-y: auto; */
  }

  /* .header__title {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: center;
    justify-content: center;
  }

  .header__img {
    grid-column: 2;
    grid-row: 1 / span 2;
    max-width: 90%;
    width: auto;
    height: auto;
    transform: none;
  } */
}

/* Prevent header from interfering with app on mobile */
@media screen and (max-width: 768px) {
  .header.hidden,
  .header.hidden * {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    top: -9999px !important;
    left: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
    z-index: -9999 !important;
  }

  .app.active {
    /* Ensure app takes full space when header is hidden */
    position: relative !important;
    top: 0 !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    margin-top: 2rem !important;
    z-index: 10 !important;
  }
}

/* Touch-friendly header improvements */
@media (hover: none) and (pointer: coarse) {
  .header:not(.hidden) {
    /* Better touch scrolling */
    -webkit-overflow-scrolling: touch;
  }

  .header__title {
    /* Prevent text selection on touch */
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }

  .header__img {
    /* Prevent image drag on touch */
    -webkit-user-drag: none;
    -moz-user-drag: none;
    pointer-events: none;
  }
}

/* iOS specific header fixes with centering */
@supports (-webkit-touch-callout: none) {
  /* iOS Safari safe area support with perfect centering */
  .header:not(.hidden) {
    /* Säilytä keskitetty sijainti iOS:ssä */
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;

    /* Safe area padding */
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));

    /* iOS text rendering */
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;

    /* Better touch scrolling */
    -webkit-overflow-scrolling: touch;
  }
}

/* iPad Pro Portrait specific header fixes (912px width) */
@media screen and (min-width: 769px) and (max-width: 1024px) and (orientation: portrait) {
  .header:not(.hidden) {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 70rem;
    max-height: 80vh;
    padding: 2rem;
    z-index: 1;
  }

  .header__title {
    display: grid;
    grid-template-columns: 1fr; /* Single column for iPad Pro Portrait */
    gap: 2.5rem;
    text-align: center;
    justify-items: center;
    align-items: center;
  }

  .header__img {
    grid-column: 1;
    grid-row: 1; /* Image on top */
    max-width: 50%;
    width: auto;
    height: auto;
    transform: none;
    margin-bottom: 1.5rem;
    border-radius: 15px;
  }

  h1 {
    grid-row: 2; /* Title below image */
    font-size: 4.5rem;
    line-height: 1.2;
    text-align: center;
    margin: 1.5rem 0;
  }

  h4 {
    grid-row: 3; /* Subtitle last */
    font-size: 2.5rem;
    text-align: center;
    margin: 1rem 0;
  }
}

/* iPad Pro 11" Portrait specific fixes (834x1194) and iPad Pro 12.9" Portrait (1024x1366) */
@media screen and (min-width: 834px) and (max-width: 1024px) and (orientation: portrait) and (min-height: 1100px) {
  .header:not(.hidden) {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 75%;
    max-width: 65rem;
    max-height: 75vh;
    padding: 2.5rem;
    z-index: 1;
  }

  .header__title {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3rem;
    text-align: center;
    justify-items: center;
    align-items: center;
  }

  .header__img {
    grid-column: 1;
    grid-row: 1;
    max-width: 45%;
    width: auto;
    height: auto;
    transform: none;
    margin-bottom: 2rem;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }

  h1 {
    grid-row: 2;
    font-size: 5rem;
    line-height: 1.2;
    text-align: center;
    margin: 2rem 0;
  }

  h4 {
    grid-row: 3;
    font-size: 2.8rem;
    text-align: center;
    margin: 1rem 0;
    max-width: 80%;
    justify-self: center;
  }
}

/* iPad Pro iOS specific header fixes */
@media screen and (-webkit-min-device-pixel-ratio: 1.5) and (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  .header:not(.hidden) {
    /* Ensure perfect centering on iPad Pro */
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 75% !important;
    max-width: 65rem !important;
    max-height: 70vh !important;
    padding: 2rem !important;
    z-index: 1 !important;

    /* iOS optimizations */
    -webkit-overflow-scrolling: touch;
    -webkit-transform: translate(-50%, -50%);
    will-change: transform;
  }

  .header__title {
    /* iOS font rendering optimization */
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
  }
}

/* iPad Pro 12.9" Portrait specific fix (1024px width) */
@media screen and (min-width: 1000px) and (max-width: 1024px) and (orientation: portrait) {
  .header:not(.hidden) {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 70% !important;
    max-width: 60rem !important;
    max-height: 65vh !important;
    padding: 3rem !important;
    z-index: 1 !important;
  }

  h1 {
    font-size: 5.5rem !important;
  }

  h4 {
    font-size: 3rem !important;
  }

  .header__img {
    max-width: 40% !important;
  }
}
