:root {
    --bg: #f5f7f8;
    --surface: #ffffff;
    --ink: #1f2933;
    --muted: #617181;
    --line: #dce4ea;
    --teal: #167a7f;
    --teal-dark: #0e5559;
    --coral: #d85c43;
    --gold: #b98215;
    --green: #2f8f62;
    --shadow: 0 18px 45px rgba(31, 41, 51, 0.12);
}

* {
    box-sizing: border-box;
}

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

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

.icon {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
}

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

.auth-page .page {
    width: min(480px, calc(100% - 32px));
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px 0;
}

.member-dashboard .page {
    min-height: 100vh;
    display: grid;
    align-content: center;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 68px;
    padding: 0 max(24px, calc((100vw - 1120px) / 2));
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.brand,
.nav,
.nav a,
.ghost-button,
.last-refresh {
    display: inline-flex;
    align-items: center;
}

.brand {
    gap: 10px;
    font-weight: 800;
}

.brand-mark {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 8px;
    background: var(--teal);
    color: #fff;
    font-weight: 900;
}

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

.nav {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav a,
.ghost-button {
    gap: 8px;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font-weight: 700;
    transition: transform 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.nav a:hover,
.ghost-button:hover {
    border-color: var(--teal);
    color: var(--teal-dark);
    transform: translateY(-1px);
}

.auth-shell,
.login-panel {
    width: 100%;
}

.login-panel {
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.login-head {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 26px;
}

.login-head h1,
.hero-line h1,
.page-title h1 {
    margin: 0;
    line-height: 1.1;
}

.login-head p,
.eyebrow,
.page-title p,
.project-item p {
    margin: 0;
    color: var(--muted);
}

.login-panel label {
    display: block;
    margin: 16px 0 7px;
    font-weight: 800;
}

.input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
}

.input-wrap:focus-within {
    border-color: var(--teal);
    box-shadow: 0 0 0 4px rgba(22, 122, 127, 0.12);
}

.input-wrap input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
}

.primary-button {
    width: 100%;
    min-height: 48px;
    margin-top: 24px;
    border: 0;
    border-radius: 8px;
    background: var(--teal);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 900;
}

.primary-button:hover {
    background: var(--teal-dark);
}

.alert {
    padding: 12px 14px;
    border: 1px solid rgba(216, 92, 67, 0.28);
    border-radius: 8px;
    background: rgba(216, 92, 67, 0.09);
    color: #8d2f20;
    font-weight: 700;
}

.success-alert {
    border-color: rgba(22, 122, 127, 0.28);
    background: rgba(22, 122, 127, 0.08);
    color: var(--teal-dark);
}

.hero-line,
.page-title,
.admin-title {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 28px;
}

.eyebrow {
    margin-bottom: 7px;
    color: var(--teal-dark);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.hero-line h1,
.page-title h1 {
    font-size: clamp(2rem, 4vw, 3.35rem);
}

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

.choice-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    min-height: 260px;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    font-size: clamp(2rem, 5vw, 3.4rem);
    font-weight: 900;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.choice-card .icon {
    width: 58px;
    height: 58px;
}

.choice-card.letter {
    color: var(--teal-dark);
}

.choice-card.objective {
    color: #8d3d2f;
}

.choice-card.locked {
    cursor: default;
    opacity: 0.45;
    box-shadow: none;
}

.choice-card:hover {
    border-color: currentColor;
    transform: translateY(-4px);
    box-shadow: 0 24px 58px rgba(31, 41, 51, 0.16);
}

.choice-card.locked:hover {
    border-color: var(--line);
    color: #8d3d2f;
    transform: none;
    box-shadow: none;
}

.business-section {
    margin-top: 24px;
}

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

.business-title-card {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 96px;
    margin-bottom: 16px;
    padding: 20px;
    border: 1px solid rgba(22, 122, 127, 0.28);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 12px 28px rgba(31, 41, 51, 0.08);
}

.business-title-card h2 {
    margin: 0;
    font-size: clamp(1.1rem, 2vw, 1.45rem);
    line-height: 1.25;
}

.business-card {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 118px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 12px 28px rgba(31, 41, 51, 0.08);
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.business-card:hover {
    border-color: rgba(22, 122, 127, 0.45);
    transform: translateY(-2px);
    box-shadow: 0 18px 38px rgba(31, 41, 51, 0.12);
}

.business-icon {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    flex: 0 0 48px;
    border-radius: 8px;
    background: rgba(22, 122, 127, 0.1);
    color: var(--teal-dark);
}

.business-icon .icon {
    width: 26px;
    height: 26px;
}

.business-card h2 {
    margin: 0 0 8px;
    font-size: 1.02rem;
    line-height: 1.2;
}

.business-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.business-card.pending {
    background: #f8fafb;
    color: var(--muted);
}

.letter-document {
    padding: clamp(24px, 5vw, 54px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    font-size: 1.05rem;
}

.page-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

.letter-actions {
    justify-content: center;
}

.letter-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 36px;
}

.letter-meta div {
    display: grid;
    gap: 6px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.letter-meta span,
.letter-object span {
    color: var(--muted);
}

.letter-date {
    margin-bottom: 28px;
    text-align: right;
}

.letter-object {
    display: flex;
    gap: 8px;
    margin-bottom: 28px;
}

.signature {
    display: flex;
    justify-content: flex-end;
    margin-top: 52px;
}

.signature span {
    min-width: 180px;
    padding-top: 12px;
    border-top: 1px solid var(--ink);
    text-align: center;
}

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

.project-item {
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.project-item > div {
    display: flex;
    align-items: center;
    gap: 10px;
}

.project-item h2 {
    margin: 0;
    font-size: 1.35rem;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: var(--green);
}

.status-dot.alt {
    background: var(--gold);
}

.status-dot.home {
    background: var(--teal);
}

.status-dot.company {
    background: var(--coral);
}

.project-item dl {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 8px 12px;
    margin: 18px 0 0;
}

.project-item dt {
    color: var(--muted);
    font-weight: 800;
}

.project-item dd {
    margin: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    display: grid;
    gap: 10px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.stat-card span,
.table-head span,
.last-refresh {
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 700;
}

.stat-card strong {
    font-size: 2rem;
    line-height: 1;
}

.table-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    overflow: hidden;
}

.table-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.table-head h2 {
    margin: 0;
    font-size: 1.25rem;
}

.table-actions,
.danger-button {
    display: flex;
    align-items: center;
}

.table-actions {
    gap: 14px;
}

.table-actions form {
    margin: 0;
}

.danger-button {
    gap: 8px;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid rgba(216, 92, 67, 0.4);
    border-radius: 8px;
    background: #fff;
    color: #b6422d;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.danger-button:hover {
    border-color: #b6422d;
    background: rgba(216, 92, 67, 0.08);
}

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

table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
}

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

th {
    background: #f8fafb;
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.event-pill {
    display: inline-flex;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(22, 122, 127, 0.1);
    color: var(--teal-dark);
    font-weight: 800;
}

.empty-row {
    color: var(--muted);
    text-align: center;
}

@media (max-width: 760px) {
    .topbar,
    .hero-line,
    .page-title,
    .admin-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar {
        position: static;
        padding: 16px;
    }

    .table-head,
    .table-actions {
        align-items: flex-start;
        flex-direction: column;
    }

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

    .choice-grid,
    .business-grid,
    .project-list,
    .stats-grid,
    .letter-meta {
        grid-template-columns: 1fr;
    }

    .choice-card {
        min-height: 190px;
        flex-direction: column;
        text-align: center;
    }

    .letter-date {
        text-align: left;
    }
}
