* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f5f7fa;
    color: #1f2933;
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

.container {
    width: min(1500px, calc(100% - 48px));
    margin: 0 auto;
}

main.container {
    padding-bottom: 40px;
}

section {
    margin-bottom: 40px;
}

section h2 {
    font-size: 20px;
    margin-bottom: 16px;
}

.site-header {
    margin-bottom: 32px;
    padding: 22px 0;
    background: #ffffff;
    border-bottom: 1px solid #d9e2ec;
}

.site-header h1 {
    margin: 0;
    font-size: 26px;
}

.byline {
    margin: 2px 0 0;
    color: #6b7280;
    font-size: 13px;
}

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

.site-title {
    color: inherit;
    text-decoration: none;
}

.header-user {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    color: #52606d;
    font-size: 14px;
}

.header-user form {
    margin: 0;
}

.header-admin-link {
    color: #1f5f99;
    font-weight: 600;
    text-decoration: none;
}

.header-admin-link:hover {
    text-decoration: underline;
}

.logout-button {
    padding: 7px 11px;
    border: 1px solid #bcccdc;
    border-radius: 6px;
    background: #ffffff;
    color: #334e68;
    font: inherit;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
}

.logout-button:hover {
    background: #f0f4f8;
}

.cancel-link {
    padding: 9px 14px;
}

.flash-messages {
    margin-bottom: 20px;
}

.flash-message {
    padding: 13px 16px;
    border-radius: 6px;
}

.flash-success {
    background: #d9f2e6;
    color: #166534;
}

.flash-error {
    background: #fee2e2;
    color: #991b1b;
}

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

.page-heading h2 {
    margin: 0;
}

.page-subtitle {
    margin: 6px 0 0;
    color: #52606d;
}

.threshold-form {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #334e68;
    font-size: 14px;
}

.threshold-form {
    flex-wrap: wrap;
}

.threshold-form .form-input {
    width: 90px;
}

.threshold-form .school-select {
    width: 220px;
}

.school-field-wide {
    grid-column: 1 / -1;
}

.school-list {
    margin-top: 32px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 18px;
}

.metric-card {
    background: white;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.metric-value {
    font-size: 36px;
    font-weight: bold;
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
}

.metric-label {
    font-size: 14px;
    color: #6b7280;
}

.metric-subtext {
    margin-top: 8px;
    font-size: 0.85rem;
    color: #6b7280;
}

.section-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.section-header h2 {
    margin: 0;
}

.period-toggle {
    display: flex;
    gap: 4px;
    background: #e5e7eb;
    padding: 4px;
    border-radius: 8px;
}

.period-toggle a {
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: #52606d;
    font-size: 14px;
}

.period-toggle a.active {
    background: white;
    color: #1f2937;
    font-weight: bold;
}

.recipient-table-wrapper {
    width: 100%;
    overflow-x: auto;
    background: #ffffff;
    border: 1px solid #d9e2ec;
    border-radius: 8px;
}

.recipient-table {
    width: 100%;
    border-collapse: collapse;
}

.recipient-table th,
.recipient-table td {
    padding: 11px 14px;
    border-bottom: 1px solid #e4e7eb;
    text-align: left;
    white-space: nowrap;
}

.recipient-table th {
    background: #f8fafc;
    color: #334e68;
    font-size: 13px;
    font-weight: 600;
}

.recipient-table td {
    font-size: 14px;
}

.recipient-table tbody tr:last-child td {
    border-bottom: none;
}

.muted {
    color: #6b7280;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 16px;
    color: #52606d;
    font-size: 14px;
}

.empty-state {
    color: #52606d;
}

.organization-form {
    display: grid;
    gap: 20px;
}

.narrow-form {
    max-width: 480px;
}

.form-card {
    padding: 24px;
    background: #ffffff;
    border: 1px solid #d9e2ec;
    border-radius: 8px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

@media (max-width: 700px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-field label {
    color: #334e68;
    font-size: 14px;
    font-weight: 600;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #bcccdc;
    border-radius: 6px;
    background: #ffffff;
    color: #1f2933;
    font: inherit;
}

.form-input:focus {
    border-color: #1f5f99;
    outline: 2px solid rgba(31, 95, 153, 0.15);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.button {
    display: inline-block;
    padding: 10px 16px;
    border: 0;
    border-radius: 6px;
    background: #1f5f99;
    color: #ffffff;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.button:hover {
    background: #174a78;
}
