:root {
    --ink: #14110e;
    --ink-soft: #1c1814;
    --cream: #f4efe6;
    --cream-deep: #ebe3d4;
    --card: #fffaf3;
    --line: rgba(20, 17, 14, 0.1);
    --muted: #6d6256;
    --text: #1c1610;
    --gold: #c4a15a;
    --gold-soft: #e8d7a8;
    --sage: #3d7a6e;
    --sage-deep: #2c5d54;
    --terracotta: #c45c3e;
    --shadow: 0 1px 2px rgba(20, 17, 14, 0.04), 0 22px 48px -28px rgba(20, 17, 14, 0.28);
    --radius: 1.15rem;
    --font-sans: "Manrope", ui-sans-serif, system-ui, sans-serif;
    --font-display: "Fraunces", ui-serif, Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
    min-height: 100%;
    background: var(--cream);
    color: var(--text);
    font-family: var(--font-sans);
}

::selection {
    background: var(--gold-soft);
    color: var(--ink);
}

[x-cloak] { display: none !important; }

/* ---------- App shell ---------- */

.app-shell {
    min-height: 100vh;
    display: flex;
    background:
        radial-gradient(1200px 500px at 80% -10%, rgba(196, 161, 90, 0.18), transparent 55%),
        radial-gradient(900px 420px at 10% 110%, rgba(61, 122, 110, 0.12), transparent 50%),
        var(--cream);
}

.sidebar {
    width: 272px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    color: #f3eadc;
    background:
        linear-gradient(180deg, rgba(196, 161, 90, 0.08), transparent 28%),
        linear-gradient(180deg, #1b1713 0%, #120f0d 100%);
    border-right: 1px solid rgba(243, 234, 220, 0.06);
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 1.35rem 1.2rem 1.1rem;
    color: inherit;
    text-decoration: none;
}

.sidebar-brand-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-brand-copy strong {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.sidebar-brand-copy span {
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(243, 234, 220, 0.5);
    margin-top: 0.15rem;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.25rem 0.85rem 1.25rem;
}

.nav-section {
    margin-top: 1.15rem;
}

.nav-section-label {
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(243, 234, 220, 0.38);
    padding: 0 0.65rem 0.4rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.52rem 0.7rem;
    border-radius: 0.8rem;
    color: rgba(243, 234, 220, 0.72);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-link svg {
    width: 1.05rem;
    height: 1.05rem;
    flex-shrink: 0;
    opacity: 0.8;
}

.sidebar-link:hover {
    background: rgba(243, 234, 220, 0.07);
    color: #fffaf3;
}

.sidebar-link.is-active {
    background: linear-gradient(180deg, rgba(196, 161, 90, 0.22), rgba(196, 161, 90, 0.1));
    color: #fff8ea;
    box-shadow: inset 0 0 0 1px rgba(196, 161, 90, 0.28);
}

.sidebar-link.is-active svg { opacity: 1; }

.sidebar-footer {
    padding: 0.9rem;
    border-top: 1px solid rgba(243, 234, 220, 0.08);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    padding: 0.55rem 0.55rem;
    border-radius: 0.9rem;
    background: rgba(243, 234, 220, 0.05);
    color: #f3eadc;
    border: 0;
    cursor: pointer;
    text-align: left;
}

.user-chip:hover { background: rgba(243, 234, 220, 0.09); }

.avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, var(--gold), #9a7430);
    color: #1c1610;
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-chip-copy {
    min-width: 0;
    flex: 1;
}

.user-chip-copy strong,
.user-chip-copy span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-chip-copy strong { font-size: 0.82rem; }
.user-chip-copy span { font-size: 0.7rem; color: rgba(243, 234, 220, 0.5); }

.dropdown-panel {
    position: absolute;
    left: 0.9rem;
    right: 0.9rem;
    bottom: 4.4rem;
    background: #fffaf3;
    color: var(--text);
    border-radius: 0.9rem;
    box-shadow: var(--shadow);
    overflow: hidden;
    z-index: 50;
}

.dropdown-panel a {
    display: block;
    padding: 0.7rem 0.9rem;
    font-size: 0.88rem;
    color: var(--text);
    text-decoration: none;
}

.dropdown-panel a:hover { background: var(--cream-deep); }

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 4.25rem;
    padding: 0.85rem 1.5rem;
    background: rgba(244, 239, 230, 0.78);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(20, 17, 14, 0.06);
}

.topbar h2 {
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--text);
    line-height: 1.2;
}

.sidebar-toggle {
    display: none;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 0.75rem;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--text);
    align-items: center;
    justify-content: center;
}

.credits-pill {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    background: #fffaf3;
    border: 1px solid rgba(196, 161, 90, 0.35);
    color: var(--text);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 700;
    box-shadow: 0 8px 20px -16px rgba(20, 17, 14, 0.5);
}

.credits-pill b { color: #8a6a28; }

.app-content {
    flex: 1;
    padding-bottom: 3rem;
}

@media (max-width: 639px) {
    .app-content > div {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

.sidebar-backdrop {
    display: none;
}

/* ---------- Shared content polish ---------- */

.app-content .bg-white,
.guest-card {
    background: var(--card) !important;
    border: 1px solid var(--line) !important;
    box-shadow: var(--shadow) !important;
}

.app-content .rounded,
.app-content .rounded-md,
.app-content .rounded-lg,
.app-content .sm\:rounded-lg {
    border-radius: var(--radius) !important;
}

.app-content input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
.app-content select,
.app-content textarea,
.guest-shell input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
.guest-shell select,
.guest-shell textarea {
    border: 1px solid rgba(20, 17, 14, 0.12) !important;
    border-radius: 0.8rem !important;
    background: #fff !important;
    color: var(--text) !important;
    box-shadow: 0 1px 1px rgba(20, 17, 14, 0.04);
    min-height: 2.55rem;
}

.app-content input:focus:not([type="checkbox"]):not([type="radio"]),
.app-content select:focus,
.app-content textarea:focus,
.guest-shell input:focus:not([type="checkbox"]):not([type="radio"]),
.guest-shell select:focus,
.guest-shell textarea:focus {
    outline: none !important;
    border-color: var(--sage) !important;
    box-shadow: 0 0 0 4px rgba(61, 122, 110, 0.15) !important;
}

.app-content label.text-sm,
.app-content form label:not(.inline-flex):not([class*="items-center"]) {
    display: block;
    font-size: 0.72rem !important;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.3rem;
}

.app-content label.inline-flex,
.app-content label[class*="items-center"] {
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.875rem !important;
    font-weight: 500;
    color: var(--text);
}

.app-content button.bg-indigo-600,
.app-content a.bg-indigo-600,
.app-content button.bg-slate-700 {
    background: linear-gradient(180deg, #3f8578, var(--sage-deep)) !important;
    color: #fff !important;
    border: 0;
    border-radius: 0.8rem !important;
    font-weight: 700 !important;
    padding: 0.55rem 1rem !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 10px 18px -12px rgba(44, 93, 84, 0.9);
    transition: transform 0.12s ease, filter 0.12s ease;
}

.app-content button.bg-emerald-600,
.app-content a.bg-emerald-600 {
    background: linear-gradient(180deg, #2f6f4f, #1f4d37) !important;
    color: #fff !important;
    border-radius: 0.8rem !important;
    font-weight: 700 !important;
    padding: 0.55rem 1rem !important;
}

.app-content button.bg-indigo-600:hover,
.app-content a.bg-indigo-600:hover,
.app-content button.bg-slate-700:hover,
.app-content button.bg-emerald-600:hover,
.app-content a.bg-emerald-600:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
}

.app-content a.text-indigo-600,
.app-content a.text-indigo-700,
.app-content a.underline {
    color: var(--sage-deep) !important;
    text-decoration: none !important;
    font-weight: 700;
    border-bottom: 1px solid rgba(44, 93, 84, 0.25);
}

.app-content a.text-indigo-600:hover,
.app-content a.text-indigo-700:hover,
.app-content a.underline:hover {
    color: var(--ink) !important;
    border-bottom-color: var(--ink);
}

.app-content table { width: 100%; border-collapse: separate; border-spacing: 0; }
.app-content thead th {
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 700;
    padding: 0.7rem 0.65rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
}
.app-content tbody td {
    padding: 0.8rem 0.65rem;
    border-bottom: 1px solid rgba(20, 17, 14, 0.06);
    vertical-align: middle;
}
.app-content tbody tr:hover td { background: rgba(196, 161, 90, 0.07); }

.app-content .bg-red-50,
.app-content .text-red-600,
.app-content .text-red-700 {
    border-radius: 0.9rem;
}
.app-content .bg-red-50 {
    border: 1px solid rgba(196, 92, 62, 0.2);
    padding: 0.85rem 1rem !important;
}
.app-content .bg-emerald-50 {
    border-radius: 0.9rem;
    border: 1px solid rgba(61, 122, 110, 0.2);
    padding: 0.85rem 1rem !important;
}
.app-content .bg-amber-50 {
    border-radius: 0.9rem;
}

.app-content pre {
    background: #f6f0e4 !important;
    border-radius: 0.8rem;
    padding: 0.75rem;
    border: 1px solid var(--line);
}

.app-content .border-b { border-color: rgba(20, 17, 14, 0.08) !important; }

/* ---------- Dashboard ---------- */

.hero-panel {
    position: relative;
    overflow: hidden;
    border-radius: 1.5rem;
    padding: 1.8rem 1.8rem 1.6rem;
    color: #fff8ea;
    background:
        linear-gradient(135deg, rgba(196, 161, 90, 0.22), transparent 42%),
        linear-gradient(180deg, #241e18 0%, #161310 100%);
    box-shadow: var(--shadow);
}

.hero-panel::after {
    content: "";
    position: absolute;
    width: 22rem;
    height: 22rem;
    right: -6rem;
    top: -8rem;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(196, 161, 90, 0.28), transparent 64%);
    pointer-events: none;
}

.hero-kicker {
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--gold-soft);
    font-weight: 700;
}

.hero-panel h1 {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    margin: 0.35rem 0 0.5rem;
    max-width: 36rem;
}

.hero-panel p {
    color: rgba(243, 234, 220, 0.72);
    max-width: 36rem;
    font-size: 0.95rem;
}

.stat-grid,
.action-grid {
    display: grid;
    gap: 1rem;
}

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

.stat-card,
.action-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 1.2rem;
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 1.15rem 1.2rem;
}

.stat-card span {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 700;
}

.stat-card strong {
    display: block;
    margin-top: 0.4rem;
    font-family: var(--font-display);
    font-size: 1.7rem;
    letter-spacing: -0.03em;
}

.action-card {
    padding: 1.2rem 1.25rem 1.15rem;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-height: 10.5rem;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.action-card:hover {
    transform: translateY(-3px);
    border-color: rgba(196, 161, 90, 0.45);
}

.action-icon {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 0.8rem;
    display: grid;
    place-items: center;
    background: rgba(61, 122, 110, 0.1);
    color: var(--sage-deep);
    margin-bottom: 0.35rem;
}

.action-card h3 {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
}

.action-card p {
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.45;
}

.action-card em {
    margin-top: auto;
    font-style: normal;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--sage-deep);
}

.wallet-hero {
    background:
        linear-gradient(135deg, rgba(196, 161, 90, 0.16), transparent 50%),
        var(--card);
}

.pack-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--line);
}

.pack-row:last-child { border-bottom: 0; }

/* ---------- Guest / auth ---------- */

.guest-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    background: var(--cream);
}

.guest-brand {
    position: relative;
    overflow: hidden;
    padding: 2.5rem;
    color: #f6eee0;
    background:
        linear-gradient(160deg, rgba(196, 161, 90, 0.2), transparent 42%),
        linear-gradient(180deg, #221c16, #120f0c);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.guest-brand::before {
    content: "";
    position: absolute;
    width: 28rem;
    height: 28rem;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(196, 161, 90, 0.22), transparent 65%);
    right: -8rem;
    bottom: -6rem;
}

.guest-brand-inner { position: relative; z-index: 1; }

.guest-brand h1 {
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 4vw, 3.4rem);
    line-height: 1.05;
    letter-spacing: -0.04em;
    margin: 1.4rem 0 1rem;
    max-width: 14ch;
}

.guest-brand p {
    max-width: 32rem;
    color: rgba(246, 238, 224, 0.72);
    font-size: 1.02rem;
}

.guest-points {
    display: grid;
    gap: 0.7rem;
    margin-top: 2rem;
}

.guest-points div {
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
    color: rgba(246, 238, 224, 0.82);
    font-size: 0.92rem;
}

.guest-points b {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 999px;
    background: rgba(196, 161, 90, 0.2);
    color: var(--gold-soft);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    font-size: 0.75rem;
}

.guest-form-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
}

.guest-card {
    width: 100%;
    max-width: 28rem;
    border-radius: 1.5rem !important;
    padding: 2rem 1.8rem;
}

.guest-card h2 {
    font-family: var(--font-display);
    font-size: 1.85rem;
    letter-spacing: -0.03em;
    margin-bottom: 0.3rem;
}

.guest-card .lede {
    color: var(--muted);
    margin-bottom: 1.4rem;
    font-size: 0.92rem;
}

.btn-primary,
.guest-shell button[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #3f8578, var(--sage-deep)) !important;
    color: #fff !important;
    border: 0 !important;
    border-radius: 0.85rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.01em;
    text-transform: none !important;
    font-size: 0.92rem !important;
    padding: 0.7rem 1.15rem !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 10px 18px -12px rgba(44, 93, 84, 0.9);
}

.logo-mark {
    width: 2.4rem;
    height: 2.4rem;
    flex-shrink: 0;
}

/* ---------- Mobile ---------- */

@media (max-width: 1024px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .guest-shell { grid-template-columns: 1fr; }
    .guest-brand { min-height: 18rem; padding: 1.6rem; }
    .guest-brand h1 { font-size: 2rem; margin: 0.8rem 0; }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        width: min(20rem, 88vw);
        transform: translateX(-105%);
        transition: transform 0.2s ease;
    }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-toggle { display: inline-flex; }
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(20, 17, 14, 0.45);
        z-index: 35;
    }
    .action-grid,
    .stat-grid { grid-template-columns: 1fr; }
    .topbar { padding: 0.8rem 1rem; }
    .credits-pill span { display: none; }
}
