:root {
    --wine: #3D1419;
    --wine-hairline: #3D141918;
    --rose: #9A3F4A;
    --sage: #2F4731;
    --cream: #FAF3EA;
    --card-bg: #FFFFFF;
    --amber: #B8720E;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--cream);
    color: var(--wine);
}

.page {
    padding: 40px 56px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 28px;
}

.eyebrow {
    font-size: 12px;
    letter-spacing: 3px;
    color: var(--rose);
    text-transform: uppercase;
    font-weight: 600;
    margin: 0 0 6px;
}

.page-title {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-weight: 600;
    font-size: 38px;
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

a.nav-link {
    color: var(--wine);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

a.nav-link:hover {
    text-decoration: underline;
}

.btn {
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    border-radius: 20px;
    padding: 10px 20px;
}

.btn-primary {
    background: var(--wine);
    color: var(--cream);
}

.btn-secondary {
    background: transparent;
    color: var(--wine);
    border: 1px solid var(--wine-hairline);
}

.btn-danger {
    background: transparent;
    color: #B3261E;
    border: 1px solid #B3261E66;
}

.btn-danger:hover {
    background: #B3261E14;
}

.cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--wine-hairline);
    border-radius: 8px;
    padding: 16px 20px;
}

.card .number {
    font-size: 26px;
    font-weight: 700;
}

.card .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.65;
}

.card.card-alert {
    border-color: var(--amber);
    background: rgba(184, 114, 14, 0.08);
}

.card.card-alert .number {
    color: var(--amber);
}

.form-card {
    background: var(--card-bg);
    border: 1px solid var(--wine-hairline);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
}

.form-field label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.65;
    margin-bottom: 4px;
}

.form-field input[type="text"],
.form-field input[type="date"],
.form-field select {
    width: 100%;
    padding: 7px 8px;
    border: 1px solid var(--wine-hairline);
    border-radius: 5px;
    font: inherit;
    font-size: 13px;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-bottom: 8px;
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border: 1px solid var(--wine-hairline);
    border-radius: 8px;
    overflow: hidden;
}

table.data-table th,
table.data-table td {
    text-align: left;
    padding: 10px 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--wine-hairline);
}

table.data-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.65;
}

table.data-table tbody tr.data-row {
    cursor: pointer;
}

table.data-table tbody tr.data-row:hover {
    background: rgba(61, 20, 25, 0.03);
}

table.data-table tbody tr.data-row.has-pending-change {
    box-shadow: inset 3px 0 0 var(--amber);
}

.badge-pending-change {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    padding: 2px 9px;
    border-radius: 12px;
    background: var(--amber);
    color: var(--cream);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    vertical-align: middle;
}

table.data-table select,
table.data-table input[type="date"] {
    font: inherit;
    font-size: 13px;
    padding: 4px 6px;
    border: 1px solid var(--wine-hairline);
    border-radius: 5px;
}

.status {
    font-weight: 600;
}

.status-coming {
    color: var(--sage);
}

.status-not_coming {
    color: var(--rose);
}

.status-no_answer {
    opacity: 0.6;
}

.status-pending {
    opacity: 0.7;
}

.status-approved {
    color: var(--sage);
}

.status-declined {
    color: var(--rose);
}

.status-muted {
    opacity: 0.5;
}

.change-request-proposal {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    font-size: 0.9em;
}

.change-request-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.expand-panel {
    background: rgba(61, 20, 25, 0.02);
}

.expand-panel td {
    padding: 0;
}

.guest-list {
    padding: 12px 14px 16px 34px;
}

.guest-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--wine-hairline);
}

.guest-row:last-child {
    border-bottom: none;
}

.guest-row-main {
    display: flex;
    justify-content: space-between;
}

.guest-row.has-pending-change {
    box-shadow: inset 3px 0 0 var(--amber);
    padding-left: 8px;
}

.invite-link-row {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.invite-link {
    font-size: 12px;
    opacity: 0.7;
    word-break: break-all;
}

.btn-copy {
    padding: 4px 12px;
    font-size: 12px;
    flex-shrink: 0;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.chip {
    font-size: 12px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 16px;
    border: 1px solid var(--wine);
    background: transparent;
    color: var(--wine);
    cursor: pointer;
}

.chip.active {
    background: var(--wine);
    color: var(--cream);
}

.chevron {
    display: inline-block;
    transition: transform 0.15s ease;
}

.chevron.expanded {
    transform: rotate(90deg);
}

.build-info {
    padding: 12px 56px 24px;
    font-size: 11px;
    letter-spacing: 0.3px;
    opacity: 0.4;
    text-align: right;
}

.logout-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding: 16px 56px 0;
}

.logout-user {
    font-size: 12px;
    opacity: 0.65;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    background: var(--card-bg);
    border: 1px solid var(--wine-hairline);
    border-radius: 10px;
    padding: 32px;
    width: 100%;
    max-width: 360px;
}

.login-card .page-title {
    margin-bottom: 20px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-form .form-field input {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--wine-hairline);
    border-radius: 5px;
    font: inherit;
    font-size: 14px;
}

.login-submit {
    margin-top: 6px;
}

.login-error {
    color: var(--rose);
    font-size: 13px;
    font-weight: 600;
    margin: -8px 0 16px;
}

.login-success {
    color: var(--sage);
    font-size: 13px;
    font-weight: 600;
    margin: -8px 0 16px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(61, 20, 25, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 100;
}

.modal {
    background: var(--card-bg);
    border-radius: 10px;
    width: 100%;
    max-width: 560px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--wine-hairline);
}

.modal-header h2 {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    color: var(--wine);
    padding: 0;
}

.modal-body {
    padding: 8px 20px 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Flex items default to min-height: auto, which lets them refuse to
       shrink below their content size — the parent's max-height then just
       clips the overflow via `overflow: hidden` instead of this element
       ever getting its own scrollbar. Force it to actually shrink. */
    min-height: 0;
}

.log-entry {
    padding: 10px 0;
    border-bottom: 1px solid var(--wine-hairline);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    font-size: 13px;
}

.log-type {
    font-weight: 600;
}

.log-time {
    font-size: 11px;
    opacity: 0.6;
    white-space: nowrap;
}

.log-detail {
    margin: 8px 0 0;
    padding: 8px 10px;
    background: rgba(61, 20, 25, 0.04);
    border-radius: 6px;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.log-detail-pretty {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 6px;
    font-size: 13px;
}

@media (max-width: 720px) {
    .page {
        padding: 24px 16px;
    }

    .logout-bar {
        padding: 16px 16px 0;
    }

    .build-info {
        padding: 12px 16px 24px;
        text-align: left;
    }

    .page-title {
        font-size: 28px;
    }

    .header-actions {
        width: 100%;
    }

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

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

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    table.data-table {
        min-width: 620px;
    }

    /* iOS Safari zooms the page in on focus for any input/select under
       16px, which shoves the rest of the form off-screen. Bump every
       form control up to 16px here so focusing a field doesn't zoom. */
    .form-field input[type="text"],
    .form-field input[type="date"],
    .form-field select,
    table.data-table select,
    table.data-table input[type="date"],
    .login-form input {
        font-size: 16px;
    }
}

@media (max-width: 420px) {
    .cards-row {
        grid-template-columns: 1fr;
    }
}
