* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.navbar {
    background: #1a1a2e;
    color: #fff;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    color: #fff;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 700;
}

.nav-links a {
    color: #ccc;
    text-decoration: none;
    margin-left: 1.5rem;
}

.nav-links a:hover {
    color: #fff;
}

.container {
    max-width: 1200px;
    margin: 1.5rem auto;
    padding: 0 1rem;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.flash-success { background: #d4edda; color: #155724; }
.flash-error { background: #f8d7da; color: #721c24; }

.login-form {
    max-width: 400px;
    margin: 4rem auto;
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.login-form h1 {
    margin-bottom: 1.5rem;
    text-align: center;
}

.event-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.event-card {
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.event-card h2 a {
    color: #1a1a2e;
    text-decoration: none;
}

.event-card h2 a:hover {
    text-decoration: underline;
}

.event-meta {
    color: #666;
    font-size: 0.9rem;
}

.status-badges {
    margin: 0.75rem 0;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    margin: 0.15rem;
    font-weight: 500;
}

.badge-pending { background: #fff3cd; color: #856404; }
.badge-validated { background: #cce5ff; color: #004085; }
.badge-needs_review { background: #fff3cd; color: #856404; }
.badge-unparseable { background: #f8d7da; color: #721c24; }
.badge-approved { background: #d4edda; color: #155724; }
.badge-rejected { background: #f8d7da; color: #721c24; }
.badge-lg { font-size: 1rem; padding: 0.3rem 0.8rem; }
.badge-email-sent { background: #e2e3e5; color: #41464b; }
.badge-email-pending { background: #fff3cd; color: #856404; }

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    background: #fff;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn:hover { background: #f0f0f0; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-primary { background: #1a1a2e; color: #fff; border-color: #1a1a2e; }
.btn-primary:hover { background: #16213e; }
.btn-success { background: #28a745; color: #fff; border-color: #28a745; }
.btn-danger { background: #dc3545; color: #fff; border-color: #dc3545; }
.btn-active { background: #1a1a2e; color: #fff; border-color: #1a1a2e; }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.status-filters {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

table {
    width: 100%;
    background: #fff;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
}

tr:hover td { background: #f8f9fa; }

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin-bottom: 0.25rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.detail-section {
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.detail-section h2 {
    font-size: 1rem;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

.data-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.3rem 1rem;
}

.data-list dt {
    font-weight: 600;
    color: #666;
}

.raw-email {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
}

.action-bar {
    display: flex;
    gap: 1rem;
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.action-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.action-form input {
    padding: 0.4rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.manual-form {
    max-width: 600px;
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.person-fieldset {
    padding: 1rem;
    margin-bottom: 1rem;
    background: #f8f9fa;
    border-radius: 4px;
}

.person-fieldset h3 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: #666;
}

.card-actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
}

/* ── Registration Accordion ── */

.reg-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.reg-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    margin-bottom: -1px;
}

.reg-card:first-child {
    border-radius: 8px 8px 0 0;
}

.reg-card:last-child {
    border-radius: 0 0 8px 8px;
    margin-bottom: 0;
}

.reg-card:only-child {
    border-radius: 8px;
}

.reg-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.reg-header:hover {
    background: #f8f9fa;
}

.reg-col-id { font-weight: 600; min-width: 2.5rem; }
.reg-col-source { color: #888; font-size: 0.85rem; min-width: 4rem; }
.reg-col-names { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reg-col-count { min-width: 3rem; text-align: center; color: #666; }
.reg-col-status { min-width: 6rem; }
.reg-col-date { min-width: 8rem; font-size: 0.85rem; color: #888; }
.reg-col-chevron { min-width: 1.5rem; text-align: center; transition: transform 0.2s; font-size: 0.75rem; color: #999; }
.chevron.open { transform: rotate(180deg); }

.reg-detail {
    display: none;
    border-top: 1px solid #eee;
    background: #fafbfc;
}

.reg-detail-inner {
    padding: 1.25rem 1.5rem;
}

.reg-detail-section {
    margin-bottom: 1.25rem;
}

.reg-detail-section:last-child {
    margin-bottom: 0;
}

.reg-detail-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #eee;
}

.person-table {
    width: 100%;
    background: #fff;
    border-collapse: collapse;
    border-radius: 4px;
    overflow: hidden;
    font-size: 0.9rem;
}

.person-table th,
.person-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.person-table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.reg-actions {
    display: flex;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
    flex-wrap: wrap;
}

.reg-actions .action-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.reg-actions .action-form input[type="text"] {
    padding: 0.4rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    width: 150px;
}

.inline-form {
    display: inline;
}

.email-sent-note {
    font-size: 0.85rem;
    color: #888;
}

.reg-empty {
    background: #fff;
    padding: 2rem;
    text-align: center;
    color: #888;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

@media (max-width: 768px) {
    .reg-header { flex-wrap: wrap; gap: 0.5rem; }
    .reg-col-date { display: none; }
    .reg-col-source { display: none; }
    .reg-actions { flex-direction: column; }
    .reg-actions .action-form { flex-wrap: wrap; }
}

@media (max-width: 768px) {
    .detail-grid { grid-template-columns: 1fr; }
    .event-grid { grid-template-columns: 1fr; }
    .toolbar { flex-direction: column; align-items: flex-start; }
    .repeatable-row { flex-direction: column; }
}

/* ── Event Form ── */

.event-form {
    max-width: 800px;
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.form-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section h2 {
    font-size: 1.1rem;
    color: #1a1a2e;
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    resize: vertical;
}

.hint {
    display: block;
    color: #888;
    font-size: 0.85rem;
    margin-top: 0.25rem;
    margin-bottom: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal !important;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.repeatable-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
}

.repeatable-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.btn-remove {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 0.5rem;
    line-height: 1;
    flex-shrink: 0;
}

.btn-remove:hover {
    color: #a71d2a;
}

.event-form .btn-primary {
    margin-top: 1rem;
}

/* ── Advanced Settings (collapsible) ── */

.event-form details {
    margin-top: 0.5rem;
}

.event-form details summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 1.1rem;
    color: #555;
    padding: 0.25rem 0;
    user-select: none;
}

.event-form details summary:hover {
    color: #1a1a2e;
}

.event-form details h3 {
    font-size: 0.95rem;
    color: #666;
    margin-top: 1rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #eee;
}

.event-form details .form-group {
    margin-left: 0.5rem;
}

/* ── Hint text ── */

/* ── Action bar checkbox ── */

.action-form .checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    margin-right: 0.5rem;
}

/* ── Receipt image gallery ── */

.receipt-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.receipt-thumb {
    display: block;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    transition: box-shadow 0.15s;
}

.receipt-thumb:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.receipt-thumb img {
    display: block;
    max-width: 200px;
    max-height: 200px;
    object-fit: contain;
    background: #fafafa;
}

/* ── Person editing ── */

.person-name-input {
    border: 1px solid transparent;
    background: transparent;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: inherit;
    width: 140px;
    transition: border-color 0.15s;
}

.person-name-input:hover,
.person-name-input:focus {
    border-color: #ccc;
    background: #fff;
    outline: none;
}

.add-person-form {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.add-person-form input[type="text"] {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 0.85rem;
}

.person-table td:last-child {
    text-align: center;
}

/* ── Check-In Page ── */

.checkin-login {
    max-width: 400px;
    margin: 4rem auto;
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
}

.checkin-login h1 {
    margin-bottom: 0.5rem;
}

.checkin-subtitle {
    color: #666;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.checkin-code-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1.1rem;
    text-align: center;
    letter-spacing: 2px;
}

.btn-block {
    display: block;
    width: 100%;
    margin-top: 1rem;
    text-align: center;
}

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

.checkin-header h1 {
    font-size: 1.25rem;
    margin-bottom: 0;
}

.checkin-stats {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.checkin-count {
    font-weight: 600;
    color: #1a1a2e;
    font-size: 0.9rem;
}

.checkin-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.checkin-search-form {
    display: flex;
    gap: 0.3rem;
    flex: 1;
    min-width: 180px;
}

.checkin-search-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.checkin-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.checkin-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    margin-bottom: -1px;
}

.checkin-card:first-child {
    border-radius: 8px 8px 0 0;
}

.checkin-card:last-child {
    border-radius: 0 0 8px 8px;
    margin-bottom: 0;
}

.checkin-card:only-child {
    border-radius: 8px;
}

.checkin-card-done {
    background: #f0faf0;
}

.checkin-card-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.checkin-card-name {
    font-weight: 600;
    font-size: 1rem;
}

.checkin-card-meta {
    font-size: 0.8rem;
    color: #888;
}

.checkin-card-time {
    font-size: 0.8rem;
    color: #28a745;
}

.checkin-card-action {
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.btn-checkin {
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
}

.checkin-empty {
    background: #fff;
    padding: 2rem;
    text-align: center;
    color: #888;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

@media (max-width: 768px) {
    .checkin-header { flex-direction: column; }
    .checkin-toolbar { flex-direction: column; }
    .checkin-search-form { width: 100%; }
    .checkin-card { flex-wrap: wrap; gap: 0.5rem; }
    .btn-checkin { width: 100%; text-align: center; }
    .checkin-card-action { width: 100%; margin-left: 0; }
}
