*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg:        #f0f4f8;
    --surface:   #ffffff;
    --surface2:  #f8fafc;
    --border:    #e2e8f0;
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.07);
    --shadow:    0 3px 12px rgba(0,0,0,0.10);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.14);
    --green:     #16a34a;
    --green-bg:  #dcfce7;
    --green-btn: #22c55e;
    --red:       #dc2626;
    --red-bg:    #fee2e2;
    --blue:      #2563eb;
    --blue-bg:   #dbeafe;
    --text:      #0f172a;
    --muted:     #64748b;
    --r:         16px;
    --rs:        10px;
}

html, body {
    height: 100dvh;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    display: flex;
    flex-direction: column;
}

/* ====== HEADER ====== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    height: 56px;
}

.header-title { font-size: 17px; font-weight: 800; }

.header-right { display: flex; align-items: center; gap: 10px; }

.header-stats {
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
    background: var(--surface2);
    border: 1px solid var(--border);
    padding: 5px 11px;
    border-radius: 20px;
}

.btn-icon {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    width: 36px; height: 36px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    display: flex; align-items: center; justify-content: center;
}

/* ====== MAIN ====== */
main {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px 8px;
    height: calc(100dvh - 56px);
}

/* left-col on mobile: transparent, contents flow into main */
.left-col {
    display: contents;
}

/* ====== CARD ====== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow);
}

/* ====== ÜRÜN KARTI (mobile compact) ====== */
.product-card {
    flex-shrink: 0;
    padding: 10px 12px 10px;
    order: 1;
}

.product-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.product-emoji { font-size: 38px; line-height: 1; }
.product-name  { font-size: 19px; font-weight: 800; }
.product-unit  { font-size: 12px; color: var(--muted); margin-top: 2px; font-weight: 500; }

.qty-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 8px;
}

.btn-qty {
    width: 54px; height: 54px;
    border-radius: 50%;
    border: none;
    font-size: 28px; font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
    transition: transform 0.1s;
    box-shadow: var(--shadow);
}
.btn-qty:active { transform: scale(0.88); }

.btn-minus { background: #f1f5f9; color: #475569; border: 2px solid #e2e8f0; }
.btn-minus:disabled { opacity: 0.25; cursor: default; }
.btn-plus  { background: var(--green-btn); color: #fff; box-shadow: 0 3px 10px rgba(34,197,94,0.4); }

.qty-value {
    font-size: 46px; font-weight: 800;
    min-width: 60px; text-align: center; line-height: 1;
}

.total-row {
    display: flex; align-items: center; justify-content: space-between;
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border: 1.5px solid #fde68a;
    border-radius: 10px;
    padding: 9px 14px;
}
.total-label  { font-size: 11px; font-weight: 700; color: #92400e; letter-spacing: 2px; }
.total-amount { font-size: 24px; font-weight: 800; color: #b45309; }

/* ====== SATIŞ LİSTESİ (sadece PC'de görünür) ====== */
.sales-list-card { display: none; order: 2; }

/* ====== TAMAMLA BUTONU ====== */
.action-row {
    flex-shrink: 0;
    order: 4;
    padding-bottom: 2px;
}

.btn-complete {
    width: 100%;
    padding: 15px;
    font-size: 18px; font-weight: 800;
    border: none; border-radius: 14px;
    cursor: pointer;
    background: #bbf7d0; color: #166534;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}
.btn-complete:not(:disabled) {
    background: var(--green-btn); color: #fff;
    box-shadow: 0 4px 16px rgba(34,197,94,0.4);
}
.btn-complete:not(:disabled):active { transform: scale(0.97); }
.btn-complete:disabled { opacity: 0.45; cursor: default; }

/* ====== ÖDEME KARTI ====== */
.payment-card {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    padding: 10px 12px 12px;
    order: 3;
}

.payment-title {
    font-size: 11px; font-weight: 700;
    color: var(--muted); letter-spacing: 1.5px; text-transform: uppercase;
    margin-bottom: 8px; flex-shrink: 0;
}

/* ── Kağıt para 2×2 ── */
.bill-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-bottom: 7px;
    flex-shrink: 0;
}

.btn-bill {
    position: relative;
    background: #f5f0e6; border: none;
    border-radius: 10px; overflow: hidden;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0,0,0,0.14);
    transition: transform 0.12s, box-shadow 0.12s;
    padding: 0;
    aspect-ratio: 500 / 262;
}
.btn-bill:active { transform: scale(0.92); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }

.btn-bill img {
    width: 100%; height: 100%;
    object-fit: cover; object-position: center; display: block;
}

.bill-label {
    position: absolute; bottom: 5px; right: 6px;
    background: rgba(255,255,255,0.92);
    color: #0f172a; font-size: 13px; font-weight: 900;
    padding: 2px 8px; border-radius: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.18);
    backdrop-filter: blur(4px);
}

/* ── Bölücü ── */
.money-divider {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 7px; flex-shrink: 0;
}
.money-divider span {
    font-size: 10px; font-weight: 700; color: var(--muted);
    letter-spacing: 1.5px; text-transform: uppercase; white-space: nowrap;
}
.money-divider::before, .money-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── Bozuk para ── */
.coin-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.btn-coin {
    background: transparent; border: none;
    cursor: pointer;
    display: flex; flex-direction: column;
    align-items: center; gap: 3px;
    padding: 3px 1px;
    transition: transform 0.12s;
}
.btn-coin:active { transform: scale(0.87); }

.btn-coin img {
    width: 100%; aspect-ratio: 1;
    object-fit: contain; border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.20);
    display: block;
}

.coin-label { font-size: 11px; font-weight: 800; color: #475569; }

/* ── Verilen para + Geri Al + Sıfırla ── */
.paid-row {
    display: flex; align-items: center;
    justify-content: space-between;
    margin-bottom: 8px; flex-shrink: 0;
}

.paid-info { font-size: 14px; color: var(--muted); font-weight: 500; }
.paid-info strong { color: var(--text); font-size: 17px; font-weight: 800; }

.paid-actions { display: flex; gap: 6px; }

.btn-undo {
    background: var(--surface2); border: 1.5px solid var(--border);
    color: var(--muted); padding: 13px 20px;
    border-radius: 12px; font-size: 16px; font-weight: 700;
    cursor: pointer; box-shadow: var(--shadow-sm);
    transition: opacity 0.2s;
    white-space: nowrap;
}
.btn-undo:disabled { opacity: 0.25; cursor: default; box-shadow: none; }

.btn-reset-sale {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border: none;
    color: #fff; padding: 13px 22px;
    border-radius: 12px; font-size: 16px; font-weight: 800;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(220,38,38,0.4);
    transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.btn-reset-sale:active {
    transform: scale(0.94);
    box-shadow: 0 1px 4px rgba(220,38,38,0.2);
    filter: brightness(0.92);
}

/* ── Para üstü kutusu ── */
.change-box {
    border: 2px solid var(--border); border-radius: 12px;
    padding: 10px 14px; text-align: center;
    transition: background 0.25s, border-color 0.25s;
    background: var(--surface2); flex-shrink: 0;
}
.change-label {
    font-size: 10px; font-weight: 700;
    letter-spacing: 2px; text-transform: uppercase;
    color: var(--muted); margin-bottom: 2px;
}
.change-value { font-size: 32px; font-weight: 800; line-height: 1.1; color: var(--muted); }

.change-box.state-waiting  { border-color: var(--border); }

.change-box.state-short    { background: var(--red-bg); border-color: var(--red); }
.change-box.state-short  .change-label { color: var(--red); }
.change-box.state-short  .change-value { color: var(--red); }

.change-box.state-exact    { background: var(--blue-bg); border-color: var(--blue); }
.change-box.state-exact  .change-label { color: var(--blue); }
.change-box.state-exact  .change-value { color: var(--blue); font-size: 20px; }

.change-box.state-give     { background: var(--green-bg); border-color: var(--green); }
.change-box.state-give   .change-label { color: var(--green); }
.change-box.state-give   .change-value { color: var(--green); }

/* ====== PC / TABLET (≥ 720px) ====== */
@media (min-width: 720px) {

    main {
        flex-direction: row;
        gap: 14px;
        padding: 14px 18px 12px;
        overflow: hidden;
    }

    /* left-col: gerçek sütun olarak render et */
    .left-col {
        display: flex;
        flex-direction: column;
        gap: 12px;
        width: 300px;
        flex-shrink: 0;
    }

    /* Sütun sıraları sıfırla */
    .product-card, .sales-list-card, .action-row, .payment-card { order: unset; }

    /* Ürün kartı — daha büyük */
    .product-card {
        flex-shrink: 0;
        padding: 14px 16px;
    }
    .product-emoji { font-size: 52px; }
    .product-name  { font-size: 22px; }
    .product-unit  { font-size: 13px; }
    .product-top   { margin-bottom: 12px; }
    .btn-qty       { width: 64px; height: 64px; font-size: 32px; }
    .qty-value     { font-size: 56px; }
    .qty-row       { gap: 18px; margin-bottom: 12px; }
    .total-row     { padding: 11px 16px; }
    .total-amount  { font-size: 30px; }

    /* Satış listesi kartı */
    .sales-list-card {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        padding: 12px 14px;
    }
    .sales-list-title {
        font-size: 12px; font-weight: 700;
        color: var(--muted); letter-spacing: 1px; text-transform: uppercase;
        margin-bottom: 8px; flex-shrink: 0;
    }
    .sales-list {
        flex: 1; min-height: 0;
        overflow-y: auto;
    }
    .sale-item {
        display: flex; align-items: center; gap: 8px;
        padding: 7px 0;
        border-bottom: 1px solid var(--border);
        font-size: 14px;
        animation: slideInTop 0.3s ease;
    }
    .sale-item:last-child { border-bottom: none; }
    .sale-time  { color: var(--muted); font-size: 12px; min-width: 38px; }
    .sale-qty   { font-weight: 700; min-width: 28px; }
    .sale-total { color: #b45309; font-weight: 800; margin-left: auto; }
    .sales-empty {
        color: var(--muted); font-size: 13px;
        text-align: center; padding: 20px 0;
    }
    .sales-footer {
        display: flex; justify-content: space-between; align-items: center;
        padding-top: 8px; margin-top: 4px;
        border-top: 1px solid var(--border);
        font-size: 14px; color: var(--muted); flex-shrink: 0;
    }
    .sales-footer strong { color: #b45309; font-size: 16px; font-weight: 800; }

    /* Tamamla butonu */
    .action-row { flex-shrink: 0; }
    .btn-complete { padding: 18px; font-size: 20px; border-radius: 14px; }

    /* Ödeme kartı — sağ sütun, tam yükseklik */
    .payment-card {
        flex: 1;
        padding: 14px 16px;
        min-height: 0;
        overflow-y: auto;
    }

    /* Banknotlar — daha büyük */
    .bill-grid { gap: 10px; margin-bottom: 10px; }
    .bill-label { font-size: 15px; padding: 3px 10px; bottom: 7px; right: 8px; }

    /* Bozuk para — daha büyük */
    .coin-grid     { gap: 14px; margin-bottom: 10px; }
    .coin-label    { font-size: 13px; }

    /* Verilen para */
    .paid-row      { margin-bottom: 10px; }
    .paid-info     { font-size: 16px; }
    .paid-info strong { font-size: 22px; }
    .btn-undo          { font-size: 17px; padding: 14px 22px; }
    .btn-reset-sale    { font-size: 17px; padding: 14px 24px; }

    /* Para üstü — büyük */
    .change-box    { padding: 16px; }
    .change-label  { font-size: 13px; letter-spacing: 2px; margin-bottom: 6px; }
    .change-value  { font-size: 64px; }
    .change-box.state-exact .change-value { font-size: 36px; }
}

@media (min-width: 720px) and (max-width: 1099px) {
    main {
        gap: 12px;
        padding: 12px 14px 10px;
    }

    .left-col {
        width: 280px;
        gap: 10px;
    }

    .payment-card {
        padding: 12px 14px;
        overflow: hidden;
    }

    .payment-title {
        margin-bottom: 7px;
    }

    .bill-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin-bottom: 9px;
    }

    .btn-bill {
        height: clamp(132px, 18dvh, 170px);
        aspect-ratio: auto;
        background: #fff;
    }

    .btn-bill img {
        object-fit: cover !important;
        object-position: center;
    }

    .money-divider {
        margin-bottom: 7px;
    }

    .coin-grid {
        gap: 8px;
        justify-items: center;
        margin-bottom: 8px;
    }

    .btn-coin {
        width: min(100%, 78px);
        gap: 2px;
        padding: 2px 1px;
    }

    .coin-label {
        font-size: 12px;
    }

    .paid-row {
        margin-bottom: 8px;
    }

    .paid-info {
        font-size: 14px;
    }

    .paid-info strong {
        font-size: 19px;
    }

    .btn-undo,
    .btn-reset-sale {
        font-size: 15px;
        padding: 11px 15px;
    }

    .change-box {
        padding: 12px 14px;
    }

    .change-label {
        font-size: 11px;
        margin-bottom: 4px;
    }

    .change-value {
        font-size: 48px;
    }

    .change-box.state-exact .change-value {
        font-size: 30px;
    }
}

@media (min-width: 1100px) {
    .bill-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .coin-grid {
        justify-items: center;
    }

    .btn-coin {
        width: min(100%, 132px);
    }
}

/* ====== BAŞARI OVERLAY ====== */
.overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 100; backdrop-filter: blur(6px);
    animation: fadeIn .2s ease;
}
.overlay.hidden { display: none; }

.overlay-card {
    background: var(--surface); border-radius: 26px;
    padding: 44px 40px; text-align: center;
    box-shadow: var(--shadow-lg);
    animation: popIn .3s cubic-bezier(.175,.885,.32,1.275);
}
.overlay-emoji { font-size: 68px; margin-bottom: 8px; }
.overlay-title { font-size: 28px; font-weight: 800; color: var(--green); margin-bottom: 6px; }
.overlay-sub   { font-size: 20px; color: var(--muted); font-weight: 600; }

/* ====== MODAL ====== */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.35);
    display: flex; align-items: flex-end; justify-content: center;
    z-index: 50; backdrop-filter: blur(6px);
    animation: fadeIn .2s ease;
}
.modal-backdrop.hidden { display: none; }

.modal {
    background: var(--surface);
    border-radius: 24px 24px 0 0;
    width: 100%; max-height: 80vh;
    overflow: hidden; display: flex; flex-direction: column;
    box-shadow: 0 -4px 30px rgba(0,0,0,0.12);
    animation: slideUp .3s ease;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-header h2 { font-size: 17px; font-weight: 700; }
.modal-body { flex: 1; overflow-y: auto; padding: 16px; }
.modal-footer { padding: 14px 16px; border-top: 1px solid var(--border); flex-shrink: 0; }

.tx-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 15px;
}
.tx-item:last-of-type { border-bottom: none; }
.tx-time  { color: var(--muted); font-size: 13px; min-width: 42px; }
.tx-desc  { flex: 1; padding: 0 10px; font-weight: 500; }
.tx-total { color: #b45309; font-weight: 800; }

.summary-empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 16px; }

.summary-grand {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border: 1px solid #fde68a; border-radius: var(--rs);
    padding: 14px 16px; margin-top: 12px;
    display: flex; justify-content: space-between;
    font-size: 17px; font-weight: 800;
}
.summary-grand .amount { color: #b45309; }

.btn-danger {
    width: 100%; padding: 14px;
    background: var(--red-bg); border: 1px solid var(--red);
    border-radius: var(--rs); color: var(--red);
    font-size: 16px; font-weight: 700; cursor: pointer;
}
.btn-danger:active { background: #fecaca; }

/* ====== PIN ====== */
.pin-modal { max-width: 380px; border-radius: 24px 24px 0 0; }

.pin-dots {
    display: flex; justify-content: center; gap: 18px; padding: 20px 20px 8px;
}
.pin-dots span {
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--border); transition: background .15s;
}
.pin-dots span.filled { background: #b45309; }
.pin-dots span.error  { background: var(--red); }

.pin-pad {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 8px; padding: 12px 16px 20px;
}
.pin-pad button {
    aspect-ratio: 1; border: 1px solid var(--border);
    background: var(--surface2); color: var(--text);
    font-size: 24px; font-weight: 700; border-radius: var(--rs);
    cursor: pointer; transition: background .1s, transform .1s;
}
.pin-pad button:active { background: var(--border); transform: scale(0.93); }
.pin-empty {
    background: transparent !important; border-color: transparent !important;
    box-shadow: none !important; cursor: default !important; pointer-events: none;
}

/* ====== ANİMASYONLAR ====== */
@keyframes fadeIn   { from { opacity: 0; }                    to { opacity: 1; } }
@keyframes slideUp  { from { transform: translateY(100%); }   to { transform: translateY(0); } }
@keyframes popIn    { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slideInTop { from { transform: translateY(-16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@keyframes shake {
    0%,100% { transform: translateX(0); }
    25%      { transform: translateX(-10px); }
    75%      { transform: translateX(10px); }
}
.shake { animation: shake .35s ease; }
