:root {
    color-scheme: light;
    --bg: #f5f7f9;
    --panel: #ffffff;
    --ink: #172026;
    --muted: #65717c;
    --line: #d9e0e6;
    --accent: #166b8f;
    --accent-strong: #0f526e;
    --danger: #b42318;
    --danger-strong: #912018;
    --success: #067647;
    --shadow: 0 12px 32px rgba(23, 32, 38, 0.08);
}

* {
    box-sizing: border-box;
}

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

.moderation-panel {
    margin: 16px 0;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.account-status { margin-top: 24px; }
.moderation-dialog {
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--ink);
    overflow: auto;
    overscroll-behavior: contain;
}
.moderation-dialog::backdrop { background: rgba(23, 32, 38, .6); }
body:has(.moderation-dialog[open]) { overflow: hidden; }
.moderation-dialog fieldset { border: 0; padding: 0; display: grid; gap: 16px; min-width: 0; }
.report-details { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; margin: 24px 0; }
.report-details dt { color: var(--muted); }
.report-details dd { margin: 0; overflow-wrap: anywhere; }
.message-evidence { white-space: pre-wrap; max-height: 240px; overflow: auto; }
.reference { overflow-wrap: anywhere; }
.action-heading { margin-top: 24px; }
.moderation-dialog .row-actions { flex-wrap: wrap; margin-top: 12px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid var(--accent); outline-offset: 3px;
}
@media (max-width: 600px) {
    .moderation-dialog { padding: 16px; }
    .report-details { grid-template-columns: minmax(0, 1fr); gap: 6px; }
    .report-details dd { margin-bottom: 10px; }
    .moderation-dialog .row-actions > button { width: 100%; }
}

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;
    font-size: 14px;
}

body.modal-open {
    overflow: hidden;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    min-height: 36px;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0 14px;
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

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

.login-panel {
    width: min(520px, 100%);
    margin: 15vh auto 0;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.login-copy {
    margin-bottom: 24px;
}

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

h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.15;
    letter-spacing: 0;
}

h2,
h3 {
    margin: 0;
}

h2 {
    font-size: 24px;
}

h3 {
    font-size: 16px;
}

.muted,
.status,
.subtle {
    color: var(--muted);
}

.muted {
    margin: 10px 0 0;
}

.login-actions {
    display: grid;
    gap: 14px;
    min-height: 76px;
}

.google-button {
    min-height: 44px;
}

.token-login {
    display: grid;
    gap: 10px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.token-login button {
    justify-self: start;
}

.admin-layout {
    display: grid;
    gap: 18px;
}

.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.topbar-actions,
.filter-actions,
.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid var(--line);
}

.tabs button {
    min-height: 38px;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 6px 6px 0 0;
    background: #fff;
    color: var(--muted);
}

.tabs button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.filters {
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) repeat(5, minmax(130px, 1fr)) auto;
    gap: 10px;
    align-items: end;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.event-filters {
    grid-template-columns: minmax(220px, 1.5fr) repeat(6, minmax(116px, 1fr)) auto;
}

.promotion-filters {
    grid-template-columns: minmax(220px, 1.5fr) repeat(6, minmax(116px, 1fr)) auto;
}

label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
}

input,
select {
    min-height: 36px;
    padding: 0 10px;
}

textarea {
    min-height: 96px;
    padding: 10px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    line-height: 1.45;
}

input:focus,
textarea:focus,
select:focus,
button:focus-visible {
    outline: 3px solid rgba(22, 107, 143, 0.18);
    outline-offset: 1px;
}

.primary-button {
    background: var(--accent);
    color: #fff;
}

.primary-button:hover:not(:disabled) {
    background: var(--accent-strong);
}

.secondary-button {
    background: #fff;
    border-color: var(--line);
    color: var(--ink);
}

.secondary-button:hover:not(:disabled) {
    border-color: #9eabb6;
}

.danger-button {
    background: #fff;
    border-color: #f1aaa4;
    color: var(--danger);
}

.danger-button:hover:not(:disabled) {
    background: #fff4f2;
    border-color: var(--danger);
}

.compact-button {
    min-height: 30px;
    padding: 0 9px;
    font-size: 12px;
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    min-height: 20px;
}

.status {
    margin: 0;
}

.error {
    color: var(--danger);
}

.success {
    color: var(--success);
}

.toolbar-messages {
    display: grid;
    gap: 4px;
    text-align: right;
}

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

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

.events-table {
    min-width: 1180px;
}

.promotions-table {
    min-width: 1420px;
}

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

th {
    background: #edf2f5;
    color: #43515c;
    font-size: 12px;
    font-weight: 700;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.strong,
.subtle {
    display: block;
}

.strong {
    font-weight: 700;
}

.subtle {
    margin-top: 3px;
    font-size: 12px;
}

.clamp {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.comment-cell {
    min-width: 280px;
    max-width: 460px;
    white-space: pre-wrap;
}

.promotion-title-cell {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 260px;
}

.promotion-thumb {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg);
    object-fit: cover;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-active {
    background: #d1fadf;
    color: #05603a;
}

.badge-upcoming {
    background: #dff2fe;
    color: #075985;
}

.badge-expired {
    background: #eceff2;
    color: #56636d;
}

.badge-cancelled {
    background: #fee4e2;
    color: var(--danger-strong);
}

.row-actions {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.empty {
    height: 92px;
    color: var(--muted);
    text-align: center;
    vertical-align: middle;
}

.pagination {
    justify-content: flex-end;
}

.modal-backdrop {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(23, 32, 38, 0.58);
}

.promotion-modal {
    display: flex;
    flex-direction: column;
    width: min(980px, 100%);
    max-height: calc(100vh - 48px);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    box-shadow: 0 24px 64px rgba(23, 32, 38, 0.28);
}

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

.icon-button {
    width: 38px;
    min-width: 38px;
    padding: 0;
    border-color: var(--line);
    background: #fff;
    color: var(--muted);
    font-size: 25px;
    line-height: 1;
}

.promotion-form {
    overflow-y: auto;
    padding: 0 22px 22px;
}

.form-section {
    display: grid;
    gap: 14px;
    border-bottom: 1px solid var(--line);
    padding: 20px 0;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

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

.description-input {
    min-height: 126px;
    font-family: inherit;
    font-size: 14px;
}

.field-hint {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

.switch-group,
.interest-picker fieldset {
    min-width: 0;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px;
}

.switch-group legend,
.interest-picker legend {
    padding: 0 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.switch-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}

.checkbox-label {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 7px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 500;
}

.checkbox-label input {
    width: 16px;
    min-height: 16px;
    margin: 0;
}

.location-search-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 10px;
}

.geocode-results {
    display: grid;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.geocode-results button {
    height: auto;
    min-height: 40px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: #fff;
    padding: 9px 12px;
    text-align: left;
}

.geocode-results button:last-child {
    border-bottom: 0;
}

.geocode-results button:hover {
    background: #f2f7fa;
}

.promotion-map {
    width: 100%;
    height: 340px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #e9eef1;
}

.location-fields {
    grid-template-columns: 2fr 1fr 1fr;
}

.image-fields {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr);
    gap: 16px;
}

.image-preview {
    display: grid;
    place-items: center;
    min-height: 170px;
    overflow: hidden;
    border: 1px dashed #aeb9c1;
    border-radius: 8px;
    background: var(--bg);
    color: var(--muted);
    font-size: 12px;
}

.image-preview img {
    width: 100%;
    height: 100%;
    max-height: 230px;
    object-fit: contain;
}

.interest-picker {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.interest-picker fieldset {
    display: grid;
    align-content: start;
    gap: 8px;
}

.empty-inline {
    grid-column: 1 / -1;
    margin: 10px 0;
    color: var(--muted);
    text-align: center;
}

.form-error {
    margin-top: 16px;
    border: 1px solid #f7c7c3;
    border-radius: 6px;
    background: #fff4f2;
    padding: 10px 12px;
}

.modal-actions {
    position: sticky;
    bottom: -22px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
    border-top: 1px solid var(--line);
    background: var(--panel);
    padding: 16px 0 0;
}

@media (max-width: 920px) {
    .shell {
        width: min(100% - 20px, 1200px);
        padding: 16px 0;
    }

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

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

    .event-filters {
        grid-template-columns: 1fr 1fr;
    }

    .promotion-filters {
        grid-template-columns: 1fr 1fr;
    }

    .image-fields,
    .interest-picker {
        grid-template-columns: 1fr 1fr;
    }

    .location-fields {
        grid-template-columns: 1fr 1fr;
    }

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

    .filter-actions {
        grid-column: 1 / -1;
    }
}

@media (max-width: 560px) {
    .login-panel {
        margin-top: 8vh;
        padding: 20px;
    }

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

    .event-filters {
        grid-template-columns: 1fr;
    }

    .promotion-filters,
    .form-grid,
    .location-fields,
    .image-fields,
    .interest-picker {
        grid-template-columns: 1fr;
    }

    .span-2,
    .location-fields .span-2 {
        grid-column: auto;
    }

    .modal-backdrop {
        padding: 0;
    }

    .promotion-modal {
        width: 100%;
        max-height: 100vh;
        min-height: 100vh;
        border: 0;
        border-radius: 0;
    }

    .modal-header,
    .promotion-form {
        padding-right: 16px;
        padding-left: 16px;
    }

    .promotion-map {
        height: 280px;
    }

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

    .location-search-row button {
        width: 100%;
    }

    .topbar-actions,
    .filter-actions,
    .token-login,
    .pagination {
        width: 100%;
        justify-content: stretch;
    }

    .topbar-actions button,
    .filter-actions button,
    .token-login button,
    .pagination button {
        flex: 1;
    }

    .token-login button {
        justify-self: stretch;
    }
}

.event-create-form {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 20px;
}

.hosting-banner {
    margin: 0;
    border-radius: 6px;
    background: #dff2fe;
    color: #075985;
    padding: 12px;
    font-weight: 700;
}

.event-form-fields {
    min-width: 0;
    margin: 0;
    border: 0;
    padding: 0;
}

.event-form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}
