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

body.pos-page .main-content {
    width: 100%;
    max-width: none;
    padding-left: clamp(16px, 2.5vw, 42px);
    padding-right: clamp(16px, 2.5vw, 42px);
}

body.pos-page .topbar,
body.pos-page #sale-form,
body.pos-page .flash {
    width: 100%;
    max-width: 1480px;
    margin-left: auto;
    margin-right: auto;
}

.pos-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(350px, 430px);
    gap: 22px;
    align-items: start;
}

.pos-catalog { min-height: 610px; }
.pos-search { min-height: 58px; font-size: 17px; }
.pos-search-actions { margin-top: 7px; }
.pos-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
    gap: 10px;
    margin-top: 18px;
}
.pos-results .result {
    display: flex;
    min-height: 92px;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    text-align: left;
}
.pos-results .result:hover { border-color: #8eaa9e; background: #f4f8f6; }
.pos-results .result span { display: grid; gap: 5px; }
.pos-results .result small { color: var(--muted); }
.pos-results .result b { white-space: nowrap; color: var(--forest); }

.pos-favorites { margin-top: 24px; }
.pos-favorites-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.pos-favorites-heading h2 { margin: 0; font-size: 17px; }
.favorite-product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 185px)); gap: 10px; }
.favorite-product {
    --favorite-background: #dcefe5;
    --favorite-foreground: #205c45;
    display: grid;
    min-width: 0;
    min-height: 138px;
    align-content: start;
    gap: 5px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fff;
    color: var(--ink);
    text-align: left;
}
.favorite-product:hover { border-color: var(--favorite-foreground); background: color-mix(in srgb, var(--favorite-background) 25%, #fff); box-shadow: 0 4px 14px rgba(23, 63, 53, .08); }
.favorite-product:focus-visible { outline: 3px solid color-mix(in srgb, var(--favorite-foreground) 22%, transparent); outline-offset: 2px; }
.favorite-product-icon { display: grid; width: 36px; height: 36px; margin-bottom: 4px; place-items: center; border-radius: 9px; background: var(--favorite-background); color: var(--favorite-foreground); font-size: 17px; font-weight: 900; }
.favorite-product-name { min-width: 0; overflow-wrap: anywhere; font-weight: 800; line-height: 1.25; }
.favorite-product small { min-width: 0; overflow-wrap: anywhere; color: var(--muted); font-size: 10px; }
.favorite-product strong { margin-top: auto; color: var(--forest); font-size: 15px; }
.favorite-product-color-0 { --favorite-background: #dff2ea; --favorite-foreground: #21664f; }
.favorite-product-color-1 { --favorite-background: #fde1da; --favorite-foreground: #94452f; }
.favorite-product-color-2 { --favorite-background: #dfeafa; --favorite-foreground: #315d8d; }
.favorite-product-color-3 { --favorite-background: #ffefbc; --favorite-foreground: #775710; }
.favorite-product-color-4 { --favorite-background: #eadff5; --favorite-foreground: #69498a; }
.favorite-product-color-5 { --favorite-background: #dceff1; --favorite-foreground: #27646a; }

.pos-cart-panel {
    position: sticky;
    top: 18px;
    display: flex;
    min-height: 610px;
    max-height: calc(100vh - 36px);
    flex-direction: column;
    padding: 20px;
}
.pos-cart-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pos-cart-heading h2 { margin: 0 0 3px; }
.link-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--forest-2);
    font: inherit;
    font-size: 13px;
    font-weight: 750;
    cursor: pointer;
}
.link-button:hover { text-decoration: underline; }
.danger-text { color: var(--red); }
.pos-register-summary { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; padding: 11px; border-radius: 7px; background: #f4f8f6; }
.pos-cart-lines { display: grid; gap: 2px; margin: 15px 0; overflow: auto; }
.cart-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cart-row > div:first-child { display: grid; gap: 3px; }
.cart-row small { color: var(--muted); }
.cart-row-price { display: flex; align-items: flex-start; gap: 8px; }
.icon-button { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: #f1f4f2; color: var(--muted); font-size: 17px; cursor: pointer; }
.cart-quantity { grid-column: 1 / -1; display: flex !important; align-items: center; gap: 7px; font-size: 11px !important; }
.cart-quantity input { width: 68px; min-height: 32px; padding: 4px 7px; }
.pos-cart-footer { display: grid; gap: 13px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.pos-receipt-options summary { color: var(--muted); font-size: 12px; cursor: pointer; }
.pos-receipt-options .check { margin-top: 9px; }
.cart-total { display: flex; align-items: end; justify-content: space-between; gap: 15px; }
.cart-total span:first-child { font-size: 17px; font-weight: 700; }
.cart-total span:last-child { font-size: 28px; font-weight: 850; letter-spacing: -.03em; }
.pos-pay-button { display: flex; justify-content: space-between; gap: 14px; }
.pos-pay-button:disabled,
.payment-method-button:disabled { cursor: not-allowed; opacity: .48; }
.quick-product[hidden] { display: none; }

.pos-dialog {
    width: min(94vw, 650px);
    max-height: 94vh;
    margin: auto;
    padding: 0;
    border: 0;
    border-radius: 17px;
    background: transparent;
    color: var(--ink);
    box-shadow: 0 30px 90px rgba(7, 31, 25, .3);
}
.pos-dialog::backdrop { background: rgba(9, 29, 25, .58); backdrop-filter: blur(2px); }
.pos-dialog-card { position: relative; display: grid; gap: 16px; max-height: 94vh; overflow: auto; padding: 30px; background: #fff; border-radius: 17px; }
.pos-dialog-close { position: absolute; top: 15px; right: 15px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: #f1f4f2; color: var(--ink); font-size: 20px; cursor: pointer; }
.pos-dialog-close:disabled { opacity: .45; }
.pos-dialog .eyebrow { margin: 0; }
.pos-dialog h2 { margin: -8px 42px 0 0; font-size: 30px; letter-spacing: -.035em; }
.payment-total { display: grid; gap: 4px; }
.payment-total span { color: var(--muted); font-size: 12px; font-weight: 700; }
.payment-total strong { font-size: 38px; letter-spacing: -.04em; }
.payment-plan { padding: 14px; border: 1px solid #bdd7cc; border-radius: 10px; background: #f1faf6; }
.payment-plan[hidden] { display: none; }
.payment-plan h3,
.payment-entry h3 { margin: 0 0 9px; font-size: 13px; }
.payment-plan-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #d7e5df; }
.payment-plan-row:last-child { border-bottom: 0; }
.payment-plan-actions { display: flex; gap: 9px; }
.payment-status { margin: 0; padding: 12px 13px; border-radius: 8px; background: #fff5dd; color: #765316; font-size: 13px; font-weight: 700; }
.payment-status.is-complete { background: #eaf8f1; color: var(--forest-2); }
.payment-entry { display: grid; gap: 12px; }
.payment-entry[hidden],
.payment-entry-fields[hidden],
.payment-final[hidden],
.payment-processing[hidden] { display: none; }
.payment-method-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.payment-method-button { display: flex; min-height: 68px; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); cursor: pointer; text-align: left; }
.payment-method-button span { display: grid; width: 35px; height: 35px; place-items: center; border-radius: 8px; background: #f0f4f2; font-size: 18px; }
.payment-method-button:hover,
.payment-method-button.is-selected { border-color: #59aa88; background: #effaf5; box-shadow: 0 0 0 2px rgba(89, 170, 136, .13); }
.payment-entry-fields { display: grid; gap: 12px; }
.payment-amount { font-size: 19px; font-weight: 750; }
.nexi-demo-card { display: grid; gap: 4px; padding: 13px; border: 1px solid #72c7a2; border-radius: 9px; background: #effaf5; }
.nexi-demo-card[hidden] { display: none; }
.nexi-demo-card b { color: var(--red); font-size: 13px; }
.nexi-demo-card small { color: var(--muted); line-height: 1.45; }
.cash-due { display: grid; gap: 5px; padding: 9px 11px; border: 1px solid #bfc9c4; border-radius: 7px; background: #fff; }
.cash-due span { color: var(--muted); font-size: 11px; font-weight: 700; }
.cash-due strong { font-size: 19px; }
.payment-final { display: grid; gap: 10px; padding: 14px; border: 1px solid #78b99d; border-radius: 10px; background: #effaf5; }
.payment-final-total { display: flex; justify-content: space-between; gap: 12px; font-weight: 850; }
.payment-final p { margin: 0; color: var(--forest-2); font-size: 13px; }
.payment-processing { display: flex; align-items: center; gap: 15px; padding: 17px; border-radius: 10px; background: #effaf5; }
.payment-processing h3,
.payment-processing p { margin: 0; }
.payment-processing p { margin-top: 4px; color: var(--muted); font-size: 13px; }
.payment-spinner { width: 30px; height: 30px; flex: 0 0 auto; border: 3px solid #bdd7cc; border-top-color: var(--forest); border-radius: 50%; animation: pos-spin .8s linear infinite; }
.payment-cancel { justify-self: center; }
.sale-complete-dialog { width: min(92vw, 590px); }
.sale-complete-dialog .pos-dialog-card { justify-items: center; padding: 36px; text-align: center; }
.sale-complete-check { display: grid; width: 68px; height: 68px; place-items: center; border-radius: 50%; background: #dff7eb; color: #27815c; font-size: 39px; }
.sale-complete-dialog h2 { margin: 2px 0 0; }
.sale-complete-dialog p { margin: 0; color: var(--muted); }
.sale-complete-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; margin-top: 8px; }
.sale-complete-actions .button { text-align: center; }

@keyframes pos-spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
    .pos-layout { grid-template-columns: minmax(0, 1fr) minmax(330px, 390px); }
    .pos-results { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media (max-width: 820px) {
    .pos-layout { grid-template-columns: 1fr; }
    .pos-catalog { min-height: 0; }
    .pos-cart-panel { position: static; min-height: 480px; max-height: none; }
    .pos-results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .favorite-product-grid { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); }
}

@media (max-width: 600px) {
    body.pos-page .main-content { padding-left: 10px; padding-right: 10px; }
    .pos-layout { gap: 12px; }
    .pos-catalog,
    .pos-cart-panel { padding: 15px; }
    .pos-results { grid-template-columns: 1fr; }
    .pos-favorites-heading { align-items: flex-start; flex-direction: column; gap: 3px; }
    .favorite-product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .favorite-product { min-height: 132px; padding: 12px; }
    .pos-dialog { width: 100%; max-width: none; max-height: 100%; height: 100%; border-radius: 0; }
    .pos-dialog-card { min-height: 100%; max-height: 100%; padding: 23px 17px; border-radius: 0; }
    .pos-dialog h2 { font-size: 26px; }
    .payment-total strong { font-size: 33px; }
    .payment-method-grid { grid-template-columns: 1fr; }
    .payment-plan-row { grid-template-columns: minmax(0, 1fr) auto; }
    .payment-plan-actions { grid-column: 1 / -1; justify-self: end; }
    .sale-complete-actions { grid-template-columns: 1fr; }
    .cart-total span:last-child { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
    .payment-spinner { animation: none; }
}

/* Ei-saatavilla oleva suosikkituote */
.favorite-product:disabled,
.favorite-product[aria-disabled="true"] {
    background: #eeeeee !important;
    border-color: #d0d0d0 !important;
    color: #777777 !important;
    opacity: 0.65;
    cursor: not-allowed;
    box-shadow: none !important;
}

.favorite-product:disabled .favorite-product-icon,
.favorite-product[aria-disabled="true"] .favorite-product-icon {
    background: #d9d9d9 !important;
    color: #777777 !important;
}

.favorite-product:disabled:hover,
.favorite-product[aria-disabled="true"]:hover {
    transform: none;
    box-shadow: none !important;
}


/* Suosikin poistopainike kassassa */
.favorite-product-wrap {
    position: relative;
    min-width: 0;
}

.favorite-product-wrap .favorite-product {
    width: 100%;
    height: 100%;
    padding-bottom: 46px;
}

.favorite-remove-form {
    position: absolute;
    right: 10px;
    bottom: 10px;
    margin: 0;
    z-index: 3;
}

.favorite-remove-button {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #b7b7b7;
    border-radius: 50%;
    background: #fff;
    color: #555;
    font-size: 20px;
    font-weight: 700;
    line-height: 24px;
    cursor: pointer;
}

.favorite-remove-button:hover,
.favorite-remove-button:focus-visible {
    background: #f1f1f1;
    border-color: #777;
}

.favorite-remove-button:disabled {
    opacity: .5;
    cursor: wait;
}

/* Suosikkikorttien kompakti mitoitus */
.favorite-product-grid {
    align-items: start;
}

.favorite-product-wrap {
    width: 100%;
    min-width: 0;
    height: max-content;
    align-self: start;
    flex: 1 1 160px;
}

.favorite-product-wrap .favorite-product {
    width: 100%;
    height: auto;
    min-height: 0;
    box-sizing: border-box;
    padding-bottom: 40px;
}

.favorite-remove-form {
    right: 9px;
    bottom: 9px;
}

/* Suosikkikorttien lopullinen vakiokoko */
.favorite-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 180px);
    gap: 12px;
    align-items: start;
    justify-content: start;
}

.favorite-product-wrap {
    position: relative;
    width: 180px;
    height: 165px;
    min-width: 180px;
    max-width: 180px;
    min-height: 165px;
    max-height: 165px;
    overflow: hidden;
    align-self: start;
}

.favorite-product-wrap .favorite-product {
    width: 180px;
    height: 165px;
    min-width: 180px;
    max-width: 180px;
    min-height: 165px;
    max-height: 165px;
    box-sizing: border-box;
    overflow: hidden;
    padding: 14px 14px 38px;
}

.favorite-product-name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    max-height: 2.6em;
    line-height: 1.3;
    font-size: 14px;
}

.favorite-product small {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 11px;
}

.favorite-product strong {
    display: block;
    margin-top: 6px;
}

/* Poista suosikeista pysyy aina kortin sisällä */
.favorite-remove-form {
    position: absolute;
    right: 7px;
    bottom: 7px;
    margin: 0;
    z-index: 5;
}

.favorite-remove-button {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    padding: 0;
    border-radius: 50%;
    font-size: 15px;
    line-height: 18px;
}

/* Saatavilla olevien suosikkien värikoodaus */
.favorite-product.favorite-product-color-0:not(:disabled) {
    background: #fff5d8;
    border-color: #e8cf84;
}

.favorite-product.favorite-product-color-1:not(:disabled) {
    background: #f3eafa;
    border-color: #ccb6df;
}

.favorite-product.favorite-product-color-2:not(:disabled) {
    background: #eaf3ff;
    border-color: #b8cfe8;
}

.favorite-product.favorite-product-color-3:not(:disabled) {
    background: #ffece6;
    border-color: #e7bcae;
}

.favorite-product.favorite-product-color-4:not(:disabled) {
    background: #edf7ef;
    border-color: #b9d8bf;
}

.favorite-product.favorite-product-color-5:not(:disabled) {
    background: #eaf7f5;
    border-color: #b3d6d0;
}

/* Ei-saatavilla oleva suosikki pysyy harmaana */
.favorite-product:disabled,
.favorite-product[aria-disabled="true"] {
    background: #eeeeee !important;
    border-color: #d0d0d0 !important;
    color: #777777 !important;
    opacity: 0.72;
}


/* Jokaisella suosikkikortilla pakollinen poistoruksi */
.favorite-product-wrap {
    position: relative;
    overflow: visible;
}

.favorite-product-wrap .favorite-product {
    overflow: hidden;
}

.favorite-product-wrap > .favorite-remove-button {
    position: absolute;
    right: 7px;
    bottom: 7px;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    margin: 0;
    padding: 0;
    border: 1px solid #b7b7b7;
    border-radius: 50%;
    background: #ffffff;
    color: #555555;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    opacity: 1;
    visibility: visible;
}


/* Kassarin määrä ja rivialennus */
.cart-row-editor {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 8px;
    margin-top: 8px;
}

.cart-quantity-stepper {
    display: grid;
    grid-template-columns: 30px 42px 30px;
    height: 32px;
}

.cart-quantity-stepper button,
.cart-quantity-stepper input {
    min-width: 0;
    height: 32px;
    padding: 0;
    text-align: center;
    border: 1px solid #cbd4d1;
    border-radius: 0;
}

.cart-quantity-stepper button:first-child {
    border-radius: 6px 0 0 6px;
}

.cart-quantity-stepper button:last-child {
    border-radius: 0 6px 6px 0;
}

.cart-quantity-stepper input {
    border-left: 0;
    border-right: 0;
}

.cart-fixed-quantity {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    font-size: 12px;
    color: #68736f;
}

.cart-discount-control {
    display: grid;
    grid-template-columns: auto 58px 46px;
    align-items: center;
    gap: 5px;
    margin: 0;
    font-size: 11px;
}

.cart-discount-control input,
.cart-discount-control select {
    height: 32px;
    min-width: 0;
    padding: 4px 6px;
}

.cart-discount-summary {
    display: block;
    margin-top: 5px;
    color: #68736f;
    font-size: 10px;
}

@media (max-width: 520px) {
    .cart-row-editor {
        align-items: stretch;
    }

    .cart-discount-control {
        grid-template-columns: auto minmax(54px, 1fr) 46px;
        width: 100%;
    }
}

/* Kassarin määrä- ja alennuskenttien kompakti viimeistely */
.cart-quantity-stepper {
    grid-template-columns: 30px 38px 30px;
    height: 32px;
}

.cart-quantity-stepper button,
.cart-quantity-stepper input {
    height: 32px;
    min-height: 32px;
    padding: 0;
    margin: 0;
    line-height: 32px;
    font-size: 14px;
    text-align: center;
    vertical-align: middle;
}

.cart-quantity-stepper input {
    appearance: textfield;
    -moz-appearance: textfield;
}

.cart-quantity-stepper input::-webkit-outer-spin-button,
.cart-quantity-stepper input::-webkit-inner-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

.cart-discount-control {
    grid-template-columns: auto 52px 40px;
    gap: 4px;
}

.cart-discount-control input,
.cart-discount-control select {
    width: 100%;
    height: 30px;
    min-height: 30px;
    padding: 2px 5px;
    font-size: 12px;
}

.cart-discount-control select {
    padding-right: 18px;
}

/* Alennustyypin merkki varmasti näkyviin */
.cart-discount-control {
    grid-template-columns: auto 52px 46px;
}

.cart-discount-control select {
    width: 46px;
    min-width: 46px;
    padding: 2px 16px 2px 5px;
    text-align: center;
    text-align-last: center;
}

/* Alennustyyppi: prosentti/euro aina kokonaan näkyviin */
.cart-discount-control {
    grid-template-columns: auto 52px 58px;
}

.cart-discount-control select {
    width: 58px;
    min-width: 58px;
    height: 30px;
    padding: 2px 22px 2px 10px;
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    color: #102c26;
}

/* Alennusrivi kompaktiksi */
.cart-discount-control {
    grid-template-columns: auto 40px 58px;
}

.cart-discount-control input {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    padding-left: 4px;
    padding-right: 4px;
    text-align: center;
}

/* Alennustyypin lopullinen kompakti select */
.cart-discount-control {
    grid-template-columns: auto 40px 54px;
}

.cart-discount-control select {
    width: 54px;
    min-width: 54px;
    max-width: 54px;
    padding: 2px 20px 2px 8px;
    text-align: left;
    text-align-last: left;
    font-size: 13px;
    font-weight: 700;
}

.cart-discount-control select option {
    text-align: left;
}

/* Alennustyyppi ilman selaimen ongelmallista select-valikkoa */
.cart-discount-control {
    grid-template-columns: auto 40px 58px;
}

.cart-discount-type {
    display: grid;
    grid-template-columns: 29px 29px;
    width: 58px;
    height: 30px;
}

.cart-discount-type-button {
    width: 29px;
    height: 30px;
    min-width: 29px;
    padding: 0;
    margin: 0;
    border: 1px solid #cbd4d1;
    background: #ffffff;
    color: #30413c;
    font-size: 13px;
    font-weight: 700;
    line-height: 28px;
    text-align: center;
    cursor: pointer;
}

.cart-discount-type-button:first-child {
    border-radius: 6px 0 0 6px;
}

.cart-discount-type-button:last-child {
    margin-left: -1px;
    border-radius: 0 6px 6px 0;
}

.cart-discount-type-button.is-active {
    background: #174c3f;
    border-color: #174c3f;
    color: #ffffff;
    position: relative;
    z-index: 1;
}

/* Suosikkikortti: nimelle aina kaksi riviä, hinta ennen viivakoodia */
.favorite-product-wrap .favorite-product {
    display: grid;
    grid-template-rows: 36px 36px 20px 14px;
    row-gap: 3px;
    align-content: start;
}

.favorite-product-icon {
    align-self: start;
    justify-self: start;
}

.favorite-product-name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    min-height: 36px;
    max-height: 36px;
    line-height: 18px;
    font-size: 14px;
}

.favorite-product strong {
    display: block;
    margin: 0;
    align-self: end;
}

.favorite-product small {
    display: block;
    margin: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    align-self: start;
}
