/* Final responsive layer. Loaded after component styles so mobile rules stay authoritative. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

img,
svg {
  max-width: 100%;
}

button,
input,
select,
textarea,
a {
  min-width: 0;
}

.page-title,
.section-title,
.metric-value,
.registered-email strong,
.policy-item strong,
.review-card strong,
.summary-line strong,
.detail-list strong,
.detail-status-stack strong,
.detail-metrics strong {
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .app-shell,
  .site-nav,
  .site-footer {
    width: 100%;
    max-width: 100%;
  }

  .portal-entry,
  .admin-signin,
  .review-layout,
  .action-grid,
  .document-layout,
  .loan-detail-grid,
  .report-panel-head-stacked {
    grid-template-columns: minmax(0, 1fr);
  }

  .entry-story,
  .signin-panel {
    min-height: 400px;
  }

  .application-heading,
  .review-hero,
  .action-hero,
  .admin-report-hero,
  .admin-hero,
  .review-actions-panel,
  .bulk-action-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .policy-summary,
  .calculated-fields,
  .review-summary-grid,
  .quote-metrics,
  .schedule-modal-summary,
  .decision-summary,
  .admin-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .registered-email,
  .action-status {
    min-width: 0;
  }

  .report-filter-form,
  .report-filter-form.simple-report-filter {
    grid-template-columns: minmax(0, 1fr);
  }

  .report-search-field,
  .report-filter-actions {
    grid-column: auto;
  }

  .bulk-upload-form {
    width: 100%;
    justify-content: flex-start;
  }

  .bulk-upload-form input[type="file"] {
    max-width: none;
    flex: 1 1 auto;
  }
}

@media (max-width: 720px) {
  html {
    font-size: 15px;
  }

  body {
    background:
      linear-gradient(180deg, rgba(255, 102, 0, 0.06), transparent 24rem),
      var(--bg);
  }

  .site-header {
    position: relative;
  }

  .site-nav {
    min-height: 64px;
    padding: 9px 14px;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
  }

  .brand {
    flex: 0 1 auto;
    gap: 9px;
  }

  .brand img {
    width: 38px;
    height: 38px;
  }

  .brand span {
    font-size: 1rem;
  }

  .nav-links {
    width: auto;
    max-width: 100%;
    margin-left: auto;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 3px;
  }

  .nav-links a,
  .nav-links button,
  .nav-user {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    padding: 8px 10px;
    font-size: 0.84rem;
  }

  .nav-user {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-shell {
    padding: 16px 12px 36px;
  }

  .site-footer {
    padding: 0 12px 20px;
    text-align: center;
  }

  .portal-entry,
  .admin-signin {
    display: block;
    min-height: auto;
  }

  .entry-story,
  .signin-panel {
    display: none;
  }

  .entry-card,
  .signin-card {
    width: 100%;
    max-width: none;
    padding: 24px 18px;
  }

  .entry-card-head {
    margin-bottom: 20px;
  }

  .entry-card-head h2 {
    font-size: 1.65rem;
  }

  .page-band,
  .admin-hero,
  .admin-report-hero,
  .report-panel-head,
  .feedback-body {
    padding: 18px 16px;
  }

  .page-title {
    font-size: 1.75rem;
    line-height: 1.15;
  }

  .application-heading,
  .review-hero,
  .action-hero,
  .admin-report-hero,
  .admin-hero,
  .review-actions-panel,
  .document-review-heading,
  .document-submit-panel,
  .bulk-action-panel {
    display: flex;
    gap: 16px;
  }

  .action-hero-side,
  .loan-detail-actions,
  .admin-hero-actions,
  .review-action-buttons,
  .report-filter-actions,
  .bulk-upload-form {
    width: 100%;
  }

  .action-hero-side,
  .loan-detail-actions,
  .admin-hero-actions,
  .review-action-buttons,
  .report-filter-actions,
  .bulk-upload-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .action-hero-side .action-status {
    margin-top: 0;
  }

  .action-status,
  .registered-email {
    width: 100%;
    margin-top: 0;
  }

  .action-grid,
  .document-layout,
  .loan-detail-grid,
  .form-grid,
  .existing-loan-fields,
  .policy-summary,
  .calculated-fields,
  .review-summary-grid,
  .quote-metrics,
  .schedule-modal-summary,
  .decision-summary,
  .detail-metrics,
  .rejection-feedback-grid,
  .otp-destinations,
  .admin-metrics {
    grid-template-columns: minmax(0, 1fr);
  }

  .full-span,
  .calculated-action-field {
    grid-column: auto;
  }

  .journey-card {
    min-height: 0;
  }

  .journey-card-content {
    padding: 22px 18px;
  }

  .journey-card h2 {
    font-size: 1.5rem;
  }

  .journey-action,
  .primary-action,
  .secondary-action,
  .danger-action,
  .confirm-action,
  .dark-action,
  .light-action,
  .decision-trigger,
  .loan-detail-actions form,
  .loan-detail-actions button,
  .review-action-buttons button,
  .review-action-buttons a,
  .report-filter-actions a,
  .report-filter-actions button,
  .bulk-upload-form button,
  .document-submit-panel form,
  .document-submit-panel button,
  .client-logout-form,
  .client-logout-button {
    width: 100%;
  }

  .primary-action,
  .secondary-action,
  .danger-action,
  .confirm-action,
  .dark-action,
  .light-action,
  .btn {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  .form-field input,
  .form-control,
  .form-select,
  .leadway-select,
  .report-search-field input,
  .report-filter-field input,
  .report-filter-field select,
  textarea {
    max-width: 100%;
    font-size: 16px;
  }

  input[type="file"] {
    max-width: 100%;
    overflow: hidden;
  }

  .existing-loan-toggle {
    width: 100%;
    border-radius: 8px;
  }

  .eligibility-status,
  .validation-panel,
  .success-panel,
  .document-signature-notice {
    padding: 14px;
  }

  .document-signature-notice {
    gap: 10px;
  }

  .document-signature-icon,
  .validation-icon {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  .document-requirement-list {
    padding-left: 18px;
  }

  .selected-document-preview-heading,
  .uploaded-list li,
  .uploaded-file-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .uploaded-list li {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .uploaded-file-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .uploaded-file-actions a,
  .uploaded-file-actions form,
  .uploaded-file-actions button,
  .document-count {
    width: 100%;
  }

  .report-status-tabs {
    padding: 10px 12px;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .report-status-tabs a {
    flex: 0 0 auto;
  }

  .bulk-upload-form input[type="file"] {
    width: 100%;
  }

  .report-pagination {
    align-items: stretch;
    flex-direction: column;
    padding: 16px;
  }

  .pagination-actions {
    justify-content: center;
  }

  .pager-link {
    flex: 1 0 42px;
  }

  .leadway-modal-backdrop {
    display: flex;
    align-items: flex-start;
    padding: 10px;
    overflow-y: auto;
  }

  .leadway-modal,
  .quote-modal,
  .schedule-modal,
  .decision-modal,
  .terms-modal,
  .feedback-modal {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - 20px);
    margin: auto;
    display: flex;
    flex-direction: column;
  }

  .leadway-modal-head,
  .leadway-modal-head.compact,
  .terms-modal .leadway-modal-head,
  .feedback-modal .leadway-modal-head {
    flex: 0 0 auto;
    padding: 22px 42px 18px 18px;
  }

  .leadway-modal h2,
  .terms-modal .leadway-modal-head h2,
  .feedback-modal .leadway-modal-head h2,
  .email-modal h2 {
    font-size: 1.3rem;
    line-height: 1.2;
  }

  .leadway-modal-body,
  .quote-modal .leadway-modal-body,
  .schedule-modal .leadway-modal-body,
  .terms-body,
  .feedback-body {
    min-height: 0;
    max-height: none;
    padding: 18px;
    overflow-y: auto;
  }

  .privacy-copy,
  .email-copy,
  .terms-body {
    font-size: 0.94rem;
    line-height: 1.5;
  }

  .leadway-modal-actions {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    padding: 12px;
  }

  .leadway-modal-actions form,
  .leadway-modal-actions button {
    width: 100%;
  }

  .modal-close {
    top: 14px;
    right: 14px;
  }

  .terms-summary-table,
  .terms-summary-table tbody,
  .terms-summary-table tr,
  .terms-summary-table th,
  .terms-summary-table td {
    display: block;
    width: 100%;
  }

  .terms-summary-table td {
    border-top: 0;
  }

  .quote-schedule,
  .schedule-modal-table,
  .report-table-wrap {
    max-height: none;
    overflow: visible;
  }

  .schedule-data-table,
  .schedule-data-table tbody,
  .schedule-data-table tr,
  .schedule-data-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .schedule-data-table thead {
    display: none;
  }

  .schedule-data-table tbody {
    display: grid;
    gap: 12px;
    padding: 12px;
  }

  .schedule-data-table tbody tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  .schedule-data-table tbody td,
  .schedule-data-table .amount-col,
  .schedule-data-table tbody td:first-child {
    display: grid;
    grid-template-columns: minmax(104px, 0.42fr) minmax(0, 1fr);
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid #f0e6dd;
    text-align: right;
    white-space: normal;
  }

  .schedule-data-table tbody td::before {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-align: left;
    text-transform: uppercase;
  }

  .schedule-data-table tbody td:nth-child(1)::before { content: "Installment"; }
  .schedule-data-table tbody td:nth-child(2)::before { content: "Due date"; }
  .schedule-data-table tbody td:nth-child(3)::before { content: "Payment due"; }
  .schedule-data-table tbody td:nth-child(4)::before { content: "Interest"; }
  .schedule-data-table tbody td:nth-child(5)::before { content: "Principal"; }
  .schedule-data-table tbody td:nth-child(6)::before { content: "Outstanding"; }

  .schedule-data-table tbody td:last-child {
    border-bottom: 0;
  }

  .searchable-report .admin-data-table,
  .searchable-report .admin-data-table tbody,
  .searchable-report .admin-data-table tr,
  .searchable-report .admin-data-table td {
    display: block;
    width: 100%;
  }

  .searchable-report .admin-data-table {
    table-layout: auto;
  }

  .searchable-report .admin-data-table thead {
    display: none;
  }

  .searchable-report .admin-data-table tbody {
    display: grid;
    gap: 12px;
    padding: 12px;
  }

  .searchable-report .admin-data-table tbody tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(37, 37, 37, 0.05);
  }

  .searchable-report .admin-data-table tbody td {
    display: grid;
    grid-template-columns: minmax(92px, 0.38fr) minmax(0, 1fr);
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border-bottom: 1px solid #f0e8e2;
    text-align: left;
    white-space: normal;
  }

  .searchable-report .admin-data-table tbody td::before {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  .searchable-report .admin-data-table tbody td:nth-child(1)::before { content: "Action"; }
  .searchable-report .admin-data-table tbody td:nth-child(2)::before { content: "Date"; }
  .searchable-report .admin-data-table tbody td:nth-child(3)::before { content: "Policy"; }
  .searchable-report .admin-data-table tbody td:nth-child(4)::before { content: "Customer"; }
  .searchable-report .admin-data-table tbody td:nth-child(5)::before { content: "Amount"; }
  .searchable-report .admin-data-table tbody td:nth-child(6)::before { content: "Tenor"; }
  .searchable-report .admin-data-table tbody td:nth-child(7)::before { content: "Decision"; }
  .searchable-report .admin-data-table tbody td:nth-child(8)::before { content: "Reference"; }

  .searchable-report .admin-data-table tbody td:first-child {
    display: block;
    padding: 12px;
  }

  .searchable-report .admin-data-table tbody td:first-child::before {
    content: none;
  }

  .searchable-report .table-view-link {
    width: 100%;
  }

  .searchable-report .admin-data-table tbody td:last-child {
    border-bottom: 0;
  }

  .searchable-report .admin-data-table .amount-col {
    width: 100%;
    text-align: left;
  }

  .searchable-report .admin-data-table td.report-empty-state {
    display: block;
    padding: 34px 16px !important;
  }

  .searchable-report .admin-data-table td.report-empty-state::before {
    content: none;
  }

  .report-panel:not(.searchable-report) .admin-data-table,
  .report-panel:not(.searchable-report) .admin-data-table tbody,
  .report-panel:not(.searchable-report) .admin-data-table tr,
  .report-panel:not(.searchable-report) .admin-data-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .report-panel:not(.searchable-report) .admin-data-table {
    table-layout: auto;
  }

  .report-panel:not(.searchable-report) .admin-data-table thead {
    display: none;
  }

  .report-panel:not(.searchable-report) .admin-data-table tbody {
    display: grid;
    gap: 12px;
    padding: 12px;
  }

  .report-panel:not(.searchable-report) .admin-data-table tbody tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  .report-panel:not(.searchable-report) .admin-data-table tbody td,
  .report-panel:not(.searchable-report) .admin-data-table .amount-col {
    display: grid;
    grid-template-columns: minmax(104px, 0.42fr) minmax(0, 1fr);
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid #f0e8e2;
    text-align: right;
    white-space: normal;
  }

  .report-panel:not(.searchable-report) .admin-data-table tbody td::before {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-align: left;
    text-transform: uppercase;
  }

  .report-panel:not(.searchable-report) .admin-data-table tbody td:nth-child(1)::before { content: "Installment"; }
  .report-panel:not(.searchable-report) .admin-data-table tbody td:nth-child(2)::before { content: "Due date"; }
  .report-panel:not(.searchable-report) .admin-data-table tbody td:nth-child(3)::before { content: "Payment due"; }
  .report-panel:not(.searchable-report) .admin-data-table tbody td:nth-child(4)::before { content: "Interest"; }
  .report-panel:not(.searchable-report) .admin-data-table tbody td:nth-child(5)::before { content: "Principal"; }
  .report-panel:not(.searchable-report) .admin-data-table tbody td:nth-child(6)::before { content: "Outstanding"; }

  .report-panel:not(.searchable-report) .admin-data-table tbody td:last-child {
    border-bottom: 0;
  }

  .report-panel:not(.searchable-report) .admin-data-table td.report-empty-state {
    display: block;
    padding: 34px 16px !important;
  }

  .report-panel:not(.searchable-report) .admin-data-table td.report-empty-state::before {
    content: none;
  }

  .page-band > .mt-4.d-flex {
    flex-direction: column;
  }

  .page-band > .mt-4.d-flex .btn {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .site-nav {
    align-items: flex-start;
  }

  .nav-links {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .brand span {
    font-size: 0.94rem;
  }

  .app-shell {
    padding-right: 10px;
    padding-left: 10px;
  }

  .entry-card,
  .signin-card,
  .page-band,
  .admin-report-hero,
  .report-panel-head {
    padding-right: 14px;
    padding-left: 14px;
  }

  .page-title {
    font-size: 1.55rem;
  }

  .policy-item,
  .review-card,
  .detail-list div,
  .detail-status-stack div,
  .detail-metrics div {
    padding: 13px;
  }

  .schedule-data-table tbody td,
  .schedule-data-table .amount-col,
  .schedule-data-table tbody td:first-child,
  .searchable-report .admin-data-table tbody td {
    grid-template-columns: minmax(88px, 0.4fr) minmax(0, 1fr);
    gap: 8px;
  }
}
