:root {
    --bg: #0f0f1a;
    --bg2: #1a1a2e;
    --accent: #6c63ff;
    --accent2: #ff6584;
    --text: #f0f0f0;
    --muted: #888;
    --card: #1e1e32;
    --border: #2a2a45;
    --success: #4caf50;
    --danger: #ef5350;
    --radius: 16px;
}

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

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

/* ── SCREENS ── */
.screen {
    position: fixed; inset: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.screen.hidden { display: none; }
.screen.active { display: flex; }

/* ── AUTH ── */
.auth-container {
    flex: 1; display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    padding: 32px 24px; gap: 24px;
    background: linear-gradient(160deg, var(--bg2) 0%, var(--bg) 100%);
}
.auth-logo { text-align: center; }
.auth-logo svg { width: 160px; height: 64px; }
.auth-logo p { color: var(--muted); font-size: 14px; margin-top: 8px; }

.auth-tabs { display: flex; background: var(--card); border-radius: 12px; padding: 4px; gap: 4px; }
.tab-btn {
    flex: 1; padding: 10px 20px; border: none; border-radius: 10px;
    background: transparent; color: var(--muted);
    font-size: 14px; font-weight: 600; cursor: pointer; transition: all .2s;
}
.tab-btn.active { background: var(--accent); color: white; }

.auth-form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.auth-form.hidden { display: none; }

input[type=text], input[type=email], input[type=tel],
input[type=password], input[type=number] {
    width: 100%; padding: 14px 16px;
    background: var(--card); border: 1px solid var(--border);
    border-radius: 12px; color: var(--text); font-size: 15px;
    outline: none; transition: border-color .2s;
}
input:focus { border-color: var(--accent); }

/* ── BUTTONS ── */
.btn-primary {
    width: 100%; padding: 14px; border: none; border-radius: 12px;
    background: var(--accent); color: white; font-size: 16px;
    font-weight: 700; cursor: pointer; transition: opacity .15s;
}
.btn-primary:active { opacity: .8; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
    width: 100%; padding: 12px; border: 1px solid var(--accent);
    border-radius: 12px; background: transparent; color: var(--accent);
    font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-ghost {
    width: 100%; padding: 12px; border: none; background: transparent;
    color: var(--muted); font-size: 14px; cursor: pointer;
}
.icon-btn {
    background: none; border: none; color: var(--text);
    font-size: 20px; cursor: pointer; padding: 4px 8px;
}

.form-error { color: var(--danger); font-size: 13px; text-align: center; }

/* Toast bildirimi */
#toast {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.8);
    background: var(--danger); color: #fff;
    font-size: 20px; font-weight: 800;
    padding: 20px 32px; border-radius: 20px;
    text-align: center; z-index: 99999;
    opacity: 0; pointer-events: none;
    transition: opacity .2s, transform .2s;
    max-width: 80vw; line-height: 1.4;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
#toast.show {
    opacity: 1; transform: translate(-50%, -50%) scale(1);
}
.hidden { display: none !important; }

/* ── TOPBAR ── */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; background: var(--bg2);
    border-bottom: 1px solid var(--border);
    position: relative; z-index: 10;
}
.topbar-brand { font-size: 18px; font-weight: 900; letter-spacing: 2px; color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.wallet-chip {
    background: var(--card); border: 1px solid var(--accent);
    border-radius: 20px; padding: 4px 12px; font-size: 14px;
    font-weight: 700; color: var(--accent); cursor: pointer;
}

/* ── SCANNER ── */
.scanner-wrap {
    flex: 1; position: relative; overflow: hidden; background: #000;
}
#scanner-video {
    width: 100%; height: 100%; object-fit: cover;
}
.scan-frame {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -55%);
    width: min(260px, 70vw); height: min(260px, 70vw);
}
.corner {
    position: absolute; width: 28px; height: 28px;
    border-color: var(--accent); border-style: solid; border-width: 0;
}
.corner.tl { top: 0; left: 0; border-top-width: 4px; border-left-width: 4px; border-radius: 6px 0 0 0; }
.corner.tr { top: 0; right: 0; border-top-width: 4px; border-right-width: 4px; border-radius: 0 6px 0 0; }
.corner.bl { bottom: 0; left: 0; border-bottom-width: 4px; border-left-width: 4px; border-radius: 0 0 0 6px; }
.corner.br { bottom: 0; right: 0; border-bottom-width: 4px; border-right-width: 4px; border-radius: 0 0 6px 0; }

.scan-hint {
    position: absolute; bottom: 16px; left: 0; right: 0;
    text-align: center; color: rgba(255,255,255,.6); font-size: 13px;
}

/* ── BOTTOM PANEL ── */
.bottom-panel {
    background: var(--bg2); border-top: 1px solid var(--border);
    padding: 16px;
}
.mode-toggle {
    display: flex; background: var(--card); border-radius: 12px;
    padding: 4px; gap: 4px;
}
.mode-btn {
    flex: 1; padding: 10px; border: none; border-radius: 10px;
    background: transparent; color: var(--muted);
    font-size: 15px; font-weight: 700; cursor: pointer; letter-spacing: 1px;
    transition: all .2s;
}
.mode-btn.active { background: var(--accent); color: white; }

.cart-area { margin-top: 12px; }
#cart-list { list-style: none; max-height: 150px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.cart-item {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--card); border-radius: 10px; padding: 8px 12px;
    font-size: 14px;
}
.cart-item-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item-price { color: var(--accent); font-weight: 700; margin: 0 8px; white-space: nowrap; }
.cart-item-remove { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; }

.cart-footer {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 10px;
}
#cart-total { font-size: 18px; font-weight: 800; color: var(--accent); }
#btn-checkout { width: auto; padding: 12px 24px; }

/* ── PREVIEW ── */
#screen-preview {
    background: rgba(0,0,0,.85); justify-content: flex-end;
    backdrop-filter: blur(8px);
}
.preview-card {
    background: var(--card); border-radius: var(--radius) var(--radius) 0 0;
    padding: 28px 24px 40px; display: flex; flex-direction: column;
    align-items: center; gap: 12px; width: 100%;
}
.preview-media {
    position: relative;
    width: 220px; height: 220px;
    display: flex; align-items: center; justify-content: center;
}
.preview-img { width: 220px; height: 220px; object-fit: cover; border-radius: 24px; }
.preview-icon { font-size: 100px; line-height: 1; }

/* Geri sayım halkası — resmin etrafında, üstünü kapatmaz */
.countdown-ring {
    position: absolute; inset: -18px;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
}
.countdown-ring svg { width: 256px; height: 256px; transform: rotate(-90deg); }
.countdown-track { fill: none; stroke: rgba(255,255,255,.12); stroke-width: 7; }
.countdown-fill {
    fill: none; stroke: var(--accent); stroke-width: 7;
    stroke-linecap: round;
    stroke-dasharray: 738; stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear;
}
.countdown-num {
    position: absolute; bottom: -36px; left: 50%; transform: translateX(-50%);
    font-size: 24px; font-weight: 900;
    color: var(--accent); background: var(--card);
    width: 46px; height: 46px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--accent);
}
.preview-card h2 { font-size: 20px; font-weight: 800; text-align: center; }
.preview-card > p { color: var(--muted); font-size: 13px; }
.preview-price-row {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; padding: 8px 0; border-top: 1px solid var(--border);
}
#preview-price { font-size: 24px; font-weight: 900; color: var(--accent); }
.qty-row { display: flex; align-items: center; gap: 12px; }
.qty-btn {
    width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--accent);
    background: transparent; color: var(--accent); font-size: 20px;
    font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
#qty-val { font-size: 18px; font-weight: 800; min-width: 28px; text-align: center; }
.preview-actions { width: 100%; display: flex; flex-direction: column; gap: 8px; }

/* ── CONFIRM ── */
#screen-confirm {
    background: var(--bg); justify-content: center; align-items: center;
    padding: 24px;
}
.confirm-card {
    background: var(--card); border-radius: var(--radius);
    padding: 32px 24px; width: 100%; max-width: 400px;
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    text-align: center;
}
.confirm-icon {
    width: 72px; height: 72px; border-radius: 50%;
    background: var(--success); display: flex; align-items: center;
    justify-content: center; font-size: 36px; color: white;
}
.confirm-card h2 { font-size: 22px; font-weight: 800; }
.confirm-ref { font-size: 13px; color: var(--muted); font-family: monospace; }
.confirm-msg { font-size: 14px; color: var(--muted); }
.confirm-items { width: 100%; border-top: 1px solid var(--border); padding-top: 12px; }
.confirm-item-row {
    display: flex; justify-content: space-between;
    font-size: 14px; padding: 4px 0; color: var(--muted);
}
.confirm-total-row {
    display: flex; justify-content: space-between;
    width: 100%; font-size: 16px; font-weight: 800;
    border-top: 1px solid var(--border); padding-top: 10px;
}

/* ── PROFILE ── */
#screen-profile { background: var(--bg); overflow-y: auto; }
.profile-content { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.wallet-card {
    background: linear-gradient(135deg, var(--accent), #a855f7);
    border-radius: var(--radius); padding: 24px;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.wallet-label { font-size: 13px; opacity: .8; }
.wallet-amount { font-size: 36px; font-weight: 900; }
.wallet-card .btn-secondary {
    border-color: white; color: white; width: auto;
    padding: 8px 20px; font-size: 14px;
}
.profile-info {
    background: var(--card); border-radius: var(--radius); padding: 16px;
    display: flex; flex-direction: column; gap: 6px;
}
.profile-field { font-size: 15px; }
.profile-field.muted { color: var(--muted); font-size: 13px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.settings-row {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--card); border-radius: 12px; padding: 14px 16px;
}
.settings-row label { font-size: 14px; color: var(--text); }
.countdown-setting { display: flex; align-items: center; gap: 10px; }
.countdown-setting span { font-size: 18px; font-weight: 800; min-width: 24px; text-align: center; }
.cd-unit { font-size: 13px !important; font-weight: 400 !important; color: var(--muted); }
.orders-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.order-item {
    background: var(--card); border-radius: 12px; padding: 14px 16px;
    display: flex; justify-content: space-between; align-items: center;
}
.order-item-left { display: flex; flex-direction: column; gap: 3px; }
.order-ref { font-size: 13px; font-weight: 700; color: var(--accent); font-family: monospace; }
.order-merchant { font-size: 12px; color: var(--muted); }
.order-amount { font-size: 16px; font-weight: 800; }

/* ── TOPUP MODAL ── */
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,.7);
    display: flex; align-items: flex-end; z-index: 100;
    backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }
.modal-card {
    background: var(--card); border-radius: var(--radius) var(--radius) 0 0;
    padding: 28px 24px 40px; width: 100%;
    display: flex; flex-direction: column; gap: 14px;
}
.modal-card h3 { font-size: 18px; font-weight: 800; }
.topup-amounts { display: flex; gap: 8px; flex-wrap: wrap; }
.amount-btn {
    flex: 1; min-width: 70px; padding: 10px;
    border: 2px solid var(--border); border-radius: 10px;
    background: var(--bg2); color: var(--text); font-size: 15px;
    font-weight: 700; cursor: pointer; transition: all .15s;
}
.amount-btn.selected { border-color: var(--accent); color: var(--accent); }
.topup-methods { display: flex; flex-direction: column; gap: 8px; }
.topup-methods label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.bank-info {
    background: var(--bg2); border-radius: 10px; padding: 14px;
    font-size: 13px; line-height: 1.8;
}
.bank-info strong { color: var(--accent); }

/* ── LOADING ── */
.loading-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 999;
}
.loading-overlay.hidden { display: none; }
.spinner {
    width: 48px; height: 48px; border: 4px solid var(--border);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
