:root {
    --bg: #0b0f14;
    --card: #121823;
    --text: #e9eef6;
    --muted: #a8b2c3;
    --line: #253044;
    --accent: #9bbcff;
    --success: #10b981;
    --error: #ef4444;
    --warn: #f59e0b;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    overflow-x: hidden;
}

.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    width: 100%;
    margin: 0 auto;
}

.screen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.screen-header h1 {
    font-size: 18px;
    font-weight: 700;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 12px 20px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn:active { background: rgba(155, 188, 255, 0.15); border-color: var(--accent); }

.btn-primary {
    background: var(--accent);
    color: #0b0f14;
    border-color: var(--accent);
}
.btn-primary:active { background: #7da8f0; }

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}
.btn-success:active { background: #0d9668; }

.btn-danger {
    background: transparent;
    color: var(--error);
    border-color: var(--error);
}
.btn-danger:active { background: rgba(239, 68, 68, 0.15); }

.btn-block { width: 100%; }

.btn-sm { min-height: 40px; padding: 8px 14px; font-size: 13px; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
}

.field { margin-bottom: 16px; }

.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.field input,
.field textarea,
.field select {
    width: 100%;
    min-height: 48px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
    font-size: 16px;
    outline: none;
    -webkit-appearance: none;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
    border-color: var(--accent);
}

.pin-display {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 30px 0;
}

.pin-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--line);
    transition: background 0.15s, border-color 0.15s;
}

.pin-dot.filled {
    background: var(--accent);
    border-color: var(--accent);
}

.pin-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 80%;
    margin: 0 auto;
}

.pin-key {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--text);
    cursor: pointer;
    transition: background 0.1s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.pin-key:active { background: rgba(155, 188, 255, 0.15); border-color: var(--accent); }
.pin-key.accent { background: var(--accent); color: #0b0f14; }
.pin-key.accent:active { background: #7da8f0; }
.pin-key.muted { color: var(--muted); font-size: 14px; }

.pin-error {
    text-align: center;
    color: var(--error);
    font-size: 14px;
    min-height: 20px;
    margin-top: 16px;
}

.nfc-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    flex: 1;
}

.nfc-icon {
    font-size: 64px;
    color: var(--accent);
    margin-bottom: 20px;
    position: relative;
}

.nfc-waves {
    position: absolute;
    width: 80px;
    height: 80px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    animation: wave 2s infinite;
}

.nfc-waves.w2 { animation-delay: 0.6s; }
.nfc-waves.w3 { animation-delay: 1.2s; }

@keyframes wave {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0.8; }
    100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

.nfc-label {
    font-size: 18px;
    font-weight: 600;
    color: var(--muted);
}

.result-card {
    width: 100%;
    text-align: center;
    animation: fadeIn 0.3s;
}

.result-name {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 8px;
}

.result-discount {
    font-size: 48px;
    font-weight: 900;
    color: var(--success);
    margin: 16px 0;
}

.result-status {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.status-active { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.status-blocked { background: rgba(168, 178, 195, 0.15); color: var(--muted); }
.status-expired { background: rgba(239, 68, 68, 0.15); color: var(--error); }

.result-visits {
    font-size: 14px;
    color: var(--muted);
    margin-top: 12px;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.tile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 120px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.15s;
    touch-action: manipulation;
}

.tile:active { border-color: var(--accent); }

.tile-icon {
    font-size: 28px;
    color: var(--accent);
}

.search-bar {
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--text);
    font-size: 16px;
    outline: none;
    margin-bottom: 16px;
}

.search-bar:focus { border-color: var(--accent); }

.customer-list { list-style: none; }

.customer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    transition: background 0.1s;
    touch-action: manipulation;
}

.customer-item:active { background: rgba(155, 188, 255, 0.08); }

.customer-name {
    font-size: 15px;
    font-weight: 600;
}

.customer-meta {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.customer-discount {
    font-size: 18px;
    font-weight: 800;
    color: var(--accent);
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.dot-active { background: var(--success); }
.dot-blocked { background: var(--muted); }
.dot-expired { background: var(--error); }

.stepper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stepper-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--text);
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
}

.stepper-btn:active { background: rgba(155, 188, 255, 0.15); border-color: var(--accent); }

.stepper-value {
    flex: 1;
    text-align: center;
    font-size: 28px;
    font-weight: 800;
    color: var(--accent);
}

.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: #0b0f14;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(155, 188, 255, 0.3);
    touch-action: manipulation;
    z-index: 10;
}

.fab:active { background: #7da8f0; }

.app-footer {
    text-align: center;
    padding: 16px;
    font-size: 11px;
    color: var(--muted);
    border-top: 1px solid var(--line);
    margin-top: auto;
}

.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}
.shake { animation: shake 0.4s; }

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    z-index: 100;
    animation: fadeIn 0.3s;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}

.toast-success { border-color: var(--success); color: var(--success); }
.toast-error { border-color: var(--error); color: var(--error); }

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
}

.dialog {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 24px;
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.dialog h3 { margin-bottom: 12px; font-size: 18px; }
.dialog p { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.dialog-actions { display: flex; gap: 10px; }
.dialog-actions .btn { flex: 1; }

.view { display: none; }
.view.active { display: flex; flex-direction: column; flex: 1; }

/* ── Tablet landscape (≥768px) ── */
@media (min-width: 768px) {
    .screen {
        max-width: 720px;
        padding: 24px;
    }

    .pin-grid {
        max-width: 360px;
    }

    .pin-key {
        min-height: 72px;
        font-size: 28px;
    }

    .tile-grid {
        gap: 16px;
    }

    .tile {
        min-height: 140px;
        font-size: 16px;
    }

    .tile-icon {
        font-size: 34px;
    }

    .form-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }

    .scan-layout {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 24px;
        align-items: center;
    }

    .result-discount {
        font-size: 56px;
    }

    .result-name {
        font-size: 28px;
    }

    .customer-item {
        padding: 16px 20px;
    }

    .btn {
        min-height: 52px;
        font-size: 16px;
    }
}

/* ── Large tablet landscape (≥1024px) ── */
@media (min-width: 1024px) {
    .screen {
        max-width: 960px;
    }
}
