/* ──────────────────────────────────────────────────────────
 * Wise 风 + 紧凑全屏版 — copybot 后台
 * ──────────────────────────────────────────────────────── */
:root {
    --color-bg: #ffffff;
    --color-canvas: #f7f8f4;
    --color-text: #0e0f0c;
    --color-text-muted: #454745;
    --color-text-faded: #868685;
    --color-surface: #e8ebe6;
    --color-mint: #e2f6d5;
    --color-green: #9fe870;
    --color-green-hover: #cdffad;
    --color-green-deep: #163300;
    --color-positive: #054d28;
    --color-danger: #d03238;
    --color-warning: #ffd11a;
    --ring: 0 0 0 1px rgba(14, 15, 12, 0.10);
    --radius-pill: 9999px;
    --radius-card: 18px;
    --radius-md: 12px;
    --topbar-h: 52px;
    --gap: 12px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--color-canvas);
    color: var(--color-text);
    font-family: 'Inter', system-ui, -apple-system, 'Helvetica', 'Arial', sans-serif;
    font-weight: 600;
    font-size: 14px;
    font-feature-settings: "calt" 1;
    -webkit-font-smoothing: antialiased;
}

/* 全屏 flex 布局 — 不让 body / main 出现外层滚动 */
html, body { height: 100%; }
body { display: flex; flex-direction: column; overflow: hidden; }

a { color: var(--color-text); text-decoration: none; }

button {
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: transparent;
    color: inherit;
    transition: transform 120ms ease;
}
button:active { transform: scale(0.96); }

/* ── 排版 ───────────────────────────────────────────── */
.h1 { font-size: 22px; font-weight: 900; line-height: 1; letter-spacing: -0.02em; margin: 0; }
.h2 { font-size: 18px; font-weight: 900; line-height: 1; margin: 0; }
.h3 { font-size: 14px; font-weight: 700; line-height: 1.2; margin: 0; }
.caption {
    font-size: 11px; font-weight: 700; line-height: 1.2;
    color: var(--color-text-faded); letter-spacing: 0.02em;
    text-transform: uppercase;
}
.small { font-size: 12px; line-height: 1.4; }
.muted { color: var(--color-text-muted); }
.faded { color: var(--color-text-faded); }
.mono { font-variant-numeric: tabular-nums; }

/* ── 顶栏 ───────────────────────────────────────────── */
.topbar {
    flex-shrink: 0;
    height: var(--topbar-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
    background: var(--color-bg);
    box-shadow: var(--ring);
    z-index: 50;
}
.brand {
    display: flex; align-items: center; gap: 8px;
    font-size: 16px; font-weight: 900;
}
.brand .dot {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--color-green);
    box-shadow: var(--ring);
}
.topbar nav { display: flex; gap: 2px; }
.topbar nav button {
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--color-text-muted);
    font-size: 13px;
    transition: background 120ms ease, color 120ms ease;
}
.topbar nav button:hover { background: rgba(211, 242, 192, 0.4); color: var(--color-text); }
.topbar nav button.active {
    background: var(--color-green);
    color: var(--color-green-deep);
}

.topbar .right { display: flex; align-items: center; gap: 8px; }
.user-pill {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 10px 4px 4px;
    border-radius: var(--radius-pill);
    background: rgba(22, 51, 0, 0.06);
    font-size: 12px;
}
.user-pill .avatar {
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--color-green); color: var(--color-green-deep);
    display: grid; place-items: center; font-size: 12px; font-weight: 900;
}

/* ── 主体 — flex 列填充 ─────────────────────────────────── */
main {
    flex: 1; min-height: 0;
    display: flex; flex-direction: column;
    padding: var(--gap);
    overflow: hidden;
}

/* tab 面板：默认 hidden；激活时变为 flex 列填满 main */
.tab-panel { display: none; }
.tab-panel.active {
    flex: 1; min-height: 0;
    display: flex; flex-direction: column;
    gap: var(--gap);
    overflow: hidden;
}

/* 配置/通知 tab 内容稀疏 → 面板内自带垂直滚动 */
.tab-panel.scroll.active { overflow-y: auto; }

.section-head {
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 8px;
}
.section-head .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* 卡片 */
.card {
    background: var(--color-bg);
    border-radius: var(--radius-card);
    box-shadow: var(--ring);
    padding: 14px 16px;
}
.card-head {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; margin-bottom: 10px;
}

/* metric */
.metrics {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}
.metric {
    background: var(--color-bg);
    border-radius: var(--radius-card);
    box-shadow: var(--ring);
    padding: 10px 14px;
}
.metric .label {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.02em;
    color: var(--color-text-faded);
    margin-bottom: 4px;
}
.metric .value {
    font-weight: 900;
    font-size: 22px;
    line-height: 1;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}
.metric .sub { margin-top: 4px; font-size: 11px; color: var(--color-text-muted); }
.metric.accent { background: var(--color-mint); box-shadow: 0 0 0 1px rgba(22, 51, 0, 0.10); }
.metric.accent .value { color: var(--color-green-deep); }

/* 状态徽章 */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    font-size: 11px; font-weight: 700;
    background: var(--color-surface);
    color: var(--color-text);
    line-height: 1.1;
}
.badge .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--color-text-faded); }
.badge.running { background: var(--color-mint); color: var(--color-green-deep); }
.badge.running .pulse { background: var(--color-positive); animation: pulse 1.4s infinite; }
.badge.stopped { background: rgba(208, 50, 56, 0.12); color: var(--color-danger); }
.badge.stopped .pulse { background: var(--color-danger); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* 按钮 */
.btn {
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-size: 13px; font-weight: 700;
    transition: transform 120ms ease, background 120ms ease;
    line-height: 1.2;
}
.btn:hover { transform: scale(1.04); }
.btn.primary { background: var(--color-green); color: var(--color-green-deep); }
.btn.primary:hover { background: var(--color-green-hover); }
.btn.secondary { background: rgba(22, 51, 0, 0.08); color: var(--color-text); }
.btn.danger   { background: rgba(208, 50, 56, 0.12); color: var(--color-danger); }
.btn.danger:hover { background: rgba(208, 50, 56, 0.20); }
.btn.ghost { background: transparent; box-shadow: var(--ring); color: var(--color-text); }
.btn.sm { padding: 4px 10px; font-size: 12px; }

/* 表格容器 — 高度自适应填充其父 flex */
.table-wrap {
    background: var(--color-bg);
    border-radius: var(--radius-card);
    box-shadow: var(--ring);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.table-wrap.fill { flex: 1; }
.table-wrap > header {
    flex-shrink: 0;
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 14px;
    border-bottom: 1px solid rgba(14, 15, 12, 0.06);
}
.table-scroll {
    flex: 1; min-height: 0;
    overflow-y: auto; overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th {
    position: sticky; top: 0;
    background: var(--color-bg);
    text-align: left;
    padding: 8px 12px;
    font-weight: 700;
    color: var(--color-text-faded);
    text-transform: uppercase;
    font-size: 11px; letter-spacing: 0.02em;
    border-bottom: 1px solid rgba(14, 15, 12, 0.06);
    white-space: nowrap;
}
tbody td {
    padding: 7px 12px;
    border-bottom: 1px solid rgba(14, 15, 12, 0.04);
    vertical-align: middle;
    white-space: nowrap;
}
tbody tr:hover { background: rgba(159, 232, 112, 0.06); }
tbody tr.fresh { animation: row-pop 600ms ease; }
@keyframes row-pop { 0% { background: var(--color-mint); } 100% { background: transparent; } }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.col-market { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }

.status-pill {
    display: inline-block; padding: 1px 8px;
    border-radius: var(--radius-pill);
    font-size: 11px; font-weight: 700; line-height: 1.4;
}
.status-pill.executed { background: var(--color-mint); color: var(--color-positive); }
.status-pill.skipped  { background: var(--color-surface); color: var(--color-text-muted); }
.status-pill.failed   { background: rgba(208, 50, 56, 0.12); color: var(--color-danger); }
.status-pill.leader   { background: rgba(56, 200, 255, 0.12); color: #1a73a3; }
.side-buy  { color: var(--color-positive); font-weight: 700; }
.side-sell { color: var(--color-danger);   font-weight: 700; }
.pnl-pos { color: var(--color-positive); font-weight: 700; }
.pnl-neg { color: var(--color-danger); font-weight: 700; }

/* 表单 */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px 14px;
}
.field { display: flex; flex-direction: column; gap: 3px; }
.field label {
    font-size: 11px; font-weight: 700;
    color: var(--color-text-faded);
    letter-spacing: 0.02em; text-transform: uppercase;
}
.field input, .field select {
    font: inherit; font-size: 13px; font-weight: 600;
    padding: 7px 10px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(14, 15, 12, 0.12);
    background: var(--color-bg);
    color: var(--color-text);
    transition: box-shadow 120ms ease, border-color 120ms ease;
}
.field input:focus, .field select:focus {
    outline: none;
    border-color: var(--color-green);
    box-shadow: 0 0 0 3px rgba(159, 232, 112, 0.30);
}
.field .hint { font-size: 11px; color: var(--color-text-faded); font-weight: 500; }
.field-inline {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border-radius: var(--radius-md);
    box-shadow: var(--ring);
    font-size: 13px;
}
.field-inline input[type="checkbox"] {
    appearance: none;
    width: 32px; height: 18px; border-radius: 999px;
    background: rgba(14, 15, 12, 0.18);
    position: relative;
    transition: background 120ms ease;
    cursor: pointer; flex-shrink: 0;
}
.field-inline input[type="checkbox"]::before {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 14px; height: 14px;
    border-radius: 50%; background: white;
    transition: transform 160ms ease;
}
.field-inline input[type="checkbox"]:checked { background: var(--color-green); }
.field-inline input[type="checkbox"]:checked::before { transform: translateX(14px); }

.toolbar {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    margin-top: 12px;
}

/* 通知吐司 — 右上角，避开顶栏 */
.toast {
    position: fixed; top: calc(var(--topbar-h) + 12px); right: 16px;
    background: var(--color-text); color: white;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-weight: 600; font-size: 13px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
    transform: translateX(140%);
    transition: transform 240ms ease;
    z-index: 200;
    max-width: 420px;
}
.toast.show { transform: translateX(0); }
.toast.ok  { background: var(--color-green-deep); color: var(--color-green); }
.toast.err { background: var(--color-danger); color: white; }

/* 模式横幅 — paper 时黄色提醒 */
.mode-banner {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 13px; font-weight: 700;
    margin-bottom: 12px;
}
.mode-banner.paper {
    background: rgba(255, 209, 26, 0.18);
    color: #6b4f00;
    box-shadow: 0 0 0 1px rgba(255, 209, 26, 0.5);
}
.mode-banner.live {
    background: var(--color-mint);
    color: var(--color-green-deep);
    box-shadow: 0 0 0 1px rgba(22, 51, 0, 0.18);
}
.mode-banner .icon { font-size: 16px; }
.mode-banner .small { font-weight: 500; }

/* 危险区域 */
.card.danger-zone {
    background: rgba(208, 50, 56, 0.04);
    box-shadow: 0 0 0 1px rgba(208, 50, 56, 0.18);
}
.card.danger-zone h3 { color: var(--color-danger); }

/* ── Modal 详情弹窗 ───────────────────────────────────── */
.modal-mask {
    position: fixed; inset: 0;
    background: rgba(14, 15, 12, 0.45);
    backdrop-filter: blur(4px);
    z-index: 300;
    display: none;
    align-items: center; justify-content: center;
    padding: 24px;
}
.modal-mask.show { display: flex; animation: fade-in 160ms ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
    background: var(--color-bg);
    border-radius: var(--radius-card);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.20), var(--ring);
    width: 100%; max-width: 640px;
    max-height: 86vh;
    display: flex; flex-direction: column;
    transform: translateY(8px);
    animation: pop-in 200ms cubic-bezier(.2,.8,.2,1) forwards;
}
@keyframes pop-in { to { transform: translateY(0); } }
.modal header {
    flex-shrink: 0;
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(14, 15, 12, 0.06);
}
.modal header .title { font-weight: 900; font-size: 14px; }
.modal .body { flex: 1; min-height: 0; overflow-y: auto; padding: 0; }
.modal .close {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--color-surface);
    display: grid; place-items: center;
    font-size: 16px;
}
.modal .close:hover { background: var(--color-mint); }

/* hero 区：图片 + 标题 + 副标题 */
.modal-hero {
    display: flex; gap: 14px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(14, 15, 12, 0.06);
    background: linear-gradient(180deg, var(--color-canvas) 0%, var(--color-bg) 100%);
}
.modal-hero .thumb {
    flex-shrink: 0;
    width: 64px; height: 64px;
    border-radius: 14px;
    object-fit: cover;
    background: var(--color-surface);
    box-shadow: var(--ring);
}
.modal-hero .thumb-fallback {
    flex-shrink: 0;
    width: 64px; height: 64px;
    border-radius: 14px;
    background: var(--color-mint);
    color: var(--color-green-deep);
    display: grid; place-items: center;
    font-weight: 900; font-size: 24px;
    box-shadow: var(--ring);
}
.modal-hero .meta { flex: 1; min-width: 0; }
.modal-hero .h-title {
    font-size: 16px; font-weight: 900; line-height: 1.25;
    margin-bottom: 4px;
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.modal-hero .h-sub {
    font-size: 13px; color: var(--color-text-muted);
    margin-bottom: 6px;
}
.modal-hero .h-tags {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-top: 4px;
}

/* 分组 */
.modal-section { padding: 14px 20px; border-bottom: 1px solid rgba(14, 15, 12, 0.06); }
.modal-section:last-child { border-bottom: none; }
.modal-section-title {
    font-size: 11px; font-weight: 700;
    color: var(--color-text-faded);
    letter-spacing: 0.02em; text-transform: uppercase;
    margin-bottom: 10px;
}

/* 横排小指标 */
.modal-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
}
.modal-stats .stat {
    background: var(--color-canvas);
    border-radius: var(--radius-md);
    padding: 8px 12px;
}
.modal-stats .stat .k {
    font-size: 10px; font-weight: 700;
    color: var(--color-text-faded);
    letter-spacing: 0.02em; text-transform: uppercase;
    margin-bottom: 2px;
}
.modal-stats .stat .v {
    font-size: 16px; font-weight: 900;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

/* 长 ID 行：左标签 + 右单行 + 复制 */
.id-row {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 0;
}
.id-row .k {
    flex-shrink: 0;
    width: 78px;
    font-size: 11px; font-weight: 700;
    color: var(--color-text-faded);
    letter-spacing: 0.02em; text-transform: uppercase;
}
.id-row .v {
    flex: 1; min-width: 0;
    font-family: 'Inter', monospace;
    font-size: 12px;
    background: var(--color-canvas);
    padding: 6px 10px;
    border-radius: var(--radius-md);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.id-row .copy-mini {
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    background: var(--color-surface);
    font-size: 11px; font-weight: 700;
    transition: background 120ms;
}
.id-row .copy-mini:hover { background: var(--color-mint); color: var(--color-green-deep); }

/* 详情说明文本 */
.modal-text {
    background: var(--color-canvas);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-all;
}

/* 链接按钮 */
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* 表格行可点击 */
tbody tr.clickable { cursor: pointer; }

/* 已清仓样式：浅灰 */
tbody tr.closed td { color: var(--color-text-faded); }
tbody tr.closed td:not(.no-fade) { opacity: 0.7; }

.status-pill.open   { background: var(--color-mint); color: var(--color-positive); }
.status-pill.closed { background: var(--color-surface); color: var(--color-text-muted); }

/* ── 钱包卡片 ─────────────────────────────────────────── */
.wallet-card {
    background: var(--color-bg);
    border-radius: var(--radius-card);
    box-shadow: var(--ring);
    padding: 20px 24px;
}
.addr-box {
    display: flex; align-items: center; gap: 10px;
    background: var(--color-canvas);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-top: 8px;
}
.addr-box .addr {
    flex: 1; min-width: 0;
    font-family: 'Inter', monospace;
    font-size: 14px; font-weight: 700;
    word-break: break-all;
    line-height: 1.35;
}
.addr-box .copy {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    background: var(--color-green);
    color: var(--color-green-deep);
    font-size: 12px; font-weight: 700;
}
.addr-box .copy:hover { background: var(--color-green-hover); }

.kv-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed rgba(14, 15, 12, 0.08);
    font-size: 13px;
}
.kv-row:last-child { border-bottom: none; }
.kv-row .k { color: var(--color-text-faded); font-weight: 700; font-size: 11px; text-transform: uppercase; }
.kv-row .v { font-weight: 700; }

/* 双列布局，子元素都填高 */
.row-2 {
    flex: 1; min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: var(--gap);
}
.row-2 > * { min-height: 0; }

/* 登录页 */
.login-shell {
    height: 100vh;
    display: grid; place-items: center;
    background: var(--color-canvas);
    padding: 24px;
}
.login-card {
    background: var(--color-bg);
    border-radius: var(--radius-card);
    box-shadow: var(--ring);
    padding: 32px;
    width: 100%; max-width: 400px;
}
.login-card h1 { font-size: 32px; font-weight: 900; line-height: 0.9; margin: 0 0 6px; }
.login-card p { color: var(--color-text-muted); margin: 0 0 18px; font-size: 13px; }
.login-card .field { margin-bottom: 12px; }
.login-card .btn { width: 100%; padding: 10px 16px; font-size: 14px; }

/* ── 响应式：小屏取消高度锁定，让页面自然滚动 ─────────────── */
@media (max-width: 920px) {
    .row-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    body { height: auto; min-height: 100%; overflow: auto; }
    main { overflow: visible; padding: 8px; }
    .tab-panel.active { overflow: visible; min-height: 0; }
    .tab-panel.scroll.active { overflow-y: visible; }
    .table-wrap.fill { flex: none; }
    .table-scroll { max-height: 60vh; }
    .topbar { padding: 0 12px; flex-wrap: wrap; height: auto; gap: 8px; padding: 8px 12px; }
    .topbar nav { order: 3; width: 100%; overflow-x: auto; }
    .h1 { font-size: 18px; }
    .metric { padding: 8px 12px; }
    .metric .value { font-size: 18px; }
    thead th, tbody td { padding: 6px 10px; }
}
