/* ==========================================================================
   btc.loveyou.tw — 挖礦平台管理面板
   純 CSS,無外部相依。深色主題,響應式(<=900px KPI 2 欄、表格轉卡片)。
   ========================================================================== */

/* ---------- 1. 設計 token ---------- */
:root {
  --bg: #0b0f14;
  --bg-soft: #0e141b;
  --card: #131a22;
  --card-2: #0f151d;
  --card-3: #18222c;
  --line: #1f2a36;
  --line-soft: #18222c;

  --amber: #f5a623;
  --amber-soft: rgba(245, 166, 35, .12);
  --green: #2ecc71;
  --green-soft: rgba(46, 204, 113, .12);
  --red: #e05252;
  --red-soft: rgba(224, 82, 82, .12);
  --blue: #5aa9ff;
  --blue-soft: rgba(90, 169, 255, .12);

  --text: #e6edf3;
  --muted: #8b98a5;
  --muted-2: #66727e;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;

  --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 10px 30px rgba(0, 0, 0, .28);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans TC", "Noto Sans CJK TC",
          "PingFang TC", "Heiti TC", "Microsoft JhengHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --gap: 16px;
  --maxw: 1220px;
  --topbar-h: 58px;
}

/* ---------- 2. reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 82% -8%, rgba(245, 166, 35, .07), transparent 60%),
    radial-gradient(900px 480px at 8% 4%, rgba(90, 169, 255, .05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: .01em; line-height: 1.25; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
img, svg { display: block; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: rgba(245, 166, 35, .3); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--amber); color: #10161d; padding: 8px 14px; border-radius: 0 0 8px 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.noscript {
  max-width: 640px; margin: 80px auto; padding: 20px; text-align: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}

/* 數字一律等寬,避免刷新時跳動 */
.num, .kpi-value, .mono, td.num, .stat-value, .chart-tip-val {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.mono { font-family: var(--mono); }

/* ---------- 3. 圖示 ---------- */
.ico {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.ico-sm { width: 15px; height: 15px; }
.ico-lg { width: 22px; height: 22px; }

/* ---------- 4. 版面 shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11, 15, 20, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto;
  min-height: var(--topbar-h);
  padding: 8px 20px;
  display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand-mark { width: 26px; height: 26px; }
.brand-hex { fill: none; stroke: var(--amber); stroke-width: 2; }
.brand-bolt { fill: var(--amber); }
.brand-text { font-weight: 700; font-size: 15.5px; letter-spacing: .02em; white-space: nowrap; }

.nav { display: flex; align-items: center; gap: 4px; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav-link {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 14px; font-weight: 550; white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--card-3); color: var(--text); }
.nav-link.is-active { background: var(--amber-soft); color: var(--amber); }

.topbar-actions { display: flex; align-items: center; gap: 10px; flex: none; margin-left: auto; }
.user-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card-2); color: var(--muted); font-size: 13px; max-width: 260px;
}
.user-chip .user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }

.main {
  max-width: var(--maxw); margin: 0 auto;
  padding: 26px 20px 60px;
  min-height: calc(100vh - var(--topbar-h) - 90px);
}
.main:focus { outline: none; }

.footer { border-top: 1px solid var(--line); background: var(--bg-soft); }
.footer-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 16px 20px;
  display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center;
  color: var(--muted-2); font-size: 12.5px;
}
.footer-inner .dot { color: var(--line); }

/* ---------- 5. 頁面標題列 ---------- */
.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 14px; margin-bottom: 20px;
}
.page-title { font-size: 22px; }
.page-sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- 6. 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.card-title { font-size: 14.5px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card-title .ico { color: var(--amber); }
.card-note { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 18px; }

.grid { display: grid; gap: var(--gap); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: var(--gap); }

/* ---------- 7. KPI ---------- */
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi::after {
  content: ""; position: absolute; inset: auto -30% -60% auto; width: 130px; height: 130px;
  background: radial-gradient(circle, rgba(245, 166, 35, .10), transparent 70%);
  pointer-events: none;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 550; letter-spacing: .04em; }
.kpi-ico { color: var(--amber); opacity: .85; }
.kpi-value {
  margin-top: 8px; font-size: 27px; font-weight: 700; line-height: 1.15;
  display: flex; align-items: baseline; gap: 6px; white-space: nowrap;
}
.kpi-value .unit { font-size: 14px; font-weight: 600; color: var(--muted); }
.kpi-sub { margin-top: 6px; color: var(--muted); font-size: 12.5px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.kpi.is-ok .kpi-value { color: var(--green); }
.kpi.is-warn .kpi-value { color: var(--amber); }

/* ---------- 8. 按鈕 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--card-3); color: var(--text);
  font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .06s, opacity .15s;
}
.btn:hover { background: #1e2a36; border-color: #27343f; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--amber); border-color: var(--amber); color: #10161d;
}
.btn-primary:hover { background: #ffb733; border-color: #ffb733; }
.btn-danger { background: var(--red-soft); border-color: rgba(224, 82, 82, .4); color: var(--red); }
.btn-danger:hover { background: rgba(224, 82, 82, .2); border-color: var(--red); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--card-3); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn.is-busy { pointer-events: none; opacity: .7; }
.btn.is-busy::before {
  content: ""; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--muted);
  cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--card-3); color: var(--text); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }

.link { color: var(--amber); font-weight: 600; }
.link:hover { text-decoration: underline; }

/* ---------- 9. 表單 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.label { font-size: 13px; font-weight: 600; color: var(--text); display: flex; gap: 6px; align-items: center; }
.hint { color: var(--muted); font-size: 12.5px; }
.input, .select, textarea.input {
  width: 100%; padding: 10px 12px;
  background: var(--card-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; font-size: 14px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.input:hover { border-color: #27343f; }
.input:focus, .select:focus {
  outline: none; border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(245, 166, 35, .16);
}
.input::placeholder { color: var(--muted-2); }
.input.is-error { border-color: var(--red); box-shadow: 0 0 0 3px rgba(224, 82, 82, .14); }
.input-mono { font-family: var(--mono); font-size: 13px; }
.field-error {
  color: var(--red); font-size: 12.5px; display: flex; align-items: center; gap: 6px;
}
.field-error:empty { display: none; }
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% - 2px), calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--amber); }

/* ---------- 10. 狀態徽章 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 650;
  border: 1px solid transparent; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-online { background: var(--green-soft); color: var(--green); border-color: rgba(46, 204, 113, .3); }
.badge-offline { background: rgba(139, 152, 165, .12); color: var(--muted); border-color: rgba(139, 152, 165, .28); }
.badge-paused { background: var(--amber-soft); color: var(--amber); border-color: rgba(245, 166, 35, .3); }
.badge-danger { background: var(--red-soft); color: var(--red); border-color: rgba(224, 82, 82, .3); }
.badge-info { background: var(--blue-soft); color: var(--blue); border-color: rgba(90, 169, 255, .3); }
.badge-online .dot { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.tag {
  display: inline-block; padding: 2px 7px; border-radius: 5px; font-size: 11.5px;
  background: var(--card-3); color: var(--muted); border: 1px solid var(--line);
  font-family: var(--mono);
}
.tag-admin { background: var(--amber-soft); color: var(--amber); border-color: rgba(245, 166, 35, .3); }

/* ---------- 11. 表格(<=900px 轉卡片) ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table thead th {
  text-align: left; padding: 11px 14px; white-space: nowrap;
  color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .05em;
  background: var(--card-2); border-bottom: 1px solid var(--line);
}
.table tbody td {
  padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: rgba(255, 255, 255, .02); }
.table .cell-name { display: flex; flex-direction: column; gap: 3px; }
.table .cell-name .wname { font-weight: 650; font-size: 14px; }
.table .cell-name .wid { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.table .cell-actions { white-space: nowrap; }
.table .cell-actions .icon-btn { width: 30px; height: 30px; }
.table .stack-cell { display: flex; flex-direction: column; gap: 3px; }
.table .sub { color: var(--muted); font-size: 12px; }
.table tfoot td { padding: 12px 14px; border-top: 1px solid var(--line); font-weight: 650; background: var(--card-2); }
.td-num { font-variant-numeric: tabular-nums; }
.hash-big { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hash-big .unit { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- 12. 礦機卡(dashboard) ---------- */
.wcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: var(--gap); }
.wcard { padding: 16px; display: flex; flex-direction: column; gap: 12px; transition: border-color .15s, transform .12s; }
.wcard:hover { border-color: #2a3846; }
.wcard.is-offline { opacity: .72; }
.wcard-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.wcard-name { font-weight: 700; font-size: 15px; }
.wcard-id { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.wcard-hash { display: flex; align-items: baseline; gap: 6px; }
.wcard-hash .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.wcard-hash .u { font-size: 13px; color: var(--muted); }
.wcard-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; font-size: 12.5px; }
.wcard-meta .k { color: var(--muted); display: block; font-size: 11.5px; }
.wcard-meta .v { font-variant-numeric: tabular-nums; }
.wcard-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line-soft); padding-top: 12px; margin-top: 2px; }
.wcard-model { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 13. 圖表 ---------- */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .grid-base { stroke: #26333f; }
.chart .axis { fill: var(--muted-2); font-size: 11px; font-family: var(--sans); font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--amber); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { stroke: none; }
.chart .grad-top { stop-color: var(--amber); stop-opacity: .32; }
.chart .grad-mid { stop-color: var(--amber); stop-opacity: .10; }
.chart .grad-bottom { stop-color: var(--amber); stop-opacity: 0; }
.chart .dot { fill: var(--amber); stroke: var(--card); stroke-width: 2; }
.chart .guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .focus { fill: var(--card); stroke: var(--amber); stroke-width: 2.5; }
.chart .empty { fill: var(--muted-2); font-size: 13px; }
.chart .hit { fill: transparent; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  min-width: 132px; padding: 8px 10px;
  background: #0c1218; border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); font-size: 12.5px;
  transition: opacity .1s;
}
.chart-tip-time { color: var(--muted); font-size: 11.5px; margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.chart-tip-val { font-size: 15px; font-weight: 700; color: var(--amber); font-variant-numeric: tabular-nums; }
.chart-tip-row { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); font-size: 12px; margin-top: 3px; }
.chart-tip-row b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }

.chart-legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.legend-swatch { width: 12px; height: 3px; border-radius: 2px; background: var(--amber); }

/* ---------- 14. 空狀態 ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 14px; padding: 46px 24px; color: var(--muted);
}
.empty-art {
  width: 92px; height: 92px; border-radius: 22px; display: grid; place-items: center;
  background: var(--card-2); border: 1px solid var(--line); color: var(--amber);
}
.empty-art .ico { width: 42px; height: 42px; stroke-width: 1.4; }
.empty-title { color: var(--text); font-size: 17px; font-weight: 650; }
.empty-text { max-width: 460px; font-size: 13.5px; line-height: 1.7; }
.empty-steps { display: flex; flex-direction: column; gap: 8px; text-align: left; margin-top: 4px; }
.empty-step { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); }
.empty-step .n {
  flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--amber-soft); color: var(--amber); font-size: 12px; font-weight: 700;
}

/* ---------- 15. 骨架載入 ---------- */
.sk {
  display: block; border-radius: 6px;
  background: linear-gradient(90deg, #172029 25%, #1e2833 37%, #172029 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.sk-line { height: 12px; margin-bottom: 8px; }
.sk-title { height: 16px; width: 40%; margin-bottom: 12px; }
.sk-num { height: 28px; width: 62%; margin: 8px 0 6px; }
.sk-block { height: 120px; border-radius: var(--radius); }
.sk-chart { height: 280px; border-radius: var(--radius); }
.sk-row { height: 44px; border-radius: var(--radius-sm); margin-bottom: 8px; }
.sk-card { height: 168px; border-radius: var(--radius); }

/* ---------- 16. 提示列 / banner ---------- */
.banner {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--card-2); font-size: 13px; color: var(--muted);
}
.banner .ico { margin-top: 1px; }
.banner-error { border-color: rgba(224, 82, 82, .35); background: var(--red-soft); color: #f0b3b3; }
.banner-warn { border-color: rgba(245, 166, 35, .35); background: var(--amber-soft); color: #f2cf94; }
.banner-ok { border-color: rgba(46, 204, 113, .3); background: var(--green-soft); color: #a7e6c3; }
.banner b { color: var(--text); }

.inline-alert {
  display: flex; gap: 8px; align-items: flex-start; margin-top: 12px;
  color: var(--red); font-size: 13px;
}

/* ---------- 17. toast ---------- */
.toasts {
  position: fixed; z-index: 120; right: 18px; bottom: 18px;
  display: flex; flex-direction: column; gap: 10px;
  max-width: min(380px, calc(100vw - 36px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: #101821; border: 1px solid var(--line);
  box-shadow: var(--shadow); font-size: 13.5px;
  animation: toast-in .18s ease-out;
}
.toast.is-out { animation: toast-out .16s ease-in forwards; }
.toast .ico { margin-top: 1px; }
.toast-msg { flex: 1 1 auto; min-width: 0; word-break: break-word; }
.toast-info { border-left: 3px solid var(--blue); }
.toast-info .ico { color: var(--blue); }
.toast-ok { border-left: 3px solid var(--green); }
.toast-ok .ico { color: var(--green); }
.toast-warn { border-left: 3px solid var(--amber); }
.toast-warn .ico { color: var(--amber); }
.toast-error { border-left: 3px solid var(--red); }
.toast-error .ico { color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------- 18. modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 20px;
  background: rgba(6, 9, 12, .68);
  opacity: 0; transition: opacity .16s;
}
.modal-backdrop.is-open { opacity: 1; }
body.modal-open { overflow: hidden; }
.modal {
  width: 100%; max-width: 480px; max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transform: translateY(10px) scale(.99); transition: transform .16s;
}
.modal-backdrop.is-open .modal { transform: none; }
.modal-lg { max-width: 760px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.modal-title { font-size: 16px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
  padding: 14px 18px; border-top: 1px solid var(--line); background: var(--card-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* 金鑰顯示 */
.cred { display: flex; flex-direction: column; gap: 14px; }
.cred-row { display: flex; flex-direction: column; gap: 6px; }
.cred-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.cred-value {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--card-2); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 13px; word-break: break-all;
}
.cred-value .txt { flex: 1 1 auto; min-width: 0; }
.cred-value.key { border-color: rgba(245, 166, 35, .35); background: rgba(245, 166, 35, .06); }
.cmd-box {
  padding: 12px; border-radius: var(--radius-sm);
  background: #0a0f14; border: 1px solid var(--line);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
  word-break: break-all; white-space: pre-wrap; color: #cfe0ee;
}
.cmd-box .c-cmd { color: var(--green); }
.cmd-box .c-url { color: var(--blue); }
.cmd-box .c-arg { color: var(--amber); }
.cmd-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }

/* ---------- 19. 分頁 / 切換 ---------- */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--card-2); border: 1px solid var(--line); border-radius: 999px; flex-wrap: wrap; }
.tab {
  padding: 6px 12px; border: 0; background: transparent; color: var(--muted);
  border-radius: 999px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--amber); color: #10161d; }

/* ---------- 20. 定義清單式統計 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { padding: 12px 14px; background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.stat-label { color: var(--muted); font-size: 11.5px; letter-spacing: .04em; }
.stat-value { margin-top: 4px; font-size: 17px; font-weight: 700; }
.stat-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.kv { display: grid; grid-template-columns: minmax(96px, 148px) 1fr; gap: 10px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; word-break: break-word; font-variant-numeric: tabular-nums; }

/* ---------- 21. 行銷首頁 ---------- */
.hero {
  display: grid; grid-template-columns: 1.05fr .95fr; gap: 40px; align-items: center;
  padding: 46px 0 40px;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-size: 12px; letter-spacing: .06em;
}
.eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.hero h1 { font-size: clamp(28px, 4.4vw, 44px); line-height: 1.18; margin: 16px 0 14px; letter-spacing: -.01em; }
.hero h1 .accent { color: var(--amber); }
.hero-lead { color: var(--muted); font-size: 15.5px; max-width: 560px; line-height: 1.75; }
.hero-cta { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.hero-trust { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 22px; color: var(--muted-2); font-size: 12.5px; }
.hero-trust span { display: inline-flex; align-items: center; gap: 6px; }
.hero-trust .ico { color: var(--green); width: 15px; height: 15px; }
.hero-panel { padding: 16px; }
.hero-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.hero-panel-title { font-size: 13px; color: var(--muted); }
.hero-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.hero-strip .stat-value { font-size: 15px; }

.section { padding: 34px 0; }
.section-title { font-size: 20px; margin-bottom: 6px; }
.section-sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.feature { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.feature-ico {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: var(--amber-soft); color: var(--amber); border: 1px solid rgba(245, 166, 35, .25);
}
.feature-ico .ico { width: 21px; height: 21px; }
.feature h3 { font-size: 15.5px; }
.feature p { color: var(--muted); font-size: 13.5px; line-height: 1.7; }
.steps { counter-reset: st; }
.step { display: flex; gap: 14px; padding: 18px; }
.step-n {
  flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--card-3); border: 1px solid var(--line); color: var(--amber); font-weight: 700; font-size: 14px;
}
.step h3 { font-size: 15px; margin-bottom: 4px; }
.step p { color: var(--muted); font-size: 13.5px; line-height: 1.7; }
.cta-band {
  margin-top: 34px; padding: 28px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(245, 166, 35, .12), rgba(245, 166, 35, .03));
  border: 1px solid rgba(245, 166, 35, .28);
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.cta-band h2 { font-size: 20px; margin-bottom: 6px; }
.cta-band p { color: var(--muted); font-size: 13.5px; }

/* ---------- 22. 認證頁 ---------- */
.auth-wrap { display: grid; place-items: center; padding: 34px 0 60px; }
.auth-card { width: 100%; max-width: 420px; padding: 26px; }
.auth-title { font-size: 21px; margin-bottom: 6px; }
.auth-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; }
.auth-foot { margin-top: 18px; text-align: center; color: var(--muted); font-size: 13px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth-brand .brand-mark { width: 30px; height: 30px; }

/* ---------- 23. 收益 / 設定 ---------- */
.pill-list { display: flex; gap: 8px; flex-wrap: wrap; }
.money { font-variant-numeric: tabular-nums; }
.money-xmr { color: var(--amber); font-weight: 700; }
.money-twd { color: var(--muted); font-size: 12.5px; }
.addr {
  font-family: var(--mono); font-size: 13px; padding: 10px 12px; word-break: break-all;
  background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.settings-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: var(--gap); align-items: start; }
.danger-zone { border-color: rgba(224, 82, 82, .3); }
.danger-zone .card-head { border-bottom-color: rgba(224, 82, 82, .25); }
.danger-zone .card-title .ico { color: var(--red); }

/* ---------- 24. 工具類 ---------- */
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1 1 auto; }
.mt-8 { margin-top: 8px; }
.mt-14 { margin-top: 14px; }
.mt-20 { margin-top: 20px; }
.mb-12 { margin-bottom: 12px; }
.sep { height: 1px; background: var(--line); border: 0; margin: 16px 0; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.scroll-x { overflow-x: auto; }

/* ---------- 25. 響應式 ---------- */
@media (max-width: 1080px) {
  .hero { grid-template-columns: 1fr; gap: 28px; padding: 30px 0 26px; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  :root { --gap: 12px; }
  .main { padding: 20px 16px 96px; }
  .topbar-inner { padding: 8px 16px; gap: 12px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 23px; }
  .page-title { font-size: 19px; }

  /* 表格轉卡片 */
  .table-wrap { overflow: visible; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tbody tr {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    margin-bottom: 12px; overflow: hidden;
  }
  .table tbody td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 9px 14px; border-bottom: 1px solid var(--line-soft); text-align: right;
  }
  .table tbody tr:hover { background: transparent; }
  .table tbody td::before {
    content: attr(data-label);
    color: var(--muted); font-size: 12px; font-weight: 600; text-align: left;
    flex: none; letter-spacing: .03em;
  }
  .table td.cell-name {
    background: var(--card-2); border-bottom: 1px solid var(--line);
    text-align: left; padding: 12px 14px;
  }
  .table td.cell-name::before { content: none; }
  .table td.cell-actions { justify-content: flex-end; padding: 10px 14px; border-bottom: 0; }
  .table td.cell-actions::before { content: "操作"; }
  .table tfoot { display: block; }
  .table tfoot td { display: flex; justify-content: space-between; gap: 12px; }
  .table tfoot td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
  .table .stack-cell { text-align: right; }

  /* 導覽移到下方 */
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    justify-content: space-around; gap: 0;
    background: rgba(11, 15, 20, .96); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    overflow: visible;
  }
  .nav-link { flex-direction: column; gap: 3px; font-size: 11px; padding: 6px 8px; border-radius: 10px; }
  .nav-link .ico { width: 20px; height: 20px; }
  .footer { padding-bottom: 62px; }
  .toasts { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); right: 12px; left: 12px; max-width: none; }
}

@media (max-width: 640px) {
  .grid-3 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .hero h1 { font-size: 27px; }
  .hero-strip { grid-template-columns: 1fr 1fr; }
  .user-chip { display: none; }
  .brand-text { font-size: 14px; }
  .modal { border-radius: var(--radius); }
  .modal-backdrop { padding: 10px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
  .cta-band { padding: 20px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

@media print {
  .topbar, .footer, .toasts, .page-actions { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border-color: #ccc; box-shadow: none; }
}
