* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100dvh;
    margin: 0;
    overflow-x: hidden;
    color: #172033;
    background: #eef2f7;
    font-family: "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 16px;
}

body {
    overscroll-behavior: none;
}

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

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

.app-shell {
    width: 100%;
    min-height: 100dvh;
}

.content {
    width: 100%;
    min-height: 100dvh;
    padding: calc(12px + env(safe-area-inset-top)) 12px calc(84px + env(safe-area-inset-bottom));
}

.page-title {
    margin: 2px 0 14px;
    font-size: 20px;
    line-height: 1.25;
}

.page-subtitle {
    margin: -8px 0 14px;
    color: #64748b;
    font-size: 13px;
    line-height: 1.5;
}

.section-title {
    margin: 0 0 10px;
    color: #0f172a;
    font-size: 16px;
    line-height: 1.3;
}

.page-heading-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    justify-content: space-between;
}

.panel {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #dbe3ef;
    border-radius: 16px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

.chat-shell {
    display: grid;
    grid-template-rows: auto 1fr auto;
    height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 68px);
    min-height: 0;
    margin: calc(-12px - env(safe-area-inset-top)) -12px 0;
    background: #e8edf5;
}

.chat-header {
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
    background: rgba(248, 250, 252, 0.92);
    border-bottom: 1px solid #dbe3ef;
    backdrop-filter: blur(14px);
}

.chat-title {
    margin: 0;
    color: #0f172a;
    font-size: 19px;
    font-weight: 700;
    line-height: 1.25;
}

.chat-subtitle {
    margin-top: 2px;
    color: #64748b;
    font-size: 12px;
}

.messages {
    min-height: 0;
    overflow-y: auto;
    padding: 14px 12px 12px;
    scroll-behavior: smooth;
}

.jump-bottom-button {
    position: fixed;
    right: 18px;
    bottom: calc(132px + env(safe-area-inset-bottom));
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 999px;
    color: #334155;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.16);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.jump-bottom-button.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.message-row {
    display: flex;
    width: 100%;
    margin-bottom: 10px;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.assistant,
.message-row.system {
    justify-content: flex-start;
}

.message-row > div {
    max-width: 78%;
}

.bubble {
    padding: 10px 13px;
    border-radius: 17px;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 15px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.message-row.assistant .bubble,
.message-row.system .bubble {
    color: #172033;
    background: #ffffff;
    border-bottom-left-radius: 6px;
}

.message-row.user .bubble {
    color: #ffffff;
    background: #2f80ed;
    border-bottom-right-radius: 6px;
}

.time {
    margin-top: 4px;
    color: #8a97aa;
    font-size: 12px;
}

.message-row.user .time {
    text-align: right;
}

.chat-form {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    align-items: end;
    padding: 10px 12px 12px;
    background: rgba(248, 250, 252, 0.96);
    border-top: 1px solid #dbe3ef;
    backdrop-filter: blur(14px);
}

.image-button {
    min-width: 44px;
    min-height: 44px;
    border: 0;
    border-radius: 22px;
    color: #172033;
    background: #e2e8f0;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.image-preview {
    grid-column: 1 / -1;
    display: none;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 14px;
    background: #eef2f7;
}

.image-preview.active {
    display: flex;
}

.image-preview img {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    object-fit: cover;
}

.image-preview button {
    margin-left: auto;
}

.chat-input,
input,
select,
textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    padding: 10px 12px;
    color: #172033;
    background: #ffffff;
    outline: none;
}

.chat-input:focus,
input:focus,
select:focus,
textarea:focus {
    border-color: #2f80ed;
    box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.12);
}

.chat-form .chat-input {
    min-height: 42px;
    max-height: 118px;
    resize: none;
}

textarea {
    min-height: 92px;
    resize: vertical;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 0;
    border-radius: 14px;
    padding: 9px 14px;
    color: #ffffff;
    background: #1d4ed8;
    cursor: pointer;
    white-space: nowrap;
}

.button.secondary {
    color: #172033;
    background: #e2e8f0;
}

.button.danger {
    background: #dc2626;
}

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

.form-card,
.list-card {
    padding: 14px;
    margin-bottom: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.full {
    grid-column: 1 / -1;
}

label {
    display: block;
    margin-bottom: 6px;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.empty {
    padding: 18px;
    color: #64748b;
    text-align: center;
    font-size: 14px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border-radius: 14px;
    overflow: hidden;
}

th,
td {
    padding: 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
    font-size: 13px;
}

th {
    color: #475569;
    background: #f8fafc;
    font-weight: 700;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

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

.monitor-card {
    padding: 14px;
}

.monitor-card span,
.monitor-list span {
    display: block;
    color: #64748b;
    font-size: 12px;
}

.monitor-card strong {
    display: block;
    margin-top: 5px;
    color: #0f172a;
    font-size: 22px;
    line-height: 1.15;
}

.monitor-card small {
    display: block;
    margin-top: 6px;
    color: #64748b;
    font-size: 12px;
}

.monitor-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.monitor-list div {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #e5e7eb;
}

.monitor-list div:last-child {
    border-bottom: 0;
}

.monitor-list strong {
    color: #111827;
    font-size: 13px;
    text-align: right;
}

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

.monitor-list.compact div {
    display: block;
    padding: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.monitor-list.compact strong {
    display: block;
    margin-top: 4px;
    text-align: left;
    font-size: 18px;
}

.alert-card {
    padding: 14px;
    margin-bottom: 14px;
    border: 1px solid rgba(220, 38, 38, 0.18);
    background: #fff7ed;
}

.monitor-log-list {
    display: grid;
    gap: 8px;
}

.monitor-log-list details {
    padding: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #f8fafc;
}

.monitor-log-list summary {
    color: #334155;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}

.monitor-log-list p,
.monitor-log-list pre {
    margin: 8px 0 0;
    color: #475569;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 12px;
    line-height: 1.5;
}

.bottom-tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.92);
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(16px);
}

.tab-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    color: #8a8f98;
    font-size: 11px;
    line-height: 1.1;
}

.bottom-nav-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 28px;
    border-radius: 999px;
    background: transparent;
}

.tab-icon {
    display: block;
    width: 23px;
    height: 23px;
    opacity: 1;
    visibility: visible;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    background: transparent;
}

.tab-link.active {
    color: #2481cc;
}

.tab-link.active .bottom-nav-icon-wrap {
    background: rgba(36, 129, 204, 0.12);
}

.tab-link.active .tab-icon {
    color: currentColor;
    background: transparent;
}

.bottom-nav-label {
    color: currentColor;
    font-size: 11px;
    line-height: 1;
}

.tab-link.active .bottom-nav-label {
    color: #2481cc;
    font-weight: 600;
}

.about-grid {
    display: grid;
    gap: 10px;
}

.portfolio-board {
    margin-bottom: 14px;
}

.portfolio-overview {
    margin-bottom: 14px;
    padding: 14px;
}

.portfolio-card-list {
    display: grid;
    gap: 12px;
}

.portfolio-card {
    padding: 14px;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}

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

.portfolio-card h4 {
    margin: 0;
    color: #0f172a;
    font-size: 18px;
    line-height: 1.25;
}

.portfolio-card p {
    margin: 4px 0 0;
    color: #64748b;
    font-size: 12px;
}

.risk-badge {
    flex: 0 0 auto;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.risk-low {
    color: #047857;
    background: #d1fae5;
}

.risk-medium {
    color: #a16207;
    background: #fef3c7;
}

.risk-high {
    color: #b91c1c;
    background: #fee2e2;
}

.portfolio-highlight {
    margin: 12px 0;
    font-size: 30px;
    line-height: 1;
    font-weight: 800;
}

.gain {
    color: #dc2626;
}

.loss {
    color: #16a34a;
}

.watching {
    color: #64748b;
}

.portfolio-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.portfolio-metrics div {
    min-width: 0;
    padding: 10px;
    border-radius: 12px;
    background: #f8fafc;
}

.portfolio-metrics span {
    display: block;
    color: #64748b;
    font-size: 12px;
}

.portfolio-metrics strong {
    display: block;
    margin-top: 4px;
    color: #0f172a;
    font-size: 14px;
    overflow-wrap: anywhere;
}

.portfolio-metrics strong.gain {
    color: #dc2626;
}

.portfolio-metrics strong.loss {
    color: #16a34a;
}

.portfolio-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.portfolio-actions .button {
    min-height: 36px;
    padding: 7px 8px;
    font-size: 13px;
}

.quote-success {
    color: #16a34a;
}

.quote-failed {
    color: #ea580c;
}

.quote-error {
    margin: 10px 0 0;
    padding: 8px 10px;
    border-radius: 12px;
    color: #9a3412;
    background: #fff7ed;
}

.quote-error summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}

.quote-error p {
    margin: 6px 0 0;
    font-size: 12px;
}

details.panel {
    padding: 14px;
    margin-bottom: 14px;
}

details > summary {
    cursor: pointer;
}

.about-item {
    padding: 12px;
    border-radius: 14px;
    background: #f8fafc;
}

.about-item h3 {
    margin: 0 0 5px;
    font-size: 15px;
}

.about-item p {
    margin: 0;
    color: #64748b;
    font-size: 13px;
    line-height: 1.5;
}

@media (min-width: 860px) {
    .content {
        max-width: 1040px;
        margin: 0 auto;
        padding-right: 18px;
        padding-left: 18px;
    }

    .chat-shell {
        max-width: 820px;
        margin-right: auto;
        margin-left: auto;
        border-right: 1px solid #dbe3ef;
        border-left: 1px solid #dbe3ef;
    }

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