:root {
    --navy: #0d2742;
    --navy-2: #173b60;
    --gold: #d3a84a;
    --bg: #f2f5f8;
    --panel: #ffffff;
    --text: #172536;
    --muted: #657383;
    --border: #d7dee6;
    --green: #147d50;
    --red: #b4232d;
    --amber: #a76400;
    --shadow: 0 8px 28px rgba(13, 39, 66, 0.10);
}

* { box-sizing: border-box; }

html { font-size: 20px; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, Arial, Helvetica, sans-serif;
    line-height: 1.45;
}

a { color: var(--navy-2); }

button, input, select, textarea { font: inherit; }

.topbar {
    background: var(--navy);
    color: #fff;
    border-bottom: 4px solid var(--gold);
}

.topbar-inner {
    width: min(1480px, calc(100% - 40px));
    min-height: 82px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    font-size: 1.15rem;
    white-space: nowrap;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 13px;
    background: var(--gold);
    color: var(--navy);
    font-size: .82rem;
}

.nav { display: flex; align-items: center; gap: 8px; flex: 1; }
.nav a {
    color: #e8eef5;
    text-decoration: none;
    padding: 13px 17px;
    border-radius: 10px;
    font-weight: 700;
}
.nav a:hover, .nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.nav a.primary-link { background: var(--gold); color: var(--navy); }

.user-box { display: flex; align-items: center; gap: 13px; white-space: nowrap; }
.user-box form { margin: 0; }
.link-button {
    border: 1px solid rgba(255,255,255,.48);
    background: transparent;
    color: #fff;
    padding: 10px 14px;
    border-radius: 9px;
    cursor: pointer;
}

.page-shell { width: min(1480px, calc(100% - 40px)); margin: 34px auto 60px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.page-heading h1 { font-size: 1.75rem; margin: 0; color: var(--navy); }
.page-heading p { margin: 4px 0 0; color: var(--muted); }

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 28px;
    margin-bottom: 24px;
}

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-bottom: 25px; }
.cards-four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-card {
    background: #fff;
    border: 1px solid var(--border);
    border-left: 7px solid var(--gold);
    border-radius: 15px;
    padding: 24px;
    box-shadow: var(--shadow);
}
.stat-label { color: var(--muted); font-weight: 700; }
.stat-value { color: var(--navy); font-size: 2rem; font-weight: 900; margin-top: 7px; }
.stat-money { font-size: 1.38rem; }

.button {
    display: inline-flex;
    min-height: 54px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 11px;
    padding: 12px 21px;
    background: var(--navy);
    color: #fff;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}
.button:hover { background: var(--navy-2); }
.button-gold { background: var(--gold); color: var(--navy); }
.button-light { background: #e7edf3; color: var(--navy); }
.button-danger { background: var(--red); }
.button-small { min-height: 42px; padding: 8px 14px; font-size: .85rem; }
.heading-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.table-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.text-green { color: var(--green) !important; }
.text-red { color: var(--red) !important; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 26px; }
.form-group { min-width: 0; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { display: block; margin-bottom: 8px; font-size: 1.05rem; font-weight: 800; color: var(--navy); }
.required { color: var(--red); }

input, select, textarea {
    width: 100%;
    min-height: 56px;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 11px;
    background: #fff;
    color: var(--text);
}
textarea { min-height: 105px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: 3px solid rgba(211,168,74,.26);
    border-color: var(--gold);
}
.field-help { color: var(--muted); font-size: .86rem; margin-top: 6px; }
.form-section-title {
    grid-column: 1 / -1;
    margin: 10px 0 -2px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
    color: var(--navy);
    font-size: 1.28rem;
}
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--border); }

.search-row { display: grid; grid-template-columns: minmax(240px, 1fr) 260px auto auto; gap: 12px; align-items: end; }
.search-row .button { min-width: 120px; }
.investment-search-row { display: grid; grid-template-columns: minmax(260px, 1fr) 230px 250px auto auto; gap: 12px; align-items: end; }
.payment-search-row { display: grid; grid-template-columns: minmax(240px, 1.6fr) repeat(3, minmax(170px, .7fr)) auto auto; gap: 12px; align-items: end; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 13px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 17px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: #edf2f6; color: var(--navy); font-size: .9rem; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfd; }
.id-link { font-weight: 900; text-decoration: none; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 12px; font-size: .82rem; font-weight: 800; }
.badge-green { background: #dff5e9; color: var(--green); }
.badge-amber { background: #fff0d5; color: var(--amber); }
.badge-red { background: #fde3e5; color: var(--red); }
.badge-blue { background: #e2eef9; color: var(--navy-2); }

.alert { border-radius: 12px; padding: 16px 19px; margin-bottom: 20px; border-left: 6px solid; background: #fff; font-weight: 700; }
.alert-success { border-color: var(--green); color: #0c603c; }
.alert-error { border-color: var(--red); color: #8d1d25; }
.alert-warning { border-color: var(--amber); color: #754800; }
.alert-info { border-color: var(--navy-2); color: var(--navy); }
.error-list { margin: 8px 0 0; }

.login-shell { min-height: calc(100vh - 86px); display: grid; place-items: center; padding: 28px 0; }
.login-card { width: min(520px, 100%); background: #fff; border-radius: 20px; padding: 36px; box-shadow: var(--shadow); border-top: 7px solid var(--gold); }
.login-card h1 { color: var(--navy); font-size: 1.8rem; margin: 0 0 8px; }
.login-card .subtitle { color: var(--muted); margin: 0 0 25px; }
.pin-input { text-align: center; letter-spacing: .45em; font-size: 1.45rem; font-weight: 900; }
.login-card .button { width: 100%; margin-top: 20px; }

.details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 34px; }
.detail { padding: 15px 0; border-bottom: 1px solid var(--border); }
.detail dt { color: var(--muted); font-weight: 700; font-size: .86rem; margin-bottom: 4px; }
.detail dd { margin: 0; font-weight: 750; overflow-wrap: anywhere; }
.empty-state { padding: 46px 20px; text-align: center; color: var(--muted); }
.money-value { color: var(--navy); font-weight: 850; }
.cost-breakdown { font-size: .75rem; font-weight: 700; white-space: normal; }

.cost-box {
    border: 2px solid #dce4eb;
    background: #f6f9fb;
    border-radius: 12px;
    min-height: 96px;
    padding: 15px 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.cost-box span { color: var(--muted); font-size: .84rem; font-weight: 750; }
.cost-box strong { color: var(--navy); font-size: 1.25rem; }

.form-section-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin: 32px 0 16px;
    padding-top: 24px;
    border-top: 2px solid var(--border);
}
.form-section-bar h2, .form-section-bar p { margin: 0; }
.form-section-bar p { color: var(--muted); margin-top: 3px; }
.broker-card {
    border: 2px solid #d8e0e8;
    background: #f8fafc;
    border-radius: 15px;
    padding: 22px;
    margin: 0 0 18px;
}
.broker-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.broker-card-heading h3 { margin: 0; color: var(--navy); font-size: 1.2rem; }
.broker-cost-preview { margin-top: 17px; text-align: right; color: var(--muted); }
.broker-cost-preview strong { color: var(--navy); font-size: 1.12rem; margin-left: 8px; }

.deal-total-box {
    margin: 26px 0 0;
    background: var(--navy);
    color: #fff;
    border-radius: 16px;
    padding: 24px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}
.deal-total-box > div { display: flex; flex-direction: column; gap: 6px; padding: 5px 12px; }
.deal-total-box span { color: #dce7f1; font-size: .87rem; font-weight: 700; }
.deal-total-box strong { font-size: 1.25rem; }
.deal-total-box .grand-total { border-left: 2px solid rgba(255,255,255,.28); }
.deal-total-box .grand-total strong { color: #f3cc72; font-size: 1.42rem; }
.deal-total-box.deal-total-four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.capacity-box {
    background: #edf5fb;
    border: 2px solid #b9d1e4;
    border-radius: 13px;
    padding: 18px 20px;
}
.capacity-box span { display: block; color: var(--muted); font-size: .88rem; font-weight: 800; margin-bottom: 6px; }
.capacity-box strong { color: var(--navy); font-size: 1.2rem; }
.capacity-box.capacity-full { background: #fff1f1; border-color: #e9aeb2; }
.capacity-box.capacity-full strong { color: var(--red); }

.agreement-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 22px;
    border-left: 7px solid var(--green);
}
.agreement-panel h2 { margin: 5px 0 0; color: var(--navy); }
.agreement-approval-grid { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 32px; align-items: center; }
.qr-card { text-align: center; color: var(--navy); }
.qr-card > div { width: 196px; height: 196px; margin: 0 auto 10px; padding: 8px; background: #fff; border: 2px solid var(--border); border-radius: 12px; }
.qr-card canvas, .qr-card img { width: 180px !important; height: 180px !important; display: block; }

.verification-shell { min-height: calc(100vh - 160px); display: grid; place-items: center; }
.verification-card { width: min(850px, 100%); background: #fff; border-radius: 20px; padding: 38px; box-shadow: var(--shadow); text-align: center; }
.verification-card h1 { color: var(--navy); margin: 12px 0 8px; }
.verification-card > p { color: var(--muted); }
.verification-icon { width: 82px; height: 82px; border-radius: 50%; display: grid; place-items: center; margin: auto; font-size: 2.5rem; font-weight: 900; }
.valid-verification { border-top: 8px solid var(--green); }
.valid-verification .verification-icon { background: #dff5e9; color: var(--green); }
.invalid-verification { border-top: 8px solid var(--red); }
.invalid-verification .verification-icon { background: #fde3e5; color: var(--red); }

.review-banner {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.review-banner > div { background: var(--navy); color: #fff; padding: 23px; border-radius: 14px; box-shadow: var(--shadow); }
.review-banner span { display: block; color: #dbe6f1; font-size: .86rem; font-weight: 700; margin-bottom: 7px; }
.review-banner strong { color: #f3cc72; font-size: 1.35rem; }
.review-banner small { display: block; margin-top: 7px; color: #dbe6f1; font-size: .74rem; line-height: 1.35; }
.review-broker { border: 1px solid var(--border); border-radius: 13px; padding: 18px 21px; margin: 15px 0; }
.review-broker-title { color: var(--navy); font-weight: 900; font-size: 1.1rem; padding-bottom: 8px; }
.review-total { margin-bottom: 22px; }
.review-actions { display: flex; justify-content: flex-end; gap: 13px; flex-wrap: wrap; }

.pagination { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 24px; }
.pagination a, .pagination span { min-width: 48px; min-height: 48px; display: grid; place-items: center; padding: 8px; border-radius: 9px; background: #fff; border: 1px solid var(--border); text-decoration: none; }
.pagination .current { background: var(--navy); color: #fff; }

.setup-shell { width: min(900px, calc(100% - 36px)); margin: 34px auto; }
.setup-logo { text-align: center; margin-bottom: 24px; color: var(--navy); }
.setup-logo h1 { margin: 8px 0; font-size: 2rem; }

@media (max-width: 1050px) {
    .topbar-inner { flex-wrap: wrap; padding: 14px 0; }
    .nav { order: 3; width: 100%; flex-basis: 100%; overflow-x: auto; }
    .cards { grid-template-columns: 1fr 1fr; }
    .search-row { grid-template-columns: 1fr 220px; }
    .investment-search-row { grid-template-columns: 1fr 1fr; }
    .payment-search-row { grid-template-columns: 1fr 1fr; }
    .deal-total-box.deal-total-four { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
    html { font-size: 18px; }
    .topbar-inner, .page-shell { width: min(100% - 24px, 1480px); }
    .topbar-inner {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px 12px;
    }
    .brand { min-width: 0; }
    .brand span:last-child { font-size: .95rem; }
    .user-box { margin-left: 0; }
    .nav {
        grid-column: 1 / -1;
        order: initial;
        width: 100%;
        min-width: 0;
        padding-bottom: 2px;
    }
    .nav a { white-space: nowrap; padding: 10px 12px; font-size: .86rem; }
    .page-shell { margin-top: 22px; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .cards, .form-grid, .details-grid, .search-row, .investment-search-row, .payment-search-row, .deal-total-box, .deal-total-box.deal-total-four, .review-banner, .agreement-approval-grid { grid-template-columns: 1fr; }
    .panel, .login-card { padding: 22px 18px; border-radius: 14px; }
    .form-group.full { grid-column: auto; }
    .form-section-title { grid-column: auto; }
    .button { width: 100%; }
    .form-actions { flex-direction: column; }
    .heading-actions, .form-section-bar, .review-actions { width: 100%; flex-direction: column; align-items: stretch; }
    .agreement-panel { align-items: stretch; flex-direction: column; }
    .deal-total-box .grand-total { border-left: 0; border-top: 2px solid rgba(255,255,255,.28); padding-top: 16px; }
    .broker-card { padding: 18px 14px; }
    .table-wrap { border: 0; overflow: visible; }
    table, thead, tbody, th, td, tr { display: block; }
    thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    tbody { display: grid; gap: 15px; }
    tbody tr { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: #fff; box-shadow: 0 4px 12px rgba(13,39,66,.06); }
    tbody td { display: grid; grid-template-columns: 125px 1fr; gap: 12px; padding: 9px 7px; border-bottom: 1px solid var(--border); }
    tbody td:last-child { border-bottom: 0; }
    tbody td::before { content: attr(data-label); color: var(--muted); font-size: .83rem; font-weight: 800; }
}

@media print {
    .topbar, .page-heading .button, .form-actions, .alert { display: none !important; }
    body { background: #fff; }
    .page-shell { width: 100%; margin: 0; }
    .panel { box-shadow: none; border: 1px solid #aaa; }
}

.checkbox-row { display:flex; flex-wrap:wrap; gap:12px; margin-top:8px; }
.checkbox-row label { display:flex; align-items:center; gap:7px; padding:12px 15px; border:1px solid var(--border); border-radius:10px; background:#fff; }
.checkbox-row input { width:24px; min-height:24px; }
