:root {
    color-scheme: light;
    --bg: #f3f5f8;
    --bg-accent: #e9eef6;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --border: #d6dde6;
    --text: #1f2937;
    --muted: #667085;
    --primary: #1f4b99;
    --primary-hover: #173b78;
    --danger: #b42318;
    --danger-hover: #912018;
    --success-bg: #ecfdf3;
    --success-border: #abefc6;
    --success-text: #067647;
    --error-bg: #fef3f2;
    --error-border: #fecdca;
    --error-text: #b42318;
    --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top, rgba(31, 75, 153, 0.08), transparent 35%),
        linear-gradient(180deg, var(--bg), #eef2f7 70%, #eaedf2);
}

body.page-auth {
    display: grid;
    place-items: center;
    padding: 1rem;
}

a {
    color: var(--primary);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.15em;
}

a:hover {
    color: var(--primary-hover);
}

a:focus-visible,
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid rgba(31, 75, 153, 0.35);
    outline-offset: 2px;
}

img,
video {
    display: block;
    max-width: 100%;
}

.page-shell,
.auth-shell {
    width: min(1080px, calc(100% - 2rem));
    display: grid;
    gap: 1rem;
}

.page-shell {
    margin: 2rem auto 3rem;
}

.auth-shell {
    width: min(520px, calc(100% - 2rem));
    margin: 0 auto;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header h1,
.page-header h2,
.page-header h3,
.card h1,
.card h2,
.card h3 {
    margin: 0;
    line-height: 1.2;
}

.page-header p,
.card > p,
.helper,
.muted {
    color: var(--muted);
}

.stack {
    display: grid;
    gap: 1rem;
}

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

.field {
    display: grid;
    gap: 0.45rem;
}

label {
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

input[type="file"] {
    padding: 0.65rem 0.9rem;
    background: var(--surface-alt);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
}

button,
.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 12px;
    min-height: 2.75rem;
    padding: 0.8rem 1rem;
    font: inherit;
    line-height: 1.1;
    font-weight: 600;
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
}

button:hover,
.btn:hover {
    background: var(--primary-hover);
    color: #fff;
}

.btn-secondary {
    background: #fff;
    border-color: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--surface-alt);
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.preview-trigger {
    white-space: nowrap;
    width: auto;
}

.page-nav,
.actions,
.inline-actions,
.auth-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.page-nav a {
    font-weight: 600;
}

.page-nav .btn,
.page-nav .btn-secondary,
.page-nav .btn-danger,
.auth-actions .btn,
.auth-actions .btn-secondary,
.auth-actions .btn-danger {
    padding-inline: 0.95rem;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.alert,
.notice {
    border-radius: 14px;
    padding: 0.9rem 1rem;
    border: 1px solid transparent;
}

.alert--success,
.notice--success {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success-text);
}

.alert--error,
.notice--error {
    background: var(--error-bg);
    border-color: var(--error-border);
    color: var(--error-text);
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
}

.event-preview {
    position: fixed;
    z-index: 60;
    display: none;
    align-items: center;
    justify-content: center;
    width: min(800px, calc(100vw - 1rem));
    max-width: calc(100vw - 1rem);
    max-height: calc(100vh - 1rem);
    padding: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 14px;
    background: #0f172a;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.32);
    pointer-events: none;
    overflow: hidden;
}

.event-preview img,
.event-preview video {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 10px;
    background: #000;
}

table {
    width: 100%;
    min-width: 820px;
    border-collapse: separate;
    border-spacing: 0;
}

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

th {
    background: var(--surface-alt);
    color: #344054;
    font-size: 0.92rem;
}

tbody tr:hover {
    background: #fafbfc;
}

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

code,
.code-block {
    display: inline-block;
    max-width: 100%;
    padding: 0.15rem 0.45rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f8fafc;
    color: #0f172a;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
    word-break: break-word;
}

.code-block {
    display: block;
    padding: 0.75rem 0.9rem;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 0.25rem 0;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

@media (max-width: 720px) {
    .page-shell,
    .auth-shell {
        width: calc(100% - 1rem);
    }

    .page-shell {
        margin: 1rem auto 2rem;
    }

    .card {
        padding: 1rem;
        border-radius: 16px;
    }

    table {
        min-width: 760px;
    }
}
