:root {
    --bg: #0f1419;
    --card: #1a2332;
    --line: #2a3648;
    --text: #e8eef6;
    --muted: #8ea0b5;
    --up: #ef5350;
    --down: #26a69a;
    --accent: #3d8bfd;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
}

button, a, .group-tab, .th-sort, .pager-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(61, 139, 253, 0.18);
}

.page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px 20px 48px;
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    padding-bottom: max(48px, calc(24px + env(safe-area-inset-bottom)));
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 20px;
}

h1 {
    margin: 0 0 6px;
    font-size: 26px;
    font-weight: 650;
}

h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.sub, .hint, .header-meta {
    color: var(--muted);
    font-size: 13px;
}

.header-meta {
    text-align: right;
}

.auto-refresh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    cursor: pointer;
}

.add-form {
    display: flex;
    gap: 8px;
    margin-bottom: 0;
    flex: 1;
}

.toolbar {
    display: flex;
    gap: 10px;
    align-items: stretch;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.ghost-btn {
    height: 42px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}

.ghost-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.accent-btn {
    height: 42px;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, #ef5350, #e53935);
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}

.accent-btn:hover {
    filter: brightness(1.05);
}

.group-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.group-tab {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
}

.group-tab:hover {
    color: var(--text);
    border-color: #4a5a72;
}

.group-tab.active {
    background: rgba(61, 139, 253, 0.15);
    border-color: var(--accent);
    color: #9ec1ff;
}

/* 涨停快照：每个交易日一个分组，折叠成下拉，chip 栏高度恒定 */
.group-dropdown {
    display: inline-block;
}

.group-tab-drop {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.group-tab-drop .caret {
    font-size: 10px;
    line-height: 1;
    transition: transform 0.15s ease;
}

.group-dropdown.open .group-tab-drop .caret {
    transform: rotate(180deg);
}

.group-menu {
    position: fixed;
    z-index: 60;
    display: none;
    min-width: 172px;
    max-height: 300px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.group-dropdown.open .group-menu {
    display: block;
}

.group-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 7px 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.group-menu-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.group-menu-item.active {
    background: rgba(61, 139, 253, 0.15);
    color: #9ec1ff;
}

.group-menu-item .mi-left {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.group-menu-item .mi-new {
    padding: 0 4px;
    border: 1px solid rgba(239, 83, 80, 0.45);
    border-radius: 4px;
    color: var(--up);
    font-size: 11px;
    line-height: 16px;
}

.group-menu-item .mi-cnt {
    color: var(--muted);
    font-size: 12px;
}

.list-meta {
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 13px;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 14px 0 8px;
}

.pager-btn {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
}

.pager-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.pager-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.pager-info {
    color: var(--muted);
    font-size: 13px;
}

.add-form input {
    flex: 1;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #121a24;
    color: var(--text);
    font-size: 15px;
}

.add-form button, .link-btn {
    height: 42px;
    padding: 0 18px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-size: 14px;
}

.link-btn {
    height: 30px;
    padding: 0 10px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
}

.link-btn:hover {
    color: var(--up);
    border-color: var(--up);
}

.toast {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
}

.toast-ok {
    background: rgba(38, 166, 154, 0.15);
    color: #80cbc4;
}

.toast-err {
    background: rgba(239, 83, 80, 0.15);
    color: #ef9a9a;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}

th {
    color: var(--muted);
    font-weight: 500;
    text-align: left;
    background: #151d29;
    user-select: none;
}

.th-sort {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    cursor: pointer;
}

.th-sort:hover,
.th-sort.active {
    color: var(--accent);
}

.num .th-sort {
    justify-content: flex-end;
    width: 100%;
}

.sort-mark {
    font-size: 12px;
    color: var(--accent);
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.code-copy {
    cursor: pointer;
}

.code-copy:hover {
    color: #9ec1ff;
    text-decoration: underline;
}

.code {
    font-family: Consolas, monospace;
    color: #9ec1ff;
}

.up {
    color: var(--up);
}

.down {
    color: var(--down);
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 36px 10px;
}

.hint {
    margin-top: 14px;
}

/* K 线看板 */
.kline-board {
    margin-top: 28px;
}

.kline-board-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.period-switch {
    display: inline-flex;
    gap: 6px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 4px;
}

.period-btn {
    height: 30px;
    padding: 0 14px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
}

.period-btn:hover {
    color: var(--text);
}

.period-btn.active {
    background: var(--accent);
    color: #fff;
}

.kline-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.kline-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 12px 8px;
    min-height: 320px;
    display: flex;
    flex-direction: column;
}

.kline-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.kline-title {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.kline-name {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kline-chg {
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.kline-chart {
    width: 100%;
    height: 260px;
    flex: 1;
}

.kline-status {
    color: var(--muted);
    font-size: 13px;
    padding: 48px 8px;
    text-align: center;
}

.kline-status.err {
    color: #ef9a9a;
}

.header-user {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 6px;
}

.header-user .who {
    color: var(--text);
    font-size: 13px;
}

.logout-btn {
    height: 28px;
    padding: 0 10px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
}

.logout-btn:hover {
    color: var(--up);
    border-color: var(--up);
}

/* 头部导航入口（链接形态，复用 logout-btn 尺寸） */
a.nav-entry {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: var(--accent);
    border-color: rgba(61, 139, 253, .5);
}

a.nav-entry:hover {
    color: #8fc2ff;
    border-color: var(--accent);
}

.table-wrap {
    position: relative;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

.table-scroll table {
    min-width: 880px;
}

.table-scroll th:nth-child(1),
.table-scroll td:nth-child(1) {
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 76px;
    background: #1a2332;
    box-shadow: 6px 0 8px -6px rgba(0, 0, 0, 0.55);
}

.table-scroll th:nth-child(1) {
    background: #151d29;
    z-index: 3;
}

.table-swipe-hint {
    display: none;
    margin: -4px 0 10px;
    color: var(--muted);
    font-size: 12px;
}

.loading-mask {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(15, 20, 25, 0.45);
    align-items: center;
    justify-content: center;
    color: #9ec1ff;
    font-size: 14px;
    z-index: 2;
}

.loading-mask.show {
    display: flex;
}

.busy-dim {
    opacity: 0.72;
    pointer-events: none;
}

.group-tab {
    cursor: pointer;
}

.th-sort,
.pager-btn {
    cursor: pointer;
    background: none;
    border: 0;
    font: inherit;
}

button.group-tab {
    font-family: inherit;
    background: transparent;
}

.auth-body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    padding-top: max(24px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 28px 24px 22px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 16px;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
}

.auth-form input {
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #121a24;
    color: var(--text);
    font-size: 15px;
}

.auth-form button {
    height: 42px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-size: 15px;
    margin-top: 4px;
}

.auth-switch {
    margin: 16px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.auth-switch a {
    color: var(--accent);
    text-decoration: none;
}

.toast-host {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 90;
    width: min(520px, calc(100% - 32px));
    pointer-events: none;
}

.toast-host .toast {
    pointer-events: auto;
    margin-bottom: 0;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
}

.confirm-host {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 80;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.confirm-host.show {
    display: flex;
}

.confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 12, 18, 0.62);
}

.confirm-box {
    position: relative;
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 22px 20px 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.confirm-box p {
    margin: 0 0 18px;
    line-height: 1.6;
    font-size: 15px;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.confirm-cancel,
.confirm-ok {
    height: 36px;
    padding: 0 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.confirm-cancel {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text);
}

.confirm-ok {
    background: var(--accent);
    border: 0;
    color: #fff;
}

.confirm-ok.danger {
    background: linear-gradient(135deg, #ef5350, #e53935);
}

#quoteBody tr.row-link {
    cursor: pointer;
}

#quoteBody tr.row-link:hover {
    background: rgba(61, 139, 253, 0.08);
}

.kline-card-link {
    cursor: pointer;
}

.kline-card-link:hover {
    border-color: var(--accent);
}

.kline-open {
    font-size: 12px;
    color: var(--accent);
    margin-left: 8px;
}

.detail-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
}

.back-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.detail-hero {
    padding: 18px 20px 14px;
    margin-bottom: 14px;
}

.detail-hero-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.detail-hero h1 {
    margin: 0 0 4px;
    font-size: 24px;
}

.detail-code {
    margin: 0;
    font-family: Consolas, monospace;
    color: #9ec1ff;
    font-size: 14px;
    cursor: pointer;
    display: inline-block;
}

.detail-code:hover {
    text-decoration: underline;
}

.detail-price-box {
    text-align: right;
}

.detail-price {
    font-size: 32px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.detail-chg {
    margin-top: 6px;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.detail-stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
}

.detail-stats .stat {
    background: #121a24;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
}

.detail-stats .stat span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}

.detail-stats .stat strong {
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.detail-chart-card {
    padding: 16px 16px 10px;
}

.detail-chart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.detail-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.detail-chart {
    width: 100%;
    height: 460px;
    cursor: pointer;
}

.detail-chart-status {
    color: var(--muted);
    text-align: center;
    padding: 48px 8px;
}

.detail-bar-info {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    min-height: 18px;
}

.detail-chart-card.is-intraday #periodSwitch,
.detail-chart-card.is-intraday #rangeSwitch {
    display: none;
}

#btnBackKline {
    display: none;
    background: rgba(61, 139, 253, 0.16);
    color: #9ec1ff;
}

.detail-chart-card.is-intraday #btnBackKline {
    display: inline-flex;
    align-items: center;
}

@media (max-width: 1100px) {
    .kline-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 800px) {
    .page {
        padding: 14px 12px 28px;
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-bottom: max(28px, calc(16px + env(safe-area-inset-bottom)));
    }

    h1 {
        font-size: 22px;
    }

    .sub {
        font-size: 12px;
    }

    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-bottom: 14px;
    }

    .header-meta {
        text-align: left;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px 14px;
    }

    .header-user {
        justify-content: space-between;
        width: 100%;
        margin-bottom: 0;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .add-form {
        width: 100%;
    }

    .add-form input,
    .add-form button,
    .accent-btn,
    .ghost-btn {
        min-height: 44px;
        height: 44px;
        font-size: 16px;
    }

    .accent-btn,
    .ghost-btn {
        width: 100%;
    }

    .group-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        margin-bottom: 8px;
    }

    .group-tab {
        flex: 0 0 auto;
        padding: 8px 12px;
        font-size: 13px;
    }

    .group-dropdown {
        flex: 0 0 auto;
    }

    .list-meta {
        font-size: 12px;
        line-height: 1.5;
    }

    .table-swipe-hint {
        display: block;
    }

    .table-scroll {
        max-width: 100%;
    }

    th, td {
        padding: 10px 8px;
        font-size: 13px;
        white-space: nowrap;
    }

    td.empty {
        white-space: normal;
    }

    .pager {
        gap: 8px;
        flex-wrap: wrap;
    }

    .pager-btn {
        min-height: 40px;
        padding: 8px 16px;
        font-size: 14px;
    }

    .kline-board-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .kline-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .kline-card {
        min-height: 280px;
        padding: 10px 8px 6px;
    }

    .kline-chart {
        height: 220px;
    }

    .period-btn {
        min-height: 36px;
        padding: 0 16px;
    }

    .detail-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .detail-hero-main {
        flex-direction: column;
    }

    .detail-price-box {
        text-align: left;
    }

    .detail-price {
        font-size: 28px;
    }

    .detail-chart {
        height: 340px;
    }

    .hint {
        font-size: 12px;
        line-height: 1.55;
    }

    .auth-card {
        padding: 22px 16px 18px;
    }

    .auth-form input,
    .auth-form button {
        height: 44px;
        font-size: 16px;
    }
}

@media (max-width: 420px) {
    .table-scroll table {
        min-width: 820px;
    }

    .logout-btn {
        min-height: 32px;
    }
}
