:root {
    --bg-void: #ffffff;
    --bg-panel: #ffffff;
    --bg-panel-2: #f0f0f0;
    --bg-input: #f8f8f8;
    --bg-btn: #aee2e4;
    --bg-btn-h: #97c9cc;
    --border: #b4b8c0;
    --border-bright: #adb8cc;
    --text-primary: #030303;
    --text-secondary: #001131;
    --text-dim: #070707;
    --amber: #008bdb;
    --amber-dim: #ecc58d;
    --green: rgb(0, 172, 0);
    --red: rgb(218, 0, 0);
    --sans: 'IBM Plex Sans', -apple-system, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg-void);
    color: var(--text-primary);
    min-width: 360px;
    width: 100%;
    overflow-x: hidden;
}

a {
    text-decoration: none;
}

/* ::selection {
    background: var(--amber-dim);
    color: #fff;
} */

.shell {
    max-width: 1600px;
    margin: 0 auto;
    padding: 15px 15px 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 667px;
}

footer {
    font-size: 14px;
    padding: 5px 0;
    text-align: center;
}
/* ── top bar ───────────────────────────── */
.topbar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.topbar h1 {
    font-size: 22px;
    font-weight: 600;
    color: #fff;
    background: #008fac;
    padding: 6px 15px;
    border-radius: 3px;
    font-family: Georgia, Cambria, "Times New Roman", Times, serif;

}

.topbar h1 span {
    color: var(--amber);
}

.SearchArea {
    display: flex;
    align-items: center;
    gap: 8px;
}

#csh {
    min-width: 0;
    width: 80px;
    border: none;
    outline: none;
    background-color: transparent;
}

.sh-input {
    background: transparent;
    border: 1px solid var(--border-bright);
    color: var(--text-primary);
    font-size: 14px;
    padding: 6px;
    border-radius: 6px;
    min-width: 100px;
    transition: border-color 0.2s ease-in-out;
}

.sh-input span {
    cursor: pointer;
    user-select: none;
}

.sh-input:focus-within {
    border-color: var(--amber);
}

.status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-dim);
    /* letter-spacing: .06em; */
    text-transform: uppercase;
}

.status .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 3px rgba(62, 217, 144, 0.12);
    /* animation: pulse 2.4s ease-in-out infinite; */
}

@media (prefers-reduced-motion: reduce) {
    .status .dot {
        animation: none;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .45;
    }
}

.status.err .dot {
    background: var(--red);
    box-shadow: 0 0 0 3px rgba(255, 92, 108, 0.12);
    animation: none;
}

/* ── control panel ─────────────────────── */
.panel {
    background: var(--bg-panel);
    /* border: 1px solid var(--border); */
    /* border-radius: 3px; */
    padding: 12px 5px;
    display: flex;
    align-items: flex-end;
    gap: 32px;
    margin-bottom: 10px;
    border-radius: 8px;
}

.field {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.field label {
    display: block;
    font-size: 16px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.term-input {
    background: transparent;
    border: 1px solid var(--border-bright);
    color: var(--text-primary);
    font-size: 14px;
    padding: 0 6px;
    border-radius: 5px;
    outline: none;
    min-width: 100px;
    text-align: left;
    cursor: pointer;
    height: 30px;
    transition: border-color 0.2s ease-in-out;
}

.term-input::-webkit-outer-spin-button,
.term-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.term-input:focus {
    border-color: var(--amber);
}

input.term-input {
    cursor: text;
}

#amountInput,
#dividendInput {
    min-width: 0;
    width: 80px;
}

#freqSelect {
    cursor: pointer;
}

.input-with-btn {
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-suffix {
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-suffix span {
    font-size: 12px;
    color: var(--text-dim);
}

.freq-badge {
    font-size: 16px;
    /* color: var(--text-dim); */
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 2px;
    letter-spacing: .06em;
    height: 34px;
    display: flex;
    align-items: center;
}

.freq-badge b {
    color: var(--text-secondary);
    font-weight: 600;
    margin-left: 5px;
}

/* ── date picker dropdown ──────────────── */
.picker-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 50;
    background: var(--bg-void);
    /* border: 1px solid var(--border-bright); */
    border-radius: 5px;
    padding: 12px;
    width: 280px;
    box-shadow: 2px 5px 15px rgba(0, 0, 0, 0.5);
}

.picker-panel.hidden {
    display: none;
}

.picker-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    letter-spacing: .03em;
    flex-wrap: wrap;
}

.picker-breadcrumb .crumb {
    cursor: pointer;
    color: var(--text-secondary);
}

.picker-breadcrumb .crumb:hover {
    color: var(--amber);
}

.picker-breadcrumb .crumb.current {
    color: var(--amber);
    cursor: default;
}

.picker-breadcrumb .sep {
    color: var(--border-bright);
}

.picker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.picker-grid button {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 12px;
    padding: 8px 4px;
    border-radius: 2px;
    cursor: pointer;
    transition: border-color .2s, color .2s;
}

.picker-grid button:hover {
    border-color: var(--amber);
    color: var(--amber);
}

.picker-grid button.active {
    border-color: var(--amber);
    color: var(--amber);
    background: rgba(255, 159, 28, 0.08);
}

/* ── summary bar ───────────────────────── */
.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 5px;
    overflow: hidden;
    margin-bottom: 18px;
    opacity: 0;
    /* min-height: 68px; */
}

.stat {
    background: #c1d0ec3d;
    padding: 10px;
    border-radius: 10px;
    animation: fadeIn-1 0.3s ease;
}

.stat .k {
    font-size: 14px;
    color: var(--text-dim);
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.stat .v {
    font-size: 18px;
    font-weight: 600;
    /* letter-spacing: .01em; */
    font-family: monospace;
}

.stat .sub.pos,
.stat .v.pos {
    color: var(--green);
}

.stat .sub.neg,
.stat .v.neg {
    color: var(--red);
}

.stat .v.neutral {
    color: var(--text-primary);
}

.stat .sub {
    font-size: 16px;
    margin-top: 4px;
    font-weight: 600;
    font-family: monospace;
}

/* ── chart panel ───────────────────────── */
.chart-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 16px 20px 8px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    flex: 1;
    min-height: 0;
}

.chart-panel-head {
    opacity: 0;
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 4px;
}

.chart-panel-head h2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-dim);
    /* letter-spacing: .06em; */
    text-transform: uppercase;
    margin: 0;
}

.legend-note {
    font-size: 14px;
    color: var(--text-dim);
}

#chart {
    width: 100%;
    /* height: 55vh; */
    display: none;
    flex: 1;
    min-height: 0;
}

.empty-state {
    padding: 80px 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 18px;
    flex: 1;
    animation: fadeIn-2 0.3s ease;
}

@keyframes fadeIn-2 {
    0% {
        opacity: 0;
    }

    70% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

.empty-state b {
    color: var(--red);
    display: block;
}

#CodeListBox {
    min-height: 32px;
    margin: 15px 0;
    display: flex;
    gap: 8px;
    align-items: center;
}

#CodeListBox input {
    min-width: 0;
    width: 70px;
    border-radius: 5px;
    padding: 6px
}

.code {
    font-size: 17px;
    display: inline-block;
    padding: 5px 12px;
    border-radius: 8px;
    cursor: pointer;
    background-color: #ebfaff;
    font-weight: 600;
    color: #000;
    user-select: none;
}

.code-active {
    background-color: #008040d5;
    color: #fff;
}



/* 当屏幕是横屏（宽度大于高度）时的全屏尺寸 */
@media (orientation: landscape) {
    #fsBtn {
        display: none;
    }
}


.btn {
    background-color: var(--bg-btn);
    padding: 3px 10px;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 15px;
    transition: all 0.2s ease-in-out;
}

.btn:hover {
    background-color: var(--bg-btn-h);
}


.fl {
    display: flex;
    justify-content: space-between;
    gap: 24px;
}

.fl span {
    color: #303030;
    font-size: 13px;
}

.fl-date {
    font-size: 14px;
    color: #222;
    margin-bottom: 4px;
}

/* ─────────────────────────────────────────────
   手机端与平板竖屏适配 (Mobile Responsive CSS)
   ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .shell {
        padding: 5px 5px 0;
    }

    /* 顶部导航 */
    .topbar {
        align-items: center;
        padding-bottom: 8px;
        gap: 8px;
    }

    .topbar h1 {
        font-size: 18px;
        padding: 4px 10px;
    }

    .status {
        font-size: 11px;
        text-align: right;
    }

    /* 搜索区与热门股票 */
    .SearchArea {
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        margin-top: 6px;
    }

    .sh-input {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 7px 10px;
    }

    #csh {
        flex: 1;
        width: auto;
        font-size: 14px;
        /* 防止 iOS 自动聚焦放大页面 */
    }

    #CodeListBox {
        margin: 2px 0;
        overflow-x: auto;
        overflow-y: hidden;
        flex-wrap: nowrap;
        gap: 2px;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

    #CodeListBox::-webkit-scrollbar {
        display: none;
    }

    .code {
        font-size: 12px;
        padding: 5px;
        flex-shrink: 0;
        white-space: nowrap;
        border-radius: 5px;
    }

    .chart-panel {
        border: none;
        padding: 0;

    }

    /* 参数控制面板：2 列网格自适应 */
    .panel {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 5px 8px;
        padding: 0;
        align-items: stretch;
        margin-bottom: 8px;

    }

    .field {
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        width: 100%;
    }

    .field label {
        font-size: 12px;
        white-space: nowrap;
        color: var(--text-dim);
    }

    .term-input {
        width: 100% !important;
        min-width: 0 !important;
        height: 30px;
        font-size: 14px;
        padding: 2px 5px;
        box-sizing: border-box;
    }

    #amountInput {
        width: 100% !important;
    }

    .input-with-btn {
        display: flex;
        align-items: center;
        gap: 6px;
        width: 100%;
    }

    #dividendInput {
        flex: 1;
        width: 0 !important;
        min-width: 0 !important;
    }

    #okBtn {
        /* height: 38px; */
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 5px 12px;
        font-size: 13px;
        font-weight: 600;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* 日期选择弹层：居中遮罩浮层，便于触控 */
    /* .picker-panel {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90vw;
        max-width: 320px;
        z-index: 99999;
        box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
        background: var(--bg-panel);
    } */

    .picker-grid button {
        padding: 10px 4px;
        font-size: 13px;
    }

    /* 核心数据看板：紧凑 2 列网格 */
    .summary {
        grid-template-columns: repeat(2, 1fr);
        gap: 1px;
        margin-bottom: 8px;
        min-height: auto;
    }

    .stat {
        padding: 5px 6px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-radius: 3px;
    }

    .stat .k {
        font-size: 12px;
        letter-spacing: .02em;
        margin-bottom: 3px;
    }

    .stat .v {
        font-size: 15px;
    }

    /* 图表控制头与高度 */
    .chart-panel-head {
        flex-wrap: wrap;
        gap: 6px;
        padding: 0;
        margin-bottom: 8px;
    }

    .chart-panel-head .btn {
        padding: 4px 10px;
        font-size: 13px;
    }

    .chart-panel-head h2 {
        font-size: 13px;
        width: 100%;
        order: 3;
        margin-top: 4px;
    }

    #chart {
        width: 100%;
        flex: 1;
        /* min-height: 260px; */
    }

    .empty-state {
        height: 280px;
        padding: 60px 10px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .topbar h1 {
        font-size: 16px;
    }

    .stat .v {
        font-size: 12px;
    }
}




@keyframes fadeIn-1 {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* 当浏览器高度大于宽度时（如手机竖屏），强制旋转 90 度实现横屏 */
@media (orientation: portrait) {
    #chart-panel.web-fullscreen {
        position: fixed;
        z-index: 999999;
        margin: 0;
        padding: 5px;
        width: 100dvh;
        height: 100dvw;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) rotate(90deg);
        transform-origin: center center;
        display: flex;
        flex-direction: column;
    }

    /* #chart-panel.web-fullscreen {} */

    .web-fullscreen .stat {
        flex-direction: column;

    }

    .web-fullscreen .stat .k,
    .web-fullscreen .stat .v {
        font-size: 12px;
        margin-bottom: 0;
    }

    .web-fullscreen .summary {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr))
    }

    .web-fullscreen .panel {
        margin-bottom: 2px;
        display: flex;

    }

    .web-fullscreen .chart-panel-head {
        flex-wrap: nowrap
    }

    .web-fullscreen .chart-panel-head h2 {
        width: auto;

    }

    .web-fullscreen #chart {
        height: auto;
        flex: 1;
    }

    #fsBtn {
        display: block;
    }

    .web-fullscreen .picker-grid {
        /* max-height: 55vw; */
        overflow-y: auto;
    }

    .web-fullscreen .picker-panel {
        position: fixed;
        top: 0;
        bottom: 0;
        width: 360px;
    }

}