* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: #f2f4f7;
    color: #17202a;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

.app-shell {
    width: 100%;
    max-width: 1120px;
    min-height: 100vh;
    margin: 0 auto;
    padding-bottom: 32px;
    background: #f8f9fb;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 62px;
    padding: 10px 18px;
    background: #ffffff;
    border-bottom: 1px solid #e8ebf0;
}

.brand-link {
    color: #17202a;
    font-size: 18px;
    font-weight: 800;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.nav-links a,
.primary-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid #dce1e8;
    border-radius: 8px;
    background: #ffffff;
    color: #364152;
    font-size: 14px;
    font-weight: 700;
}

.nav-links a.active,
.primary-link {
    border-color: #222831;
    background: #222831;
    color: #ffffff;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 16px;
    padding: 16px;
}

.content-grid.single {
    grid-template-columns: minmax(0, 720px);
    justify-content: center;
}

.topbar h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.account-panel,
.panel {
    margin: 0;
    padding: 16px;
    background: #ffffff;
    border: 1px solid #e8ebf0;
    border-radius: 8px;
}

.account-panel {
    border-top: 4px solid #222831;
}

.detail-panel {
    border-top-color: #1f7a4d;
}

.muted {
    color: #7b8491;
    font-size: 13px;
}

.net-value {
    margin-top: 6px;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: 0;
}

.panel-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.stock-title {
    margin: 0 0 4px;
    font-size: 22px;
}

.gain-line {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 8px;
    font-size: 14px;
}

.gain-line em {
    font-style: normal;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 16px;
    margin-top: 16px;
}

.metric-grid div,
.readonly-grid div {
    min-width: 0;
}

.metric-grid span,
.readonly-grid span {
    display: block;
    color: #7b8491;
    font-size: 12px;
}

.metric-grid b,
.readonly-grid b {
    display: block;
    margin-top: 4px;
    overflow-wrap: anywhere;
    font-size: 15px;
}

.readonly-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 10px 0 14px;
}

.readonly-grid div {
    padding: 12px;
    border: 1px solid #e8ebf0;
    border-radius: 8px;
    background: #f8fafc;
}

.positive {
    color: #087f5b;
}

.negative {
    color: #d64545;
}

.position-table {
    margin: 0;
    overflow: hidden;
    border: 1px solid #e8ebf0;
    border-radius: 8px;
    background: #ffffff;
}

.table-head,
.position-row {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr .9fr .8fr 1fr;
    gap: 8px;
    align-items: center;
}

.table-head {
    padding: 10px;
    color: #7b8491;
    background: #f3f5f8;
    font-size: 11px;
}

.table-title {
    padding: 14px 14px 0;
}

.position-row {
    padding: 12px 10px;
    border-top: 1px solid #edf0f4;
    font-size: 12px;
}

.position-row strong {
    display: block;
    font-size: 16px;
}

.position-row small {
    display: block;
    color: #7b8491;
    line-height: 1.35;
}

.num {
    text-align: right;
}

.empty {
    padding: 24px 12px;
    color: #8b95a1;
    text-align: center;
}

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #eef1f5;
}

.login-card {
    width: min(100%, 380px);
    padding: 24px;
    border: 1px solid #e1e5ea;
    border-radius: 8px;
    background: #ffffff;
}

.brand {
    color: #7b8491;
    font-size: 13px;
}

.login-card h1,
.panel h2 {
    margin: 6px 0 16px;
    font-size: 22px;
}

.panel h2 {
    font-size: 17px;
}

.form {
    display: grid;
    gap: 14px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.form label,
.form-field {
    display: grid;
    gap: 6px;
}

.form label span,
.form-field > span {
    color: #5f6875;
    font-size: 13px;
}

.radio-segment {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 4px;
    border: 1px solid #dce1e8;
    border-radius: 8px;
    background: #f3f5f8;
}

.radio-segment label {
    display: block;
}

.radio-segment input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
    appearance: none;
    -webkit-appearance: none;
}

.radio-segment span {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #687384;
    font-size: 14px;
    font-weight: 700;
    box-shadow: none;
    transition: background .16s ease, color .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.radio-segment input:checked + span {
    border-color: #ffffff;
    background: #ffffff;
    color: #17202a;
    box-shadow: 0 4px 12px rgba(23, 32, 42, .12);
}

.radio-segment label:first-child input:checked + span {
    background: #0f8b5f;
    color: #ffffff;
    box-shadow: 0 6px 14px rgba(15, 139, 95, .22);
}

.radio-segment label:last-child input:checked + span {
    background: #c93d3d;
    color: #ffffff;
    box-shadow: 0 6px 14px rgba(201, 61, 61, .2);
}

input,
select {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid #d7dde5;
    border-radius: 8px;
    background: #ffffff;
    color: #17202a;
}

.primary-btn {
    height: 42px;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    background: #222831;
    color: #ffffff;
    font-weight: 700;
}

.inline-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.stock-summary,
.holding-box,
.day-range,
.message {
    margin-top: 12px;
    line-height: 1.55;
}

.holding-box {
    padding: 10px 12px;
    border: 1px solid #dce1e8;
    border-radius: 8px;
    background: #f8fafc;
    color: #364152;
    font-size: 14px;
    font-weight: 700;
}

.holding-box.warning {
    border-color: #f1c7c7;
    background: #fff4f4;
    color: #a33232;
}

.alert,
.message {
    padding: 10px 12px;
    border-radius: 8px;
}

.alert.error,
.message.error {
    color: #9b1c1c;
    background: #fdecec;
}

.message.success {
    color: #0f6848;
    background: #e8f6ef;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.section-title h2 {
    margin: 0;
}

.trade-item {
    padding: 12px 0;
    border-top: 1px solid #edf0f4;
}

.trade-item:first-child {
    border-top: 0;
}

.trade-item .line {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 4px;
}

.trade-item strong {
    color: #17202a;
}

@media (max-width: 760px) {
    .app-shell {
        max-width: none;
        padding-bottom: 20px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .nav-links {
        justify-content: flex-start;
        width: 100%;
    }

    .nav-links a {
        flex: 1;
        padding: 0 8px;
        font-size: 13px;
    }

    .content-grid,
    .content-grid.single {
        grid-template-columns: 1fr;
        padding: 12px;
    }

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

    .form-row {
        grid-template-columns: 1fr;
    }

    .panel-title {
        align-items: stretch;
        flex-direction: column;
    }

    .table-head,
    .position-row {
        grid-template-columns: 1.5fr .9fr .9fr .8fr .7fr 1fr;
        gap: 5px;
    }

    .table-head {
        font-size: 10px;
    }

    .position-row {
        font-size: 11px;
    }
}
