:root {
    --bg: #f6efe7;
    --surface: rgba(255, 252, 248, 0.88);
    --surface-strong: #fff8f1;
    --line: #06c755;
    --milk: #d57b2c;
    --milk-dark: #9a4f1f;
    --cream: #fff4e8;
    --ink: #2f1c12;
    --ink-soft: #71564a;
    --border: rgba(92, 61, 40, 0.12);
    --shadow: 0 24px 60px rgba(93, 57, 28, 0.12);
    --radius: 24px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    color: var(--ink);
    background:
        linear-gradient(rgba(255, 248, 240, 0.78), rgba(248, 236, 223, 0.88)),
        url("/assets/khundream-bg.png") center top / cover no-repeat fixed;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
}

.shell {
    max-width: 1040px;
    margin: 0 auto;
    padding: 16px;
}

.shell::before {
    content: "";
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0));
    pointer-events: none;
}

.topbar,
.footer,
.section-title,
.profile-head,
.actions,
.metrics,
.search-form,
.inline-form,
.nav {
    display: flex;
    gap: 16px;
    align-items: center;
}

.topbar,
.footer {
    justify-content: space-between;
}

.topbar {
    margin-bottom: 16px;
}

.brand {
    font-size: 1.25rem;
    font-weight: 800;
}

.nav {
    flex-wrap: wrap;
    color: var(--ink-soft);
}

.nav a,
.actions a,
.actions button {
    min-height: 40px;
}

.hero,
.page-grid,
.stats-grid,
form,
label,
.metric {
    display: grid;
    gap: 16px;
}

.hero {
    grid-template-columns: 1.4fr 1fr;
    gap: 24px;
}

.stats-grid,
.page-grid {
    gap: 16px;
}

.card {
    background: rgba(255, 252, 248, 0.92);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
    padding: 18px;
}

.hero-card {
    min-height: 320px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background:
        linear-gradient(135deg, rgba(255, 251, 247, 0.95), rgba(255, 239, 224, 0.92)),
        url("/assets/cup-logo.png") right 24px bottom 12px / 160px auto no-repeat;
}

.eyebrow,
.muted,
.metric-label {
    color: var(--ink-soft);
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    font-size: clamp(1.4rem, 2.6vw, 2.25rem);
    margin-bottom: 8px;
}

h2 {
    font-size: 1rem;
    margin-bottom: 6px;
}

.button,
button,
input {
    border-radius: 999px;
    font: inherit;
}

.button,
button {
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 14px;
    font-weight: 700;
}

.primary {
    background: var(--ink);
    color: #fff;
}

.ghost {
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--border);
}

.milk {
    background: linear-gradient(135deg, var(--milk), var(--milk-dark));
    color: #fff;
}

.line {
    background: var(--line);
    color: #fff;
}

button:disabled,
.button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.centered {
    display: grid;
    place-items: center;
    min-height: 70vh;
}

.form-card {
    width: min(100%, 460px);
}

input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface-strong);
    padding: 12px 16px;
}

.flash {
    border-radius: 20px;
    padding: 14px 18px;
    margin-bottom: 20px;
}

.flash-success {
    background: rgba(6, 199, 85, 0.18);
}

.flash-error {
    background: rgba(196, 63, 63, 0.18);
}

.profile-card,
.metrics {
    grid-column: 1 / -1;
}

.profile-card {
    background:
        linear-gradient(135deg, rgba(255, 252, 248, 0.95), rgba(255, 241, 226, 0.92)),
        url("/assets/cup-logo.png") right 24px center / 160px auto no-repeat;
}

.profile-head {
    flex-wrap: wrap;
    align-items: center;
}

.avatar {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-fallback {
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #d77f4f, #5c3d28);
    color: #fff;
    font-size: 2rem;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-content: space-between;
    gap: 10px;
}

.metric strong {
    font-size: 1.35rem;
}

.reward-badge {
    grid-template-columns: auto 1fr;
    align-items: center;
}

.reward-badge img {
    width: 48px;
    filter: drop-shadow(0 12px 24px rgba(93, 57, 28, 0.16));
}

.customer-code-box {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
    margin: 8px 0;
    padding: 12px 14px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(154, 79, 31, 0.14);
}

.customer-code-box strong {
    display: block;
    font-size: 1.1rem;
    letter-spacing: 0.08em;
}

.qr-card {
    display: grid;
    gap: 12px;
    background:
        linear-gradient(135deg, rgba(255, 251, 246, 0.96), rgba(255, 239, 224, 0.92));
}

.qr-layout,
.qr-meta,
.admin-search-grid,
.search-card,
.scan-card,
.reward-status-card,
.empty-admin-state {
    display: flex;
    gap: 18px;
}

.qr-layout,
.admin-search-grid {
    align-items: stretch;
}

.qr-layout {
    flex-wrap: wrap;
}

.qr-image {
    width: min(150px, 100%);
    border-radius: 16px;
    background: #fff;
    padding: 10px;
    border: 1px solid rgba(154, 79, 31, 0.1);
}

.qr-meta {
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
}

.qr-meta strong {
    font-size: 1.05rem;
    letter-spacing: 0.08em;
}

.loyalty-card {
    background:
        linear-gradient(135deg, rgba(255, 248, 240, 0.96), rgba(253, 236, 216, 0.92)),
        radial-gradient(circle at top right, rgba(213, 123, 44, 0.12), transparent 35%);
}

.stamp-track {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.stamp {
    aspect-ratio: 0.9;
    display: grid;
    place-items: center;
    gap: 4px;
    border-radius: 16px;
    font-weight: 700;
    color: var(--ink-soft);
    background: rgba(255, 255, 255, 0.72);
    border: 1px dashed rgba(92, 61, 40, 0.22);
    padding: 8px;
}

.stamp-cup {
    position: relative;
    display: inline-grid;
    place-items: center;
}

.stamp img {
    width: 46px;
    opacity: 0.42;
    transform: translateY(2px);
}

.stamp.filled {
    background: linear-gradient(135deg, rgba(215, 127, 79, 0.2), rgba(111, 63, 36, 0.1));
    color: var(--ink);
    border-style: solid;
    border-color: rgba(154, 79, 31, 0.22);
}

.stamp.filled img {
    opacity: 1;
}

.stamp span {
    font-size: 0.82rem;
}

.stamp-check {
    position: absolute;
    right: -4px;
    bottom: 0;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: linear-gradient(135deg, #d74833, #a9271b);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 900;
    box-shadow: 0 6px 14px rgba(169, 40, 26, 0.24);
}

.admin-hero {
    background:
        linear-gradient(135deg, rgba(255, 250, 245, 0.95), rgba(255, 236, 214, 0.92)),
        url("/assets/cup-logo.png") right 28px center / 150px auto no-repeat;
}

.admin-search-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
    gap: 18px;
}

.search-card,
.scan-card {
    flex-direction: column;
    padding: 20px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.68);
    border: 1px solid rgba(92, 61, 40, 0.1);
}

.scanner-video {
    width: 100%;
    max-width: 360px;
    border-radius: 20px;
    background: #2f1c12;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.member-grid {
    display: grid;
    gap: 24px;
}

.member-card {
    display: grid;
    gap: 20px;
}

.member-card-head,
.member-id-block,
.member-stat-pills,
.stamp-logo {
    display: flex;
    gap: 16px;
    align-items: center;
}

.member-card-head {
    justify-content: space-between;
    flex-wrap: wrap;
}

.stamp-logo {
    width: 82px;
    height: 82px;
    justify-content: center;
    border-radius: 24px;
    background: linear-gradient(135deg, rgba(255, 244, 232, 0.96), rgba(255, 227, 196, 0.96));
}

.stamp-logo img {
    width: 56px;
}

.member-stat-pills {
    flex-wrap: wrap;
}

.stat-pill {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 250, 245, 0.9);
    border: 1px solid rgba(154, 79, 31, 0.12);
    font-weight: 700;
}

.stat-pill.accent {
    background: rgba(213, 123, 44, 0.12);
}

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

.admin-action-card {
    padding: 20px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(92, 61, 40, 0.1);
}

.redeem-card {
    background: linear-gradient(135deg, rgba(255, 247, 239, 0.88), rgba(255, 236, 214, 0.82));
}

.reward-status-card {
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    padding: 18px 20px;
    border-radius: 22px;
    background: rgba(255, 248, 240, 0.84);
    border: 1px solid rgba(154, 79, 31, 0.12);
}

.reward-status-card.ready {
    background: linear-gradient(135deg, rgba(213, 123, 44, 0.16), rgba(255, 239, 224, 0.88));
}

.reward-status-card img {
    width: 74px;
}

.empty-admin-state {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 48px 28px;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.inline-form {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.inline-form input[type="number"] {
    max-width: 92px;
}

.footer {
    margin-top: 28px;
    color: var(--ink-soft);
}

@media (max-width: 1180px) {
    .shell {
        max-width: 960px;
    }

    .hero {
        grid-template-columns: 1fr;
    }

    .admin-search-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .shell {
        padding: 14px;
    }

    .topbar,
    .footer,
    .section-title,
    .profile-head,
    .member-card-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .nav,
    .actions,
    .member-stat-pills,
    .customer-code-box,
    .qr-layout {
        width: 100%;
    }

    .actions,
    .nav,
    .member-stat-pills {
        flex-wrap: wrap;
    }

    .metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .qr-meta {
        width: 100%;
    }

    .admin-action-grid {
        grid-template-columns: 1fr;
    }

    .scanner-video {
        max-width: 100%;
    }
}

@media (max-width: 900px) {
    .stamp-track {
        grid-template-columns: repeat(2, 1fr);
    }

    body {
        background:
            linear-gradient(rgba(255, 248, 240, 0.82), rgba(248, 236, 223, 0.9)),
            url("/assets/khundream-bg.png") center top / contain no-repeat;
        background-color: #fff6ee;
    }

    .profile-card,
    .hero-card,
    .admin-hero {
        background-size: 110px auto;
        background-position: right 16px top 16px;
    }
}

@media (max-width: 560px) {
    .shell {
        padding: 12px;
    }

    .card {
        padding: 14px;
        border-radius: 18px;
    }

    .brand {
        font-size: 1.05rem;
    }

    .nav a,
    .button,
    button {
        width: 100%;
    }

    .search-form,
    .customer-code-box,
    .actions {
        display: grid;
        gap: 10px;
        width: 100%;
    }

    .metrics {
        grid-template-columns: 1fr;
    }

    .metric strong {
        font-size: 1.2rem;
    }

    .stamp-track {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .stamp {
        border-radius: 14px;
        padding: 6px;
    }

    .stamp img {
        width: 40px;
    }

    .stamp-check {
        width: 22px;
        height: 22px;
        font-size: 0.85rem;
    }

    .qr-image {
        width: min(130px, 100%);
    }

    th,
    td {
        padding: 10px 8px;
        font-size: 0.92rem;
    }
}
