:root {
    --bg: #f7f1ec;
    --surface: #fffaf7;
    --surface-strong: #ffffff;
    --text: #221d1b;
    --muted: #776861;
    --line: rgba(77, 55, 48, .14);
    --rose: #c8a19c;
    --taupe: #91766e;
    --beige: #f3ece3;
    --gold: #c8a650;
    --sage: #7d9487;
    --danger: #a33b3b;
    --shadow: 0 24px 70px rgba(65, 45, 39, .14);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

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

button,
input,
textarea,
select {
    font: inherit;
    letter-spacing: 0;
}

.page-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(135deg, rgba(255,255,255,.88), rgba(243,236,227,.84)),
        radial-gradient(circle at 18% 12%, rgba(200,161,156,.16), transparent 30%),
        radial-gradient(circle at 86% 18%, rgba(125,148,135,.12), transparent 28%);
    z-index: -1;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 56px;
}

.shell-auth {
    min-height: calc(100vh - 62px);
    display: grid;
    place-items: center;
    padding: 40px 0;
}

.topbar {
    width: min(1180px, calc(100% - 32px));
    margin: 16px auto 0;
    min-height: 64px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 250, 247, .88);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: 0 12px 32px rgba(65,45,39,.08);
}

.brand-link,
.auth-heading,
.heading-with-logo,
.topnav,
.button-row,
.hero-actions,
.panel-title,
.progress-label,
.admin-card-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-link {
    font-weight: 800;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(145deg, var(--rose), var(--taupe));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 10px 24px rgba(145,118,110,.22);
}

.brand-mark.large {
    width: 54px;
    height: 54px;
    font-size: 1.35rem;
}

.topnav {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.topnav a,
.icon-text {
    min-height: 38px;
    padding: 9px 12px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.topnav a:hover,
.icon-text:hover {
    color: var(--text);
    background: rgba(145,118,110,.1);
}

.topnav form {
    margin: 0;
}

.footer {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto 20px;
    color: var(--muted);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: .92rem;
}

.footer a {
    font-weight: 700;
}

.beating-heart {
    position: relative;
    display: inline-block;
    width: 13px;
    height: 13px;
    margin: 0 2px;
    background: #d85a75;
    transform: rotate(-45deg);
    animation: heartbeat 1.15s ease-in-out infinite;
}

.beating-heart::before,
.beating-heart::after {
    content: "";
    position: absolute;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #d85a75;
}

.beating-heart::before {
    top: -6px;
    left: 0;
}

.beating-heart::after {
    left: 6px;
    top: 0;
}

@keyframes heartbeat {
    0%, 45%, 100% { transform: rotate(-45deg) scale(1); }
    18% { transform: rotate(-45deg) scale(1.22); }
    30% { transform: rotate(-45deg) scale(.96); }
}

.auth-page .footer,
.home-page .footer,
.public-page .footer {
    margin-top: -44px;
}

.auth-card,
.center-panel,
.panel,
.floating-card,
.lookup-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255,250,247,.94);
    box-shadow: var(--shadow);
}

.auth-card {
    width: min(440px, 100%);
    padding: 30px;
}

.wide-card {
    width: min(760px, 100%);
}

.auth-heading {
    margin-bottom: 24px;
}

.auth-heading.centered {
    justify-content: center;
    text-align: center;
}

.eyebrow {
    display: block;
    color: var(--taupe);
    font-size: .76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
}

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

h1 {
    margin-bottom: 0;
    font-size: clamp(2rem, 6vw, 4.2rem);
    line-height: 1;
}

.auth-card h1,
.panel h1,
.page-heading h1,
.loyalty-card h2,
.lookup-card h1 {
    font-size: clamp(1.55rem, 4vw, 2.4rem);
    line-height: 1.08;
}

h2 {
    font-size: 1.22rem;
    line-height: 1.2;
}

h3 {
    font-size: 1rem;
}

.stack-form,
.form-grid,
.settings-layout {
    display: grid;
    gap: 16px;
}

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

.form-grid.compact {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
}

.span-2 {
    grid-column: 1 / -1;
}

.form-section-title {
    grid-column: 1 / -1;
    color: var(--taupe);
    font-weight: 900;
    margin-top: 4px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: .9rem;
    font-weight: 700;
}

input,
textarea,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    padding: 10px 12px;
    outline: 0;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--rose);
    box-shadow: 0 0 0 4px rgba(200,161,156,.18);
}

input[type="color"] {
    padding: 4px;
    cursor: pointer;
}

.btn,
.small-btn {
    border: 0;
    border-radius: var(--radius);
    background: var(--taupe);
    color: #fff;
    font-weight: 850;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 44px;
    padding: 11px 16px;
    box-shadow: 0 14px 30px rgba(145,118,110,.22);
}

.small-btn {
    min-height: 36px;
    padding: 8px 11px;
    font-size: .86rem;
    box-shadow: none;
}

.btn.secondary,
.small-btn.secondary {
    background: #fff;
    color: var(--taupe);
    border: 1px solid var(--line);
    box-shadow: none;
}

.btn.danger,
.link-danger {
    background: var(--danger);
}

.link-danger {
    width: 100%;
    border: 0;
    color: #fff;
    border-radius: var(--radius);
    min-height: 38px;
    padding: 8px 10px;
    cursor: pointer;
}

.subtle-link {
    text-align: center;
    color: var(--taupe);
    font-weight: 800;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.check-row input {
    width: 18px;
    min-height: 18px;
}

.file-label small {
    color: var(--muted);
    font-weight: 500;
}

.alert {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-weight: 750;
}

.alert-error {
    background: #fff0f0;
    color: #843232;
    border: 1px solid rgba(163,59,59,.2);
}

.alert-success {
    background: #eff8f1;
    color: #315f3a;
    border: 1px solid rgba(74,130,85,.24);
}

.home-hero {
    min-height: calc(100vh - 120px);
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(300px, .7fr);
    align-items: center;
    gap: 36px;
}

.hero-copy p {
    max-width: 520px;
    margin: 18px 0 24px;
    color: var(--muted);
    font-size: 1.08rem;
}

.sample-card {
    padding: 28px;
    min-height: 280px;
    display: grid;
    align-content: center;
    gap: 16px;
    transform: rotate(1.2deg);
}

.sparkle {
    color: var(--gold);
    font-size: 2rem;
}

.mini-stamps {
    display: grid;
    grid-template-columns: repeat(5, 42px);
    gap: 8px;
}

.mini-stamps span {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--taupe);
    background: var(--beige);
}

.mini-stamps .done {
    color: #fff;
    background: var(--rose);
}

.mini-stamps .reward {
    color: #fff;
    background: var(--gold);
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.page-heading p {
    margin: 7px 0 0;
    color: var(--muted);
}

.stat-grid,
.detail-grid,
.card-layout {
    display: grid;
    gap: 16px;
}

.stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 16px;
}

.stat,
.panel {
    padding: 20px;
}

.stat {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255,255,255,.78);
}

.stat span,
.big-number {
    display: block;
    font-size: 2.4rem;
    font-weight: 900;
    line-height: 1;
}

.stat p,
.details {
    margin-bottom: 0;
    color: var(--muted);
}

.panel {
    margin-bottom: 16px;
}

.panel-title {
    justify-content: space-between;
    margin-bottom: 14px;
}

.panel-title h2,
.panel-title h3 {
    margin: 0;
}

.search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-bottom: 16px;
}

.table-wrap {
    overflow-x: auto;
}

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

th,
td {
    text-align: left;
    padding: 13px 10px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 850;
}

.pill.ok {
    background: #e9f5ed;
    color: #326343;
}

.pill.muted {
    background: #eee8e2;
    color: var(--muted);
}

.empty-state {
    min-height: 120px;
    display: grid;
    place-items: center;
    color: var(--muted);
    text-align: center;
}

.details {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 16px;
}

.details dt {
    font-weight: 850;
    color: var(--text);
}

.detail-grid {
    grid-template-columns: 1fr 280px;
}

.logo-mark {
    width: 58px;
    height: 58px;
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    object-fit: cover;
    background: linear-gradient(145deg, var(--biz-detail, var(--rose)), var(--biz-button, var(--taupe)));
    color: #fff;
    font-weight: 900;
    border: 3px solid rgba(255,255,255,.8);
    box-shadow: 0 12px 30px rgba(70,48,40,.16);
}

.logo-mark.xl {
    width: 86px;
    height: 86px;
    font-size: 1.35rem;
}

.card-layout {
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
}

.loyalty-card {
    position: relative;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--biz-detail) 32%, transparent);
    border-radius: var(--radius);
    background: var(--biz-card);
    color: var(--biz-text);
    padding: 24px;
    box-shadow: var(--shadow);
}

.card-glow {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(115deg, rgba(255,255,255,.44), transparent 28%),
        radial-gradient(circle at 92% 8%, color-mix(in srgb, var(--biz-detail) 24%, transparent), transparent 24%);
}

.loyalty-header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.loyalty-header h2 {
    margin: 3px 0 5px;
}

.loyalty-header p {
    margin: 0;
    color: color-mix(in srgb, var(--biz-text) 58%, transparent);
}

.progress-box {
    position: relative;
    margin-bottom: 18px;
}

.progress-label {
    justify-content: space-between;
    margin-bottom: 8px;
    color: color-mix(in srgb, var(--biz-text) 72%, transparent);
}

.progress-track {
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--biz-empty);
}

.progress-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--biz-marked), var(--biz-reward));
    transition: width .35s ease;
}

.stamp-grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
    gap: 10px;
    margin: 18px 0;
}

.stamp-form {
    margin: 0;
}

.stamp {
    width: 100%;
    aspect-ratio: 1 / 1;
    min-height: 56px;
    border: 1px dashed color-mix(in srgb, var(--biz-button) 35%, transparent);
    border-radius: 50%;
    background: var(--biz-empty);
    color: color-mix(in srgb, var(--biz-text) 55%, transparent);
    display: grid;
    place-items: center;
    position: relative;
    overflow: hidden;
}

button.stamp {
    cursor: pointer;
}

.stamp span {
    font-size: 1.55rem;
    line-height: 1;
}

.stamp small {
    position: absolute;
    right: 8px;
    bottom: 7px;
    font-size: .72rem;
    font-weight: 900;
}

.stamp.marked {
    border-style: solid;
    background: var(--biz-marked);
    color: #fff;
    animation: soft-pop .42s ease;
}

.stamp.reward-stamp {
    box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--biz-reward) 42%, transparent);
}

.stamp.next-stamp {
    border-style: solid;
    background: color-mix(in srgb, var(--biz-detail) 18%, var(--biz-empty));
    color: var(--biz-button);
}

.stamp.next-stamp:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px color-mix(in srgb, var(--biz-detail) 24%, transparent);
}

@keyframes soft-pop {
    0% { transform: scale(.82); filter: brightness(1.25); }
    60% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

.celebrate .stamp.marked:last-of-type {
    animation: soft-pop .42s ease, shine 1.1s ease;
}

@keyframes shine {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--biz-reward) 0%, transparent); }
    50% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--biz-reward) 22%, transparent); }
    100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--biz-reward) 0%, transparent); }
}

.reward-strip,
.reward-card {
    border: 1px solid color-mix(in srgb, var(--biz-reward) 26%, transparent);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--biz-reward) 10%, #fff);
}

.muted-strip {
    padding: 12px;
    color: color-mix(in srgb, var(--biz-text) 68%, transparent);
}

.reward-list {
    display: grid;
    gap: 10px;
    margin: 18px 0;
}

.reward-card {
    padding: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.reward-card h3,
.reward-card p {
    margin-bottom: 5px;
}

.reward-card small {
    color: color-mix(in srgb, var(--biz-text) 62%, transparent);
}

.reward-card.used {
    opacity: .72;
}

.admin-card-actions {
    align-items: stretch;
    flex-wrap: wrap;
    margin: 18px 0;
}

.history {
    border-top: 1px solid color-mix(in srgb, var(--biz-button) 18%, transparent);
    margin-top: 20px;
    padding-top: 18px;
}

.history details {
    border: 1px solid color-mix(in srgb, var(--biz-button) 16%, transparent);
    border-radius: var(--radius);
    margin-top: 8px;
    background: rgba(255,255,255,.45);
}

.history summary {
    padding: 12px;
    cursor: pointer;
    font-weight: 850;
}

.history-list {
    padding: 0 12px 12px;
    display: grid;
    gap: 6px;
    color: color-mix(in srgb, var(--biz-text) 72%, transparent);
}

.history-reward {
    color: var(--biz-button);
    font-weight: 800;
}

.qr-panel {
    position: sticky;
    top: 96px;
    display: grid;
    gap: 13px;
}

.qr-img {
    width: 100%;
    max-width: 230px;
    justify-self: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    padding: 10px;
}

.copy-input {
    font-size: .8rem;
}

.public-lookup,
.public-card-wrap {
    min-height: calc(100vh - 110px);
    display: grid;
    place-items: center;
    padding: 30px 0 70px;
}

.public-lookup {
    background: var(--biz-bg);
    border-radius: var(--radius);
}

.lookup-card {
    width: min(430px, calc(100% - 24px));
    padding: 30px;
    text-align: center;
    color: var(--biz-text);
    background: var(--biz-card);
}

.lookup-card .logo-mark {
    margin-bottom: 15px;
}

.lookup-card .btn,
.preview-card .btn {
    background: var(--biz-button);
}

.settings-layout {
    grid-template-columns: minmax(0, 1fr) minmax(320px, .72fr);
    align-items: start;
}

.settings-layout > .panel:nth-of-type(2) {
    grid-column: 1;
}

.preview-panel {
    grid-column: 2;
    grid-row: 1 / span 2;
    position: sticky;
    top: 96px;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.preview-card {
    border: 1px solid color-mix(in srgb, var(--biz-detail) 30%, transparent);
    border-radius: var(--radius);
    padding: 22px;
    display: grid;
    gap: 14px;
    color: var(--biz-text);
    background: var(--biz-card);
    box-shadow: var(--shadow);
}

.reward-editor {
    margin: 18px 0;
}

.reward-rows {
    display: grid;
    gap: 10px;
}

.reward-row {
    display: grid;
    grid-template-columns: 88px 104px minmax(150px, .8fr) minmax(220px, 1fr) 34px;
    gap: 8px;
    align-items: end;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

.icon-only {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
}

.danger-icon {
    background: #fff0f0;
    color: var(--danger);
    font-size: 1.25rem;
}

.narrow {
    max-width: 520px;
}

.legal {
    max-width: 780px;
    margin: 0 auto 16px;
}

.legal p {
    color: var(--muted);
    line-height: 1.65;
}

.center-panel {
    width: min(560px, 100%);
    padding: 32px;
    text-align: center;
}

@media (max-width: 900px) {
    .home-hero,
    .card-layout,
    .settings-layout,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .preview-panel,
    .settings-layout > .panel:nth-of-type(2) {
        grid-column: auto;
        grid-row: auto;
        position: static;
    }

    .qr-panel {
        position: static;
    }

    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topnav {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 680px) {
    .shell {
        width: min(100% - 20px, 1180px);
        padding-top: 18px;
    }

    .auth-card,
    .panel,
    .loyalty-card,
    .lookup-card {
        padding: 18px;
    }

    .form-grid,
    .form-grid.compact,
    .color-grid,
    .search-row,
    .stat-grid {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: auto;
    }

    .reward-row {
        grid-template-columns: 1fr;
    }

    .danger-icon {
        width: 100%;
        border-radius: var(--radius);
    }

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

    .stamp {
        min-height: 58px;
    }

    .button-row,
    .admin-card-actions {
        flex-direction: column;
    }

    .button-row .btn,
    .button-row form,
    .button-row button,
    .admin-card-actions form,
    .admin-card-actions button {
        width: 100%;
    }

    .mini-stamps {
        grid-template-columns: repeat(5, minmax(34px, 1fr));
    }

    .mini-stamps span {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
    }
}

