:root {
    --bg: #f2f3f5;
    --card: #ffffff;
    --line: #efeff1;
    --text: #1a1a1a;
    --muted: #8a8a8a;
    --hint: #b0b0b0;
    --up: #e8453c;
    --down: #12a06a;
    --brand: #e8453c;
    --soft: #f7f8fa;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.app {
    max-width: 480px;
    min-height: 100vh;
    margin: 0 auto;
    background: var(--bg);
    padding-bottom: 84px;
    overflow-x: hidden;
}

/* 首页 / 已异动共用一个页面，切换 tab 只显隐面板，不跳转重载 */
.pane[hidden] {
    display: none !important;
}

.hd {
    padding: 18px 16px 6px;
}

.hd h1 {
    font-size: 21px;
    font-weight: 600;
    margin: 0;
    letter-spacing: .2px;
}

.hd .sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px 6px;
}

.fab {
    position: fixed;
    right: 20px; /* 回退：不支持 min() 的老浏览器用旧行为 */
    /* 跟随 480px 内容栏右下角：窄屏=贴视口右边 20px，宽屏=内容栏右缘 */
    left: calc(50% + min(50vw, 240px) - 74px);
    bottom: 28px;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: none;
    background: #e9eaed;
    color: #9a9aa2;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    z-index: 60;
    transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
}

.fab:active {
    transform: scale(0.92);
}

.fab svg {
    width: 24px;
    height: 24px;
    display: block;
    transition: transform 0.2s;
}

.fab.on {
    background: var(--up);
    color: #fff;
    box-shadow: 0 6px 18px rgba(232, 69, 60, 0.35);
}

.fab.on svg path {
    fill: currentColor;
}

.fab:disabled {
    opacity: 0.6;
}

@supports (bottom: env(safe-area-inset-bottom)) {
    .fab {
        bottom: calc(28px + env(safe-area-inset-bottom));
    }
}

.nav-back {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    line-height: 1.35;
    min-width: 0;
}

.nav-back i {
    width: 11px;
    height: 11px;
    border-left: 2.2px solid var(--text);
    border-bottom: 2.2px solid var(--text);
    transform: rotate(45deg);
    display: block;
    flex: 0 0 auto;
}

.nav-back span {
    font-size: 18px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.nav-back em {
    font-style: normal;
    color: var(--hint);
    font-size: 14px;
    font-weight: 400;
    margin-left: 2px;
}

.idx-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--line);
    margin: 12px 0 14px;
}

.idx-bar > div {
    background: var(--bg);
    padding: 4px 10px;
    min-width: 0;
}

.idx-bar .lb {
    font-size: 11.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.idx-bar .vl {
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.idx-bar .vl span {
    font-size: 11px;
    font-weight: 500;
    margin-left: 3px;
}

.card {
    background: var(--card);
    border-radius: 12px;
    padding: 16px;
    margin: 0 12px 12px;
}

.up {
    color: var(--up);
}

.down {
    color: var(--down);
}

.muted {
    color: var(--muted);
}

.hint {
    color: var(--hint);
}

.num {
    font-variant-numeric: tabular-nums;
}

.tag {
    display: inline-block;
    font-size: 11px;
    line-height: 1.5;
    padding: 1px 7px;
    border-radius: 4px;
    font-weight: 500;
}

.tag.high {
    background: #fdecea;
    color: var(--up);
}

.tag.safe {
    background: #e9f6ef;
    color: var(--down);
}

.tag.warn {
    background: #fdf3e6;
    color: #c07a12;
}

.stock-card {
    background: var(--card);
    border-radius: 12px;
    padding: 15px 16px;
    cursor: pointer;
}

.swipe-item {
    position: relative;
    margin: 0 12px 12px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--card);
}

.swipe-body {
    position: relative;
    background: var(--card);
    border-radius: 12px;
    will-change: transform;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y;
    box-shadow: 6px 0 16px -6px rgba(0, 0, 0, .22);
}

.swipe-del {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 82px;
    background: var(--card);
    border: none;
    padding: 0;
    cursor: pointer;
    border-radius: 0 12px 12px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--up);
}

.del-ico {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #fdeceb;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}

.swipe-del:active .del-ico {
    background: #f9dbd8;
}

.swipe-del svg {
    width: 19px;
    height: 19px;
    display: block;
}

.sc-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.sc-name {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.35;
}

.sc-name .tag {
    margin-left: 6px;
    vertical-align: 1px;
}

.sc-code {
    font-size: 13px;
    color: var(--muted);
    margin-top: 3px;
}

.sc-trig {
    text-align: right;
    white-space: nowrap;
}

.sc-trig b {
    display: block;
    font-size: 16px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.sc-trig span {
    font-size: 11px;
    color: var(--hint);
}

.sc-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: var(--soft);
    border-radius: 10px;
    padding: 12px 0;
    margin: 13px 0 10px;
}

.sc-stats > div {
    text-align: center;
}

.sc-stats > div + div {
    border-left: 1px solid #ececef;
}

.sc-stats b {
    display: block;
    font-size: 19px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

.sc-stats span {
    font-size: 11px;
    color: var(--muted);
}

.sc-rule {
    font-size: 12.5px;
    color: var(--muted);
    margin: 0;
    line-height: 1.65;
}

.foot-note {
    text-align: center;
    font-size: 12px;
    color: var(--hint);
    padding: 8px 16px 0;
}

.price-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    padding: 4px 16px 14px;
}

.price-row .pl {
    min-width: 0;
}

.price-row .pr {
    text-align: right;
    flex: 0 0 auto;
}

.price-row .p {
    font-size: 30px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}

.price-row .c {
    font-size: 15px;
    font-weight: 500;
    margin-top: 3px;
    font-variant-numeric: tabular-nums;
}

.price-row .pr .lb {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

.price-row .pr .vl {
    font-size: 15px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    margin-top: 2px;
}

.tier-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 0 12px 6px;
}

.tier-card {
    background: var(--card);
    border-radius: 12px;
    padding: 14px 14px 12px;
}

.tier-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.tier-head b {
    font-weight: 500;
    font-size: 13.5px;
}

.tier-val {
    font-size: 26px;
    font-weight: 600;
    margin: 7px 0 5px;
    font-variant-numeric: tabular-nums;
}

.tier-note {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.55;
}

.tier-note b {
    color: var(--up);
    font-weight: 500;
}

.tier-bar {
    height: 4px;
    background: #f0f0f2;
    border-radius: 2px;
    margin-top: 9px;
    overflow: hidden;
}

.tier-bar i {
    display: block;
    height: 100%;
    background: var(--up);
    border-radius: 2px;
}

.section-tip {
    font-size: 12px;
    color: var(--hint);
    padding: 10px 18px 12px;
    line-height: 1.6;
}

.table-wrap {
    padding: 0 4px 4px;
}

.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    table-layout: fixed;
}

.tbl th {
    text-align: left;
    color: var(--muted);
    font-weight: 400;
    padding: 10px 5px 8px;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
}

.tbl td {
    padding: 11px 5px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.tbl tr:last-child td {
    border-bottom: none;
}

.tbl .c-day {
    width: 26%;
}

.tbl .c-pct {
    width: 27%;
}

.tbl .c-rule {
    width: 47%;
}

.tbl .d1 {
    font-size: 12.5px;
    white-space: nowrap;
}

.tbl .d2 {
    font-size: 11px;
    color: var(--hint);
    margin-top: 1px;
    white-space: nowrap;
}

.tbl .pct {
    font-size: 13.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tbl .px {
    font-size: 10.5px;
    color: var(--hint);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tbl .rule-line {
    font-size: 11px;
    line-height: 1.6;
    color: var(--muted);
    white-space: nowrap;
}

.tbl .rule-line b {
    color: var(--text);
    font-weight: 500;
}

.tbl .rule-line.hot, .tbl .rule-line.hot b {
    color: var(--up);
}

.searchbar {
    padding: 8px 16px 0;
}

.searchbar .box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #e8e9ec;
    border-radius: 8px;
    padding: 9px 12px;
}

.searchbar input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    padding: 0;
}

.searchbar .clr {
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: #b9bac0;
    color: #fff;
    font-size: 12px;
    line-height: 17px;
    text-align: center;
    border: none;
    padding: 0;
    cursor: pointer;
    flex: 0 0 auto;
}

.result-head {
    padding: 14px 16px 8px;
    font-size: 13px;
    color: var(--muted);
}

.history {
    padding: 14px 16px 0;
}

.history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 8px;
}

.history-head button {
    border: none;
    background: none;
    color: var(--hint);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    padding: 2px 0;
}

.hist-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 2px;
    border-bottom: 0.5px solid var(--line);
    cursor: pointer;
}

.hist-item .nm {
    font-size: 14px;
}

.hist-item .cd {
    font-size: 12px;
    color: var(--hint);
    font-variant-numeric: tabular-nums;
}

.hist-del {
    margin-left: auto;
    width: 22px;
    height: 22px;
    border: none;
    background: none;
    color: var(--hint);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.result {
    padding: 0 12px;
}

.result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--card);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
    cursor: pointer;
}

.result-item:active {
    background: #f7f8fa;
}

.result-item .nm {
    font-size: 15px;
    font-weight: 500;
}

.result-item .cd {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.add-btn {
    border: 1px solid #9db8e0;
    color: #2f6fb0;
    background: #fff;
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.add-btn:disabled {
    border-color: var(--line);
    color: var(--hint);
}

.search-entry {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 12px 12px 0;
    padding: 11px 14px;
    background: #e8e9ec;
    border-radius: 10px;
    color: var(--hint);
    font-size: 14px;
    text-decoration: none;
}

.search-entry:active {
    background: #e0e1e5;
}

.search-entry .ico {
    width: 13px;
    height: 13px;
    border: 1.8px solid #9a9aa2;
    border-radius: 50%;
    position: relative;
    flex: 0 0 auto;
}

.search-entry .ico::after {
    content: "";
    position: absolute;
    width: 6px;
    height: 1.8px;
    background: #9a9aa2;
    transform: rotate(45deg);
    right: -4px;
    bottom: -1px;
    border-radius: 1px;
}

.tabbar {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: 100%;
    max-width: 480px;
    z-index: 50;
    display: flex;
    background: var(--card);
    box-shadow: 0 -2px 14px rgba(0, 0, 0, .07);
    padding-bottom: env(safe-area-inset-bottom);
}

.tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 7px 0 8px;
    text-decoration: none;
    color: var(--hint);
    font-size: 11px;
    letter-spacing: .3px;
}

.tabbar a.on {
    color: var(--up);
}

.tabbar a svg {
    width: 23px;
    height: 23px;
    display: block;
}

.empty {
    text-align: center;
    color: var(--hint);
    font-size: 13px;
    padding: 40px 20px;
    line-height: 1.8;
}

.loading {
    text-align: center;
    color: var(--hint);
    font-size: 13px;
    padding: 40px 20px;
}

.filters {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 10px 16px 6px;
    font-size: 13px;
    color: var(--muted);
}

.filters label {
    display: flex;
    align-items: center;
    gap: 5px;
}

.filters input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--up);
    margin: 0;
}

.filters .upd {
    margin-left: auto;
    font-size: 12px;
    color: var(--hint);
}

.group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 4px 12px;
}

.group-head b {
    font-size: 16px;
    font-weight: 600;
    position: relative;
    padding-left: 10px;
}

.group-head b::before {
    content: "";
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    background: var(--up);
    border-radius: 2px;
}

.group-head span {
    font-size: 12.5px;
    color: var(--muted);
}

.mv-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    table-layout: fixed;
}

.mv-tbl th {
    text-align: left;
    color: var(--muted);
    font-weight: 400;
    font-size: 12px;
    padding: 8px 6px;
    border-bottom: 1px solid var(--line);
}

.mv-tbl th.r, .mv-tbl td.r {
    text-align: right;
}

.mv-tbl td {
    padding: 12px 6px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.mv-tbl tbody tr {
    cursor: pointer;
}

.mv-tbl tbody tr:active {
    background: #f7f8fa;
}

.mv-tbl tr:last-child td {
    border-bottom: none;
}

.mv-tbl .c-nm {
    width: 30%;
}

.mv-tbl .c-date {
    width: 33%;
}

.mv-tbl .c-src {
    width: 17%;
}

.mv-tbl .c-st {
    width: 20%;
}

.mv-tbl .nm {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.3;
}

.mv-tbl .cd {
    font-size: 12px;
    color: var(--hint);
    margin-top: 3px;
    font-variant-numeric: tabular-nums;
}

.mv-tbl .d1, .mv-tbl .d2 {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
}

.mv-tbl .src {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.5;
}

.badge {
    display: inline-block;
    font-size: 12px;
    padding: 1px 7px;
    border-radius: 4px;
    white-space: nowrap;
}

.badge.red {
    background: #fdecea;
    color: var(--up);
    font-weight: 500;
}

.badge.plain {
    color: var(--muted);
}
