* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 25px;
    font-family: Arial, sans-serif;
    background: #f3f5f8;
    color: #222;
}

.container {
    width: 100%;
    max-width: 950px;
    margin: auto;
    padding: 30px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1);
}

.wide-container {
    max-width: 1300px;
}

.small-container {
    max-width: 560px;
}

.landing-container {
    max-width: 900px;
}

.landing-subtitle {
    margin-top: -5px;
    margin-bottom: 22px;
    color: #4d5560;
}

.landing-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.landing-action-card {
    display: block;
    padding: 22px;
    border: 1px solid #e2d7db;
    border-radius: 10px;
    background: linear-gradient(180deg, #fff 0%, #fdf9fa 100%);
    color: #222;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.landing-action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(139, 30, 63, 0.12);
}

.landing-action-card h2 {
    margin: 0 0 10px;
}

.landing-action-card p {
    margin: 0;
    color: #4d5560;
}

.stack-form {
    display: grid;
    gap: 14px;
}

.alert {
    margin-bottom: 14px;
    padding: 12px;
    border-radius: 6px;
}

.alert-success {
    color: #114d23;
    border: 1px solid #b5e2c0;
    background: #eaf8ee;
}

.alert-error {
    color: #7d1229;
    border: 1px solid #efb9c6;
    background: #fdeff3;
}

.credential-card {
    margin: 16px 0 14px;
    padding: 14px;
    border: 1px solid #e2d7db;
    border-radius: 8px;
    background: #fff8fa;
}

.credential-card p {
    margin: 8px 0;
}

.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.inline-actions .secondary-button {
    margin: 0;
}

h1 {
    margin-top: 0;
    color: #8b1e3f;
}

h2 {
    color: #8b1e3f;
    border-bottom: 2px solid #8b1e3f;
    padding-bottom: 7px;
    font-size: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.full-width {
    grid-column: 1 / -1;
}

label {
    font-weight: bold;
    margin-bottom: 7px;
}

input,
select,
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #c9c9c9;
    border-radius: 5px;
    font: inherit;
}

textarea {
    resize: vertical;
}

button,
.secondary-button {
    display: inline-block;
    margin-top: 24px;
    padding: 11px 20px;
    border: none;
    border-radius: 5px;
    background: #8b1e3f;
    color: white;
    text-decoration: none;
    font-size: 15px;
    cursor: pointer;
}

.secondary-button {
    margin-left: 8px;
    background: #555;
}

button:hover,
.secondary-button:hover {
    opacity: 0.9;
}

.admin-link {
    margin-top: 25px;
}

.photo-frame {
    width: 180px;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #f8f8f8;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-preview,
.profile-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.profile-photo {
    margin-bottom: 20px;
}

.photo-preview.visible {
    display: block;
}

.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 10px;
    border: 1px solid #ddd;
    text-align: left;
}

table th {
    background: #8b1e3f;
    color: white;
}

.small-photo {
    width: 55px;
    height: 73px;
    object-fit: cover;
}

.actions a {
    display: inline-block;
    margin: 3px;
    color: #8b1e3f;
    font-weight: bold;
}

/* Printable A4 profile */
.a4-profile {
    width: 210mm;
    min-height: 297mm;
    margin: 20px auto;
    padding: 15mm;
    background: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
}

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 3px solid #8b1e3f;
    padding-bottom: 12px;
    margin-bottom: 20px;
}

.profile-header h1 {
    margin: 0;
    font-size: 28px;
    letter-spacing: 1px;
}

.profile-header p {
    margin-bottom: 0;
    color: #555;
}

.print-photo {
    width: 35mm;
    height: 45mm;
    object-fit: cover;
    border: 1px solid #777;
}

.no-photo {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #777;
    font-size: 12px;
}

.profile-table {
    margin-bottom: 20px;
}

.profile-table th {
    width: 18%;
    background: #f3dce4;
    color: #222;
}

.profile-table td {
    width: 32%;
}

.about-box {
    border: 1px solid #ccc;
    padding: 12px;
    min-height: 70px;
    line-height: 1.5;
}

.a4-profile footer {
    margin-top: 25px;
    text-align: right;
    font-size: 12px;
    color: #666;
}

.print-actions {
    width: 210mm;
    margin: auto;
}

@media (max-width: 700px) {
    body {
        padding: 12px;
    }

    .container {
        padding: 20px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .landing-actions {
        grid-template-columns: 1fr;
    }

    .full-width {
        grid-column: auto;
    }

    .a4-profile {
        width: 100%;
        min-height: auto;
        padding: 20px;
    }

    .print-actions {
        width: 100%;
    }
}

@media print {
    @page {
        size: A4;
        margin: 0;
    }

    body {
        padding: 0;
        background: white;
    }

    .no-print,
    .print-actions {
        display: none !important;
    }

    .a4-profile {
        width: 210mm;
        min-height: 297mm;
        margin: 0;
        padding: 15mm;
        box-shadow: none;
    }
}

/* View profile page enhancements */
body.view-profile-page {
    min-height: 100vh;
    padding: 22px;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 15% 20%, rgba(139, 30, 63, 0.12), transparent 45%),
        radial-gradient(circle at 85% 10%, rgba(200, 78, 111, 0.14), transparent 40%),
        linear-gradient(145deg, #f9f4f6 0%, #eef3f8 100%);
}

.view-profile-page .small-container {
    position: relative;
    max-width: 540px;
    margin-top: 20px;
    padding: 34px;
    border: 1px solid #e8d6dd;
    border-radius: 18px;
    box-shadow: 0 16px 36px rgba(44, 22, 30, 0.12);
}

.view-profile-page .small-container::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 18px;
    pointer-events: none;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.5), transparent 55%);
}

.view-profile-page h1 {
    margin-bottom: 10px;
    font-size: clamp(1.7rem, 4.8vw, 2.1rem);
    letter-spacing: 0.02em;
}

.view-profile-page .landing-subtitle {
    margin: 0 0 24px;
    font-size: 0.98rem;
    line-height: 1.55;
    color: #5d4f56;
}

.view-profile-page .stack-form {
    gap: 16px;
}

.view-profile-page label {
    margin-bottom: 8px;
    color: #3b2a32;
    font-size: 0.93rem;
    letter-spacing: 0.01em;
}

.view-profile-page input {
    padding: 12px 13px;
    border: 1px solid #d8c4cb;
    border-radius: 10px;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.view-profile-page input:focus {
    outline: none;
    border-color: #8b1e3f;
    box-shadow: 0 0 0 4px rgba(139, 30, 63, 0.14);
}

.view-profile-page button {
    width: 100%;
    margin-top: 6px;
    padding: 12px 18px;
    border-radius: 10px;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: 0 10px 20px rgba(139, 30, 63, 0.26);
}

.view-profile-page .alert {
    margin-bottom: 18px;
    border-radius: 10px;
}

.view-profile-page .admin-link {
    margin-top: 18px;
    text-align: center;
}

.view-profile-page .admin-link a {
    color: #7d1f3c;
    font-weight: 600;
}

@media (max-width: 700px) {
    body.view-profile-page {
        padding: max(12px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
    }

    .view-profile-page .small-container {
        margin-top: 4px;
        padding: 22px 16px;
        border-radius: 14px;
    }

    .view-profile-page h1 {
        margin-bottom: 8px;
    }

    .view-profile-page .landing-subtitle {
        margin-bottom: 18px;
        font-size: 0.94rem;
    }

    .view-profile-page input {
        font-size: 16px;
    }
}

/* Landing page enhancements */
body.landing-page {
    min-height: 100vh;
    padding: 24px;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 14% 16%, rgba(193, 63, 98, 0.16), transparent 42%),
        radial-gradient(circle at 88% 12%, rgba(41, 120, 170, 0.16), transparent 40%),
        linear-gradient(160deg, #fdf8fa 0%, #edf4fa 100%);
}

.landing-page .landing-container {
    position: relative;
    margin-top: 20px;
    max-width: 920px;
    padding: 38px;
    border: 1px solid #e8d5dc;
    border-radius: 22px;
    box-shadow: 0 20px 42px rgba(43, 26, 31, 0.12);
    overflow: hidden;
}

.landing-page .landing-container::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(115deg, rgba(255, 255, 255, 0.5), transparent 48%);
}

.landing-page h1 {
    margin-bottom: 10px;
    font-size: clamp(1.9rem, 4.3vw, 2.65rem);
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.landing-page .landing-subtitle {
    margin: 0 0 28px;
    max-width: 640px;
    font-size: 1.03rem;
    line-height: 1.6;
    color: #564951;
}

.landing-page .landing-actions {
    gap: 18px;
}

.landing-page .landing-action-card {
    position: relative;
    padding: 24px;
    border-radius: 14px;
    border: 1px solid #e4cfd6;
    background:
        linear-gradient(170deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 245, 248, 0.92) 100%);
    box-shadow: 0 8px 16px rgba(112, 39, 61, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    animation: landingCardReveal 0.55s ease both;
}

.landing-page .landing-action-card:nth-child(2) {
    animation-delay: 0.12s;
}

.landing-page .landing-action-card:hover,
.landing-page .landing-action-card:focus-visible {
    transform: translateY(-4px);
    border-color: #d8b7c2;
    box-shadow: 0 14px 28px rgba(112, 39, 61, 0.18);
}

.landing-page .landing-action-card h2 {
    margin-bottom: 12px;
    font-size: 1.2rem;
}

.landing-page .landing-action-card p {
    color: #564951;
    line-height: 1.55;
}

@keyframes landingCardReveal {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 700px) {
    body.landing-page {
        padding: max(12px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
    }

    .landing-page .landing-container {
        margin-top: 4px;
        padding: 24px 16px;
        border-radius: 14px;
    }

    .landing-page h1 {
        font-size: clamp(1.6rem, 7vw, 2rem);
    }

    .landing-page .landing-subtitle {
        margin-bottom: 20px;
        font-size: 0.96rem;
    }

    .landing-page .landing-action-card {
        padding: 18px;
        border-radius: 12px;
        animation-duration: 0.42s;
    }
}

/* Search page */
body.search-page {
    min-height: 100vh;
    padding: 22px;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 12% 14%, rgba(31, 125, 106, 0.13), transparent 42%),
        radial-gradient(circle at 86% 16%, rgba(139, 30, 63, 0.11), transparent 38%),
        linear-gradient(155deg, #f5fbf8 0%, #f7f2f4 100%);
}

.search-container {
    max-width: 1100px;
    margin-top: 12px;
    border: 1px solid #dce7e1;
    border-radius: 18px;
    box-shadow: 0 16px 38px rgba(29, 40, 35, 0.11);
}

.search-filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
    padding: 16px;
    border: 1px solid #d8e5de;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f5fbf8 100%);
}

.search-filter-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
    grid-column: 1 / -1;
}

.search-filter-actions button,
.search-filter-actions .secondary-button {
    margin-top: 0;
}

.search-result-summary {
    margin: 8px 0 14px;
    color: #425950;
    font-weight: 700;
}

.search-results-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.search-card {
    display: grid;
    grid-template-columns: 105px 1fr;
    gap: 12px;
    padding: 12px;
    border: 1px solid #dbe5e0;
    border-radius: 12px;
    background: #fff;
}

.search-photo-wrap {
    width: 100%;
}

.search-photo,
.search-no-photo {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 8px;
}

.search-photo {
    object-fit: cover;
    border: 1px solid #cedbd4;
}

.search-no-photo {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed #cedbd4;
    color: #60726a;
    background: #f5fbf8;
    font-size: 13px;
}

.search-card-body h2 {
    margin: 2px 0 8px;
    border-bottom: none;
    padding-bottom: 0;
    font-size: 18px;
    color: #8b1e3f;
}

.search-card-body p {
    margin: 4px 0;
    line-height: 1.35;
}

.search-card-actions {
    margin-top: 10px;
}

.search-card-actions .secondary-button {
    margin-left: 0;
    margin-top: 0;
}

@media (max-width: 900px) {
    .search-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .search-results-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    body.search-page {
        padding: max(12px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
    }

    .search-container {
        margin-top: 4px;
        border-radius: 14px;
    }

    .search-filters {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .search-card {
        grid-template-columns: 88px 1fr;
    }
}

/* Match profile page */
body.match-profile-page {
    min-height: 100vh;
    padding: 22px;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 12% 14%, rgba(31, 125, 106, 0.13), transparent 42%),
        radial-gradient(circle at 86% 16%, rgba(139, 30, 63, 0.11), transparent 38%),
        linear-gradient(155deg, #f5fbf8 0%, #f7f2f4 100%);
}

.match-profile-page .page-wrapper {
    max-width: 1000px;
    margin: 0 auto;
}

.match-profile-page .profile-document {
    width: 100%;
    overflow: hidden;
    border: 1px solid #d8dee8;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.08);
}

.match-profile-page .document-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 20px 28px;
    color: #ffffff;
    background: var(--primary-color);
}

.match-profile-page .document-header h1 {
    margin: 0;
    color: #ffffff;
    font-size: 25px;
    font-family: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
    font-weight: 700;
}

.match-profile-page .profile-id {
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 5px;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
}

.match-profile-page .content {
    padding: 28px;
}

.match-privacy-note {
    margin: 0 0 18px;
    padding: 10px 12px;
    color: #5b6873;
    border: 1px solid #d6dfe6;
    border-radius: 6px;
    background: #f7fafc;
    font-size: 14px;
    text-align: center;
}

.match-profile-page .profile-summary {
    display: flex;
    gap: 28px;
    align-items: flex-start;
    padding-bottom: 25px;
    margin-bottom: 25px;
    border-bottom: 2px solid #dce5ec;
}

.match-profile-page .photo-section {
    flex: 0 0 190px;
    text-align: center;
}

.match-profile-page .photo-frame {
    width: 180px;
    height: 210px;
    margin: 0 auto;
    overflow: hidden;
    border: 2px solid var(--primary-color);
    border-radius: 7px;
    background: #f3f5f7;
}

.match-profile-page .profile-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.match-profile-page .no-photo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 180px;
    height: 210px;
    margin: 0 auto;
    color: #6b7280;
    border: 2px solid var(--primary-color);
    border-radius: 7px;
    background: #f3f5f7;
    font-size: 14px;
}

.match-profile-page .basic-details {
    flex: 1;
    min-width: 0;
}

.match-profile-page .basic-details h2 {
    margin: 0 0 16px;
    color: var(--primary-dark-color);
    border-bottom: 2px solid var(--name-underline-color, #2986cc);
    padding-bottom: 7px;
    font-size: 26px;
}

.match-profile-page .basic-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 12px 25px;
}

.match-profile-page .info-item {
    padding-bottom: 9px;
    border-bottom: 1px solid #e2e8ee;
}

.match-profile-page .info-label {
    display: block;
    margin-bottom: 3px;
    color: #5b6873;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.match-profile-page .info-value {
    color: #1d2932;
    font-size: 15px;
    line-height: 1.4;
}

.match-profile-page .section-title {
    margin: 25px 0 10px;
    padding: 9px 12px;
    color: var(--primary-dark-color);
    border-left: 5px solid var(--primary-color);
    background: var(--light-color);
    font-size: 17px;
}

.match-profile-page .profile-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 14px;
}

.match-profile-page .profile-table th,
.match-profile-page .profile-table td {
    padding: 11px 13px;
    border: 1px solid #d6dfe6;
    vertical-align: top;
    text-align: left;
    line-height: 1.45;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.match-profile-page .profile-table th {
    width: 30%;
    color: var(--primary-dark-color);
    background: var(--light-color);
    font-weight: 700;
}

.match-profile-page .profile-table td {
    width: 70%;
    background: #ffffff;
}

.match-profile-page .action-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 28px;
}

@media (max-width: 700px) {
    body.match-profile-page {
        padding: max(12px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
    }

    .match-profile-page .content {
        padding: 18px;
    }

    .match-profile-page .document-header,
    .match-profile-page .profile-summary {
        flex-direction: column;
    }

    .match-profile-page .basic-info-grid {
        grid-template-columns: 1fr;
    }

    .match-profile-page .profile-table th {
        width: 40%;
    }

    .match-profile-page .profile-table td {
        width: 60%;
    }
}
