:root {
    color-scheme: light;
    font-family: "Segoe UI", Arial, sans-serif;
    color: #172b3f;
    background: #f1f5f8;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    --color-primary: #1764a0;
    --color-primary-dark: #104879;
    --color-green: #36a177;
    --color-border: #d4dfe7;
    --color-muted: #637487;
}

* {
    box-sizing: border-box;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(255, 255, 255, 0.96) 0, rgba(241, 245, 248, 0.94) 46%, transparent 75%),
        linear-gradient(135deg, #edf2f6 0%, #f8fafb 52%, #e9f0f5 100%);
}

a {
    color: inherit;
}

.site-header {
    position: relative;
    z-index: 1;
    display: flex;
    min-height: 76px;
    align-items: center;
    justify-content: space-between;
    padding: 0 max(5vw, calc((100vw - 1160px) / 2));
    background: #fff;
    box-shadow: 0 2px 12px rgba(24, 55, 82, 0.08);
}

.brand {
    color: #16517b;
    font-size: 21px;
    font-weight: 800;
    letter-spacing: 0.035em;
    text-decoration: none;
}

.brand::first-letter {
    color: var(--color-green);
}

.main-navigation {
    display: flex;
    gap: 30px;
}

.main-navigation a {
    color: #25384a;
    font-size: 14px;
    text-decoration: none;
}

.main-navigation a:hover {
    color: var(--color-primary);
}

.loan-page {
    position: relative;
    display: flex;
    min-height: calc(100vh - 126px);
    flex-direction: column;
    align-items: center;
    padding: 28px 20px 48px;
    overflow: hidden;
}

.loan-page::before {
    position: absolute;
    z-index: 0;
    top: 0;
    right: 0;
    left: 0;
    height: 190px;
    border-radius: 0 0 28px 28px;
    background: linear-gradient(115deg, #104a83, #2674a9 55%, #3b89b5);
    content: "";
}

.step-indicator,
.form-container {
    position: relative;
    z-index: 1;
    width: min(100%, 560px);
}

.step-indicator {
    display: flex;
    justify-content: center;
    gap: 28px;
    margin: 3px 0 24px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

.step-indicator__item {
    padding-bottom: 8px;
}

.step-indicator__item--active {
    border-bottom: 3px solid #55c994;
    color: #fff;
    font-weight: 700;
}

.step-indicator__item--complete {
    color: #b9f0d5;
}

.form-container {
    padding: 30px 42px 34px;
    border: 1px solid rgba(20, 55, 80, 0.06);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 14px 38px rgba(26, 60, 87, 0.14);
}

.form-title {
    margin: 0;
    color: #19466b;
    font-size: 23px;
    font-weight: 750;
    text-align: center;
}

.form-description {
    margin: 7px 0 24px;
    color: #35475a;
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
}

.loan-form {
    display: grid;
    gap: 17px;
}

.form-group {
    display: grid;
    gap: 7px;
}

.input-label,
.upload-label {
    color: #263d51;
    font-size: 14px;
    font-weight: 600;
}

.input-field {
    width: 100%;
    min-height: 46px;
    padding: 10px 13px;
    border: 1px solid #cbd7e0;
    border-radius: 7px;
    outline: none;
    background-color: #fff;
    color: #172b3f;
    font: inherit;
    font-size: 15px;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.input-field::placeholder {
    color: #8998a5;
}

.input-field:focus {
    border-color: #2878ad;
    box-shadow: 0 0 0 3px rgba(40, 120, 173, 0.15);
}

.input-field:disabled {
    background-color: #f0f3f5;
    cursor: not-allowed;
}

.btn-submit {
    display: inline-flex;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    margin-top: 5px;
    padding: 11px 20px;
    border: 0;
    border-radius: 7px;
    background: linear-gradient(105deg, #1765a2, #1b568d);
    box-shadow: 0 4px 10px rgba(23, 89, 143, 0.18);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 16px;
    font-weight: 750;
    text-align: center;
    text-decoration: none;
    transition: filter 150ms ease, transform 150ms ease;
}

.btn-submit:hover {
    filter: brightness(1.08);
}

.btn-submit:active {
    transform: translateY(1px);
}

.btn-submit:focus-visible,
.btn-secondary:focus-visible,
.main-navigation a:focus-visible {
    outline: 3px solid rgba(55, 159, 210, 0.55);
    outline-offset: 3px;
}

.upload-form {
    gap: 13px;
}

.upload-card {
    display: grid;
    gap: 10px;
    padding: 16px;
    border: 1px dashed #b9cbd8;
    border-radius: 9px;
    background: #fbfcfd;
}

.upload-input {
    min-height: 44px;
    padding: 7px;
    font-size: 13px;
}

.upload-input::file-selector-button {
    margin-right: 10px;
    padding: 8px 12px;
    border: 0;
    border-radius: 5px;
    background: #e8f1f7;
    color: #174c73;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}

.image-preview {
    display: block;
    width: 100%;
    max-height: 220px;
    border-radius: 6px;
    object-fit: contain;
    background: #edf2f5;
}

.image-preview[hidden] {
    display: none;
}

.form-hint {
    margin: 0;
    color: var(--color-muted);
    font-size: 12px;
}

.form-errors {
    margin-bottom: 18px;
    padding: 11px 15px;
    border: 1px solid #f1b6b6;
    border-radius: 7px;
    background: #fff2f2;
    color: #9c2929;
    font-size: 14px;
}

.form-errors ul {
    margin: 0;
    padding-left: 20px;
}

.form-errors li + li {
    margin-top: 4px;
}

.site-footer {
    display: flex;
    min-height: 50px;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    background: #fff;
    color: #667788;
    font-size: 12px;
    text-align: center;
}

.success-container {
    margin-top: 32px;
    text-align: center;
}

.success-container .btn-submit {
    width: 100%;
}

.admin-page {
    min-height: 100vh;
    padding: 42px 24px;
}

.admin-container {
    width: min(100%, 1180px);
    margin: 0 auto;
    padding: 28px;
    border: 1px solid #e1e7ec;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 12px 34px rgba(26, 60, 87, 0.08);
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.page-title {
    margin: 0;
    color: #19466b;
    font-size: 25px;
}

.page-description {
    margin: 6px 0 0;
    color: var(--color-muted);
}

.btn-secondary {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    padding: 8px 14px;
    border: 1px solid #c5d8e5;
    border-radius: 6px;
    color: #185781;
    font-size: 14px;
    text-decoration: none;
}

.btn-secondary:hover {
    background: #f0f6fa;
}

.table-container {
    overflow-x: auto;
}

.applications-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    text-align: left;
}

.applications-table th,
.applications-table td {
    padding: 13px 12px;
    border-bottom: 1px solid #e5ebef;
    white-space: nowrap;
}

.applications-table th {
    background: #f3f7fa;
    color: #34536d;
    font-weight: 650;
}

.applications-table tbody tr:hover {
    background: #f9fbfc;
}

.empty-state {
    padding: 28px !important;
    color: var(--color-muted);
    text-align: center;
}

.status-badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 650;
}

.status-badge--approved {
    background: #e5f6ed;
    color: #187244;
}

.status-badge--pending {
    background: #f7d9d6;
    color: #a73e35;
}

.status-badge--rejected {
    background: #fff0d4;
    color: #966315;
}

.status-badge--unknown {
    background: #edf0f2;
    color: #53616d;
}

.admin-shell {
    min-height: 100vh;
    background: #eef2f6;
}

.admin-topbar {
    position: relative;
    z-index: 2;
    display: flex;
    min-height: 66px;
    align-items: center;
    justify-content: space-between;
    padding: 0 max(4vw, calc((100vw - 1320px) / 2));
    border-bottom: 1px solid #e6ebef;
    background: #fff;
}

.admin-layout {
    display: grid;
    min-height: calc(100vh - 66px);
    grid-template-columns: 218px minmax(0, 1fr);
}

.admin-sidebar {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 27px 14px;
    border-right: 1px solid #e1e7ec;
    background: #fff;
}

.admin-nav-item {
    display: flex;
    min-height: 43px;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 6px;
    color: #304355;
    font-size: 14px;
    text-decoration: none;
    transition: background-color 150ms ease, color 150ms ease;
}

.admin-nav-item span {
    width: 20px;
    color: #48708c;
    font-size: 18px;
    text-align: center;
}

.admin-nav-item:hover {
    background: #edf4f8;
    color: #174f7c;
}

.admin-nav-item--active,
.admin-nav-item--active:hover {
    background: linear-gradient(110deg, #24689f, #195586);
    color: #fff;
}

.admin-nav-item--active span {
    color: #fff;
}

.admin-main {
    display: flex;
    min-width: 0;
    flex-direction: column;
    justify-content: space-between;
}

.admin-content {
    width: min(100%, 1440px);
    margin: 0 auto;
    padding: 27px 30px 42px;
}

.admin-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 17px;
}

.admin-eyebrow {
    margin: 0 0 6px;
    color: #738598;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.11em;
}

.admin-eyebrow--center {
    text-align: center;
}

.admin-panel {
    padding: 16px;
    border: 1px solid #e0e6eb;
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 5px 18px rgba(35, 62, 83, 0.06);
}

.application-filters {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 12px;
}

.filter-control {
    width: 150px;
    min-width: 0;
    height: 38px;
    padding: 7px 10px;
    border: 1px solid #d5dfe6;
    border-radius: 5px;
    outline: none;
    background: #fff;
    color: #293d50;
    font: inherit;
    font-size: 13px;
}

.filter-control:focus {
    border-color: #4384b0;
    box-shadow: 0 0 0 3px rgba(40, 120, 173, 0.12);
}

.filter-search {
    width: clamp(170px, 22vw, 270px);
}

.filter-status-label {
    margin-left: auto;
    color: #34475a;
    font-size: 13px;
    white-space: nowrap;
}

.filter-status {
    width: 128px;
}

.filter-submit {
    min-height: 36px;
    padding: 7px 12px;
    border: 0;
    border-radius: 5px;
    background: #1c6397;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
}

.filter-submit:hover {
    background: #174f7c;
}

.filter-reset {
    color: #476b86;
    font-size: 12px;
    text-decoration: none;
    white-space: nowrap;
}

.filter-reset:hover,
.detail-link:hover {
    text-decoration: underline;
}

.application-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
    padding: 11px 13px;
    border-radius: 5px;
    background: #f0f4f7;
}

.stat-item {
    color: #35495b;
    font-size: 13px;
}

.stat-item strong {
    color: #285f8e;
    font-size: 15px;
}

.stat-item--pending strong {
    color: #c38c32;
}

.stat-item--approved strong {
    color: #299259;
}

.stat-item--rejected strong {
    color: #bb4e4e;
}

.admin-applications-table {
    font-size: 13px;
}

.admin-applications-table th,
.admin-applications-table td {
    padding: 13px 10px;
}

.admin-applications-table th {
    background: #f6f8fa;
}

.application-name {
    min-width: 150px;
}

.detail-link {
    color: #205a86;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.admin-logout-form {
    margin: 0;
}

.admin-logout-form .btn-secondary {
    min-height: 37px;
    background: #fff;
    cursor: pointer;
    font: inherit;
}

.admin-footer {
    display: flex;
    min-height: 49px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 10px 30px;
    border-top: 1px solid #e0e6eb;
    background: #fff;
    color: #617285;
    font-size: 12px;
}

.detail-panel {
    padding: 24px;
}

.detail-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.detail-section-heading h2 {
    margin: 0;
    color: #244d6d;
    font-size: 17px;
}

.application-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 16px 0 0;
    border-top: 1px solid #e7edf1;
}

.detail-field {
    min-width: 0;
    padding: 15px 12px 13px 0;
    border-bottom: 1px solid #e7edf1;
}

.detail-field dt {
    margin-bottom: 6px;
    color: #708193;
    font-size: 12px;
}

.detail-field dd {
    margin: 0;
    color: #233a4e;
    font-size: 14px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.detail-field dd a {
    color: #205a86;
    text-decoration: none;
}

.detail-images-heading {
    margin-top: 28px;
}

.detail-images-heading .page-description {
    margin-top: 5px;
    font-size: 12px;
}

.document-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.document-card {
    min-width: 0;
    margin: 0;
    padding: 12px;
    border: 1px solid #e0e7ec;
    border-radius: 7px;
    background: #fbfcfd;
}

.document-card figcaption {
    margin-bottom: 10px;
    color: #314b61;
    font-size: 13px;
    font-weight: 650;
}

.document-image-link {
    display: flex;
    min-height: 180px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 5px;
    background: #edf2f5;
}

.document-image {
    display: block;
    width: 100%;
    height: 220px;
    object-fit: contain;
}

.document-placeholder {
    display: grid;
    min-height: 180px;
    place-items: center;
    border-radius: 5px;
    background: #edf2f5;
    color: #758696;
    font-size: 13px;
}

.admin-login-page {
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 50% 30%, #fff 0, #f3f6f8 50%, transparent 80%),
        linear-gradient(135deg, #eaf0f5, #f8fafb);
}

.login-home-link {
    color: #31536f;
    font-size: 14px;
    text-decoration: none;
}

.admin-login-main {
    display: grid;
    min-height: calc(100vh - 66px);
    place-items: center;
    padding: 28px 18px;
}

.admin-login-card {
    width: min(100%, 430px);
    padding: 34px 38px 38px;
    border: 1px solid #e3e9ed;
    border-radius: 11px;
    background: #fff;
    box-shadow: 0 16px 42px rgba(29, 60, 83, 0.12);
}

.admin-login-card .form-description {
    margin-bottom: 23px;
}

.admin-login-form {
    gap: 17px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.status-badge--paid {
    background: #e7f3ff;
    color: #1c5ea8;
}

.loan-slider-wrap {
    display: grid;
    gap: 11px;
}

.loan-slider-wrap input[type="range"] {
    width: 100%;
    accent-color: #1764a0;
}

.loan-slider-amount-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    color: #425a70;
    font-size: 12px;
}

.loan-slider-amount-row strong {
    color: #184b78;
    font-size: 14px;
}

.term-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.term-option {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 10px 8px;
    border: 1px solid #d7e1ea;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    text-align: center;
    transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

.term-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.term-option span {
    color: #2c4260;
    font-size: 13px;
    font-weight: 600;
}

.term-option--selected {
    border-color: #135b90;
    background: #ebf5ff;
}

.summary-card {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid #dfeaf1;
    border-radius: 10px;
    background: linear-gradient(135deg, #f3f9fc, #edf7f1);
}

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #355070;
    font-size: 14px;
}

.summary-row strong {
    color: #174e7c;
    font-size: 16px;
}

.summary-meta {
    color: #5b6f83;
    font-size: 12px;
}

.next-payment-amount {
    color: #114f78;
    font-weight: 700;
}

.next-payment-amount--overdue {
    color: #b63030;
}

.repayment-schedule-table {
    margin-top: 14px;
}

.repayment-row--overdue {
    background: rgba(181, 48, 48, 0.05);
    color: #a62d2d;
    font-weight: 600;
}

.btn-submit--danger {
    background: linear-gradient(105deg, #ac3b3b, #7f2d2d);
}

.decision-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e6edf2;
}

.decision-actions form {
    display: grid;
    gap: 10px;
}

.decision-actions label {
    color: #334d68;
    font-size: 13px;
    font-weight: 600;
}

.detail-field--wide {
    grid-column: 1 / -1;
}

.payment-bar {
    display: flex;
    justify-content: flex-end;
    margin-top: 22px;
}

.payment-modal {
    position: fixed;
    inset: 0;
    display: none;
    place-items: center;
    padding: 20px;
    background: rgba(20, 31, 41, 0.45);
}

.payment-modal.is-visible {
    display: grid;
}

.payment-modal__content {
    width: min(100%, 430px);
    padding: 22px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 12px 44px rgba(13, 29, 45, 0.18);
}

.payment-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.payment-modal__header h3 {
    margin: 0;
    color: #1e4468;
}

.payment-modal__close {
    padding: 0;
    border: none;
    background: none;
    color: #4d6476;
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
}

.customer-portrait {
    display: block;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    object-fit: cover;
    background: #edf2f5;
}

.empty-mini {
    color: #7d8ea2;
    font-size: 12px;
}

.admin-settings-panel {
    padding: 20px;
}

.settings-form {
    display: grid;
    gap: 18px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.history-card {
    margin-top: 28px;
}

.history-card h2 {
    margin: 0 0 12px;
    color: #214a6f;
    font-size: 18px;
}

.report-date {
    font-weight: 600;
}

.report-date--normal {
    color: #1c8c5d;
}

.report-date--overdue {
    color: #b13a3a;
}

.report-date--done {
    color: #4b5f72;
}

@media (max-width: 600px) {
    .site-header {
        min-height: 62px;
        padding: 0 18px;
    }

    .brand {
        font-size: 18px;
    }

    .main-navigation {
        gap: 14px;
    }

    .main-navigation a {
        font-size: 12px;
    }

    .loan-page {
        min-height: calc(100vh - 100px);
        padding: 20px 14px 32px;
    }

    .loan-page::before {
        height: 170px;
        border-radius: 0 0 20px 20px;
    }

    .step-indicator {
        width: 100%;
        gap: 12px;
        margin-bottom: 18px;
        font-size: 12px;
    }

    .step-indicator__item {
        text-align: center;
    }

    .form-container {
        padding: 24px 20px;
        border-radius: 10px;
    }

    .form-title {
        font-size: 20px;
    }

    .form-description {
        margin-bottom: 20px;
        font-size: 13px;
    }

    .loan-form {
        gap: 14px;
    }

    .admin-page {
        padding: 18px 12px;
    }

    .admin-container {
        padding: 18px 14px;
    }

    .admin-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-title {
        font-size: 21px;
    }

    .admin-layout {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px;
        padding: 10px;
        border-right: 0;
        border-bottom: 1px solid #e1e7ec;
    }

    .admin-nav-item {
        min-height: 38px;
        padding: 7px 8px;
        font-size: 12px;
    }

    .admin-content {
        padding: 20px 12px 28px;
    }

    .admin-heading-row {
        align-items: flex-start;
    }

    .application-filters {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-control,
    .filter-search,
    .filter-status {
        width: 100%;
    }

    .filter-status-label {
        margin-left: 0;
    }

    .application-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .admin-panel {
        padding: 11px;
    }

    .admin-footer {
        padding: 10px 14px;
    }

    .detail-panel {
        padding: 17px 14px;
    }

    .application-details {
        grid-template-columns: 1fr;
    }

    .document-grid {
        grid-template-columns: 1fr;
    }

    .admin-login-card {
        padding: 28px 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}