/* Semantic colors cover every surface, including dynamically rendered results. */
:root {
  color-scheme: light;
  --bg: #f3f6fa; --panel: #ffffff; --sidebar: #ffffff; --surface: #f5f7fa;
  --line: #d6dfe9; --input-border: #8998ab; --hover: #e8eef5;
  --text: #182638; --secondary: #3e5066; --muted: #53657b;
  --mint: #17643c; --amber: #805300; --negative: #b4233a;
  --accent-soft: #eaf4ed; --accent-border: #94baa1; --notice-text: #285538;
  --primary: #216b43; --primary-text: #ffffff; --primary-hover: #195334;
  --danger-soft: #fff0f1; --danger-border: #c77985;
  --row-hover: #f0f5fa; --shadow: 0 4px 18px #1b304008;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1018; --panel: #151d29; --sidebar: #101722; --surface: #101722;
  --line: #344155; --input-border: #65758c; --hover: #263448;
  --text: #edf2f9; --secondary: #c1cddd; --muted: #a5b4c8;
  --mint: #b6f583; --amber: #f1cc83; --negative: #ff9eac;
  --accent-soft: #223428; --accent-border: #607b57; --notice-text: #c3dcbc;
  --primary: #b6f583; --primary-text: #15200e; --primary-hover: #cbffa1;
  --danger-soft: #35222c; --danger-border: #b87180;
  --row-hover: #1e2b3d; --shadow: none;
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--text);font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC",sans-serif;font-size:15px;line-height:1.7}
button,input,select{font:inherit}
button{cursor:pointer;color:inherit;transition:background .15s}
button:disabled{cursor:not-allowed;opacity:1;color:var(--muted);background:var(--surface);border-color:var(--line)}
a{color:var(--mint)}
button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid var(--mint);outline-offset:3px}
.sidebar{width:214px;position:fixed;inset:0 auto 0 0;border-right:1px solid var(--line);padding:32px 20px;display:flex;flex-direction:column;background:var(--sidebar)}
.brand{font-size:40px;color:var(--mint);display:flex;gap:10px;align-items:center;text-decoration:none;line-height:1}
.brand>span{font-size:32px;font-weight:750;letter-spacing:-1.5px;color:var(--text)}
.brand-dot{color:var(--mint)}
.workspace{font-size:12px;letter-spacing:2px;color:var(--muted);margin:42px 10px 16px}
.nav{width:100%;display:flex;gap:13px;align-items:center;background:none;border:0;text-align:left;padding:13px 12px;color:var(--muted);border-radius:7px;margin-bottom:6px}
.nav.active{background:var(--accent-soft);color:var(--mint)}
.nav:hover{background:var(--hover)}
.nav small{font-size:12px;border:1px solid var(--line);padding:0 4px;margin-left:auto}
.sidebar-bottom{margin-top:auto}
.sidebar-bottom p{font-size:14px;color:var(--muted);margin:18px 12px}
.private{font-size:14px;color:var(--muted);padding:12px;display:flex;gap:9px;align-items:center}
.private i{width:6px;height:6px;background:var(--mint);border-radius:50%}
main{margin-left:214px;padding:0 38px;max-width:1770px}
header{height:83px;border-bottom:1px solid var(--line);display:flex;justify-content:space-between;align-items:center;margin-bottom:36px}
.breadcrumb{font-size:14px;color:var(--muted)}
.breadcrumb span{margin:0 14px;color:var(--muted)}
.breadcrumb b{color:var(--text);font-weight:500}
.connection{font-size:14px;border:1px solid var(--line);border-radius:20px;background:var(--surface);padding:7px 13px;color:var(--mint)}
.heading{display:flex;justify-content:space-between;align-items:center;margin-bottom:23px;gap:20px}
.eyebrow{font-size:12px;letter-spacing:2px;color:var(--muted);font-weight:600}
h1{font-size:31px;letter-spacing:-1px;font-weight:650;margin:9px 0}
h1 span{color:var(--mint)}
h2{font-size:15px;font-weight:600;margin:0}
h3{font-size:17px;margin:12px 0}
p{margin:6px 0;color:var(--muted)}
.heading p{font-size:14px}
.tag{white-space:nowrap;color:var(--mint);font-size:14px;border:1px solid var(--accent-border);padding:9px 13px;border-radius:5px}
.notice{font-size:14px;padding:10px 15px;background:var(--accent-soft);color:var(--notice-text);border:1px solid var(--accent-border);border-radius:6px;margin-bottom:22px}
.research-grid{display:grid;grid-template-columns:minmax(0,1fr) 285px;gap:20px}
.main-column,.right-column{display:flex;flex-direction:column;gap:20px}
.card{background:var(--panel);border:1px solid var(--line);padding:22px;border-radius:10px}
.section-title{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:20px}
.section-title>span{font-size:12px;letter-spacing:1px;color:var(--muted)}
.subtle{font-size:14px;color:var(--muted)}
.control-row{display:flex;align-items:flex-end;gap:15px}
.control-row>label{flex:1;min-width:90px}
label,.label{display:block;font-size:14px;color:var(--secondary)}
input:not([type=checkbox]),select{display:block;width:100%;border:1px solid var(--input-border);border-radius:6px;background:var(--surface);color:var(--text);padding:10px 12px;margin-top:7px;outline-color:var(--mint)}
input[type=checkbox]{accent-color:var(--mint)}
.segmented{display:flex;border:1px solid var(--input-border);padding:3px;border-radius:7px;margin-top:7px;height:43px}
.segmented button{background:none;border:0;border-radius:4px;color:var(--muted);padding:4px 17px;white-space:nowrap}
.segmented .selected{background:var(--accent-soft);color:var(--mint)}
.outline{border:1px solid var(--input-border);background:transparent;padding:10px 14px;border-radius:6px;font-size:14px;white-space:nowrap}
.outline:hover{background:var(--hover)}
.primary{background:var(--primary);color:var(--primary-text);font-size:14px;font-weight:650;border:0;padding:12px 20px;border-radius:6px;white-space:nowrap}
.primary:hover{background:var(--primary-hover)}
.primary span{margin-left:35px}
#selected-source{margin-top:12px}
.analysis-options{display:flex;gap:20px;margin:20px 0 16px;flex-wrap:wrap}
.analysis-options label{display:flex;gap:7px;align-items:center}
.action-row{display:flex;align-items:center;gap:12px}
.action-row .subtle{font-size:12px;margin-left:auto}
.quote{display:flex;gap:20px;align-items:baseline}
.quote strong{font-size:31px;font-weight:550;letter-spacing:-.7px}
.quote .subtle{font-size:12px}
.pill{font-size:12px;border:1px solid var(--accent-border);padding:3px 9px;border-radius:4px;color:var(--mint)!important}
.chart{height:192px;margin-top:15px}
.chart svg{width:100%;height:100%}
.empty-chart{height:100%;display:grid;place-items:center;font-size:14px;color:var(--muted);background:repeating-linear-gradient(0deg,transparent,transparent 46px,var(--line) 47px)}
.metrics{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;border-top:1px solid var(--line);padding-top:17px;margin-top:14px}
.metrics>div{font-size:12px;color:var(--muted)}
.metrics strong{display:block;font-size:13px;font-weight:500;color:var(--text);margin-top:5px}
.empty-state{padding:25px 0 30px;text-align:center}
.empty-state h3{font-size:16px}
.empty-state p{font-size:14px;line-height:1.9}
.orb{font-size:30px;color:var(--mint);background:var(--accent-soft);width:60px;height:60px;margin:0 auto 16px;display:grid;place-items:center;border-radius:15px}
.watch-row{display:flex;gap:10px;align-items:center;border-bottom:1px solid var(--line);padding:13px 0}
.coin-icon{display:grid;place-items:center;width:30px;height:30px;background:var(--hover);color:var(--secondary);border-radius:50%;font-size:12px;font-weight:bold}
.watch-row>button:first-of-type{border:0;background:none;flex:1;text-align:left;font-size:14px}
.icon-button{background:none;border:0;color:var(--muted);padding:5px 8px}
.note{font-size:12px;line-height:1.9;margin-top:16px}
.source-row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:12px 0;border-bottom:1px solid var(--line);font-size:14px}
.source-row span{font-size:12px;color:var(--muted);text-align:right}
.source-row .ok{color:var(--mint)}
.source-row .amber,.amber{color:var(--amber)}
.accent-card{background:linear-gradient(120deg,var(--accent-soft),var(--surface));border-color:var(--accent-border)}
.accent-card h3{font-size:22px;line-height:1.6;font-weight:500}
.accent-card p{font-size:14px}
.market-list{margin-top:22px}
.market-list>input{max-width:280px;margin-bottom:16px}
.table-wrap{overflow:auto}
table{border-collapse:collapse;width:100%;white-space:nowrap;text-align:left}
th{font-size:12px;color:var(--muted);font-weight:500;padding:12px;border-bottom:1px solid var(--line)}
td{padding:14px 12px;font-size:14px;border-bottom:1px solid var(--line)}
td small{display:block;font-size:12px;color:var(--muted)}
.positive{color:var(--mint)}
.negative{color:var(--negative)}
.table-link{background:none;border:0;color:var(--text);text-align:left;padding:0}
.table-link:hover{color:var(--mint)}
.result-top{display:flex;align-items:center;justify-content:space-between}
.direction{font-size:14px;background:var(--accent-soft);color:var(--mint);padding:5px 12px;border-radius:5px}
.forecast-price{font-size:35px;letter-spacing:-1px;margin:10px 0}
.price-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:18px 0}
.price-grid>div{background:var(--surface);border:1px solid var(--line);border-radius:6px;padding:13px;color:var(--muted);font-size:12px}
.price-grid strong{display:block;font-size:17px;color:var(--text);font-weight:550;margin-top:5px}
.result h4{margin:20px 0 6px;font-size:14px}
.result p,.result li{font-size:14px;color:var(--secondary);line-height:1.9}
.result ul{padding-left:18px}
.result a{word-break:break-all;font-size:14px}
.error{color:var(--negative)!important;border-left:2px solid var(--negative);padding:10px 15px;background:var(--danger-soft);border-radius:3px}
.loading{color:var(--mint);padding:35px 10px;text-align:center}
.history-item{margin-bottom:14px}
.history-item button{margin-top:12px}
.hidden{display:none!important}
footer{display:flex;justify-content:space-between;gap:20px;color:var(--muted);font-size:12px;letter-spacing:1px;border-top:1px solid var(--line);padding:25px 0;margin-top:36px}
dialog{color:var(--text);background:var(--panel);border:1px solid var(--input-border);border-radius:12px;width:min(520px,94vw);padding:26px;max-height:90vh}
dialog::backdrop{background:#03060bcc;backdrop-filter:blur(6px)}
dialog label{margin-top:14px}
dialog .checkbox{display:flex;gap:7px}
dialog .action-row{margin-top:24px}
hr{border:0;border-top:1px solid var(--line);margin:20px 0}
.toast{position:fixed;bottom:28px;left:50%;transform:translateX(-50%);background:var(--accent-soft);border:1px solid var(--accent-border);color:var(--notice-text);box-shadow:0 12px 40px #0007;max-width:90vw;padding:12px 22px;border-radius:7px;z-index:10;font-size:14px}
.page{min-height:65vh}
#account-view .metrics{margin-bottom:24px}
@media(min-width:1500px){main{padding:0 60px}
.research-grid{grid-template-columns:minmax(0,1fr) 325px}
}
@media(max-width:1120px){.sidebar{width:175px;padding:30px 12px}
main{margin-left:175px;padding:0 24px}
.research-grid{grid-template-columns:minmax(0,1fr)}
.right-column{display:grid;grid-template-columns:1fr 1fr}
.accent-card{display:none}
}
@media(max-width:640px){.sidebar{position:static;width:100%;padding:16px;border-right:0;border-bottom:1px solid var(--line)}
.brand{font-size:28px}
.brand>span{font-size:24px}
.workspace,.sidebar-bottom{display:none}
nav{display:flex;gap:3px;margin-top:18px}
.nav{font-size:14px;padding:8px;gap:5px;margin:0;justify-content:center}
.nav small{display:none}
main{margin-left:0;padding:0 16px}
header{height:64px;margin-bottom:26px}
.heading{align-items:flex-start}
.heading h1{font-size:25px}
.tag{display:none}
.heading p{font-size:14px}
.card{padding:17px}
.control-row{flex-wrap:wrap}
.control-row>label{flex-basis:35%}
.control-row>.outline{display:none}
.action-row{flex-wrap:wrap}
.action-row .subtle{margin-left:0;width:100%}
.quote{flex-direction:column;gap:3px}
.right-column{grid-template-columns:1fr}
.research-grid{gap:16px}
.metrics{grid-template-columns:1fr 1fr}
.chart{height:165px}
.price-grid strong{font-size:14px}
.price-grid{gap:6px}
.breadcrumb{font-size:12px}
.connection{font-size:12px}
.heading>.primary{padding:10px}
.analysis-options{gap:10px}
.notice{font-size:12px}
footer{flex-direction:column}
.section-title{gap:8px}
.market-list .section-title{align-items:flex-start}
}

.account-summary{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;margin-bottom:20px}
.account-summary .card{display:flex;flex-direction:column;gap:9px}
.account-summary span{font-size:14px;color:var(--muted)}
.account-summary strong{font-size:25px;font-weight:550;line-height:1.4;overflow-wrap:anywhere}
.account-summary strong span{font-size:22px;color:inherit}
.account-summary strong .positive{color:var(--mint)}
.account-summary strong .negative{color:var(--negative)}
.account-summary small{font-size:12px;color:var(--muted)}
.portfolio-section{margin-bottom:20px}
.positions-table{min-width:1220px}
.position-actions{display:flex;gap:5px}
.position-actions .outline{padding:7px 9px}
.positions-table td{vertical-align:top}
.positions-table td:last-child{max-width:280px}
.positions-table td:last-child small{white-space:normal;margin-top:7px}
.positions-table small.positive{color:var(--mint)}
.positions-table small.negative{color:var(--negative)}
.auth-status{padding:18px 0;color:var(--mint)}
details{margin:20px 0}
summary{cursor:pointer;color:var(--muted);font-size:14px}
#protection-status{color:var(--amber);font-size:14px}
#account-summary .card{min-height:136px}
@media(max-width:760px){.account-summary{grid-template-columns:1fr}
.account-summary .card{min-height:100px!important}
.segmented button{padding:4px 10px}
.control-row{flex-wrap:wrap}
.account-summary strong{font-size:24px}
}


#execution-dialog{width:min(760px,94vw);overflow-y:auto}
#execution-list .price-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
#execution-list p,#execution-review p{line-height:1.7;font-size:14px;overflow-wrap:anywhere}
#execution-list button{margin-right:10px}
#execution-budget{margin-bottom:12px}
@media(max-width:700px){#execution-list .price-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}


.positions-table{min-width:1030px;font-variant-numeric:tabular-nums}
.positions-table th,.positions-table td{padding:13px 10px}
.positions-table .position-coin{min-width:70px;position:sticky;left:0;background:var(--panel);z-index:1}
.positions-table th:first-child{position:sticky;left:0;background:var(--panel);z-index:2}
.positions-table .position-coin b{font-size:15px;letter-spacing:.2px}
.positions-table td:nth-child(4) b{font-size:13px}
.positions-table td:nth-child(5){font-size:13px}
.positions-table .position-actions{gap:4px}
.positions-table .position-actions .outline{padding:6px 8px;font-size:14px}
.positions-table td:last-child{min-width:145px;max-width:190px}
.positions-table td:last-child>.outline{padding:7px 9px;font-size:14px}
.close-position-button{margin-left:5px;border-color:var(--danger-border);color:var(--negative)}
.positions-table td:last-child small{font-size:12px;line-height:1.6}
.close-presets{display:flex;gap:8px;margin-top:16px}
.close-presets button{flex:1;padding:9px}
#close-position-status{color:var(--amber);font-size:14px}
#close-position-dialog p{line-height:1.7}
@media(max-width:760px){.positions-table{min-width:960px}
.positions-table th,.positions-table td{padding:11px 8px}
}


.exchange-orders-table{min-width:1000px;font-variant-numeric:tabular-nums}
.exchange-orders-table td{vertical-align:top;white-space:normal;min-width:105px}
.exchange-orders-table td:nth-child(4){min-width:250px;max-width:420px}
.exchange-orders-table small{overflow-wrap:anywhere}
.position-orders{margin:8px 0 0}
.position-orders summary{font-size:12px;line-height:1.7;color:var(--mint)}
.position-orders small{border-top:1px solid var(--line);padding-top:6px;margin-top:6px}


#scan-progress{margin-bottom:20px}
#scan-progress progress{width:100%;accent-color:var(--mint);height:7px}
.scan-reason{min-width:220px;white-space:normal}
#scan-table small{display:block;opacity:1;margin-top:5px}
#scan-recommendations details{margin-top:16px}


.autopilot-grid{display:grid;grid-template-columns:1.5fr 1fr;gap:20px;margin:20px 0}
.autopilot-fields{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.autopilot-decision{border-bottom:1px solid var(--line);padding:14px 0}
#autopilot-dialog{max-width:720px}
@media(max-width:900px){.autopilot-grid{grid-template-columns:1fr}
}
@media(max-width:520px){.autopilot-fields{grid-template-columns:1fr}
}


/* Shared reading rhythm and controls. */
body { -webkit-font-smoothing: antialiased; }
p { color: var(--secondary); }
h2 { font-size: 18px; line-height: 1.5; }
h3 { font-size: 19px; }
small { font-size: 12px; }
button { min-height: 40px; }
button:disabled:hover { color: var(--muted); background: var(--surface); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--mint); outline-offset: 3px;
}
input:not([type=checkbox]), select { font-size: 16px; min-height: 44px; }
input::placeholder { color: var(--muted); opacity: 1; }
input[type=checkbox] { width: 17px; height: 17px; flex-shrink: 0; }
label, .label { font-size: 14px; line-height: 1.7; }
.header-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; }
header { height: auto; min-height: 84px; gap: 18px; padding: 16px 0; }
.theme-toggle { background: var(--panel); font-size: 14px; }
.connection { font-size: 13px; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.breadcrumb { flex-shrink: 0; font-size: 13px; }
.breadcrumb b { font-weight: 650; }
.sidebar { overflow-y: auto; }
.workspace { letter-spacing: 1px; margin-left: 8px; }
.nav { font-size: 15px; min-height: 46px; }
.nav.active { font-weight: 650; box-shadow: inset 3px 0 var(--mint); }
.heading, .section-title, .action-row, .result-top { flex-wrap: wrap; }
.heading p { max-width: 80ch; }
.notice { font-size: 14px; line-height: 1.9; padding: 14px 18px; overflow-wrap: anywhere; }
.card { box-shadow: var(--shadow); min-width: 0; }
.main-column, .right-column, .page { min-width: 0; }
.section-title > span { font-size: 12px; letter-spacing: 0; }
.outline, .primary { font-size: 14px; }
.icon-button { min-width: 40px; }
.segmented { height: auto; min-height: 46px; }
.segmented button { min-height: 36px; font-size: 14px; }
.segmented .selected { font-weight: 650; }
.control-row { flex-wrap: wrap; }
.action-row .subtle { font-size: 13px; }
.quote { flex-wrap: wrap; }
.quote .subtle, .metrics > div { font-size: 13px; }
.metrics strong { font-size: 16px; overflow-wrap: anywhere; }
.subtle, .note { font-size: 13px; line-height: 1.8; }
.source-row { flex-wrap: wrap; font-size: 14px; }
.source-row span { font-size: 12px; }
.watch-row > button:first-of-type { font-size: 14px; }
.coin-icon { flex-shrink: 0; }
.price-grid > div { font-size: 13px; min-width: 0; }
.price-grid strong { font-size: 18px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.result h4 { font-size: 16px; }
.result p, .result li, #execution-list p, #execution-review p { font-size: 15px; line-height: 1.9; }
.result li + li { margin-top: 12px; }
.result a { font-size: 14px; overflow-wrap: anywhere; word-break: normal; text-decoration: underline; text-underline-offset: 3px; }
summary { font-size: 14px; padding: 6px 0; }
details[open] > summary { margin-bottom: 10px; color: var(--text); }
.error:empty { display: none; }
.error { line-height: 1.8; overflow-wrap: anywhere; }
/* Keep complete financial values readable; wide tables scroll within their cards. */
.table-wrap { max-width: 100%; border: 1px solid var(--line); border-radius: 8px; scrollbar-color: var(--input-border) var(--surface); }
table { font-variant-numeric: tabular-nums; }
th { background: var(--surface); font-size: 13px; font-weight: 650; color: var(--secondary); }
td { font-size: 14px; }
th, td { padding: 15px 13px; }
tbody tr:hover { background: var(--row-hover); }
td small { font-size: 12px; line-height: 1.8; }
.positions-table th, .positions-table td { padding: 15px 12px; }
.positions-table th:first-child { background: var(--surface); }
.positions-table .position-coin { box-shadow: 1px 0 var(--line); }
.positions-table tr:hover .position-coin { background: var(--row-hover); }
.positions-table .position-coin b { font-size: 16px; }
.positions-table td:nth-child(4) b, .positions-table td:nth-child(5) { font-size: 15px; }
.positions-table .position-actions { gap: 6px; flex-wrap: wrap; min-width: 136px; }
.positions-table .position-actions .outline, .positions-table td:last-child > .outline { font-size: 13px; padding: 8px 10px; }
.positions-table td:last-child { min-width: 210px; max-width: 260px; }
.positions-table td:last-child small, .position-orders summary { font-size: 12px; }
.close-position-button:hover { background: var(--danger-soft); }
.account-summary span { font-size: 14px; }
.account-summary small { font-size: 12px; }
.account-summary strong { font-weight: 650; font-variant-numeric: tabular-nums; }
#scan-table small { opacity: 1; }
#scan-progress progress { height: 10px; }
.autopilot-grid { grid-template-columns: minmax(0,1.4fr) minmax(0,1fr); }
.autopilot-fields { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px 16px; }
.autopilot-decision { padding: 18px 0; overflow-wrap: anywhere; }
#autopilot-list .card { margin-bottom: 20px; }
dialog { padding: 28px; overscroll-behavior: contain; box-shadow: 0 20px 80px #0004; }
dialog p { font-size: 14px; line-height: 1.9; }
#autopilot-dialog, #execution-dialog { width: min(760px,94vw); max-width: 760px; }
#confirm-execution, #autopilot-confirm { width: 100%; margin-top: 16px; min-height: 46px; white-space: normal; }
.toast { font-size: 14px; line-height: 1.7; }
footer { font-size: 12px; letter-spacing: 0; }
@media (max-width: 1120px) {
  .sidebar { width: 190px; }
  main { margin-left: 190px; }
  .workspace { font-size: 11px; }
}
@media (max-width: 900px) {
  .autopilot-grid { grid-template-columns: minmax(0,1fr); }
  .heading { align-items: flex-start; }
}
@media (max-width: 640px) {
  .sidebar { width: 100%; padding: 16px; }
  nav { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; margin-top: 16px; }
  .nav { font-size: 14px; padding: 10px 6px; gap: 6px; min-height: 44px; }
  .sidebar-bottom { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
  .sidebar-bottom p { display: none; }
  .private { font-size: 12px; padding: 0 8px 0 0; }
  #open-settings { width: auto; margin: 0; font-size: 13px; }
  main { margin-left: 0; padding: 0 14px; }
  header { align-items: flex-start; flex-direction: column; gap: 10px; margin-bottom: 24px; }
  .header-actions { width: 100%; justify-content: flex-start; }
  .connection { flex: 1; font-size: 12px; }
  .breadcrumb { font-size: 13px; }
  .heading { gap: 12px; }
  .heading p { font-size: 14px; }
  .heading > .primary { white-space: normal; min-height: 44px; }
  .card { padding: 16px; }
  .notice { padding: 12px 14px; font-size: 14px; }
  .control-row > label { min-width: 120px; }
  .price-grid { gap: 10px; }
  .price-grid strong { font-size: 16px; }
  .positions-table th, .positions-table td { padding: 13px 10px; }
  .action-row > button { min-height: 44px; }
  dialog { padding: 20px 16px; max-height: 92dvh; }
  .toast { bottom: 16px; width: max-content; max-width: 92vw; }
}
@media (max-width: 520px) {
  .autopilot-fields { grid-template-columns: minmax(0,1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(440px,100%); }
.login-card label { margin: 24px 0; }
.login-card .primary { width: 100%; margin-bottom: 16px; }

/* Mobile application shell. Desktop tables remain available above 760px. */
.mobile-topbar, .mobile-tabs, .mobile-position-tag { display: none; }
.mobile-sheet { width: min(520px, 94vw); }
.new-mandate { margin: 0 0 20px; }
.new-mandate > summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; color: var(--mint); font-weight: 650; list-style: none; }
.new-mandate > summary small { color: var(--muted); font-weight: 400; }
.new-mandate[open] > summary { margin-bottom: 0; }
.mobile-menu-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.mobile-menu-grid button { text-align: left; padding: 18px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.mobile-menu-grid b, .mobile-menu-grid span { display: block; }
.mobile-menu-grid b { font-size: 15px; margin-bottom: 5px; }
.mobile-menu-grid span { font-size: 12px; color: var(--muted); }
.mobile-menu-footer { display: flex; gap: 12px; padding-top: 22px; margin: 0 0 12px; }
.mobile-menu-footer > * { flex: 1; }
.mobile-menu-footer form button { width: 100%; }
.sheet-handle { width: 32px; height: 4px; border-radius: 4px; background: var(--input-border); margin: 0 auto 20px; }
@media (max-width: 760px) {
  :root { --bg: #f4f6f9; --line: #e0e6ee; --mint: #126b50; --primary: #166c51; --accent-soft: #edf6f1; --muted: #596b80; }
  :root[data-theme="dark"] { --bg: #0d1420; --line: #303e51; --mint: #a9e6c8; --primary: #a9e6c8; --accent-soft: #203b32; --muted: #a9b8cc; }
  body { font-size: 14px; line-height: 1.65; -webkit-tap-highlight-color: transparent; }
  .sidebar, main > header, footer { display: none; }
  main { margin: 0; padding: 18px 16px 100px; width: 100%; }
  .mobile-topbar { display: flex; height: 60px; padding: 0 20px; align-items: center; justify-content: space-between; background: var(--panel); border-bottom: 1px solid var(--line); }
  .mobile-brand { display: flex; gap: 8px; align-items: center; color: var(--text); text-decoration: none; }
  .mobile-brand b { font-size: 25px; letter-spacing: -1px; font-weight: 750; }
  .brand-emblem { display: grid; place-items: center; width: 27px; height: 29px; border-radius: 8px; font-size: 18px; font-weight: 750; background: var(--primary); color: var(--primary-text); }
  .mobile-private { font-size: 11px; color: var(--muted); padding-left: 4px; }
  #mobile-settings { display: flex; align-items: center; gap: 6px; padding: 8px 0 8px 10px; background: none; border: 0; color: var(--muted); font-size: 12px; }
  #mobile-ai-dot { height: 6px; width: 6px; background: var(--mint); border-radius: 50%; }
  #mobile-ai-dot.offline { background: var(--amber); }
  .mobile-tabs { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); position: fixed; inset: auto 0 0; z-index: 8; margin: 0; gap: 0; padding: 8px 8px max(8px,env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -4px 20px #14203205; }
  .mobile-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 52px; border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 500; padding: 3px; }
  .mobile-tab svg { width: 23px; height: 23px; }
  .mobile-tab.active { color: var(--mint); font-weight: 750; }
  .mobile-tab.active svg { background: var(--accent-soft); border-radius: 8px; box-sizing: content-box; padding: 3px 13px; margin: -3px -13px; }
  .mobile-sheet { margin: auto 0 0; width: 100%; max-width: none; max-height: 85dvh; border-radius: 22px 22px 0 0; border-bottom: 0; padding: 14px 20px 28px; }
  dialog { width: calc(100% - 20px); padding: 22px 18px; border-radius: 18px; }
  dialog .section-title h2 { font-size: 18px; }
  .heading { gap: 10px; margin: 0 0 16px; }
  .heading .eyebrow { display: none; }
  .heading h1 { font-size: 24px; line-height: 1.35; letter-spacing: -.5px; margin: 0 0 6px; font-weight: 730; }
  .heading h1 span { display: none; }
  .heading p { font-size: 12px; line-height: 1.65; }
  #portfolio > .heading p { display: none; }
  #portfolio > .heading { align-items: center; margin-bottom: 12px; }
  #sync-account { font-size: 12px; background: none; color: var(--mint); padding: 7px 0 7px 12px; min-height: 36px; }
  #sync-status { background: none; border: 0; font-size: 11px; padding: 0; margin: -8px 0 16px; color: var(--muted); }
  #sync-status.error { padding: 10px 12px; background: var(--danger-soft); font-size: 13px; }
  .account-summary { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; margin-bottom: 24px; }
  #account-summary .card { border: 0; box-shadow: none; border-radius: 0; padding: 16px; min-height: 0 !important; gap: 5px; background: none; }
  #account-summary .card:first-child { grid-column: 1 / -1; padding: 20px 18px 16px; border-bottom: 1px solid var(--line); }
  #account-summary .card:nth-child(2) { border-right: 1px solid var(--line); }
  .account-summary .card > span { font-size: 12px; }
  .account-summary .card > strong { font-size: 23px; font-weight: 720; letter-spacing: -.5px; line-height: 1.35; }
  .account-summary .card:first-child > strong { font-size: 34px; letter-spacing: -1px; }
  .account-summary strong span { font-size: 17px; font-weight: 650; letter-spacing: -.3px; }
  .account-summary small { font-size: 10px; line-height: 1.6; }
  .account-summary .card:first-child small { font-size: 11px; }
  .card { border-radius: 14px; padding: 16px; box-shadow: none; }
  .section-title { margin-bottom: 14px; gap: 8px; }
  .section-title h2 { font-size: 17px; font-weight: 700; }
  .section-title > span { font-size: 11px; }
  .portfolio-section { margin-bottom: 24px; }
  #account-view > .portfolio-section:first-of-type { padding: 0; background: none; border: 0; }
  #account-view > .portfolio-section:first-of-type > .subtle { font-size: 11px; margin-top: 12px; }
  .table-wrap { border: 0; border-radius: 0; overflow: visible; }
  main table, main thead, main tbody, main tr, main th, main td { white-space: normal; }
  main table { display: block; min-width: 0 !important; width: 100%; }
  main table thead { display: none; }
  main table tbody { display: block; }
  main table tr { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
  main table td { display: block; border: 0; padding: 0; min-width: 0 !important; max-width: none !important; font-size: 14px; vertical-align: top; overflow-wrap: anywhere; }
  main table td::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); font-weight: 400; margin-bottom: 3px; }
  main table td[colspan] { grid-column: 1 / -1; }
  main table td small { font-size: 11px; margin-top: 2px; }
  main table td .outline { font-size: 12px; padding: 7px 9px; margin: 4px 3px 0 0; }
  .positions-table tr { background: var(--panel); border: 1px solid var(--line); border-radius: 15px; padding: 17px 16px 14px; margin-bottom: 12px; gap: 13px 16px; }
  .positions-table tr:hover, .positions-table tr:hover .position-coin { background: var(--panel); }
  .positions-table th, .positions-table td { padding: 0; }
  .positions-table .position-coin { position: static; grid-column: 1; grid-row: 1; box-shadow: none; background: none; }
  .positions-table .position-coin::before { display: none; }
  .positions-table .position-coin b { display: block; font-size: 21px; letter-spacing: -.3px; line-height: 1.4; }
  .mobile-position-tag { display: inline-block; font-size: 11px; font-weight: 600; margin-top: 4px; }
  .positions-table td:nth-child(4) { grid-column: 2; grid-row: 1; text-align: right; }
  .positions-table td:nth-child(4)::before { content: '未实现盈亏'; }
  .positions-table td:nth-child(4) b { font-size: 18px; line-height: 1.4; letter-spacing: -.4px; }
  .positions-table td:nth-child(4) small { font-size: 12px; font-weight: 600; }
  .positions-table td:nth-child(3) { grid-column: 1; grid-row: 2; }
  .positions-table td:nth-child(6) { grid-column: 2; grid-row: 2; text-align: right; }
  .positions-table td:nth-child(2) { grid-column: 1; grid-row: 3; }
  .positions-table td:nth-child(5) { grid-column: 2; grid-row: 3; text-align: right; font-size: 14px; }
  .positions-table td:nth-child(2) small { display: inline; margin-left: 5px; }
  .positions-table td:nth-child(7) { grid-column: 1 / -1; padding-top: 12px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
  .positions-table td:nth-child(7)::before { content: 'AI 分析'; font-size: 12px; white-space: nowrap; margin: 0; }
  .positions-table .position-actions { flex: 1; min-width: 0; gap: 6px; flex-wrap: nowrap; }
  .positions-table .position-actions .outline { flex: 1; min-height: 38px; margin: 0; padding: 5px 4px; font-size: 12px; background: var(--surface); border-color: var(--line); }
  .positions-table td:nth-child(8) { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .positions-table td:nth-child(8)::before { display: none; }
  .positions-table td:last-child > .outline { font-size: 13px; min-height: 42px; margin: 0; padding: 8px; border-color: var(--line); }
  .positions-table td:last-child > small, .positions-table td:last-child > details { grid-column: 1 / -1; margin: 0; }
  .positions-table td:last-child > small { font-size: 11px; }
  .close-position-button { color: var(--negative); background: var(--danger-soft); }
  .position-orders summary { font-size: 12px; padding: 6px 0; }
  .exchange-orders-table td:nth-child(4) { grid-column: 1 / -1; }
  #scan-table td:first-child { grid-column: 1 / -1; font-size: 17px; font-weight: 700; }
  #scan-table td:first-child::before { display: none; }
  .scan-reason { grid-column: 1 / -1; }
  .notice { padding: 12px 14px; font-size: 12px; line-height: 1.8; border-radius: 10px; margin-bottom: 16px; }
  #scan > .heading, #autopilot > .heading { align-items: center; }
  #scan > .heading .primary { width: 100%; margin-top: 4px; min-height: 46px; font-size: 14px; }
  .primary { min-height: 44px; font-size: 14px; border-radius: 9px; }
  .outline { border-radius: 9px; }
  .empty-state { padding: 30px 12px; }
  .empty-state p { font-size: 13px; }
  .price-grid { gap: 10px; margin: 16px 0; }
  .price-grid > div { padding: 12px; font-size: 12px; border: 0; border-radius: 10px; }
  .price-grid strong { font-size: 17px; font-weight: 650; line-height: 1.5; }
  .result p, .result li, #execution-review p, #execution-list p { font-size: 14px; line-height: 1.85; }
  .result h4 { font-size: 16px; font-weight: 700; margin-top: 24px; }
  .forecast-price { font-size: 32px; font-weight: 700; }
  .result-top { gap: 8px; }
  #autopilot { display: flex; flex-direction: column; }
  #autopilot > .heading { order: 0; }
  #autopilot > .notice { order: 1; }
  #autopilot-list { order: 2; }
  #new-mandate { order: 3; }
  #new-mandate > summary { padding: 16px; border-radius: 12px; font-size: 15px; min-height: 60px; }
  #new-mandate > summary small { font-size: 11px; }
  .autopilot-fields { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px 12px; }
  .autopilot-fields label:first-child { grid-column: 1 / -1; }
  .autopilot-grid { margin: 12px 0 0; gap: 12px; }
  .autopilot-grid > section p { font-size: 13px; margin-top: 10px; }
  .autopilot-fields label { font-size: 12px; }
  .autopilot-fields input, .autopilot-fields select { font-size: 15px; padding: 10px; }
  #autopilot-form > .primary { width: 100%; white-space: normal; margin-top: 18px; }
  .control-row { gap: 12px; }
  .control-row > label { min-width: 0; flex-basis: 40%; }
  .control-row .segmented { width: 100%; }
  .analysis-options { gap: 10px; margin: 16px 0; }
  .analysis-options label { font-size: 12px; }
  #analyze { flex: 1; }
  .action-row { gap: 8px; }
  .action-row .subtle { font-size: 11px; }
  .subtle { font-size: 12px; }
  #execution-list .card { overflow-wrap: anywhere; }
  .toast { bottom: 82px; font-size: 13px; z-index: 15; }
}
.mandate-quick { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; padding: 16px 0; margin-top: 8px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mandate-quick > div { font-size: 12px; color: var(--muted); }
.mandate-quick strong { display: block; font-size: 17px; color: var(--text); font-weight: 650; margin-top: 4px; }
.mandate-quick small { font-size: 10px; font-weight: 400; color: var(--muted); }
@media (max-width: 760px) {
  #autopilot > .heading > div { flex: 1; min-width: 0; }
  #refresh-autopilot { padding: 7px 10px; font-size: 12px; min-height: 38px; }
  #autopilot > .notice details { margin: 4px 0 0; }
  #autopilot > .notice summary { padding: 0; font-size: 12px; }
  #autopilot > .notice p { margin-top: 8px; font-size: 12px; }
  #autopilot-list > .card > .section-title { margin-bottom: 8px; }
  #autopilot-list > .card > .section-title h2 { font-size: 16px; }
  #autopilot-list > .card > p { font-size: 12px; }
  #autopilot-list .action-row { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); margin: 14px 0; }
  #autopilot-list .action-row button { padding: 8px 6px; white-space: normal; font-size: 12px; }
  #autopilot-list .action-row button:last-child { grid-column: 1 / -1; }
  #autopilot-list details { margin: 8px 0; }
  #autopilot-list summary { font-size: 12px; }
  #autopilot-list .price-grid { margin: 12px 0; }
  .mandate-quick { gap: 6px; padding: 12px 0; }
  .mandate-quick > div { font-size: 11px; }
  .mandate-quick strong { font-size: 14px; }
  #scan-progress .section-title { flex-wrap: nowrap; margin-bottom: 10px; }
  #scan-progress .section-title h3 { font-size: 17px; margin: 0; }
  #scan-progress .section-title > span { font-size: 12px; }
  #scan-progress .scan-stage { margin-top: 12px; font-size: 13px; }
  #scan-progress details { margin: 10px 0; }
  #scan-progress details summary { font-size: 12px; }
  #scan-progress .subtle { font-size: 11px; }
  .positions-table td:nth-child(2) small { display: block; margin: 0; }
  .positions-table td:last-child > small:not(.amber) { font-size: 10px; }
}

/* Compact position cards and a dedicated exchange-order view. */
.margin-mode { display: inline-block; margin-left: 7px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: 10px; font-weight: 500; letter-spacing: 0; vertical-align: middle; }
.position-tools { margin: 0; }
.position-tools > summary { font-size: 13px; color: var(--mint); padding: 6px 0; }
.position-trade-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-top: 10px; }
.position-trade-actions > small { grid-column: 1 / -1; }
.spot-fold > summary { font-size: 16px; font-weight: 650; color: var(--text); }
.spot-fold > summary small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.spot-fold[open] > .section-title { margin-top: 18px; }
.order-price-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.order-price { color: #865300; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.order-market { display: inline !important; color: var(--muted); font-size: 12px; white-space: nowrap; }
.order-conditions { line-height: 1.9; margin-top: 4px; }
.quote-time { font-size: 10px; color: var(--muted); }
:root[data-theme="dark"] { --bg: #000000; --panel: #090909; --sidebar: #000000; --surface: #121212; --line: #292929; --hover: #191919; --row-hover: #151515; --text: #f4f4f4; --secondary: #cccccc; --muted: #a4a4a4; --mint: #36ed8e; --accent-soft: #0c281b; --primary: #36ed8e; --negative: #ff7b8b; }
:root[data-theme="dark"] .order-price { color: #ffd166; }
@media (max-width: 760px) {
  .positions-table tr { gap: 9px 14px; padding: 14px 14px 8px; margin-bottom: 10px; border-radius: 12px; }
  .positions-table .position-coin b { font-size: 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
  .positions-table .position-coin b .margin-mode { display: inline-block; font-size: 10px; margin: 0; padding: 1px 4px; }
  .mobile-position-tag { margin-top: 2px; font-size: 11px; }
  .positions-table td:nth-child(4) b { font-size: 18px; }
  .positions-table td:nth-child(4)::before { font-size: 10px; margin-bottom: 2px; }
  .positions-table td:nth-child(2), .positions-table td:nth-child(3), .positions-table td:nth-child(5), .positions-table td:nth-child(6) { font-size: 13px; line-height: 1.5; }
  .positions-table td:nth-child(2)::before, .positions-table td:nth-child(3)::before, .positions-table td:nth-child(5)::before, .positions-table td:nth-child(6)::before { margin-bottom: 2px; }
  .positions-table td:nth-child(2) small { display: inline; margin-left: 4px; font-size: 10px; }
  .positions-table td:nth-child(5) small { display: none; }
  .positions-table td:nth-child(7) { display: block; padding-top: 4px; margin-top: 3px; }
  .positions-table td:nth-child(7)::before { display: none; }
  .position-tools > summary { min-height: 36px; padding: 8px 0; font-size: 12px; }
  .position-tools[open] > summary { margin-bottom: 8px; }
  .position-tools .position-actions { display: flex; gap: 7px; }
  .position-tools .position-actions .outline { min-height: 40px; }
  .position-trade-actions { margin: 10px 0 8px; }
  .position-trade-actions .outline { margin: 0; min-height: 42px; padding: 8px; }
  .spot-fold { padding: 13px 16px; }
  #orders .heading > div { flex: 1; min-width: 0; }
  #orders .heading .outline { font-size: 12px; padding: 8px 12px; }
  #orders .exchange-orders-table tr { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin: 12px 0; gap: 10px 14px; }
  #orders .exchange-orders-table td:nth-child(1) { grid-column: 1; grid-row: 1; }
  #orders .exchange-orders-table td:nth-child(1) b { font-size: 18px; }
  #orders .exchange-orders-table td:nth-child(1)::before { display: none; }
  #orders .exchange-orders-table td:nth-child(2) { grid-column: 2; grid-row: 1; text-align: right; }
  #orders .exchange-orders-table td:nth-child(4) { grid-column: 1 / -1; grid-row: 2; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px 0; }
  #orders .exchange-orders-table td:nth-child(4)::before { display: none; }
  #orders .exchange-orders-table td:nth-child(5) { text-align: right; }
  #orders .exchange-orders-table td:last-child { grid-column: 1 / -1; }
  #orders .exchange-orders-table td:last-child::before { display: none; }
  #orders .exchange-orders-table td:last-child small { display: inline; margin-right: 8px; font-size: 10px; }
  .order-price { font-size: 17px; }
  .order-price-line { justify-content: space-between; gap: 4px 8px; }
  .order-market { font-size: 11px; }
  .order-conditions { font-size: 12px; }
}
