:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --info: #0284c7;
    --info-bg: #e0f2fe;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    background: #0f172a;
    color: #fff;
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    white-space: nowrap;
}
.topbar-brand .badge-lite {
    font-size: 11px;
    background: var(--primary);
    color: #fff;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
}
.topbar-nav a {
    color: #cbd5e1;
    padding: 7px 12px;
    border-radius: 8px;
    font-weight: 500;
    white-space: nowrap;
}
.topbar-nav a:hover, .topbar-nav a.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    text-decoration: none;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #cbd5e1;
    white-space: nowrap;
}

.container {
    max-width: 1280px;
    margin: 24px auto;
    padding: 0 18px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}
.page-header h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}
.page-subtitle {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 18px;
}
.card h2, .card h3 {
    margin-top: 0;
    margin-bottom: 14px;
    font-size: 16px;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

@media (max-width: 960px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .grid-4 { grid-template-columns: 1fr; }
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-value { font-size: 24px; font-weight: 800; margin-top: 6px; color: var(--text); }
.stat-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 15px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: #fff; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--surface-2); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: var(--text);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: 500;
    cursor: pointer;
}
.form-check input[type="checkbox"] { width: 17px; height: 17px; cursor: pointer; }
.help-text { font-size: 12px; color: var(--muted); margin-top: 4px; }

.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-weight: 500;
    border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: #166534; border-color: #bbf7d0; }
.alert-danger { background: var(--danger-bg); color: #991b1b; border-color: #fecaca; }
.alert-warning { background: var(--warning-bg); color: #92400e; border-color: #fde68a; }
.alert-info { background: var(--info-bg); color: #075985; border-color: #bae6fd; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
th { background: var(--surface-2); font-weight: 700; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.02em; }
tr:hover td { background: #f8fafc; }

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: #e2e8f0;
    color: #334155;
}
.badge-success { background: var(--success-bg); color: #166534; }
.badge-danger { background: var(--danger-bg); color: #991b1b; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-info { background: var(--info-bg); color: #075985; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.text-right { text-align: right; }
.text-muted { color: var(--muted); }
.hidden { display: none !important; }

pre.code-block {
    background: #0f172a;
    color: #e2e8f0;
    padding: 14px 16px;
    border-radius: 10px;
    overflow-x: auto;
    font-size: 12px;
    line-height: 1.5;
}

/* Auth layout */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}
.auth-box {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

/* Public Digital Card */
.public-page {
    min-height: 100vh;
    background: #f1f5f9;
    padding: 20px 14px 40px;
}
.public-wrap {
    max-width: 460px;
    margin: 0 auto;
}
.loyalty-card-widget {
    border-radius: 18px;
    padding: 22px;
    color: #fff;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.18);
    margin-bottom: 16px;
}
.barcode-box {
    background: #fff;
    border-radius: 12px;
    padding: 12px 10px 8px;
    text-align: center;
    margin-top: 16px;
    color: #0f172a;
}
.barcode-svg {
    width: 100%;
    max-width: 340px;
    height: auto;
    display: block;
    margin: 0 auto;
}
.progress-track {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 8px;
}
.progress-fill {
    height: 100%;
    background: #fff;
    border-radius: 999px;
}

/* Cashier POS Desk */
.cashier-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.cashier-tab {
    flex: 1;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-weight: 700;
    cursor: pointer;
    text-align: center;
}
.cashier-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.discount-callout {
    background: #ecfdf5;
    border: 2px solid #16a34a;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    margin-top: 14px;
}
.discount-callout .big-amount {
    font-size: 30px;
    font-weight: 800;
    color: #15803d;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 100;
}
.modal-card {
    background: #fff;
    border-radius: 14px;
    max-width: 480px;
    width: 100%;
    padding: 22px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.3);
}
