:root {
    --bg: #f4f5f7;
    --card-bg: #ffffff;
    --text: #1f2430;
    --muted: #6b7280;
    --border: #e2e4e9;
    --primary: #3b5bdb;
    --primary-dark: #2f47ad;
    --danger: #d64545;
    --success: #2f9e44;
    --radius: 8px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }

.topnav { display: flex; align-items: center; gap: 16px; font-size: 0.9rem; }
.who { color: var(--muted); }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}

.container-wide { max-width: none; }

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

.card-narrow { max-width: 420px; margin-left: auto; margin-right: auto; }

dialog.modal {
    border: none;
    border-radius: var(--radius);
    padding: 0;
    width: 90vw;
    max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(15, 17, 23, 0.2);
}

dialog.modal::backdrop {
    background: rgba(15, 17, 23, 0.5);
}

dialog.modal .modal-body { padding: 20px 24px; }
dialog.modal h2 { margin-top: 0; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.card-head h1 { margin: 0; }

h1 { font-size: 1.4rem; margin-top: 0; }
h2 { font-size: 1.1rem; }

label {
    display: block;
    margin-bottom: 14px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
}

label.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.checkbox input { width: auto; }

.field { margin-bottom: 14px; }
.field-label {
    margin-bottom: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
}

input[type=text], input[type=email], input[type=password], input[type=number],
select, textarea {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: #fff;
}

textarea { resize: vertical; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.btn, button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.3;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover, button:hover { background: #eef0f5; text-decoration: none; }

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

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

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

button.danger:hover { background: #fdecec; }

.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.inline-form { display: inline-flex; gap: 6px; margin: 0; align-items: center; }
.inline-form input { display: inline-block; width: auto; margin-top: 0; }

.flash {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.flash-error { background: #fdecec; color: #a12a2a; border: 1px solid #f3c3c3; }
.flash-success { background: #eaf7ec; color: #1f7a34; border: 1px solid #c3e6cb; }

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th, .data-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    white-space: nowrap;
}

.data-table th { color: var(--muted); font-weight: 600; }

.data-table td.rich-cell {
    white-space: normal;
    min-width: 220px;
    max-width: 320px;
}

.rich-text { font-size: 0.9rem; }
.rich-text :first-child { margin-top: 0; }
.rich-text :last-child { margin-bottom: 0; }
.rich-text h1 { font-size: 1.15rem; margin: 6px 0; }
.rich-text h2 { font-size: 1.05rem; margin: 6px 0; }
.rich-text h3 { font-size: 1rem; margin: 6px 0; }
.rich-text p { margin: 4px 0; }
.rich-text ol, .rich-text ul { margin: 4px 0; padding-left: 1.2em; }

.rich-excerpt { font-size: 0.88rem; color: var(--muted); }
.show-more-btn { margin-top: 4px; }

.rich-text-empty { color: var(--muted); }

.badge {
    display: inline-block;
    background: #eef0f5;
    color: var(--muted);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.78rem;
    font-weight: 600;
}

.event-picker { list-style: none; padding: 0; }
.event-picker li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.filter-form { margin-bottom: 16px; max-width: 260px; }

.quill-editor {
    background: #fff;
    border-radius: 0 0 6px 6px;
    min-height: 140px;
}

.mt { margin-top: 20px; }

.event-desc { color: var(--muted); }

@media (max-width: 600px) {
    .topbar-inner { flex-direction: column; align-items: flex-start; }
    .card { padding: 16px; }
}
