:root {
    --navy-dark: #071f33;
    --navy: #0d3a63;
    --blue-accent: #2f8fe4;
    --green: #1fa454;
    --amber: #e2861f;
    --bg: #eef1f4;
    --white: #ffffff;
    --text-muted: #7c8a99;
    --text-dark: #10243a;
    --border: #e1e6eb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text-dark);
}

a {
    color: inherit;
}

/* Top bar */
.topbar {
    background: var(--navy-dark);
    color: #fff;
}

.topbar__inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand__word {
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #fff;
}

.brand__word--dark {
    color: var(--navy);
}

.brand__divider {
    width: 1px;
    height: 28px;
    background: rgba(255, 255, 255, 0.25);
}

.brand__tagline {
    font-size: 0.6rem;
    line-height: 1.2;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.6);
    text-transform: lowercase;
}

.brand__tagline--dark {
    color: var(--text-muted);
    display: block;
    margin-top: 4px;
}

.topbar__user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.topbar__name {
    font-weight: 500;
}

.logout-form {
    margin: 0;
}

.link-button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: underline;
    padding: 0;
}

/* Hero */
.hero {
    background: linear-gradient(180deg, var(--navy) 0%, #0a2f52 100%);
    color: #fff;
}

.hero__inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 40px 24px 48px;
}

.hero__eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    margin: 0 0 12px;
}

.hero__title {
    font-size: 2.4rem;
    line-height: 1.15;
    margin: 0 0 14px;
    font-weight: 800;
}

.hero__title--accent {
    color: var(--blue-accent);
}

.hero__subtitle {
    color: rgba(255, 255, 255, 0.75);
    max-width: 620px;
    margin: 0 0 24px;
}

.referral-box {
    display: flex;
    gap: 12px;
    max-width: 620px;
    margin-bottom: 10px;
}

.referral-box input {
    flex: 1;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    padding: 12px 14px;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.9rem;
}

.referral-code {
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 20px;
    font-size: 0.9rem;
}

.referral-code strong {
    color: var(--blue-accent);
}

.share-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    padding: 11px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.btn--accent {
    background: var(--blue-accent);
    color: #fff;
}

.btn--solid {
    background: var(--blue-accent);
    color: #fff;
}

.btn--ghost {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.btn--block {
    width: 100%;
}

/* Page / tabs */
.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 24px 60px;
}

.tabs {
    display: flex;
    gap: 6px;
    background: #fff;
    border-radius: 999px;
    padding: 6px;
    width: fit-content;
    margin-bottom: 24px;
    box-shadow: 0 1px 2px rgba(16, 36, 58, 0.06);
}

.tabs__item {
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

.tabs__item--active {
    background: var(--navy);
    color: #fff;
}

.banner {
    padding: 14px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.banner--error {
    background: #fdecea;
    color: #a33a2e;
    border: 1px solid #f5c6c0;
}

/* Stat cards */
.stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border-radius: 14px;
    padding: 20px 22px;
    box-shadow: 0 1px 2px rgba(16, 36, 58, 0.06);
}

.stat-card__label {
    color: var(--text-muted);
    margin: 0 0 8px;
    font-size: 0.9rem;
}

.stat-card__value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    color: var(--navy);
}

.stat-card__value--green {
    color: var(--green);
}

.stat-card__value--amber {
    color: var(--amber);
}

/* Earned card */
.earned-card {
    background: var(--navy);
    color: #fff;
    border-radius: 14px;
    padding: 26px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.earned-card__label {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    margin: 0 0 6px;
}

.earned-card__value {
    font-size: 2.4rem;
    font-weight: 800;
    margin: 0;
    color: var(--blue-accent);
}

.earned-card__note {
    color: rgba(255, 255, 255, 0.65);
    margin: 4px 0 0;
    font-size: 0.85rem;
}

.earned-card__aside {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
}

.earned-card__brand {
    opacity: 0.35;
    font-weight: 600;
}

/* Generic card */
.card {
    background: #fff;
    border-radius: 14px;
    padding: 24px 26px;
    box-shadow: 0 1px 2px rgba(16, 36, 58, 0.06);
    margin-bottom: 20px;
}

.card__eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0 0 12px;
}

.milestone-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.milestone-card__title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 16px;
}

.milestone-card__star {
    color: #f5b731;
    font-size: 1.4rem;
}

.progress-bar {
    height: 8px;
    background: var(--bg);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar__fill {
    height: 100%;
    background: var(--blue-accent);
    border-radius: 999px;
}

.milestone-card__remaining {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 10px 0 0;
}

.how-it-works {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.how-it-works li {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.how-it-works__badge {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--navy);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Footer */
.site-footer {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 24px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.site-footer__brand {
    opacity: 0.5;
    font-weight: 600;
}

/* Auth pages (Login / Join / Error) */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 36px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 30px rgba(16, 36, 58, 0.1);
}

.auth-card--wide {
    max-width: 620px;
}

.brand--stacked {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    margin-bottom: 24px;
}

.auth-card__title {
    font-size: 1.4rem;
    margin: 0 0 8px;
}

.auth-card__subtitle {
    color: var(--text-muted);
    margin: 0 0 20px;
}

.field {
    margin-bottom: 16px;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.field input,
.field textarea {
    width: 100%;
    padding: 11px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 0.95rem;
    font-family: inherit;
}

.field__error {
    color: #a33a2e;
    font-size: 0.8rem;
}

/* Tables / lists */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 12px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.data-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    background: #f2f4f6;
    color: var(--text-muted);
}

.status-pill--installed {
    background: #e5f6ea;
    color: var(--green);
}

.status-pill--pending {
    background: #fdf1e2;
    color: var(--amber);
}

.empty-state {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.product-card__title {
    font-weight: 700;
    margin: 0 0 8px;
}

.product-card__desc {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 720px) {
    .stat-row {
        grid-template-columns: 1fr;
    }

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

    .hero__title {
        font-size: 1.9rem;
    }

    .referral-box {
        flex-direction: column;
    }
}
