:root {
    --primary: #294289;
    --primary-dark: #1e3166;
    --dark: #1f2933;
    --gray: #64748b;
    --light-gray: #f1f5f9;
    --border: #e2e8f0;
    --green: #16a34a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--dark);
    background: #fafafa;
}

.topbar {
    background: var(--primary);
    color: white;
}
.topbar-inner {
    max-width: 1000px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}
.brand {
    color: white;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.brand-logo {
    height: 40px;
    width: 40px;
    object-fit: contain;
}
.topbar nav a {
    color: white;
    text-decoration: none;
    margin-left: 20px;
    font-weight: 500;
    opacity: 0.9;
}
.nav-user {
    color: white;
    opacity: 0.9;
    font-weight: 500;
    margin-left: 20px;
    font-size: 0.9rem;
}
.nav-user .muted { color: rgba(255,255,255,0.7); }
.nav-logout-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.4);
    color: white;
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-left: 10px;
}
.nav-logout-btn:hover { background: rgba(255,255,255,0.15); }

.login-wrap {
    display: flex;
    justify-content: center;
    padding: 60px 20px;
}
.login-box {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 36px;
    max-width: 360px;
    width: 100%;
    text-align: center;
}
.login-logo { height: 90px; width: 90px; object-fit: contain; margin-bottom: 12px; }
.login-box h1 { font-size: 1.3rem; margin-top: 0; margin-bottom: 24px; }
.login-box .form { text-align: left; }

.topbar nav a:hover { opacity: 1; text-decoration: underline; }

.nav-utilities {
    display: inline-block;
    position: relative;
    margin-left: 20px;
    vertical-align: middle;
}
.nav-utilities summary {
    display: inline-block;
    color: white;
    font-weight: 500;
    opacity: 0.9;
    cursor: pointer;
    list-style: none;
}
.nav-utilities summary:hover { opacity: 1; text-decoration: underline; }
.nav-utilities summary::-webkit-details-marker { display: none; }
.nav-utilities summary::after { content: " \25BE"; }
.nav-utilities[open] summary::after { content: " \25B4"; }
.nav-utilities-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.18);
    padding: 6px;
    min-width: 160px;
    z-index: 20;
}
.topbar .nav-utilities-menu a {
    display: block;
    padding: 8px 10px;
    color: var(--dark);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.92rem;
    border-radius: 6px;
    white-space: nowrap;
}
.topbar .nav-utilities-menu a:hover { background: var(--light-gray); }

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

h1 { margin-top: 0; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
    text-align: center;
}
.stat-number { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--gray); font-size: 0.9rem; margin-top: 4px; }

.action-row { display: flex; gap: 10px; margin-bottom: 30px; flex-wrap: wrap; }

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 700px) {
    .two-col { grid-template-columns: 1fr; }
}

.panel {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}
.panel h2 { margin-top: 0; font-size: 1.1rem; }

.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
    border: none;
    cursor: pointer;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--light-gray); color: var(--dark); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e6ebf1; }
.btn-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.btn-danger:hover { background: #fecaca; }
.btn-link { background: none; color: var(--gray); text-decoration: underline; padding: 9px 6px; }

.filter-bar {
    display: flex;
    gap: 12px;
    align-items: end;
    flex-wrap: wrap;
    background: white;
    border: 1px solid var(--border);
    padding: 14px;
    border-radius: 8px;
    margin-bottom: 20px;
}
.filter-bar input[type="text"] { min-width: 220px; }
.filter-bar label { display: flex; flex-direction: column; font-size: 0.8rem; color: var(--gray); gap: 4px; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.data-table th, .data-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.data-table th { background: var(--light-gray); font-size: 0.85rem; text-transform: uppercase; color: var(--gray); }
.data-table th a.sort-link { color: var(--gray); text-decoration: none; }
.data-table th a.sort-link:hover { color: var(--primary); text-decoration: underline; }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: #f2f4fa; }

.simple-list { list-style: none; padding: 0; margin: 0; }
.simple-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.simple-list li:last-child { border-bottom: none; }
.simple-list a { color: var(--dark); text-decoration: none; }
.simple-list a:hover { color: var(--primary); }

.muted { color: var(--gray); }

.form { max-width: 600px; }
.form label {
    display: block;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 0.9rem;
}
.form input, .form select, .form textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    font-weight: normal;
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}
.form-actions { margin-top: 20px; display: flex; gap: 10px; align-items: center; }

fieldset.attendee-box {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 16px;
}
fieldset.attendee-box legend { font-weight: 600; padding: 0 6px; }
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px 16px;
    /* No max-height/scroll here on purpose - the box should grow to
       fit every responder on the roster rather than hiding some
       behind a scrollbar. */
}
/* ".form label" (a class+type selector) is more specific than a bare
   ".checkbox-item" class selector, so without this extra ".form"
   prefix here, the general label rule above (display:block etc.)
   would win the cascade and break the inline checkbox layout below. */
.form .checkbox-item {
    font-weight: normal;
    margin-bottom: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}
.checkbox-item input[type="checkbox"] {
    width: auto;
    margin: 0;
    flex: 0 0 auto;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

.badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
}
.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #f1f5f9; color: var(--gray); }

.flash {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-weight: 500;
}
.flash-success { background: #dcfce7; color: #166534; }
.flash-info { background: #dbeafe; color: #1e40af; }

.footer {
    text-align: center;
    color: var(--gray);
    font-size: 0.85rem;
    padding: 20px;
}
