:root {
    --primary: #6C5CE7;
    --primary-dark: #5A4BD1;
    --danger: #E74C3C;
    --warning: #F39C12;
    --success: #27AE60;
    --bg: #F8F9FA;
    --card: #FFFFFF;
    --text: #2D3436;
    --text-light: #636E72;
    --border: #DFE6E9;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* ─── Nav ─── */
.navbar {
    background: var(--primary);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar .logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 2px;
}

.navbar a { color: white; text-decoration: none; margin-left: 15px; }
.navbar a:hover { opacity: 0.8; }

/* ─── Cards ─── */
.card {
    background: var(--card);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
}

.card h2 {
    margin-bottom: 16px;
    font-size: 1.2rem;
}

/* ─── Forms ─── */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-light);
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ─── Buttons ─── */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.2s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-full { width: 100%; }

/* ─── Alerts ─── */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-success { background: #D4EDDA; color: #155724; }
.alert-error { background: #F8D7DA; color: #721C24; }
.alert-warning { background: #FFF3CD; color: #856404; }

/* ─── Dashboard ─── */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-box {
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    border: 1px solid var(--border);
}

.stat-box .number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
}

.stat-box .label {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* ─── Customer List ─── */
.customer-list { list-style: none; }

.customer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.customer-item:last-child { border-bottom: none; }

.customer-name { font-weight: 600; }

.customer-meta {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* ─── Churn Alert ─── */
.churn-alert {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px;
    background: #FFF5F5;
    border: 1px solid #FED7D7;
    border-radius: 8px;
    margin-bottom: 10px;
}

.churn-alert .risk-badge {
    background: var(--danger);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* ─── QR Code ─── */
.qr-container {
    text-align: center;
    padding: 20px;
}

.qr-container img {
    max-width: 250px;
    border-radius: 12px;
}

/* ─── Customer Card (mobile) ─── */
.loyalty-card {
    background: linear-gradient(135deg, var(--primary), #A29BFE);
    color: white;
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    margin-bottom: 20px;
}

.loyalty-card h1 { font-size: 1.8rem; margin-bottom: 4px; }
.loyalty-card .shop { font-size: 0.9rem; opacity: 0.8; margin-bottom: 20px; }
.loyalty-card .visits-count { font-size: 3rem; font-weight: 800; }
.loyalty-card .visits-label { font-size: 0.85rem; opacity: 0.8; }

.qr-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
}

.qr-card img { max-width: 200px; }
.qr-card p {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-light);
}

/* ─── Scan Page ─── */
#scanner-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

#scanner-container video {
    width: 100%;
    border-radius: 12px;
}

.scan-result {
    text-align: center;
    padding: 30px;
}

.scan-result.success .icon { font-size: 4rem; }
.scan-result.fail .icon { font-size: 4rem; }

/* ─── Auth Pages ─── */
.auth-container {
    max-width: 400px;
    margin: 60px auto;
    padding: 20px;
}

.auth-container .logo-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-container .logo-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 3px;
}

.auth-container .logo-header p {
    color: var(--text-light);
    font-size: 0.9rem;
}

.auth-link {
    text-align: center;
    margin-top: 16px;
    font-size: 0.9rem;
}

.auth-link a { color: var(--primary); }

/* ─── Mobile ─── */
.mobile-container {
    max-width: 420px;
    margin: 0 auto;
    padding: 20px;
}

/* ─── Tabs ─── */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.tab {
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--border);
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
}

.tab.active {
    background: var(--primary);
    color: white;
}

/* ─── Tier Badges ─── */
.tier-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tier-bronze { background: #FDF2E9; color: #CD7F32; }
.tier-silver { background: #F0F0F0; color: #6B7280; }
.tier-gold { background: #FEF9E7; color: #B7950B; }
.tier-platinum { background: #F4ECF7; color: #7D3C98; }
