:root {
    color: #14213d;
    background: #f1f5fb;
    font-family: "Segoe UI", Arial, sans-serif;
    font-synthesis: none;
    letter-spacing: 0;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    background: #f1f5fb;
}

button,
input,
select {
    font: inherit;
    letter-spacing: 0;
}

.shell {
    width: min(100% - 40px, 1200px);
    margin-inline: auto;
}

.app-header {
    padding-top: 32px;
    color: #ffffff;
}

.brand-hero {
    position: relative;
    min-height: 172px;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 28px 30px;
    overflow: hidden;
    background: linear-gradient(118deg, #12356f 0%, #1557b5 62%, #2879dd 100%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 30px;
    box-shadow: 0 18px 44px rgba(25, 63, 123, 0.18);
}

.brand-hero::after {
    content: "";
    position: absolute;
    right: -90px;
    bottom: -150px;
    width: 410px;
    height: 300px;
    border: 52px solid rgba(255, 255, 255, 0.07);
    border-radius: 50%;
    pointer-events: none;
}

.brand-mark {
    position: relative;
    z-index: 1;
    width: 132px;
    height: 100px;
    flex: 0 0 132px;
    display: grid;
    place-items: center;
    background: #ffffff;
    border: 6px solid rgba(255, 255, 255, 0.3);
    border-radius: 18px;
    box-shadow: 0 10px 28px rgba(7, 30, 70, 0.22);
}

.brand-logo {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    border-radius: 11px;
}

.brand-copy {
    position: relative;
    z-index: 1;
    min-width: 0;
    flex: 1 1 auto;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: 40px;
    line-height: 1.15;
}

h2 {
    margin-bottom: 18px;
    font-size: 20px;
    line-height: 1.3;
}

h3 {
    margin-bottom: 5px;
    color: #172c3e;
    font-size: 17px;
    line-height: 1.35;
}

.eyebrow {
    margin-bottom: 7px;
    color: #6a83a8;
    font-size: 12px;
    font-weight: 700;
}

.brand-kicker {
    margin-bottom: 7px;
    color: #bcd8ff;
    font-size: 12px;
    font-weight: 750;
}

.brand-description {
    max-width: 760px;
    margin-bottom: 0;
    color: rgba(255, 255, 255, 0.92);
    font-size: 17px;
    line-height: 1.45;
}

.mode-chip {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 7px 11px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
}

.mode-chip[data-mode="live"] {
    color: #092d20;
    background: #83dbc0;
    border-color: #83dbc0;
}

.mode-chip[data-mode="mock"] {
    color: #4a3000;
    background: #ffd978;
    border-color: #ffd978;
}

.main-content {
    padding-block: 26px 48px;
}

.mode-banner,
.message {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 6px;
    line-height: 1.45;
}

.mode-banner {
    color: #513500;
    background: #fff4cf;
    border: 1px solid #d69b16;
}

.message {
    color: #742525;
    background: #fff0f0;
    border: 1px solid #df9999;
}

.message[data-type="success"] {
    color: #17523d;
    background: #eaf8f2;
    border-color: #86cdb4;
}

.search-section,
.results-section {
    padding: 22px;
    background: #ffffff;
    border: 1px solid #d9e2f0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(30, 62, 112, 0.07);
}

.results-section {
    margin-top: 20px;
    scroll-margin-top: 18px;
}

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.section-heading .eyebrow {
    color: #2766bd;
}

.search-heading-row {
    align-items: center;
    padding-bottom: 17px;
    border-bottom: 1px solid #e2e6ea;
}

.search-heading-row h2 {
    margin-bottom: 0;
}

.text-button {
    padding: 6px 3px;
    color: #245fb2;
    background: transparent;
    border: 0;
    cursor: pointer;
    font-weight: 650;
}

.text-button:hover {
    color: #154486;
    text-decoration: underline;
}

.criteria-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 17px 16px;
    padding-top: 20px;
}

.field-group {
    min-width: 0;
}

.field-wide {
    grid-column: span 2;
}

label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    font-weight: 650;
}

input,
select {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    color: #18212f;
    background: #ffffff;
    border: 1px solid #9aa7b5;
    border-radius: 6px;
    outline: none;
}

select {
    padding-right: 30px;
}

input:focus,
select:focus {
    border-color: #2c69c8;
    box-shadow: 0 0 0 3px rgba(44, 105, 200, 0.15);
}

select:disabled {
    color: #71808e;
    background: #edf0f2;
}

.field-help {
    margin: 0;
    color: #617080;
    font-size: 13px;
}

.search-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-top: 21px;
    padding-top: 18px;
    border-top: 1px solid #e2e6ea;
}

.button {
    min-height: 42px;
    padding: 8px 15px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.button.primary {
    color: #ffffff;
    background: #1d5fbd;
    border-color: #1d5fbd;
}

.button.primary:hover:not(:disabled) {
    background: #154b98;
}

.button.secondary {
    color: #194f99;
    background: #ffffff;
    border-color: #8192a2;
}

.button.secondary:hover:not(:disabled) {
    background: #eef4fc;
}

.button.external {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: #174783;
    border-color: #174783;
    text-decoration: none;
}

.button.external:hover {
    background: #103664;
}

.button.compact {
    min-height: 36px;
    padding: 6px 11px;
    font-size: 13px;
}

.results-summary {
    margin-bottom: 0;
    color: #60707e;
    font-size: 13px;
}

.cache-note {
    padding: 5px 8px;
    color: #42515e;
    background: #edf2f5;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
}

.results-list {
    display: grid;
    gap: 14px;
    margin-top: 4px;
}

.result-card {
    padding: 17px;
    border: 1px solid #d7dde3;
    border-left: 4px solid #2b6dcc;
    border-radius: 6px;
    background: #ffffff;
}

.result-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.result-meta {
    margin-bottom: 0;
    color: #5d6b78;
    font-size: 13px;
}

.status-badge {
    flex: 0 0 auto;
    max-width: 220px;
    padding: 5px 8px;
    overflow-wrap: anywhere;
    color: #154b37;
    background: #e6f5ef;
    border: 1px solid #9bceb9;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

.result-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 24px;
    margin: 15px 0 0;
    border-top: 1px solid #e2e6ea;
}

.result-row {
    display: grid;
    grid-template-columns: minmax(130px, 0.65fr) minmax(0, 1.35fr);
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid #edf0f2;
}

dt {
    color: #63717e;
    font-size: 12px;
    font-weight: 650;
}

dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 13px;
    font-weight: 600;
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 15px;
}

.details-dialog {
    width: min(1080px, calc(100% - 32px));
    max-height: min(860px, calc(100vh - 32px));
    padding: 0;
    color: #18212f;
    background: #ffffff;
    border: 1px solid #b9c3cc;
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(18, 35, 48, 0.28);
}

.details-dialog::backdrop {
    background: rgba(12, 28, 40, 0.55);
}

.dialog-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 22px;
    color: #ffffff;
    background: #174c9a;
}

.dialog-header h2 {
    margin-bottom: 4px;
    font-size: 20px;
}

.dialog-subtitle {
    margin-bottom: 0;
    color: #d5e2eb;
    font-size: 13px;
}

.dialog-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.button.header-action {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.58);
}

.button.header-action:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

.icon-button {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    padding: 0;
    color: #ffffff;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 6px;
    cursor: pointer;
    font-size: 26px;
    line-height: 1;
}

.icon-button:hover {
    background: rgba(255, 255, 255, 0.12);
}

.details-loading {
    min-height: 180px;
    display: grid;
    place-items: center;
    padding: 30px;
    color: #5e6d79;
}

.details-dialog > .message {
    margin: 20px;
}

.detail-tabs {
    position: sticky;
    top: 117px;
    z-index: 1;
    display: flex;
    gap: 2px;
    padding: 0 20px;
    overflow-x: auto;
    background: #edf1f4;
    border-bottom: 1px solid #ccd4db;
}

.detail-tab {
    min-height: 44px;
    flex: 0 0 auto;
    padding: 9px 12px;
    color: #485966;
    background: transparent;
    border: 0;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 650;
}

.detail-tab.active {
    color: #174f9d;
    border-bottom-color: #2869c8;
}

.detail-panel {
    min-height: 260px;
    padding: 20px 22px 28px;
}

.detail-panel .result-details {
    margin-top: 0;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #dbe1e6;
    border-radius: 6px;
}

.detail-table {
    width: 100%;
    min-width: 680px;
    border-collapse: collapse;
    font-size: 13px;
}

.detail-table th,
.detail-table td {
    padding: 10px 11px;
    vertical-align: top;
    border-bottom: 1px solid #e3e8ec;
    text-align: left;
}

.detail-table th {
    color: #405260;
    background: #edf2f5;
    font-size: 12px;
    white-space: nowrap;
}

.detail-table tbody tr:last-child td {
    border-bottom: 0;
}

.empty-detail {
    padding: 24px 0;
    color: #667581;
}

.subsection-heading {
    margin-top: 26px;
}

.branch-list {
    margin: 0;
    padding-left: 22px;
}

.branch-list li + li {
    margin-top: 8px;
}

.branch-list a,
.document-row a {
    color: #1b5bad;
    font-weight: 650;
}

.document-row {
    padding: 15px 0;
    border-bottom: 1px solid #e1e6ea;
}

.document-row h3 {
    margin-bottom: 5px;
    font-size: 15px;
}

.document-row p {
    margin-bottom: 7px;
    color: #5f6e7a;
    line-height: 1.45;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 20px;
}

#page-indicator {
    min-width: 78px;
    color: #53616e;
    font-size: 13px;
    text-align: center;
}

.app-footer {
    padding: 22px 0;
    color: #5e6c79;
    background: #e7edf7;
    border-top: 1px solid #d2dceb;
    font-size: 13px;
}

.print-report {
    display: none;
}

[hidden] {
    display: none !important;
}

@media (max-width: 820px) {
    .brand-hero {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .brand-copy {
        flex-basis: calc(100% - 156px);
    }

    .mode-chip {
        margin-left: 156px;
    }

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

    .field-wide {
        grid-column: span 1;
    }

    .result-details {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .shell {
        width: min(100% - 22px, 1200px);
    }

    .app-header {
        padding-top: 11px;
    }

    .brand-hero {
        min-height: 0;
        align-items: flex-start;
        flex-direction: column;
        gap: 14px;
        padding: 20px;
        border-radius: 18px;
    }

    .brand-mark {
        width: 104px;
        height: 76px;
        flex-basis: 76px;
        border-width: 5px;
        border-radius: 14px;
    }

    .brand-logo {
        border-radius: 8px;
    }

    .brand-copy {
        flex-basis: auto;
    }

    h1 {
        font-size: 28px;
    }

    .brand-description {
        font-size: 15px;
    }

    .mode-chip {
        margin-left: 0;
    }

    .search-section,
    .results-section {
        padding: 16px;
    }

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

    .search-actions,
    .result-card-header {
        align-items: stretch;
        flex-direction: column;
    }

    .search-actions .button,
    .result-actions .button {
        width: 100%;
    }

    .result-row {
        grid-template-columns: 1fr;
        gap: 3px;
    }

    .status-badge {
        max-width: none;
        align-self: flex-start;
    }

    .result-actions {
        flex-direction: column;
    }

    .details-dialog {
        width: calc(100% - 14px);
        max-height: calc(100vh - 14px);
    }

    .dialog-header {
        padding: 17px;
    }

    .dialog-header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .dialog-header-actions .header-action {
        flex: 1 1 180px;
    }

    .detail-tabs {
        top: 126px;
        padding-inline: 10px;
    }

    .detail-panel {
        padding: 16px;
    }
}

@media print {
    @page {
        size: A4 portrait;
        margin: 13mm;
    }

    html,
    body {
        color: #111827;
        background: #ffffff;
    }

    body.printing-report > :not(.print-report) {
        display: none !important;
    }

    body.printing-report .print-report {
        width: 100%;
        display: block !important;
        color: #111827;
        font-family: "Segoe UI", Arial, sans-serif;
        font-size: 9.5pt;
    }

    .print-header {
        display: flex;
        align-items: center;
        gap: 16px;
        margin-bottom: 18px;
        padding: 14px 16px;
        color: #ffffff;
        background: #164b96 !important;
        border-radius: 6px;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .print-header img {
        width: 92px;
        height: 62px;
        flex: 0 0 92px;
        object-fit: contain;
        background: #ffffff;
        border: 3px solid #ffffff;
        border-radius: 4px;
    }

    .print-header h1 {
        margin: 2px 0 4px;
        color: #ffffff;
        font-size: 18pt;
        line-height: 1.2;
    }

    .print-kicker,
    .print-meta {
        margin: 0;
    }

    .print-kicker {
        color: #cfe2ff;
        font-size: 8pt;
        font-weight: 700;
    }

    .print-meta {
        color: #ffffff;
        font-size: 9pt;
    }

    .print-section {
        margin: 0 0 16px;
    }

    .print-section > h2 {
        margin: 0 0 7px;
        padding: 6px 8px;
        color: #173f78;
        background: #e8f0fb !important;
        border-left: 4px solid #2464be;
        font-size: 12pt;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .print-section h3 {
        margin: 10px 0 5px;
        color: #173f78;
        font-size: 10pt;
    }

    .print-section .result-details {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-top: 0;
        border: 1px solid #cfd8e5;
    }

    .print-section .result-row {
        grid-template-columns: minmax(105px, 0.75fr) minmax(0, 1.25fr);
        gap: 7px;
        padding: 6px 8px;
        border-color: #dce3ec;
        break-inside: avoid;
    }

    .print-section dt,
    .print-section dd {
        font-size: 8.5pt;
    }

    .print-section .table-scroll {
        overflow: visible;
        border-color: #cfd8e5;
    }

    .print-section .detail-table {
        min-width: 0;
        table-layout: auto;
        font-size: 7.5pt;
    }

    .print-section .detail-table th,
    .print-section .detail-table td {
        padding: 5px 6px;
        overflow-wrap: anywhere;
        border-color: #dce3ec;
    }

    .print-section .detail-table th {
        background: #eef3f9 !important;
        white-space: normal;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .print-section tr,
    .print-document {
        break-inside: avoid;
    }

    .print-document {
        padding: 8px 0;
        border-bottom: 1px solid #d8e0e9;
    }

    .print-document h3,
    .print-document p {
        margin: 0 0 4px;
    }

    .print-document a {
        color: #174f9d;
        overflow-wrap: anywhere;
    }

    .print-empty {
        margin: 6px 0;
        color: #5f6b78;
        font-style: italic;
    }

    .print-footer {
        margin-top: 20px;
        padding-top: 8px;
        color: #566273;
        border-top: 1px solid #cfd8e5;
        font-size: 8pt;
    }
}
