:root {
    --remax-red: #e11b22;
    --remax-blue: #0054a6;
    --deep-blue: #073763;
    --ink: #172033;
    --muted: #5d6678;
    --line: #d8dde8;
    --soft: #f3f6fb;
    --white: #ffffff;
    --focus: #ffcc33;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        linear-gradient(180deg, rgba(0, 84, 166, 0.08), rgba(255, 255, 255, 0) 320px),
        var(--soft);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

.page-shell {
    width: min(100%, 920px);
    margin: 0 auto;
    padding: 24px 16px 48px;
}

.intro {
    border-top: 8px solid var(--remax-red);
    background: var(--white);
    padding: 24px;
    box-shadow: 0 16px 36px rgba(7, 55, 99, 0.09);
}

.brand-mark {
    margin: 0 0 8px;
    color: var(--remax-blue);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    color: var(--deep-blue);
    font-size: 2rem;
    line-height: 1.15;
}

.intro-copy {
    max-width: 680px;
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 1.05rem;
}

.application-form {
    margin-top: 18px;
}

fieldset {
    min-width: 0;
    margin: 0;
    border: 0;
    padding: 0;
}

.question-block,
.contact-grid,
.submit-panel,
.notice-panel {
    background: var(--white);
    border: 1px solid var(--line);
    padding: 20px;
    box-shadow: 0 12px 28px rgba(7, 55, 99, 0.06);
}

.question-block,
.contact-grid {
    display: block;
}

.question-block::after,
.contact-grid::after {
    content: "";
    display: table;
    clear: both;
}

.question-block + .question-block,
.qualified-fields > * + *,
.contact-grid + .question-block {
    margin-top: 16px;
}

legend {
    display: block;
    float: left;
    width: 100%;
    margin: 0 0 16px;
    padding: 0;
    color: var(--deep-blue);
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.35;
}

.question-block > legend + *,
.contact-grid > legend + * {
    clear: both;
}

.radio-grid,
.radio-stack {
    display: grid;
    gap: 10px;
}

.radio-grid {
    grid-template-columns: 1fr;
}

.radio-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-height: 52px;
    border: 1px solid var(--line);
    background: #fbfcff;
    padding: 14px;
    color: var(--ink);
    font-weight: 700;
    cursor: pointer;
}

.radio-card:hover {
    border-color: var(--remax-blue);
    background: #f5f9ff;
}

.radio-card input {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    margin-top: 1px;
    accent-color: var(--remax-blue);
}

.radio-card:has(input:checked) {
    border-color: var(--remax-blue);
    box-shadow: inset 4px 0 0 var(--remax-blue);
}

.qualified-fields {
    margin-top: 16px;
}

.contact-grid {
    display: grid;
    gap: 16px;
}

.contact-grid legend {
    grid-column: 1 / -1;
    margin-bottom: 4px;
}

.field-control {
    display: grid;
    gap: 7px;
}

.field-control label {
    color: var(--deep-blue);
    font-weight: 700;
}

.field-control input {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--white);
    padding: 13px 14px;
    color: var(--ink);
    font: inherit;
}

.field-control select,
.field-control textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--white);
    padding: 13px 14px;
    color: var(--ink);
    font: inherit;
}

.field-control textarea {
    min-height: 160px;
    resize: vertical;
}

.field-control input:focus,
.field-control select:focus,
.field-control textarea:focus,
.radio-card input:focus-visible,
button:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.notice-panel {
    margin-top: 16px;
    border-left: 6px solid var(--remax-red);
}

.notice-panel p {
    margin: 0;
}

.notice-panel p + p {
    margin-top: 12px;
}

.privacy-note {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 0.95rem;
}

button {
    width: 100%;
    border: 0;
    background: var(--remax-red);
    color: var(--white);
    padding: 15px 18px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

button:hover {
    background: #c81017;
}

.form-trap {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

[hidden] {
    display: none !important;
}

.admin-shell {
    max-width: 560px;
}

.dashboard-shell {
    width: min(100%, 1240px);
}

.admin-card {
    margin-top: 24px;
}

.admin-form {
    display: grid;
    gap: 16px;
    margin-top: 24px;
}

.admin-alert {
    margin-top: 18px;
    border-left: 6px solid var(--remax-red);
    background: #fff5f5;
    padding: 12px 14px;
    color: #8a1015;
    font-weight: 700;
}

.admin-link,
.intro a {
    color: var(--remax-blue);
    font-weight: 700;
}

.dashboard-header {
    display: grid;
    gap: 16px;
}

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

.button-link {
    display: inline-block;
    border: 0;
    background: var(--remax-red);
    color: var(--white);
    padding: 10px 14px;
    font-weight: 700;
    text-decoration: none;
}

.button-link:hover {
    background: #c81017;
}

.button-link-secondary {
    background: var(--remax-blue);
}

.button-link-secondary:hover {
    background: #003f7d;
}

.button-link-small {
    padding: 7px 10px;
    font-size: 0.85rem;
}

.button-danger {
    background: #9f1239;
}

.button-danger:hover {
    background: #7f0f2e;
}

.button-success {
    background: #2e7d32;
}

.button-success:hover {
    background: #245f24;
}

.inline-form {
    display: inline;
}

.inline-form button {
    width: auto;
    min-width: 0;
    padding: 8px 10px;
    font-size: 0.85rem;
}

.success-alert {
    margin-top: 18px;
    border-left: 6px solid #2e7d32;
    background: #edf7ed;
    padding: 12px 14px;
    color: #245f24;
    font-weight: 700;
}

.logout-link {
    align-self: start;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    margin-top: 18px;
}

.detail-card {
    background: var(--white);
    border: 1px solid var(--line);
    box-shadow: 0 12px 28px rgba(7, 55, 99, 0.06);
    padding: 20px;
}

.detail-card h2 {
    margin: 0 0 16px;
    color: var(--deep-blue);
    font-size: 1.25rem;
}

.attribution-card {
    grid-column: 1 / -1;
}

.detail-list {
    display: grid;
    gap: 12px;
    margin: 0;
}

.detail-list div {
    display: grid;
    gap: 4px;
}

.detail-list dt {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.detail-list dd {
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--ink);
    font-weight: 700;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.summary-card,
.admin-panel {
    background: var(--white);
    border: 1px solid var(--line);
    box-shadow: 0 12px 28px rgba(7, 55, 99, 0.06);
}

.summary-card {
    padding: 18px;
}

.summary-card span {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.summary-card strong {
    display: block;
    margin-top: 6px;
    color: var(--deep-blue);
    font-size: 2rem;
    line-height: 1;
}

.admin-panel {
    margin-top: 18px;
    padding: 20px;
}

.admin-panel h2 {
    margin: 0 0 16px;
    color: var(--deep-blue);
    font-size: 1.25rem;
}

.search-form {
    display: grid;
    gap: 14px;
}

.status-cell .button-link {
    display: block;
    width: max-content;
    margin-top: 8px;
}

.notes-history {
    display: grid;
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.note-entry {
    border-left: 4px solid var(--remax-blue);
    background: #f7f9fd;
    padding: 14px;
}

.note-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 16px;
    color: var(--muted);
    font-size: 0.88rem;
}

.note-text {
    margin-top: 10px;
    overflow-wrap: anywhere;
}

.add-note-form {
    margin-top: 24px;
    border-top: 1px solid var(--line);
    padding-top: 20px;
}

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

.table-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.table-heading p {
    margin: 0 0 16px;
    color: var(--muted);
    font-weight: 700;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
}

.applications-table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
    background: var(--white);
}

.dashboard-applications-table {
    min-width: 980px;
}

.archived-table {
    min-width: 860px;
}

.answers-table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
    background: var(--white);
}

.users-table {
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
    background: var(--white);
}

.audit-table {
    width: 100%;
    min-width: 1180px;
    border-collapse: collapse;
    background: var(--white);
}

.report-table {
    width: 100%;
    min-width: 1120px;
    border-collapse: collapse;
    background: var(--white);
}

.applications-table th,
.applications-table td,
.answers-table th,
.answers-table td,
.users-table th,
.users-table td,
.audit-table th,
.audit-table td,
.report-table th,
.report-table td {
    border-bottom: 1px solid var(--line);
    padding: 12px;
    text-align: left;
    vertical-align: top;
    font-size: 0.92rem;
}

.applications-table td {
    overflow-wrap: anywhere;
}

.applications-table th,
.answers-table th,
.users-table th,
.audit-table th {
    background: #f7f9fd;
    color: var(--deep-blue);
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.report-table th {
    background: #f7f9fd;
    color: var(--deep-blue);
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.applications-table tbody tr:hover,
.answers-table tbody tr:hover,
.users-table tbody tr:hover,
.audit-table tbody tr:hover {
    background: #fbfcff;
}

.dashboard-applications-table tbody tr.dashboard-row--not-qualified {
    box-shadow: inset 4px 0 0 #c93a3a;
    background: #fffafa;
}

.dashboard-applications-table tbody tr.dashboard-row--not-qualified:hover {
    background: #fff6f6;
}

.report-table tbody tr:hover {
    background: #fbfcff;
}

.report-table td {
    overflow-wrap: anywhere;
}

.applicant-cell {
    font-weight: 700;
    color: var(--deep-blue);
}

.id-cell {
    width: 72px;
    white-space: nowrap;
    font-weight: 700;
    color: var(--deep-blue);
}

.ad-cell {
    max-width: 220px;
}

.dashboard-applications-table .ad-cell {
    max-width: 240px;
    white-space: normal;
    overflow-wrap: anywhere;
}

.action-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.badge {
    display: inline-block;
    border: 1px solid transparent;
    padding: 4px 8px;
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
}

.dashboard-grade-badge {
    min-width: 2.35rem;
    text-align: center;
    background: #f7f9fd;
    border-color: #8fa4c4;
    color: var(--deep-blue);
}

.dashboard-qualification-badge {
    white-space: nowrap;
}

.dashboard-qualification--qualified {
    background: #e7f8f3;
    border-color: #58ad99;
    color: #16624f;
}

.dashboard-qualification--not-qualified {
    background: #fff0f0;
    border-color: #d66a6a;
    color: #8d1f1f;
}

.dashboard-qualification--unclassified {
    background: #f7f2e8;
    border-color: #b89554;
    color: #624617;
}

.dashboard-submission-count {
    display: inline-block;
    min-width: 1.75rem;
    font-weight: 700;
    color: var(--deep-blue);
}

.grade-aplus {
    background: #e8f3ff;
    border-color: #0054a6;
    color: #003f7d;
}

.grade-a {
    background: #fff5f5;
    border-color: #e11b22;
    color: #9b1016;
}

.grade-b {
    background: #edf7ed;
    border-color: #7bbf7b;
    color: #245f24;
}

.grade-c {
    background: #fff8e6;
    border-color: #dfb64b;
    color: #6f4b00;
}

.grade-d {
    background: #f1f3f7;
    border-color: #c8cfdb;
    color: #4f596b;
}

.repeat-badge {
    margin-left: 6px;
    background: #f7f2e8;
    border-color: #b89554;
    color: #624617;
}

.status-new {
    background: #e8f3ff;
    border-color: #8bbce8;
    color: #064a87;
}

.status-no-response {
    background: #fff8e6;
    border-color: #dfb64b;
    color: #6f4b00;
}

.status-contacted {
    background: #f3ecff;
    border-color: #b99be8;
    color: #533280;
}

.status-confirmed {
    background: #edf7ed;
    border-color: #7bbf7b;
    color: #245f24;
}

.status-attended {
    background: #e7f8f3;
    border-color: #6dc3aa;
    color: #145d4c;
}

.status-no-show {
    background: #fff1e8;
    border-color: #e0a074;
    color: #7a3d11;
}

.status-unreachable {
    background: #f1f3f7;
    border-color: #b9c0ce;
    color: #394355;
}

.status-rejected {
    background: #fff5f5;
    border-color: #e6a3a7;
    color: #8a1015;
}

.status-archived {
    background: #f1f3f7;
    border-color: #c8cfdb;
    color: #4f596b;
}

.danger-link {
    border-color: #e6a3a7;
    background: #fff5f5;
    color: #8a1015;
}

.danger-button {
    background: #9b1016;
}

.warning-copy {
    border-left: 6px solid var(--remax-red);
    background: #fff5f5;
    padding: 12px 14px;
    color: #691015;
    font-weight: 700;
}

.delete-confirm-form {
    align-items: start;
}

.status-guide-intro,
.field-help {
    margin: -4px 0 16px;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.45;
}

.field-help {
    margin: 8px 0 0;
    font-size: 0.86rem;
}

.status-guide-grid {
    display: grid;
    gap: 14px;
}

.status-guide-group {
    border: 1px solid var(--line);
    background: #fbfcff;
    padding: 14px;
}

.status-guide-group h3 {
    margin: 0 0 12px;
    color: var(--deep-blue);
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.status-guide-list {
    display: grid;
    gap: 12px;
    margin: 0;
}

.status-guide-item {
    display: grid;
    gap: 6px;
}

.status-guide-item dt,
.status-guide-item dd {
    margin: 0;
}

.status-guide-item dd {
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.4;
}

.status-guide-note {
    margin: 14px 0 0;
    border-left: 4px solid var(--line);
    background: #f7f9fd;
    padding: 10px 12px;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

.share-panel {
    margin-top: 24px;
    border-top: 1px solid var(--line);
    padding-top: 22px;
}

.share-panel h2 {
    margin: 0 0 8px;
    color: var(--deep-blue);
    font-size: 1.25rem;
    line-height: 1.25;
}

.share-panel p {
    margin: 0;
}

.share-panel__actions {
    margin-top: 16px;
}

.share-button {
    border: 0;
    background: var(--remax-red);
    color: var(--white);
    cursor: pointer;
}

.share-button:focus-visible {
    outline: 3px solid rgba(0, 84, 166, 0.35);
    outline-offset: 3px;
}

.share-status {
    min-height: 1.4em;
    margin-top: 12px;
    color: var(--deep-blue);
    font-weight: 700;
}

.manual-share-link {
    margin-top: 14px;
}

.manual-share-link[hidden] {
    display: none;
}

.manual-share-link label {
    display: block;
    margin-bottom: 6px;
    color: var(--deep-blue);
    font-weight: 700;
}

.manual-share-link input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 0;
    background: #ffffff;
    padding: 12px;
    color: var(--text);
    font: inherit;
}

.manual-share-link input:focus {
    border-color: var(--remax-blue);
    outline: 3px solid rgba(0, 84, 166, 0.18);
    outline-offset: 1px;
}

.role-super_admin {
    background: #fff5f5;
    border-color: var(--remax-red);
    color: #9b1016;
}

.role-admin {
    background: #e8f3ff;
    border-color: var(--remax-blue);
    color: #003f7d;
}

.active-badge {
    background: #edf7ed;
    border-color: #7bbf7b;
    color: #245f24;
}

.inactive-badge {
    background: #f1f3f7;
    border-color: #c8cfdb;
    color: #4f596b;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

.pagination a {
    border: 1px solid var(--line);
    background: var(--white);
    padding: 8px 12px;
    color: var(--remax-blue);
    font-weight: 700;
    text-decoration: none;
}

.pagination span,
.empty-state {
    color: var(--muted);
    font-weight: 700;
}

@media (max-width: 640px) {
    .question-block,
    .contact-grid {
        padding: 20px;
    }

    legend {
        margin-bottom: 16px;
        font-size: 1rem;
        line-height: 1.35;
    }
}

@media (min-width: 680px) {
    .page-shell {
        padding-top: 40px;
    }

    .intro,
    .question-block,
    .contact-grid,
    .submit-panel,
    .notice-panel {
        padding: 28px;
    }

    h1 {
        font-size: 2.6rem;
    }

    .radio-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .contact-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .contact-grid legend,
    .submit-panel {
        grid-column: 1 / -1;
    }

    button {
        width: auto;
        min-width: 240px;
    }

    .dashboard-header {
        grid-template-columns: 1fr auto;
        align-items: start;
    }

    .detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .admin-panel {
        padding: 28px;
    }

    .search-form {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        align-items: end;
    }

    .report-filter-form {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .status-guide-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        align-items: stretch;
    }

    .search-actions {
        grid-column: 1 / -1;
    }
}
