@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #1e3a5f;
  --accent-hover: #16304f;
  --accent-soft: #eff6ff;
  --accent-line: #3b82f6;
  --good: #059669;
  --bad: #dc2626;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --warn-border: #fcd34d;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06);
  --header-h: 64px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, "PingFang TC", "Noto Sans TC",
    "Microsoft JhengHei", sans-serif;
  font-family: var(--sans);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  /* stop rubber-band / overscroll revealing a different color */
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  min-height: 100dvh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

a {
  color: var(--accent-line);
}

/* ── login ── */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: max(1.25rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1.25rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  background: var(--bg);
}

.login-card {
  width: min(400px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  box-shadow: var(--shadow-md);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.brand-logo {
  flex-shrink: 0;
  display: block;
  width: 32px;
  height: 32px;
}

.brand-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}

.brand-tag {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.3;
}

.login-card h1 {
  margin: 0 0 0.4rem;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.eyebrow {
  margin: 0 0 0.35rem;
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #dbeafe;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
}

.sub {
  margin: 0 0 1.35rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.login-visit {
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.login-note {
  margin: 0 0 1.15rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.login-visit-headline {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 650;
  color: var(--text);
  line-height: 1.4;
}
.login-visit-meta {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.login-visit-body {
  margin: 0.55rem 0 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text);
}

.login-form {
  display: grid;
  gap: 0.5rem;
}

.login-form label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
}

.login-form input {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.85rem 0.95rem;
  /* ≥16px prevents iOS focus zoom */
  font-size: 16px;
  font-family: inherit;
}

.login-form input:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.login-form button {
  margin-top: 0.35rem;
  min-height: 2.75rem;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
}

.login-form button:hover {
  background: var(--accent-hover);
}

.err {
  color: var(--bad);
  margin-top: 0.85rem;
  font-size: 0.92rem;
}

/* ── app shell ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(248, 250, 252, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-meta {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52vw;
}

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  flex-shrink: 0;
  min-width: 15.5rem;
  max-width: 22rem;
}

.header-status {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.4rem;
  width: 100%;
}

.header-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  width: 100%;
}

.header-status .bot-run-pill,
.header-status .vultr-pill,
.header-nav .btn {
  width: 100%;
  min-width: 0;
  justify-content: center;
}

.header-nav .tab-btn.is-active {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

.header-btns {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  padding: 0 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  font-family: inherit;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn.danger {
  background: #dc2626;
  border-color: #b91c1c;
  color: #fff;
  font-weight: 600;
}

.btn.danger:hover {
  background: #b91c1c;
  border-color: #991b1b;
  color: #fff;
}

.btn.good {
  background: #059669;
  border-color: #047857;
  color: #fff;
  font-weight: 600;
}

.btn.good:hover {
  background: #047857;
  border-color: #065f46;
  color: #fff;
}

.bot-run-pill {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: 0 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.vultr-pill {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: 0 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.vultr-pill.is-ok {
  color: var(--good);
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.vultr-pill.is-warn {
  color: var(--warn);
  border-color: var(--warn-border);
  background: var(--warn-bg);
}

.vultr-pill.is-bad {
  color: var(--muted);
  border-color: var(--border);
  background: #f8fafc;
}

.bot-run-pill.is-on {
  color: var(--good);
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.bot-run-pill.is-off {
  color: var(--bad);
  border-color: #fecaca;
  background: #fef2f2;
}

.bot-run-pill.is-mixed {
  color: var(--warn);
  border-color: var(--warn-border);
  background: var(--warn-bg);
}

.btn.bark-toggle {
  font-weight: 600;
}

.btn.bark-toggle.is-on {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.btn.bark-toggle.is-off {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #64748b;
  text-decoration: line-through;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.35rem max(1rem, env(safe-area-inset-right))
    max(2.5rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  width: 100%;
  min-width: 0;
}

#pane-monitor,
#pane-history,
#pane-kol {
  min-width: 0;
  max-width: 100%;
}

.banner {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
}

.banner.error {
  color: #991b1b;
  border-color: #fecaca;
  background: #fef2f2;
}

.banner.ok {
  color: #065f46;
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.section-title {
  margin: 0.65rem 0 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.approach-card {
  padding-bottom: 0.85rem;
}

.approach-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin-bottom: 0.55rem;
}

.approach-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--text);
}

.approach-sub {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
}

.approach-now {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  align-items: stretch;
}

.ap-metric {
  display: flex;
  flex-direction: column;
  min-width: 4.6rem;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  line-height: 1.25;
}

.ap-k {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.ap-v {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--text);
}

.ap-l {
  font-size: 0.72rem;
  color: var(--muted);
}

.ap-metric.ap-hot {
  border-color: #86efac;
  background: #f0fdf4;
}
.ap-metric.ap-hot .ap-v { color: var(--good); }

.ap-metric.ap-near {
  border-color: #93c5fd;
  background: #eff6ff;
}
.ap-metric.ap-near .ap-v { color: #1d4ed8; }

.ap-metric.ap-mid .ap-v { color: var(--warn); }

.ap-metric.ap-far .ap-v { color: var(--muted); }

#approach-canvas {
  display: block;
  width: 100%;
  height: 200px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
}

.approach-legend {
  display: flex;
  gap: 1rem;
  margin-top: 0.45rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.lg::before {
  content: "";
  display: inline-block;
  width: 0.7rem;
  height: 0.2rem;
  margin-right: 0.35rem;
  vertical-align: middle;
  border-radius: 2px;
}
.lg-btc::before { background: #94a3b8; }
.lg-pred::before { background: #2563eb; height: 0.28rem; }
.lg-mtf::before { background: #0d9488; height: 0.28rem; }
.lg-sig::before {
  content: "◆";
  width: auto;
  height: auto;
  background: none;
  color: #7c3aed;
  font-size: 0.7rem;
  margin-right: 0.2rem;
}
.lg-entry::before {
  content: "●";
  width: auto;
  height: auto;
  background: none;
  color: #16a34a;
  font-size: 0.65rem;
  margin-right: 0.2rem;
}

.ap-metric.ap-sig {
  border-color: #c4b5fd;
  background: #f5f3ff;
}
.ap-metric.ap-sig .ap-v { color: #6d28d9; }

.ap-hint {
  font-size: 0.68rem;
  color: var(--muted);
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0.5rem 0 0;
  line-height: 1.45;
}

.muted.miss {
  color: var(--bad);
}

.gap-sections {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.gap-block {
  border-top: 1px solid var(--border);
  padding-top: 0.55rem;
}

.gap-h {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
  font-weight: 650;
}

.gap-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.86rem;
  line-height: 1.45;
}

.gap-list li {
  padding: 0.15rem 0;
  color: var(--text);
}

.gap-list .log-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-right: 0.35rem;
}

.kv dd .muted {
  font-size: 0.85em;
  margin: 0;
}

.err-inline {
  color: var(--bad);
  margin: 0;
  font-size: 0.92rem;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.25rem;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
  line-height: 1.35;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: #fff;
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
}

.badge.ok {
  color: var(--good);
  border-color: #bbf7d0;
  background: #f0fdf4;
  min-width: 2.6rem;
}

.badge.bad {
  color: var(--bad);
  border-color: #fecaca;
  background: #fef2f2;
  min-width: 2.6rem;
}

.badge.warn {
  color: var(--warn);
  border-color: var(--warn-border);
  background: var(--warn-bg);
}

.badge.extreme {
  color: #9a3412;
  border-color: #fdba74;
  background: #fff7ed;
}

.martin-lvl {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.martin-lvl-l3 {
  color: #dc2626;
}

tr.row-extreme td {
  background: #fffaf5;
}

.kv {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 0.45rem 0.75rem;
  font-size: 0.95rem;
  margin: 0;
  line-height: 1.45;
}

.kv dt {
  color: var(--muted);
  font-weight: 500;
}

.kv dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.9rem;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  margin-top: 0.5rem;
  border-radius: var(--radius-sm);
}

.compare-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.9rem;
  table-layout: auto;
}

.compare-table th,
.compare-table td {
  text-align: center;
  padding: 0.55rem 0.45rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
  word-break: keep-all;
  overflow-wrap: normal;
  line-height: 1.35;
}

.compare-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  white-space: nowrap;
}

.compare-table .col-tf,
.compare-table .col-time,
.compare-table .col-side {
  white-space: nowrap;
}

.compare-table .col-badge {
  text-align: center;
}

.compare-table .col-badge .badge,
.compare-table .col-badge .muted {
  display: inline-flex;
  justify-content: center;
  vertical-align: middle;
}

.compare-table td.num,
.compare-table th.num {
  font-family: var(--mono);
  font-size: 0.88rem;
  white-space: nowrap;
  text-align: center;
}

.cmp-scroll {
  width: 100%;
  margin-top: 0.45rem;
}

.cmp-board {
  --cmp-box: 4.8ch;
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.72rem;
}

.cmp-board th,
.cmp-board td {
  border-bottom: 1px solid var(--border);
  padding: 0.28rem 0.06rem;
  vertical-align: middle;
  text-align: center;
}

.cmp-board thead th {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  background: #fff;
}

.cmp-board th:not(.cmp-time) + th,
.cmp-board td + td {
  border-left: 1px solid var(--border);
}

.cmp-board tbody .cmp-time {
  vertical-align: middle;
}

.cmp-time {
  width: 2.55rem;
  color: var(--muted);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cmp-slot {
  text-align: center;
  overflow: visible;
}

.cmp-pair {
  display: grid;
  width: 100%;
  align-items: center;
  column-gap: 0;
  vertical-align: middle;
  grid-template-columns: 1fr var(--cmp-box) 1fr;
}

.cmp-pair > .cmp-lines {
  grid-column: 2;
  grid-row: 1;
  width: 100%;
}

.cmp-pair:not(.is-event) > .cmp-arrow,
.cmp-pair:not(.is-event) > .cmp-coin {
  grid-column: 2;
  grid-row: 1;
  justify-self: start;
  align-self: center;
  position: relative;
  z-index: 1;
  text-align: center;
}

.cmp-pair:not(.is-event) > .cmp-arrow {
  width: 0.78rem;
  margin-left: calc(-0.78rem - 0.06rem);
}

.cmp-pair:not(.is-event) > .cmp-coin {
  width: 0.7rem;
  margin-left: calc(-0.7rem - 0.78rem - 0.14rem);
}

.cmp-lines {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  min-width: 0;
  width: 100%;
}

.cmp-line {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.1rem;
  position: relative;
  width: 100%;
  min-width: 0;
}

.cmp-pair.is-event .cmp-arrow {
  position: absolute;
  left: calc(-0.78rem - 0.06rem);
  top: 50%;
  width: 0.78rem;
  margin: 0;
  text-align: center;
  transform: translateY(-50%) scaleY(1.45);
  transform-origin: center;
}

.cmp-scroll.is-blank {
  min-height: 8rem;
}

.cmp-line + .cmp-line::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -0.28rem;
  border-top: 1px dashed var(--border);
  pointer-events: none;
}

.cmp-line.is-box + .cmp-line,
.cmp-line + .cmp-line.is-box {
  margin-top: 0.14rem;
}

.cmp-cell {
  position: relative;
  z-index: 1;
  line-height: 1;
  min-width: 0;
}

/* 未成／缺進／跳過／未開：欄內置中，箭頭位置不變 */
.cmp-line.is-center {
  width: 100%;
  justify-content: center;
}

.cmp-line.is-center .cmp-main {
  justify-content: center;
}

/*
 * 框左右對稱外擴（與左側包箭頭的距離相同），看起來置中；
 * 欄寬仍 100%，箭頭／文字位置不變。
 */
.cmp-line.is-box {
  --cmp-box-hang: calc(0.78rem + 0.18rem);
  width: 100%;
  align-self: stretch;
}

.cmp-line.is-box::after {
  content: "";
  position: absolute;
  top: -0.14rem;
  bottom: -0.14rem;
  left: calc(-1 * var(--cmp-box-hang));
  right: calc(-1 * var(--cmp-box-hang));
  border: 1.5px solid #f97316; /* 不足等：橘框 */
  border-radius: 6px;
  pointer-events: none;
  z-index: 0;
  box-sizing: border-box;
}

.cmp-line.is-box.is-box-red::after {
  border-color: #ef4444; /* 缺進／多進：紅框 */
}

/* 手機點按顯示 title 詳情（無 hover） */
#tip-pop {
  position: fixed;
  z-index: 10000;
  max-width: min(20rem, calc(100vw - 1.25rem));
  padding: 0.5rem 0.65rem;
  background: rgba(15, 23, 42, 0.96);
  color: #f8fafc;
  font-size: 0.75rem;
  line-height: 1.35;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.28);
  pointer-events: none;
  white-space: pre-wrap;
  word-break: break-word;
}

#tip-pop[hidden] {
  display: none !important;
}

@media (hover: none) {
  .cmp-cell[title],
  .cmp-cell[data-tip],
  .log-panel[title],
  .log-panel[data-tip],
  .log-item[title],
  .log-item[data-tip],
  .bot-run-pill[title],
  .bot-run-pill[data-tip],
  .vultr-pill[title],
  .vultr-pill[data-tip],
  .cmp-zero i[title],
  .cmp-zero i[data-tip] {
    -webkit-tap-highlight-color: transparent;
    cursor: help;
  }
}

.cmp-main {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: center;
  gap: 0.12rem;
  white-space: nowrap;
  line-height: 1;
  min-width: 0;
}

.perf-ev-bal {
  margin-left: 0.15rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
}

.cmp-arrow {
  display: inline-block;
  font-weight: 800;
  line-height: 1;
  transform: scaleY(1.45);
  transform-origin: center;
}

.cmp-arrow.is-long { color: var(--good); }
.cmp-arrow.is-short { color: var(--bad); }

.cmp-coin {
  font-weight: 750;
}

.cmp-cell.is-up .cmp-pnl,
.cmp-cell.is-up .cmp-tag { color: var(--good); }
.cmp-cell.is-down .cmp-pnl,
.cmp-cell.is-down .cmp-tag { color: var(--bad); }
.cmp-cell.is-live .cmp-tag { color: var(--muted); }

.cmp-cell + .cmp-cell {
  position: relative;
  margin-top: 0.5rem;
  padding-top: 0;
}

.cmp-cell + .cmp-cell::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -0.32rem;
  border-top: 1px dashed var(--border);
  pointer-events: none;
}

.cmp-pnl {
  font-family: var(--mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cmp-meta {
  color: var(--muted);
  font-size: 0.62rem;
}

.cmp-zero {
  margin: 0.15rem 0 0.7rem;
}

.cmp-stack-head,
.cmp-stack {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  align-items: center;
  gap: 0.55rem;
}

.cmp-stack-head { margin-bottom: 0.15rem; }

.cmp-stack-axis {
  grid-column: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  text-align: center;
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.cmp-stack-sum {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  font-weight: 650;
  color: #1c2430;
  white-space: nowrap;
}

.cmp-stack-sum:first-child { text-align: right; }

.cmp-stack-track {
  position: relative;
  height: 1.7rem;
}

.cmp-stack-clip {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1.05rem;
  transform: translateY(-50%);
  border-radius: 5px;
  background-color: #eef1f4;
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(15, 23, 42, 0.055) 0 1px,
    transparent 1px 7px
  );
  overflow: hidden;
}

.cmp-zero-line {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 0.32rem;
  bottom: 0.32rem;
  width: 1px;
  transform: translateX(-50%);
  background: #334155;
  pointer-events: none;
}

.cmp-stack-side {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  max-width: 50%;
}

.cmp-stack-side.is-loss { right: 50%; }
.cmp-stack-side.is-gain { left: 50%; }

.cmp-stack-side i {
  display: block;
  height: 100%;
}

.cmp-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  margin: 0.4rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.72rem;
  color: #334155;
}

.cmp-legend li {
  display: flex;
  align-items: center;
  gap: 0.28rem;
}

.cmp-legend i {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 2px;
}

.cmp-flags {
  margin: -0.25rem 0 0.55rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.logs {
  margin: 0.75rem 0 0;
  padding: 0.75rem 0.85rem;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text);
  max-height: 11rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  white-space: pre-wrap;
  word-break: break-word;
}

.week-log {
  margin-top: 0.85rem;
}

.log-panel {
  margin: 0.7rem 0 0;
  max-height: 13.5rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  overscroll-behavior: contain;
}

.log-date-picks {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.4rem 0.45rem 0.35rem;
  background: rgba(248, 250, 252, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(4px);
}

.date-chip.is-muted {
  opacity: 0.45;
}

.log-leg-note {
  margin-left: auto;
  font-size: 0.68rem;
}

.log-list {
  list-style: none;
  margin: 0;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.log-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  padding: 0.3rem 0.5rem 0.45rem;
  border-top: 1px solid var(--border);
  font-size: 0.68rem;
  color: var(--muted);
}

.log-leg {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

.log-item {
  display: grid;
  grid-template-columns: 4.6rem 1.7rem 4.6rem minmax(0, 1fr);
  gap: 0.35rem 0.55rem;
  align-items: baseline;
  padding: 0.28rem 0.45rem;
  background: #fff;
  border: none;
  border-radius: 4px;
  border-left: 2px solid var(--border-strong);
  font-variant-numeric: tabular-nums;
}

.log-item.log-act-entry {
  background: #eff6ff;
  border-left-color: #3b82f6;
}
.log-item.log-act-fill {
  background: #ecfdf5;
  border-left-color: #10b981;
}
.log-item.log-act-unfill,
.log-item.log-act-cancel {
  background: #fffbeb;
  border-left-color: #f59e0b;
}
.log-item.log-act-win {
  background: #ecfdf5;
  border-left-color: #059669;
}
.log-item.log-act-loss {
  background: #fef2f2;
  border-left-color: #dc2626;
}
.log-item.log-act-extreme,
.log-item.log-act-miss {
  background: #fff7ed;
  border-left-color: #ea580c;
}
.log-item.log-act-bark {
  background: #f5f3ff;
  border-left-color: #8b5cf6;
}
.log-item.log-act-sys,
.log-item.log-act-martin {
  background: #f8fafc;
  border-left-color: #cbd5e1;
}

.log-time,
.log-tf,
.log-win {
  font-family: var(--mono);
  font-size: 0.74rem;
  white-space: nowrap;
}

.log-time {
  color: var(--muted);
}

.log-tf {
  color: var(--muted);
  font-weight: 600;
}

.log-win {
  color: var(--text);
}

.log-act {
  font-size: 0.78rem;
  font-weight: 650;
  white-space: nowrap;
}

.log-act-entry .log-act { color: #2563eb; }
.log-act-fill .log-act { color: #047857; }
.log-act-unfill .log-act,
.log-act-cancel .log-act { color: #b45309; }
.log-act-win .log-act { color: #047857; }
.log-act-loss .log-act { color: #dc2626; }
.log-act-extreme .log-act,
.log-act-miss .log-act { color: #c2410c; }
.log-act-bark .log-act { color: #6d28d9; }
.log-act-sys .log-act { color: var(--muted); }

.log-detail {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-x {
  margin-left: 0.25rem;
  color: var(--muted);
  font-size: 0.68rem;
}

.log-leg.log-act-entry { color: #2563eb; background: #eff6ff; }
.log-leg.log-act-fill,
.log-leg.log-act-win { color: #047857; background: #ecfdf5; }
.log-leg.log-act-unfill { color: #b45309; background: #fffbeb; }
.log-leg.log-act-loss { color: #dc2626; background: #fef2f2; }
.log-leg.log-act-extreme { color: #c2410c; background: #fff7ed; }

.log-empty {
  margin: 0.75rem 0 0;
}

.card > p {
  line-height: 1.5;
}

@media (max-width: 900px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    min-height: auto;
    padding-top: max(0.55rem, env(safe-area-inset-top));
    padding-bottom: 0.55rem;
  }

  .brand {
    width: 100%;
  }

  .brand-tag,
  .top-meta {
    max-width: none;
    white-space: normal;
  }

  .header-actions {
    width: 100%;
    max-width: none;
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    flex-shrink: 1;
  }

  .header-status .bot-run-pill,
  .header-status .vultr-pill {
    min-height: 2.35rem;
    font-size: 0.78rem;
    padding: 0 0.4rem;
  }

  .header-nav .btn {
    min-height: 2.5rem;
    padding: 0 0.35rem;
    font-size: 0.92rem;
  }

  .wrap {
    padding-top: 1rem;
    gap: 0.85rem;
  }

  .card {
    padding: 1.05rem 0.95rem;
  }

  .card h2 {
    font-size: 1.08rem;
  }

  .kv {
    grid-template-columns: 4.75rem minmax(0, 1fr);
    font-size: 0.98rem;
    gap: 0.55rem 0.65rem;
  }

  .kv dd {
    font-size: 0.92rem;
  }

  .btn {
    min-height: 2.5rem;
    padding: 0 0.85rem;
    font-size: 0.9rem;
  }

  .compare-table {
    font-size: 0.88rem;
  }

  .logs {
    font-size: 0.8rem;
  }

  .log-panel {
    max-height: 12rem;
  }

  .log-item {
    grid-template-columns: 4.4rem 1.6rem 4.2rem minmax(0, 1fr);
    padding: 0.28rem 0.4rem;
  }
}

/* ── Poly-only monitor ── */
.wrap-poly {
  max-width: 920px;
  min-width: 0;
}

.wrap-poly:has(#pane-kol:not(.hidden)) {
  max-width: 1120px;
}

.poly-msg {
  margin: -0.25rem 0 0.75rem;
  min-height: 1.2em;
}

.poly-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.poly-block {
  min-width: 0;
  padding: 0.55rem 0.65rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.poly-block .gap-h {
  margin-top: 0;
}

.emph {
  font-weight: 650;
  font-size: 1.05rem;
}

.compare-table .good {
  color: var(--good);
  font-weight: 600;
}

.compare-table .bad {
  color: var(--bad);
  font-weight: 600;
}

.compare-table .num.tone-up {
  color: var(--good);
  font-weight: 600;
}

.compare-table .num.tone-down {
  color: var(--bad);
  font-weight: 600;
}

.wrap-poly .log-panel {
  max-height: 26rem;
}

@media (max-width: 700px) {
  .poly-grid {
    grid-template-columns: 1fr;
  }
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.card-head h2 {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.55rem;
}

.card-head-right {
  flex-shrink: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
}

.week-date-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: flex-end;
}

.date-chip {
  appearance: none;
  border: 1px solid var(--border, #e2e8f0);
  background: #fff;
  color: var(--muted, #64748b);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--mono, ui-monospace, monospace);
  padding: 0.22rem 0.45rem;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.2;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.06rem;
  min-width: 3.6rem;
}

.date-chip .chip-pnl {
  font-size: 0.66rem;
  font-weight: 700;
}

.date-chip .chip-pnl.tone-up,
.history-date .chip-pnl.tone-up {
  color: var(--good);
}

.date-chip .chip-pnl.tone-down,
.history-date .chip-pnl.tone-down {
  color: var(--bad);
}

.chip-pnl-event {
  color: #2563eb;
}

.date-chip.is-active .chip-pnl.tone-up,
.history-date.is-active .chip-pnl.tone-up {
  color: #6ee7b7;
}

.date-chip.is-active .chip-pnl.tone-down,
.history-date.is-active .chip-pnl.tone-down {
  color: #fca5a5;
}

.date-chip.is-active .chip-pnl-event,
.history-date.is-active .chip-pnl-event {
  color: #93c5fd;
}

.week-day-pnl {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.75rem;
}

.day-pnl-card {
  flex: 1 1 5.2rem;
  min-width: 5rem;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 0.4rem 0.4rem 0.35rem;
  background: #fff;
}

.day-pnl-date {
  font-size: 0.72rem;
  color: var(--muted, #64748b);
  font-weight: 600;
}

.day-pnl-amt {
  font-size: 0.95rem;
  font-weight: 700;
  font-family: var(--mono, ui-monospace, monospace);
  margin-top: 0.08rem;
}

.day-pnl-legs {
  font-size: 0.66rem;
  margin-top: 0.12rem;
  line-height: 1.3;
}

.date-chip:hover {
  border-color: #94a3b8;
  color: #0f172a;
}

.date-chip.is-active {
  border-color: #0f172a;
  background: #0f172a;
  color: #f8fafc;
}

@media (max-width: 720px) {
  .card-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .card-head-right {
    width: 100%;
    justify-content: flex-start;
  }
  .week-date-picks {
    justify-content: flex-start;
  }
}

.host-ip {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  font-family: var(--mono);
}

.human-line {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text);
}

.human-line:last-child {
  margin-bottom: 0;
}

.today-summary {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.today-summary > div + div {
  margin-top: 0.15rem;
}

tr.row-miss td {
  color: var(--muted);
}

tr.row-size-short td {
  background: #fffbeb;
}

.status-summary {
  margin: 0.15rem 0 0.85rem;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.size-hint {
  margin: 0.55rem 0 0;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.size-hint p {
  margin: 0 0 0.35rem;
}

.size-hint p:last-child {
  margin-bottom: 0;
}

/* ── Visit note ── */
.card-visit {
  padding: 1rem 1.1rem 1.1rem;
}
.card-visit h2 {
  margin: 0;
  font-size: 1.05rem;
}
.visit-meta {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.visit-body {
  margin: 0.65rem 0 0;
  font-size: 0.95rem;
  line-height: 1.55;
}
.visit-good {
  border-color: #86efac;
  background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%);
}
.visit-down {
  border-color: #fecaca;
  background: linear-gradient(180deg, #fef2f2 0%, #ffffff 100%);
}
.visit-warn {
  border-color: #fde68a;
  background: linear-gradient(180deg, #fffbeb 0%, #ffffff 100%);
}

/* ── Performance hero ── */
.card-perf {
  padding: 1.05rem 1.1rem 1.15rem;
  background:
    linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--border);
}

.perf-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.perf-sub {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.perf-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 0.35rem 0.85rem;
  margin: 0.85rem 0 0.65rem;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  background: #0f172a;
  color: #f8fafc;
}

.perf-hero.tone-up {
  background: linear-gradient(135deg, #064e3b 0%, #0f172a 70%);
}

.perf-hero.tone-down {
  background: linear-gradient(135deg, #7f1d1d 0%, #0f172a 70%);
}

.perf-k {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  opacity: 0.75;
  white-space: nowrap;
}

.perf-pnl {
  margin-top: 0.15rem;
  font-size: clamp(1.45rem, 5.2vw, 2.35rem);
  font-weight: 700;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.perf-unit {
  margin-left: 0.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.8;
}

.perf-hero-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.perf-hero-side {
  display: grid;
  grid-template-columns: 3.6rem max-content;
  column-gap: 0.5rem;
  row-gap: 0.12rem;
  align-items: baseline;
  align-content: end;
  justify-self: end;
  font-size: 0.78rem;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.perf-row {
  display: grid;
  grid-template-columns: 3.6rem max-content;
  column-gap: 0.5rem;
  align-items: baseline;
  font-size: 0.78rem;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.perf-hero-side .perf-row {
  display: contents;
}

.perf-hero-main .perf-row {
  margin-top: auto;
  padding-top: 0.5rem;
}

.perf-lab {
  opacity: 0.72;
}

.perf-val {
  text-align: right;
}

#btn-lock {
  display: none;
}

.perf-ret {
  font-size: clamp(1.35rem, 4.5vw, 1.7rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.perf-eq {
  margin-top: 0.2rem;
  font-size: 0.8rem;
  opacity: 0.75;
  color: inherit !important;
}

.perf-transfer {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.perf-wd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.55rem;
  margin: 0.65rem 0 0.45rem;
}

.perf-legs {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin: 0.15rem 0 0.85rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.perf-legs th,
.perf-legs td {
  padding: 0.28rem 0.12rem;
  vertical-align: middle;
  white-space: nowrap;
  text-align: center;
  overflow: hidden;
}

.perf-legs th:nth-child(1),
.perf-legs td:nth-child(1) {
  width: 34%;
  white-space: normal;
}

.perf-legs th:nth-child(2),
.perf-legs td:nth-child(2) {
  width: 38%;
}

.perf-legs th:nth-child(3),
.perf-legs td:nth-child(3) {
  width: 28%;
}

.perf-legs th {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}

.perf-legs-name {
  color: var(--text);
  font-weight: 600;
}

.perf-legs-ret.tone-up,
.perf-legs-pnl.tone-up {
  color: var(--good);
}

.perf-legs-ret.tone-down,
.perf-legs-pnl.tone-down {
  color: var(--bad);
}

.perf-legs-note {
  margin: -0.4rem 0 0.85rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.perf-event-login td {
  width: auto;
  white-space: normal;
  text-align: left;
  font-size: 0.84rem;
  color: var(--muted);
  padding-top: 0.1rem;
}

.perf-event-login.tone-down td {
  color: var(--bad);
  font-weight: 600;
}

.perf-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  margin-bottom: 0.85rem;
  font-size: 0.84rem;
  color: var(--muted);
}

.month-stack {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.month-card {
  padding: 0.75rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
}

.month-card.tone-up {
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.month-card.tone-down {
  border-color: #fecaca;
  background: #fef2f2;
}

.month-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.month-pnl {
  margin-top: 0.25rem;
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.month-card.tone-up .month-pnl {
  color: var(--good);
}

.month-card.tone-down .month-pnl {
  color: var(--bad);
}

.month-unit {
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.7;
}

.month-meta,
.month-pct {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.month-sleeves {
  margin-top: 0.45rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--border);
  display: grid;
  gap: 0.22rem;
}

.month-sleeve {
  display: grid;
  grid-template-columns: 2.6rem auto minmax(0, 1fr);
  gap: 0.35rem;
  align-items: baseline;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.month-sleeve-pnl {
  text-align: right;
}

.month-sleeve-k { font-weight: 700; }
.month-sleeve-pnl.tone-up { color: var(--good); }
.month-sleeve-pnl.tone-down { color: var(--bad); }

.month-wr5m {
  margin-top: 0.45rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--border);
}

.month-wr-cap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.month-wr-wl {
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.month-wr {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.28rem;
  font-size: 0.82rem;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.month-wr-k {
  font-weight: 600;
  color: var(--muted);
}

.month-wr-v {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}

.month-wr-live {
  font-weight: 700;
  color: var(--text);
}

.month-wr.tone-up .month-wr-live {
  color: var(--good);
}

.month-wr.tone-down .month-wr-live {
  color: var(--bad);
}

.month-wr-now {
  margin-left: 0.3rem;
  font-style: normal;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
}

.month-wr-bt {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.month-wr-bt.tone-up {
  color: var(--good);
  opacity: 0.8;
}

.month-wr-bt.tone-down {
  color: var(--bad);
  opacity: 0.8;
}

.month-hist {
  margin: 0;
  padding: 0.85rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
}

.month-hist-toggle {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  user-select: none;
}

.month-hist-toggle::-webkit-details-marker {
  display: none;
}

.month-hist-toggle::after {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  margin-top: -0.15rem;
  flex-shrink: 0;
}

.month-hist[open] .month-hist-toggle::after {
  transform: rotate(-135deg);
  margin-top: 0.15rem;
}

.month-hist:not([open]) {
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.month-hist-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.75rem;
}

/* position side label — neutral (PnL color lives on 勝率 / BTC) */
.side-pill {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.3;
  color: var(--muted);
  background: #f1f5f9;
  border: 1px solid var(--border);
}
.pos-table tbody tr.side-up td:first-child {
  box-shadow: inset 3px 0 0 #10b981;
}
.pos-table tbody tr.side-down td:first-child {
  box-shadow: inset 3px 0 0 #ef4444;
}

/* live win-rate (stable DOM; patch text only) */
.live-odds {
  margin-top: 0.65rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--border);
  background: #fff;
  min-height: 5.5rem;
}
.live-odds-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.live-odds-title {
  flex: 1;
  min-width: 0;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.live-odds-shares {
  font-size: 0.78rem;
  flex-shrink: 0;
}
.live-odds-link {
  font-size: 0.75rem;
  text-decoration: none;
  flex-shrink: 0;
}
.live-empty,
.live-status {
  margin: 0.35rem 0 0;
}
.live-odds-main {
  margin-top: 0.55rem;
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.live-odds-col {
  min-width: 4.5rem;
}
.live-odds-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 0.2rem;
}
.live-odds-num {
  font-size: 2.1rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text);
}
.live-odds-num.tone-good {
  color: var(--good);
}
.live-odds-num.tone-bad {
  color: var(--bad);
}
.live-odds-num.live-btc {
  font-size: 1.55rem;
  font-weight: 700;
}

.bot-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 8px 0 16px;
  align-items: stretch;
}
@media (max-width: 720px) {
  .bot-split { grid-template-columns: 1fr; }
}
.bot-leg {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  min-width: 0;
}
.bot-leg-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 10px;
  margin-bottom: 6px;
  font-size: 0.95rem;
  min-height: 1.75rem;
}
.bot-leg-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bot-leg-head .badge {
  justify-self: end;
  flex-shrink: 0;
}
.bot-leg .status-summary { margin: 0; font-size: 0.88rem; }

.stake-hint {
  margin: 0 0 0.85rem;
  font-size: 0.82rem;
}
.stake-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
}
.stake-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.92rem;
}
#ctrl-withdrawn {
  width: 6.5rem;
}
.stake-field input {
  width: 4.6rem;
  min-height: 2.25rem;
  padding: 0 0.5rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-variant-numeric: tabular-nums;
}
.stake-field input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
.stake-suffix {
  color: var(--muted);
  font-weight: 500;
}
#stake-live {
  overflow-wrap: anywhere;
  word-break: break-word;
}
#stake-status,
#withdrawn-status {
  margin: 0.7rem 0 0;
  min-height: 1.2em;
}

.tab-nav {
  display: inline-flex;
  align-items: stretch;
  padding: 0.15rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  gap: 0.1rem;
}

.tab-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  min-height: 2.05rem;
  padding: 0 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.is-active {
  background: var(--text);
  color: #fff;
}

.header-nav .tab-btn {
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  border-radius: var(--radius-sm);
}

.header-nav .tab-btn.is-active {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

.params-toggle {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.35;
  user-select: none;
}

.params-toggle::-webkit-details-marker {
  display: none;
}

.params-toggle::after {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  margin-top: -0.15rem;
  flex-shrink: 0;
}

.card-params[open] .params-toggle::after {
  transform: rotate(-135deg);
  margin-top: 0.15rem;
}

.card-params:not([open]) {
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
}

.params-body {
  margin-top: 0.85rem;
}

.params-ops {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
  margin: 0 0 1rem;
  padding: 0 0 1rem;
  border-bottom: 1px solid var(--border);
}

.params-btns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.bot-ctrl {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0 0 1rem;
}

.bot-ctrl-row {
  display: grid;
  grid-template-columns: minmax(6.2rem, 1fr) auto auto;
  align-items: center;
  gap: 0.45rem;
}

.bot-ctrl-label {
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--text);
}

.bn-run-pill {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--muted);
}
.bn-run-pill.is-on { color: var(--good); }
.bn-run-pill.is-off { color: var(--bad); }

.bot-ctrl-row .btn {
  min-width: 4.4rem;
}

.kol-lead {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.kol-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  align-items: start;
}

.kol-person {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 0.95rem 0.95rem 0.8rem;
  min-width: 0;
}

.kol-person.is-b { border-top-color: #b45309; }
.kol-person.is-c { border-top-color: #334155; }
.kol-person.is-d { border-top-color: #0f766e; }

.kol-person-top {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.35rem;
}

.kol-notify {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  padding: 0.28rem 0.7rem;
  min-height: 2rem;
  cursor: pointer;
}

.kol-notify.is-on {
  background: #ecfdf5;
  color: #047857;
  border-color: #6ee7b7;
}

.kol-person h2 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.kol-person-sub {
  margin: 0.15rem 0 0.15rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.kol-sec {
  margin: 0.85rem 0 0.15rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.kol-trade {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 10px;
  padding: 0.62rem 0.7rem 0.55rem;
  margin-top: 0.5rem;
}

.kol-trade.is-long { border-left-color: var(--good); }
.kol-trade.is-short { border-left-color: var(--bad); }
.kol-trade.is-close { background: #fff; }

.kol-trade-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.4rem;
  min-width: 0;
}

.kol-pill {
  flex: none;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.3;
  padding: 0.08rem 0.42rem;
  border-radius: 999px;
}

.kol-pill.is-open.is-long { background: #ecfdf5; color: #047857; }
.kol-pill.is-open.is-short { background: #fef2f2; color: #b91c1c; }
.kol-pill.is-close { background: #f1f5f9; color: #475569; }

.kol-sym {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.kol-when {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kol-px {
  margin-top: 0.28rem;
  font-size: 1.28rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.kol-px-label {
  margin-right: 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0;
}

.kol-meta,
.kol-range {
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.kol-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 0.7rem;
}

.kol-empty {
  margin: 0.55rem 0 0.15rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.kol-ask {
  appearance: none;
  margin-top: 0.35rem;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.1rem 0;
  cursor: pointer;
}

.kol-ask:disabled {
  opacity: 0.55;
  cursor: default;
}

.kol-hist-toggle {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 0.75rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.15rem 0;
  cursor: pointer;
}

.kol-chat {
  margin-top: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  padding: 0.55rem;
}

.kol-chat-topic {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.kol-chat-topic:empty {
  display: none;
}

.kol-chat-log {
  max-height: 18rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.kol-chat-empty {
  margin: 0.2rem 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.kol-bubble {
  border-radius: 10px;
  padding: 0.42rem 0.55rem;
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.kol-bubble.is-user {
  align-self: flex-end;
  max-width: 92%;
  background: var(--accent);
  color: #fff;
}

.kol-bubble.is-ai {
  background: #fff;
  border: 1px solid var(--border);
}

.kol-chat-form {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.kol-chat-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.42rem 0.5rem;
  font: inherit;
  font-size: 0.85rem;
  background: #fff;
}

.kol-chat-send {
  appearance: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}

.kol-chat-send:disabled,
.kol-chat-input:disabled {
  opacity: 0.55;
  cursor: default;
}

.kol-hist {
  max-height: 24rem;
  overflow: auto;
  margin-top: 0.2rem;
}

.kol-hist-row {
  padding: 0.55rem 0.05rem 0.45rem;
  border-bottom: 1px solid var(--border);
}

.kol-hist-row:last-child {
  border-bottom: 0;
}

.kol-when.is-up { color: var(--good); font-weight: 700; }
.kol-when.is-down { color: var(--bad); font-weight: 700; }

@media (max-width: 900px) {
  .kol-board {
    grid-template-columns: 1fr;
  }
}

.history-layout {
  display: grid;
  grid-template-columns: 8.4rem minmax(0, 1fr);
  gap: 0.85rem;
  align-items: start;
}

.history-dates {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  position: sticky;
  top: calc(var(--header-h) + 0.75rem);
  max-height: calc(100vh - var(--header-h) - 1.5rem);
  overflow: auto;
  padding-right: 0.15rem;
}

.history-date {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.08rem;
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
}

.history-date-top {
  display: flex;
  width: 100%;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem;
}

.history-date .chip-pnl {
  font-size: 0.66rem;
  font-weight: 700;
  font-family: var(--mono, ui-monospace, monospace);
}

.history-date:hover {
  border-color: #94a3b8;
  color: var(--text);
}

.history-date.is-active {
  border-color: var(--text);
  background: var(--text);
  color: #f8fafc;
}

.history-date-md {
  font-variant-numeric: tabular-nums;
}

.history-date-wd {
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.78;
}

.history-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
}

#history-compare .log-panel {
  max-height: 36rem;
}

@media (max-width: 720px) {
  .history-layout {
    grid-template-columns: 1fr;
  }

  .history-dates {
    position: static;
    max-height: none;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.15rem;
    -webkit-overflow-scrolling: touch;
  }

  .history-date {
    width: auto;
    flex: 0 0 auto;
    min-width: 4.6rem;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
  }

  .params-ops {
    flex-direction: column;
    align-items: stretch;
  }

  .params-ops .vultr-pill,
  .params-ops #btn-bark,
  .params-ops #btn-anomaly {
    width: 100%;
    justify-content: center;
  }

  .bot-ctrl-row {
    grid-template-columns: minmax(5.2rem, 1fr) 1fr 1fr;
  }

  .bot-ctrl-row .btn {
    width: 100%;
    min-height: 2.6rem;
  }
}

body.is-view-locked .tab-nav,
body.is-view-locked .header-nav .tab-btn,
body.is-view-locked #pane-monitor,
body.is-view-locked #pane-history,
body.is-view-locked #pane-kol,
body.is-view-locked #btn-lock,
body.is-view-locked #btn-refresh {
  display: none !important;
}

.card-lock-status h2 {
  margin: 0 0 0.35rem;
}

.lock-until-line {
  margin: 0 0 1.1rem;
  color: var(--muted);
}

.lock-bots {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
}

.lock-bot {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 0.75rem;
  background: var(--bg);
}

.lock-bot-k {
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

.lock-bot-v {
  width: 100%;
  justify-content: center;
}

.lock-login {
  margin: 0.9rem 0 0;
  font-weight: 650;
}

.lock-login.is-warn {
  color: var(--bad);
}

.lock-hint {
  margin: 0.45rem 0 0;
}

.lock-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.45);
}

.lock-modal.hidden {
  display: none !important;
}

.lock-modal-card {
  width: min(420px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.25rem;
  box-shadow: var(--shadow-md);
}

.lock-modal-card h2 {
  margin: 0 0 0.55rem;
  font-size: 1.1rem;
}

.lock-modal-card p {
  margin: 0 0 0.7rem;
  font-size: 0.92rem;
}

.lock-date-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0.9rem 0 0.35rem;
}

.lock-date-field input {
  min-height: 2.4rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
}

.lock-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  margin-top: 1rem;
}

@media (max-width: 720px) {
  .lock-bots {
    grid-template-columns: 1fr 1fr;
  }
}
