/* CoinTech2u 雙帳號彙整 · 對齊原站暗色配色 */

:root {
  --bg: #000000;
  --surface: #0d0e12;
  --card: #15171d;
  --card-lift: #1a1c23;
  --line: #25272e;
  --line-soft: #1c1e25;
  --text: #ffffff;
  --text-soft: #b4b6bd;
  --text-mute: #7a7d85;
  --accent: #c84afb;        /* magenta brand */
  --accent-soft: #8c2fb8;
  --pos: #c8e94a;           /* electric lime green — 原站盈利色 */
  --neg: #f24a6e;           /* pink-red — 原站虧損色 */
  --warn: #f5a623;
  --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 12px 32px rgba(0,0,0,0.2);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans TC", "PingFang TC", "Source Han Sans TC", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

/* ─── Brand ─── */
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-soft);
}
.brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.06em;
}
.brand h1 .o {
  color: var(--accent);
  font-weight: 700;
}
.brand .sub {
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.25em;
  text-transform: uppercase;
}
.brand .spacer { flex: 1; }
.brand .actions { display: flex; gap: 6px; }

.icon-btn {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text-soft);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all 0.15s;
}
.icon-btn:hover { background: var(--card-lift); color: var(--text); border-color: var(--accent-soft); }

/* ─── Overlay (setup) ─── */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  overflow-y: auto;
}
.overlay-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
  margin: auto;
}
.overlay-box h2 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 500;
}
.overlay-box p {
  margin: 0 0 22px;
  color: var(--text-mute);
  font-size: 13px;
  line-height: 1.7;
}
.overlay-box label {
  display: block;
  font-size: 11px;
  color: var(--text-mute);
  margin: 14px 0 4px;
  letter-spacing: 0.04em;
}
.overlay-box input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.overlay-box input:focus { border-color: var(--accent); background: var(--bg); }
.overlay-box input::placeholder { color: #50535b; }
.overlay-box .actions {
  margin-top: 22px;
  display: flex;
  gap: 8px;
}
.overlay-box .err {
  margin-top: 12px;
  color: var(--neg);
  font-size: 12px;
  min-height: 1em;
}
.overlay-box .ok-msg {
  margin-top: 12px;
  color: var(--pos);
  font-size: 12px;
  min-height: 1em;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  flex: 1;
  transition: all 0.15s;
}
.btn-primary:hover { background: #d568fc; box-shadow: 0 0 16px rgba(200, 74, 251, 0.3); }
.btn-primary:disabled { background: #444; cursor: not-allowed; box-shadow: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--line);
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-mute); background: var(--card-lift); }

/* ─── Status bar ─── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  font-size: 12px;
  color: var(--text-mute);
}
.status-bar .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-mute);
}
.status-bar .dot.live { background: var(--pos); box-shadow: 0 0 8px var(--pos); animation: pulse 2s infinite; }
.status-bar .dot.warn { background: var(--warn); }
.status-bar .dot.err { background: var(--neg); box-shadow: 0 0 8px var(--neg); }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
.status-bar .ts { flex: 1; }

.btn-refresh {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  transition: all 0.15s;
}
.btn-refresh:hover { border-color: var(--accent); color: var(--accent); }
.btn-refresh:disabled { color: var(--text-mute); cursor: wait; border-color: var(--line-soft); }

/* ─── Combined header ─── */
.combined {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 30px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.combined .label {
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.combined .big {
  font-size: 38px;
  font-weight: 500;
  margin: 6px 0 0;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.combined .big .ccy {
  font-size: 13px;
  color: var(--text-mute);
  margin-left: 8px;
  font-weight: 400;
  letter-spacing: 0.04em;
}
.combined-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 18px;
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line-soft);
}
.combined-grid .cell .v { font-size: 19px; }
.combined-grid .cell .label { display: block; margin-bottom: 4px; }
.combined-grid .cell .v {
  font-size: 22px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

/* ─── Account section ─── */
.account {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.account-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.account-head:hover { background: var(--card-lift); }
.account-head .caret {
  margin-left: 18px;
  color: var(--text-mute);
  font-size: 11px;
  transition: transform 0.2s;
}
.account.collapsed .account-head { border-bottom: none; }
.account.collapsed .account-head .caret { transform: rotate(-90deg); }
.account.collapsed .account-body { display: none; }
.account-head .name {
  font-size: 14px;
  font-weight: 500;
}
.account-head .email {
  font-size: 11px;
  color: var(--text-mute);
}
.account-head .stat-grid {
  margin-left: auto;
  display: flex;
  gap: 20px;
}
.account-head .stat .label {
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.account-head .stat .v {
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.account-body {
  padding: 18px 24px 20px;
}

.wallet-bar {
  display: flex;
  gap: 32px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.wallet-bar .item .label {
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.06em;
}
.wallet-bar .item .v {
  font-size: 18px;
  font-weight: 500;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.wallet-bar .item .sub {
  font-size: 10px;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* ─── Portfolio cards ─── */
.portfolio-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* minmax(0,..) 而非預設 auto：避免內含寬表格時 grid 欄被撐爆 */
  gap: 10px;
}
.pcard {
  min-width: 0; /* 允許 grid 子項縮到比內容窄，讓內部 .pos-table 的水平捲動生效 */
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  background: var(--card-lift);
  transition: border-color 0.15s;
}
.pcard:hover { border-color: var(--text-mute); }
.pcard.empty { opacity: 0.45; }
.pcard.empty:hover { border-color: var(--line); }
.pcard-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.pcard-head .label {
  font-size: 14px;
  font-weight: 500;
}
.pcard-head .platform {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent-soft);
  letter-spacing: 0.04em;
  font-weight: 500;
}
.pcard-head .pid {
  font-size: 10px;
  color: var(--text-mute);
  margin-left: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.btn-hide-portfolio {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-mute);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  padding: 0;
  transition: all 0.15s;
  line-height: 1;
}
.btn-hide-portfolio:hover {
  border-color: var(--neg);
  color: var(--neg);
  background: rgba(242, 74, 110, 0.08);
}
.pcard-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}
.pcard-grid .cell .label {
  display: block;
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}
.pcard-grid .cell .v {
  font-size: 15px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.mute { color: var(--text-mute); }

/* ─── Positions table ─── */
.pos-toggle {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}
.pos-toggle summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-soft);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.pos-toggle summary::-webkit-details-marker { display: none; }
.pos-toggle summary::before {
  content: '▸';
  font-size: 10px;
  transition: transform 0.15s;
  color: var(--text-mute);
}
.pos-toggle[open] summary::before { transform: rotate(90deg); }
.pos-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.pos-table th, .pos-table td {
  text-align: right;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line-soft);
}
.pos-table th:first-child, .pos-table td:first-child { text-align: left; }
.pos-table th {
  color: var(--text-mute);
  font-weight: 400;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pos-table tr:last-child td { border-bottom: none; }
.pos-table .sym { font-weight: 500; color: var(--text); }
.pos-table .side-long {
  color: var(--pos);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(200, 233, 74, 0.08);
}
.pos-table .side-short {
  color: var(--neg);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(242, 74, 110, 0.08);
}
.pos-table .badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.pos-table .badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-stop {
  color: var(--neg);
  background: rgba(242, 74, 110, 0.12);
  border: 1px solid rgba(242, 74, 110, 0.3);
}
.badge-surge-on {
  color: var(--accent);
  background: rgba(200, 74, 251, 0.12);
  border: 1px solid rgba(200, 74, 251, 0.45);
  animation: surgePulse 2.4s ease-in-out infinite;
}
.badge-surge-expired {
  color: var(--text-mute);
  background: transparent;
  border: 1px dashed var(--line);
}
@keyframes surgePulse {
  0%, 100% { box-shadow: 0 0 0 rgba(200, 74, 251, 0); }
  50% { box-shadow: 0 0 8px rgba(200, 74, 251, 0.45); }
}

/* ─── Misc states ─── */
.spinner-inline {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid rgba(200, 74, 251, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-mute);
}
.error-banner {
  background: rgba(242, 74, 110, 0.08);
  border: 1px solid rgba(242, 74, 110, 0.35);
  color: var(--neg);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
}
.proxy-warn {
  background: rgba(245, 166, 35, 0.08);
  border: 1px solid rgba(245, 166, 35, 0.35);
  color: var(--warn);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.7;
}
.proxy-warn code {
  background: rgba(255,255,255,0.05);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text);
}

/* ─── Account-row item in settings ─── */
.cred-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.cred-row .cred-info { flex: 1; min-width: 0; }
.cred-row .cred-email { font-size: 13px; }
.cred-row .cred-sub { font-size: 11px; color: var(--text-mute); }
.cred-row .cred-actions { display: flex; gap: 6px; }
.btn-mini {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--line);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
}
.btn-mini:hover { color: var(--text); border-color: var(--text-mute); }
.btn-mini.danger:hover { color: var(--neg); border-color: var(--neg); }

.pref-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s;
}
.pref-row:hover { border-color: var(--text-mute); }
.pref-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}
.pref-row .pref-label { flex: 1; font-size: 13px; }
.pref-row .pref-sub { font-size: 11px; color: var(--text-mute); margin-top: 2px; }

/* ─── 期間統計 對話框 ─── */
.date-row {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}
.date-row > div { flex: 1; }
.date-row label {
  display: block;
  font-size: 11px;
  color: var(--text-mute);
  margin-bottom: 4px;
  letter-spacing: 0.04em;
}
.date-row input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  outline: none;
  color-scheme: dark;
}
.date-row input:focus { border-color: var(--accent); }

.preset-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.btn-preset {
  background: var(--surface);
  color: var(--text-soft);
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  transition: all 0.15s;
}
.btn-preset:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.period-result-box {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}
.period-range {
  font-size: 11px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
  letter-spacing: 0.04em;
}
.period-row, .period-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-variant-numeric: tabular-nums;
}
.period-total {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  font-weight: 500;
}
.period-name { font-size: 13px; color: var(--text); }
.period-v { font-size: 16px; }
.period-total .period-v { font-size: 20px; }

.section-divider {
  margin: 16px 0 10px;
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.btn-add-account {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--text-soft);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 8px;
  transition: all 0.15s;
}
.btn-add-account:hover { border-color: var(--accent); color: var(--accent); background: rgba(200, 74, 251, 0.04); }

/* ─── 告警 banner ─── */
.alert-banner {
  background: rgba(245, 166, 35, 0.07);
  border: 1px solid rgba(245, 166, 35, 0.45);
  color: var(--warn);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  animation: surgePulse 2.4s ease-in-out infinite;
}
.alert-banner-title { font-weight: 500; margin-bottom: 6px; }
.alert-banner-list { margin: 4px 0 0; padding-left: 20px; color: var(--text-soft); font-size: 12px; line-height: 1.7; }

/* layer 徽章 */
.badge-layer {
  color: var(--warn);
  background: rgba(245, 166, 35, 0.12);
  border: 1px solid rgba(245, 166, 35, 0.35);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
}

/* ─── 主分頁切換（趨勢圖 / 幣種績效） ─── */
.main-tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.main-tab {
  background: transparent;
  border: none;
  color: var(--text-mute);
  padding: 12px 20px;
  font-size: 14px;
  transition: all 0.15s;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.main-tab:hover { color: var(--text); }
.main-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ─── 圖表 overlay ─── */
.chart-section-label {
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 14px 0 6px;
}
.chart-tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.chart-tab {
  flex: 1;
  min-width: 80px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-mute);
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12px;
  transition: all 0.15s;
  white-space: nowrap;
}
.chart-tab:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.chart-tab.active {
  background: var(--card-lift);
  color: var(--text);
  border-color: var(--line);
}
.btn-preset.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(200, 74, 251, 0.08);
}

.chart-box {
  margin-top: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}
.chart-wrap {
  position: relative;
  margin-top: 12px;
}
.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}
.chart-grid {
  stroke: var(--line-soft);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}
.chart-zero {
  stroke: var(--text-mute);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}
.chart-axis-label {
  fill: var(--text-mute);
  font-size: 10px;
  font-family: inherit;
}
.chart-cursor {
  stroke: var(--accent);
  stroke-width: 1;
  stroke-dasharray: 2 3;
  opacity: 0.6;
  pointer-events: none;
}
.chart-cursor-dot {
  pointer-events: none;
  stroke: var(--bg);
  stroke-width: 2;
}
.chart-tooltip {
  position: absolute;
  background: var(--card-lift);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11px;
  pointer-events: none;
  box-shadow: var(--shadow);
  min-width: 110px;
}
.chart-tooltip .tt-time { color: var(--text-mute); font-size: 10px; }
.chart-tooltip .tt-v { color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; margin-top: 2px; }

.chart-summary {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.chart-summary .cs-item .cs-label {
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.chart-summary .cs-item .cs-v {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* ─── 告警設定區塊 ─── */
.alert-section {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.alert-field { margin-bottom: 14px; }
.alert-field label {
  display: block;
  font-size: 11px;
  color: var(--text-mute);
  margin-bottom: 4px;
  letter-spacing: 0.04em;
}
.alert-field input[type="text"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  outline: none;
  font-family: monospace;
}
.alert-field input[type="text"]:focus { border-color: var(--accent); }
.alert-field-hint {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 4px;
}
.alert-section .pref-row {
  background: var(--bg);
  margin-bottom: 8px;
}
.alert-section .pref-row:last-of-type { margin-bottom: 0; }
.inline-num {
  width: 50px;
  background: var(--card-lift);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  outline: none;
  margin: 0 4px;
}
.inline-num:focus { border-color: var(--accent); }
.alert-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 14px;
  align-items: center;
}
.alert-test-status {
  font-size: 11px;
  margin-left: auto;
}

/* ─── Debug log ─── */
#btn-debug.has-error {
  border-color: var(--warn);
  color: var(--warn);
}
.debug-log-list {
  max-height: 60vh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 8px;
}
.debug-log-row {
  display: grid;
  grid-template-columns: 60px 50px 1fr;
  gap: 8px;
  padding: 6px 8px;
  font-size: 11px;
  font-family: ui-monospace, "SF Mono", Monaco, monospace;
  border-bottom: 1px solid var(--line-soft);
}
.debug-log-row:last-child { border-bottom: none; }
.debug-log-time { font-variant-numeric: tabular-nums; }
.debug-log-level {
  font-size: 9px;
  letter-spacing: 0.05em;
  padding: 1px 4px;
  border-radius: 3px;
  text-align: center;
  height: fit-content;
}
.debug-log .debug-log-level, .debug-log-row.debug-log .debug-log-level { color: var(--text-mute); background: rgba(255,255,255,0.05); }
.debug-log-row.debug-warn .debug-log-level { color: var(--warn); background: rgba(245, 166, 35, 0.12); }
.debug-log-row.debug-error .debug-log-level { color: var(--neg); background: rgba(242, 74, 110, 0.12); }
.debug-log-text {
  color: var(--text-soft);
  word-break: break-all;
  white-space: pre-wrap;
}
.debug-log-row.debug-warn .debug-log-text { color: var(--text); }
.debug-log-row.debug-error .debug-log-text { color: var(--text); }

/* ─── 告警歷史 ─── */
.alert-row {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 8px;
}
.alert-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.alert-row-time {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.alert-row-body {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  flex-wrap: wrap;
}
.alert-row-body .sym { font-weight: 500; }
.alert-row-body .side-long,
.alert-row-body .side-short {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
}
.alert-row-body .side-long { color: var(--pos); background: rgba(200, 233, 74, 0.08); }
.alert-row-body .side-short { color: var(--neg); background: rgba(242, 74, 110, 0.08); }
.alert-row-desc {
  font-size: 11px;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
  .app { padding: 18px 12px 60px; }
  .combined { padding: 18px; }
  .combined .big { font-size: 28px; }
  .combined-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .account-head .stat-grid { gap: 14px; flex-wrap: wrap; }
  .account-head .stat .v { font-size: 14px; }
  .combined-grid .cell .v { font-size: 18px; }
  .account-head { flex-wrap: wrap; padding: 14px 16px; }
  .account-head .stat-grid { margin-left: 0; width: 100%; gap: 16px; }
  .account-body { padding: 14px 16px 16px; }
  .pcard { padding: 12px 14px; }
  .pcard-grid { grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
  .pos-table th, .pos-table td { padding: 6px 4px; font-size: 11px; }
  .chart-summary { grid-template-columns: repeat(3, 1fr); }
  .chart-tab { min-width: auto; padding: 6px 8px; font-size: 11px; }
}

/* ── 手機（窄螢幕）專屬優化：保留全部功能，只把版面調好看好按 ── */
@media (max-width: 560px) {
  /* 寬表格（持倉／平倉／補倉／止損／幣種績效都用 .pos-table）改水平捲動，永不爆版 */
  .pos-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  /* 捲動區給點視覺提示：底線淡化、捲動條細 */
  .pos-table::-webkit-scrollbar { height: 5px; }
  .pos-table::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

  /* 頂部品牌列：縮字、圖示鈕加大好點，使用者名過長省略 */
  .brand h1 { font-size: 18px; }
  .brand .sub { display: none; }
  .brand .actions { gap: 8px; }
  .portal-user { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .icon-btn { width: 38px; height: 38px; }

  /* 狀態列：一排塞不下的按鈕自動換行，時間自己佔一行 */
  .status-bar { flex-wrap: wrap; gap: 8px; }
  .status-bar .ts { flex-basis: 100%; order: -1; }
  .btn-refresh { padding: 9px 14px; font-size: 12px; }

  /* 彈窗（設定／歷史／各分頁）更貼邊、內距收斂，手機看得更滿 */
  .overlay { padding: 10px; align-items: stretch; }
  .overlay-box { padding: 20px 14px; max-width: 100% !important; }
  .overlay-box .actions { flex-wrap: wrap; }

  /* 總覽大數字與格子再縮一點，兩欄維持 */
  .combined .big { font-size: 26px; }
  .combined-grid { gap: 10px; }

  /* 日期/篩選列容易擠：允許換行 */
  .date-row { flex-wrap: wrap; gap: 8px; }
}
