/* ============================================================
   auto-traders 통합 대시보드 — UI mock
   Dark navy/black dashboard with subtle noise grid.
   ============================================================ */

:root {
  /* Surface */
  --bg-app: #050810;
  --bg-sidebar: #0a0e18;
  --bg-card: rgba(17, 22, 35, 0.78);
  --bg-card-solid: #11161f;
  --bg-card-soft: rgba(22, 28, 42, 0.65);
  --bg-elev: #161b27;
  --grid-line: rgba(255, 255, 255, 0.035);

  /* Border */
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.09);
  --border-blue: rgba(96, 165, 250, 0.35);

  /* Text */
  --text: #e6e9f2;
  --text-dim: #aab0c0;
  --text-mute: #6e7689;
  --text-faint: #4a5163;

  /* Accents */
  --green: #22c98a;
  --green-soft: rgba(34, 201, 138, 0.14);
  --red: #ef4f5b;
  --red-soft: rgba(239, 79, 91, 0.15);
  --amber: #f4b740;
  --amber-soft: rgba(244, 183, 64, 0.16);
  --orange: #f48a3e;
  --orange-soft: rgba(244, 138, 62, 0.18);
  --blue: #4ea8ff;
  --blue-soft: rgba(78, 168, 255, 0.14);
  --purple: #a978ff;
  --purple-soft: rgba(169, 120, 255, 0.18);

  /* Radii / shadows */
  --r-card: 14px;
  --r-pill: 999px;
  --shadow-card: 0 1px 0 rgba(255,255,255,0.02) inset, 0 8px 24px rgba(0,0,0,0.35);
}

body.theme-light {
  --bg-app: #f3efe6;
  --bg-sidebar: #e8e1d5;
  --bg-card: rgba(255, 253, 247, 0.82);
  --bg-card-solid: #fffdf7;
  --bg-card-soft: rgba(246, 241, 232, 0.82);
  --bg-elev: #eee7da;
  --grid-line: rgba(57, 74, 62, 0.07);
  --border: rgba(59, 76, 64, 0.13);
  --border-strong: rgba(59, 76, 64, 0.22);
  --border-blue: rgba(65, 111, 145, 0.28);
  --text: #202820;
  --text-dim: #4f5f53;
  --text-mute: #738073;
  --text-faint: #a4aca2;
  --green: #2e8f61;
  --green-soft: rgba(46, 143, 97, 0.13);
  --red: #b74750;
  --red-soft: rgba(183, 71, 80, 0.13);
  --amber: #a96f19;
  --amber-soft: rgba(169, 111, 25, 0.14);
  --orange: #b86428;
  --orange-soft: rgba(184, 100, 40, 0.14);
  --blue: #416f91;
  --blue-soft: rgba(65, 111, 145, 0.13);
  --purple: #7d67a6;
  --purple-soft: rgba(125, 103, 166, 0.13);
  --shadow-card: 0 1px 0 rgba(255,255,255,0.65) inset, 0 10px 24px rgba(74, 62, 45, 0.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg-app);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
  min-height: 100vh;
  /* Subtle grid + radial glow background */
  background-image:
    radial-gradient(1100px 600px at 70% -10%, rgba(40, 70, 130, 0.12), transparent 60%),
    radial-gradient(900px 500px at -5% 110%, rgba(30, 90, 70, 0.08), transparent 60%),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: auto, auto, 32px 32px, 32px 32px;
}

.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--text-mute); }
.small { font-size: 11px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }
/* 한국식 손익 색상: 수익+ 빨강, 수익- 파랑. 손익(P&L) 표시 전용. */
.text-pnl-up { color: var(--red); font-weight: 600; }
.text-pnl-down { color: #4ea8ff; font-weight: 600; }
/* 봇 장부 / 청산 기록 테이블 셀 — specificity 우선 + bold */
.log-table tbody td.text-pnl-up,
.log-table tbody td.text-pnl-up.mono { color: var(--red); font-weight: 600; }
.log-table tbody td.text-pnl-down,
.log-table tbody td.text-pnl-down.mono { color: #4ea8ff; font-weight: 600; }
/* 행 전체에 클래스 붙은 경우(레거시 호환) */
.log-table tbody tr.text-pnl-up td,
.log-table tbody tr.text-pnl-up td.mono { color: var(--red); font-weight: 600; }
.log-table tbody tr.text-pnl-down td,
.log-table tbody tr.text-pnl-down td.mono { color: #4ea8ff; font-weight: 600; }

/* =================== LAYOUT =================== */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

/* =================== SIDEBAR =================== */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 14px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 6px 14px;
  color: var(--text);
}
.brand-mark {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2a4bff, #3da4ff);
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06), 0 4px 14px rgba(60, 120, 255, 0.35);
}
.brand-text { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--text-dim);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
  user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item .nav-icon { display: inline-flex; color: currentColor; opacity: 0.85; }
.nav-item.is-active {
  background: rgba(59, 130, 246, 0.14);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.28);
}
.nav-item.is-active .nav-icon { opacity: 1; }

/* sidebar bottom */
.sidebar-bottom { display: flex; flex-direction: column; gap: 12px; }
.kill-switch {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 11px 12px;
  background: linear-gradient(180deg, rgba(239, 79, 91, 0.16), rgba(239, 79, 91, 0.08));
  border: 1px solid rgba(239, 79, 91, 0.45);
  border-radius: 10px;
  color: #ffb4ba;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background .15s ease;
}
.kill-switch:hover { background: linear-gradient(180deg, rgba(239, 79, 91, 0.22), rgba(239, 79, 91, 0.1)); }
.kill-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: rgba(239, 79, 91, 0.18);
  color: #ff8a93;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 30px;
}
.kill-text { display: flex; flex-direction: column; line-height: 1.2; }
.kill-title { font-size: 12.5px; font-weight: 600; color: #ffb9be; }
.kill-sub { font-size: 10.5px; letter-spacing: 0.08em; color: #ff8a93; font-weight: 600; }

.status-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
}
.status-title { font-size: 11px; font-weight: 600; color: var(--text-dim); margin-bottom: 8px; letter-spacing: 0.02em; }
.status-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.status-list li {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-dim);
}
.status-value { color: var(--text); font-weight: 500; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); box-shadow: 0 0 8px rgba(34, 201, 138, 0.55); }
.dot-orange { background: var(--orange); }
.dot-blue { background: var(--blue); }
.dot-muted { background: var(--text-faint); }

.sidebar-footer {
  font-size: 10.5px; color: var(--text-faint);
  text-align: center; padding-top: 4px;
}

/* =================== MAIN =================== */
.main {
  padding: 18px 26px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

/* topbar */
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.page-title { margin: 0 0 4px; font-size: 22px; font-weight: 700; letter-spacing: -0.015em; }
.page-subtitle { margin: 0; color: var(--text-mute); font-size: 12.5px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px;
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600;
}
.pill-green {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(34, 201, 138, 0.35);
}

.btn-ghost, .btn-outline, .icon-btn, .btn-ghost-sm {
  font-family: inherit;
  font-size: 12.5px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
  color: var(--text);
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  padding: 6px 12px;
  font-weight: 500;
}
.btn-ghost:hover { background: rgba(255,255,255,0.04); }
.btn-outline {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent;
  border: 1px solid var(--border-strong);
  padding: 6px 11px;
  font-weight: 500;
}
.btn-outline:hover { background: rgba(255,255,255,0.04); }
.icon-btn {
  width: 30px; height: 30px;
  background: transparent;
  border: 1px solid var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-dim);
}
.icon-btn:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.btn-ghost-sm {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 4px 6px;
  font-size: 12px;
}
.btn-ghost-sm:hover { color: var(--text); }

.theme-menu-wrap {
  position: relative;
  display: inline-flex;
}
.theme-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 218px;
  display: none;
  z-index: 80;
  padding: 9px;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  background: var(--bg-card-solid);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.34);
}
.theme-menu-wrap.is-open .theme-menu-panel,
.theme-menu-wrap:focus-within .theme-menu-panel {
  display: block;
}
.theme-menu-title {
  padding: 4px 6px 8px;
  color: var(--text-mute);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.theme-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  margin: 1px 0;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--text-dim);
  background: transparent;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.theme-option:hover,
.theme-option.is-selected {
  color: var(--text);
  background: var(--bg-card-soft);
  border-color: var(--border);
}
.theme-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
}
.dot-system {
  background: linear-gradient(135deg, #11161f 0 48%, #fffdf7 52% 100%);
}
.dot-dark {
  background: #11161f;
}
.dot-light {
  background: linear-gradient(135deg, #d9cdb9, #6f9879);
}
.theme-palette-note {
  margin-top: 7px;
  padding: 8px 7px 2px;
  border-top: 1px solid var(--border);
  color: var(--text-mute);
  font-size: 11px;
  line-height: 1.35;
}

/* Light theme contrast fixes */
body.theme-light .nav-item.is-active,
body.theme-light.page-coin .nav-item.is-active,
body.theme-light.page-stock .nav-item.is-active,
body.theme-light.page-logs .nav-item.is-active,
body.theme-light.page-settings .nav-item.is-active {
  background: rgba(47, 111, 145, 0.13);
  color: #234d67;
  border-color: rgba(47, 111, 145, 0.30);
}
body.theme-light .top-tab.is-active,
body.theme-light .btab.is-active {
  color: #243126;
}
body.theme-light .kill-switch {
  background: linear-gradient(180deg, rgba(183, 71, 80, 0.15), rgba(183, 71, 80, 0.08));
  border-color: rgba(183, 71, 80, 0.42);
  color: #7f2730;
}
body.theme-light .kill-switch:hover {
  background: linear-gradient(180deg, rgba(183, 71, 80, 0.20), rgba(183, 71, 80, 0.10));
}
body.theme-light .kill-icon {
  background: rgba(183, 71, 80, 0.14);
  color: #9b303a;
}
body.theme-light .kill-title {
  color: #7f2730;
}
body.theme-light .kill-sub {
  color: #9b303a;
}
body.theme-light .log-viewer-body {
  background: #fffaf0;
  border-color: rgba(59, 76, 64, 0.18);
}
body.theme-light .log-row,
body.theme-light .log-table tbody td,
body.theme-light .logs-row {
  color: #314036;
}
body.theme-light .log-ts,
body.theme-light .logs-cell.time {
  color: #667567;
}
body.theme-light .log-src {
  color: #2a4f62;
}
body.theme-light .log-msg,
body.theme-light .logs-cell.message {
  color: #1f2a24;
}
body.theme-light .log-table thead th,
body.theme-light .logs-th {
  color: #59685d;
}
body.theme-light .log-table tbody td,
body.theme-light .logs-row {
  border-bottom-color: rgba(59, 76, 64, 0.10);
}
body.theme-light .lvl-info,
body.theme-light .src-upbit {
  color: #285f86;
}
body.theme-light .lvl-buy {
  color: #226b48;
}
body.theme-light .lvl-sell {
  color: #97343d;
}
body.theme-light .lvl-warn,
body.theme-light .src-kis {
  color: #8a5812;
}
body.theme-light .alert-info {
  background: rgba(65, 111, 145, 0.12);
  border-color: rgba(65, 111, 145, 0.28);
  color: #24485f;
}
body.theme-light .alert-warn {
  background: rgba(169, 111, 25, 0.13);
  border-color: rgba(169, 111, 25, 0.30);
  color: #71450f;
}
body.theme-light .alert code,
body.theme-light .control-notes code {
  background: rgba(59, 76, 64, 0.08);
  color: #314036;
}

/* =================== CARDS =================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* KPI row */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.kpi { padding: 12px 16px 11px; }
.kpi-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.kpi-label { color: var(--text-mute); font-size: 12px; font-weight: 500; }
.kpi-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
}
.bg-blue { background: var(--blue-soft); color: var(--blue); }
.bg-green { background: var(--green-soft); color: var(--green); }
.bg-purple { background: var(--purple-soft); color: var(--purple); }
.bg-blue-tint { background: rgba(78, 168, 255, 0.18); color: var(--blue); }
.bg-amber-tint { background: rgba(244, 183, 64, 0.18); color: var(--amber); }

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi-foot {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 10px; margin-top: 6px;
}
.kpi-foot-left { display: flex; flex-direction: column; gap: 1px; }
.kpi-sub { color: var(--text-mute); font-size: 11.5px; }
.kpi-delta { font-size: 13px; font-weight: 600; }
.delta-up { color: var(--green); }
.delta-down { color: var(--red); }
.kpi-strong { font-weight: 600; font-size: 13.5px; }
.kpi-unit { color: var(--text-mute); font-weight: 500; font-size: 11.5px; }
.sparkline { display: block; }

/* Risk strip */
.risk-strip {
  display: grid;
  grid-template-columns: 1.1fr 1.6fr repeat(4, 1fr);
  align-items: center;
  padding: 11px 18px;
  gap: 8px;
}
.risk-cell { display: flex; flex-direction: column; gap: 4px; }
.risk-cell.risk-main { flex-direction: row; align-items: center; gap: 10px; }
.risk-label { color: var(--text-mute); font-size: 12px; font-weight: 500; }
.risk-shield {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--green-soft); color: var(--green);
  display: inline-flex; align-items: center; justify-content: center;
}
.risk-text { display: flex; flex-direction: column; line-height: 1.15; }
.risk-title { color: var(--green); font-weight: 700; font-size: 17px; }
.risk-sub { color: var(--text-mute); font-size: 10.5px; letter-spacing: 0.06em; }
.risk-value { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text); font-size: 13px; }
.risk-value-strong { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.risk-unit { color: var(--text-mute); font-size: 11.5px; font-weight: 500; }

/* Engine cards */
.engine-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.engine-card { padding: 12px 16px 13px; }
.engine-head { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.engine-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.engine-badge {
  width: 28px; height: 28px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
}
.engine-badge .engine-glyph { font-size: 10px; }
.engine-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px 14px;
}
.cell { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.cell-label { color: var(--text-mute); font-size: 11.5px; }
.cell-value { color: var(--text); font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }

/* chip pills */
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 600;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  font-family: inherit;
  cursor: pointer;
}
.chip-orange { background: var(--orange-soft); color: var(--orange); border-color: rgba(244, 138, 62, 0.35); }

/* Charts row */
.charts-row {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 12px;
}
.chart-card { padding: 12px 16px; display: flex; flex-direction: column; min-width: 0; }
.chart-head { margin-bottom: 5px; }
.chart-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.legend { display: flex; gap: 14px; margin-top: 6px; font-size: 11.5px; color: var(--text-dim); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend-swatch.bg-blue { background: var(--blue); }
.legend-swatch.bg-green { background: var(--green); }
.big-stat { font-size: 18px; font-weight: 700; margin-top: 6px; letter-spacing: -0.01em; }
.big-stat-unit { font-size: 12px; color: var(--text-mute); font-weight: 500; }
.chart-body { flex: 1; min-height: 128px; height: 128px; position: relative; }

/* Donut */
.donut-wrap { display: grid; grid-template-columns: 96px 1fr; gap: 16px; align-items: center; padding-top: 2px; }
.donut-canvas-wrap { position: relative; width: 96px; height: 96px; }
.donut-canvas-wrap canvas { width: 96px !important; height: 96px !important; }
.donut-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.donut-num { font-size: 22px; font-weight: 700; }
.donut-label { font-size: 11px; color: var(--text-mute); }
.donut-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.donut-legend li {
  display: grid;
  grid-template-columns: 12px 1fr auto auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.donut-legend .ll-name { font-weight: 600; }
.donut-legend .ll-pct { color: var(--text-dim); font-size: 11.5px; }
.donut-legend .ll-amt { color: var(--text-mute); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.donut-foot { display: flex; justify-content: space-between; padding-top: 8px; margin-top: 6px; border-top: 1px solid var(--border); }
.donut-foot .right { text-align: right; }

/* Log table */
.log-card { padding: 11px 16px 4px; }
.log-head { display: flex; align-items: center; gap: 14px; }
.log-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.chips { display: flex; gap: 6px; flex: 1; }
.chip-active { background: rgba(255,255,255,0.08); color: var(--text); border-color: rgba(255,255,255,0.15); }
.chip-info   { color: var(--blue);  border-color: rgba(78, 168, 255, 0.25); }
.chip-buy    { color: var(--green); border-color: rgba(34, 201, 138, 0.25); }
.chip-sell   { color: var(--red);   border-color: rgba(239, 79, 91, 0.25); }
.chip-warn   { color: var(--amber); border-color: rgba(244, 183, 64, 0.25); }
.chip-error  { color: var(--red);   border-color: rgba(239, 79, 91, 0.30); background: var(--red-soft); }

.table-wrap { overflow-x: auto; margin-top: 6px; }
.log-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.log-table thead th {
  text-align: left; font-weight: 500; color: var(--text-mute);
  padding: 7px 10px; border-bottom: 1px solid var(--border);
  font-size: 11.5px; letter-spacing: 0.02em;
}
.log-table tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text);
}
.log-table tbody tr:last-child td { border-bottom: none; }
.log-table .right { text-align: right; }
.lvl {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 8px; border-radius: 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em;
}
.lvl-info { background: var(--blue-soft); color: var(--blue); }
.lvl-buy { background: var(--green-soft); color: var(--green); }
.lvl-sell { background: var(--red-soft); color: var(--red); }
.lvl-warn { background: var(--amber-soft); color: var(--amber); }
.lvl-trailing { background: var(--amber-soft); color: var(--amber); font-weight: 700; }

/* =================== RESPONSIVE =================== */
@media (max-width: 1240px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr 1fr; }
  .charts-row .chart-card:nth-child(3) { grid-column: span 2; }
  .risk-strip { grid-template-columns: repeat(3, 1fr); row-gap: 14px; }
  .engine-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .kpi-row, .engine-row, .charts-row { grid-template-columns: 1fr; }
  .charts-row .chart-card:nth-child(3) { grid-column: auto; }
  .engine-grid { grid-template-columns: repeat(2, 1fr); }
  .risk-strip { grid-template-columns: 1fr 1fr; }
}

/* 거래시간 표시 — 데스크톱 = 풀("YYYY-MM-DD HH:MM:SS"), 모바일 ≤880px = 6자리 HHMMSS */
.dt-mobile { display: none; }
@media (max-width: 880px) {
  .dt-full   { display: none; }
  .dt-mobile { display: inline; letter-spacing: 0.5px; }
}

/* =================================================================
   COIN BOT PAGE (coin.html) — auto-traders 코인봇 (업비트)
   ================================================================= */

/* nav-item active variant for coin page — slightly bluer */
.page-coin .nav-item.is-active {
  background: rgba(59, 130, 246, 0.20);
  color: #cfe2ff;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

/* Sidebar: 봇 상태 mini card (only on coin page) */
.bot-status-card {
  margin-top: 14px;
  padding: 12px 13px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bsc-title {
  font-size: 11.5px;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}
.bsc-run {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--green);
  font-weight: 700;
  font-size: 14px;
}
.bsc-pid {
  color: var(--text-mute);
  font-size: 11px;
  margin-left: 14px;
  margin-bottom: 4px;
}
.bsc-sub-label {
  color: var(--text-mute);
  font-size: 11px;
  margin-top: 6px;
}
.bsc-sub-value {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

/* Top horizontal tabs */
.top-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-top: 2px;
  margin-bottom: 4px;
}
.top-tab {
  padding: 9px 16px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s ease, border-color .15s ease;
  text-decoration: none;
}
.top-tab:hover { color: var(--text); }
.top-tab.is-active {
  color: #fff;
  border-bottom-color: var(--red);
  font-weight: 600;
}

/* Coin KPI row — 4 cards */
.coin-kpi-row {
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.coin-kpi {
  padding: 13px 16px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.ckpi-head {
  display: inline-flex; align-items: center; gap: 9px;
}
.ckpi-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 30px;
}
.ckpi-label {
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 500;
}
.ckpi-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.ckpi-value .ckpi-pid {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-mute);
  margin-left: 4px;
}
.ckpi-value .ckpi-unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-mute);
}
.ckpi-sub-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-top: 2px;
}
.ckpi-sub-row {
  display: flex; flex-direction: column; gap: 2px;
}
.ckpi-sub-label { color: var(--text-mute); font-size: 11.5px; }
.ckpi-sub-value { color: var(--text); font-size: 13.5px; font-weight: 600; }
.ckpi-sub-strong { font-size: 12px; font-weight: 600; color: var(--text); }

.ckpi-progress-wrap { display: flex; flex-direction: column; gap: 6px; }
.ckpi-progress-head {
  display: flex; justify-content: space-between; align-items: baseline;
}
.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.05);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--purple);
}
.bg-grad-purple {
  background: linear-gradient(90deg, #a978ff, #ec4899);
}

.bg-red { background: var(--red-soft); color: var(--red); }

/* Coin section title */
.coin-section-title {
  padding: 11px 18px;
}
.coin-section-title h2 {
  margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -0.01em;
}

/* Coin status strip (auto-mode / new-buy / refresh-time / note) */
.coin-status-strip {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1.1fr 1.4fr;
  align-items: stretch;
  padding: 14px 18px;
  gap: 14px;
}
.cstrip-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  border-right: 1px solid var(--border);
  padding-right: 14px;
}
.cstrip-cell:last-child { border-right: none; }
.cstrip-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 32px;
}
.cstrip-label {
  color: var(--text-mute);
  font-size: 11.5px;
  margin-bottom: 3px;
}
.cstrip-value {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}
.cstrip-note .cstrip-value {
  font-size: 13.5px;
  font-weight: 600;
}

/* Mid row: 시장 입력 / 적용 파라미터 */
.coin-mid-row {
  display: grid;
  grid-template-columns: 1fr 1.45fr;
  gap: 12px;
}
.coin-mid-card { padding: 13px 18px 14px; }
.coin-mid-head { margin-bottom: 11px; }
.coin-mid-head h3 { margin: 0; font-size: 14px; font-weight: 700; }

.coin-mid-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px 16px;
}
.cell-value.big {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.coin-params-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px 18px;
}

.coin-mid-note {
  color: var(--text-mute);
  font-size: 11.5px;
  margin: 0 4px;
}

/* Bot control card */
.coin-control-card { padding: 14px 18px 16px; }
.control-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.control-field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
}
.select-like, .number-stepper {
  display: flex; align-items: center;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  height: 38px;
  padding: 0 12px;
  font-size: 13px;
  color: var(--text);
}
.select-like { justify-content: space-between; }
.select-like svg { color: var(--text-mute); }
.number-stepper {
  position: relative;
  padding: 0;
}
.number-stepper input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 0 12px;
  height: 100%;
}
.stepper-btn {
  width: 38px; height: 100%;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border-strong);
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
}
.stepper-btn:hover { color: var(--text); background: rgba(255,255,255,0.03); }

.control-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 14px;
}
.control-actions-left { display: flex; gap: 8px; }
.btn-start, .btn-stop, .btn-restart {
  font-family: inherit;
  border-radius: 8px;
  padding: 8px 22px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter .15s ease, background .15s ease;
}
.btn-start {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(34, 201, 138, 0.45);
}
.btn-start:hover { filter: brightness(1.1); }
.btn-stop {
  background: rgba(255,255,255,0.04);
  color: var(--text-dim);
  border-color: var(--border-strong);
}
.btn-stop:hover { background: rgba(255,255,255,0.07); color: var(--text); }
.btn-restart {
  background: var(--blue-soft);
  color: var(--blue);
  border-color: rgba(78, 168, 255, 0.4);
}
.btn-restart:hover { filter: brightness(1.1); }

.control-notes {
  margin-top: 12px;
  display: flex; flex-direction: column; gap: 3px;
}
.control-notes p {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-mute);
}
.control-notes code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  background: rgba(255,255,255,0.05);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-dim);
}

/* Log viewer card */
.log-viewer-card { padding: 13px 18px 14px; }
.log-viewer-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.log-viewer-head h3 { margin: 0; font-size: 14px; font-weight: 700; }
.log-viewer-actions { display: flex; gap: 8px; }
.btn-sm {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px;
  font-size: 11.5px;
}

.log-viewer-body {
  background: #07090f;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 11.5px;
  line-height: 1.6;
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.log-row {
  display: grid;
  grid-template-columns: 168px 50px 70px 1fr;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 11px;
}
.log-ts { color: var(--text-mute); }
.log-src { font-weight: 600; }
.log-msg { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.text-blue { color: var(--blue); }
.text-purple { color: var(--purple); }
.lvl-spacer { display: inline-block; }

/* Bottom tabs */
.bottom-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-top: 4px;
}
.btab {
  padding: 9px 18px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
}
.btab:hover { color: var(--text); }
.btab.is-active {
  color: #fff;
  border-bottom-color: var(--red);
  font-weight: 600;
}

/* Info/warn alerts */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.5;
}
.alert-icon {
  flex: 0 0 24px;
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
}
.alert code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
}
.alert-info {
  background: rgba(78, 168, 255, 0.10);
  border: 1px solid rgba(78, 168, 255, 0.30);
  color: #cfe1ff;
}
.alert-info .alert-icon { color: var(--blue); }
.alert-warn {
  background: rgba(244, 183, 64, 0.10);
  border: 1px solid rgba(244, 183, 64, 0.32);
  color: #fadfa0;
}
.alert-warn .alert-icon { color: var(--amber); }

/* RESPONSIVE for coin page */
@media (max-width: 1240px) {
  .coin-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .coin-status-strip { grid-template-columns: 1fr 1fr; row-gap: 14px; }
  .coin-mid-row { grid-template-columns: 1fr; }
  .coin-mid-grid { grid-template-columns: repeat(2, 1fr); }
  .coin-params-grid { grid-template-columns: repeat(2, 1fr); }
  .control-grid { grid-template-columns: 1fr; }
  .log-row { grid-template-columns: 130px 44px 60px 1fr; }
}
@media (max-width: 880px) {
  .coin-kpi-row { grid-template-columns: 1fr; }
  .coin-status-strip { grid-template-columns: 1fr; }
  .cstrip-cell { border-right: none; border-bottom: 1px solid var(--border); padding-bottom: 10px; padding-right: 0; }
  .cstrip-cell:last-child { border-bottom: none; }
  .top-tabs, .bottom-tabs { overflow-x: auto; flex-wrap: nowrap; }
}

/* =================================================================
   index.html (통합 대시보드) — add top-tabs spacing
   ================================================================= */
.kpi-row + .risk-strip { margin-top: 0; }

/* =================================================================
   STOCK BOT PAGE (stock.html)
   ================================================================= */
.page-stock .nav-item.is-active {
  background: rgba(244, 183, 64, 0.16);
  color: #f7d57b;
  border: 1px solid rgba(244, 183, 64, 0.32);
}
.bg-grad-amber {
  background: linear-gradient(90deg, #f4b740, #f48a3e);
}
.lvl-strategy {
  background: rgba(34, 201, 138, 0.14);
  color: var(--green);
}
.text-amber { color: var(--amber); }

/* Stock book table */
.stock-book-card { padding: 4px 4px; overflow: hidden; }
.stock-book-table { width: 100%; font-size: 12.5px; }
.stock-book-table thead th {
  padding: 9px 14px;
  background: rgba(255,255,255,0.02);
}
.stock-book-table tbody td { padding: 9px 14px; }

/* =================================================================
   LOGS PAGE (logs.html)
   ================================================================= */
.page-logs .nav-item.is-active {
  background: rgba(239, 79, 91, 0.14);
  color: #ffb3b9;
  border: 1px solid rgba(239, 79, 91, 0.28);
}

/* Page head shared */
.page-head { padding: 4px 2px 2px; }
.page-h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: inline-flex; align-items: center; gap: 8px;
}
.page-anchor {
  color: var(--text-mute);
  display: inline-flex; align-items: center;
  cursor: pointer;
}
.page-anchor:hover { color: var(--text-dim); }
.page-desc { margin: 0; color: var(--text-mute); font-size: 12.5px; }

/* Controls row */
.logs-controls {
  display: grid;
  grid-template-columns: 1fr 1.4fr 2fr;
  gap: 18px;
  padding: 14px 18px;
  align-items: end;
}
.logs-ctrl-field { display: flex; flex-direction: column; gap: 6px; }
.logs-stepper { max-width: 240px; }

/* source filter chip area */
.source-filter {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
  min-height: 38px;
  padding: 4px 6px 4px 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}
.source-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 6px 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}
.source-chip.source-upbit {
  background: rgba(239, 79, 91, 0.42);
  border: 1px solid rgba(239, 79, 91, 0.55);
}
.source-chip.source-kis {
  background: rgba(239, 79, 91, 0.42);
  border: 1px solid rgba(239, 79, 91, 0.55);
}
.source-chip .chip-x {
  width: 18px; height: 18px;
  background: rgba(0,0,0,0.18);
  border: none; border-radius: 4px;
  color: #fff; font-size: 12px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.source-tail {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 10px;
  padding-right: 6px;
  color: var(--text-mute);
}
.chip-clear {
  background: transparent; border: none;
  color: var(--text-mute); cursor: pointer;
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
}
.chip-clear:hover { color: var(--text); }
.chip-caret { color: var(--text-mute); }

/* logs table card */
.logs-table-card { padding: 0; overflow: hidden; }
.logs-table-head-row {
  display: grid;
  grid-template-columns: 168px 80px 92px 1fr 340px;
  gap: 0;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.015);
}
.logs-th {
  color: var(--text-mute);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.logs-th.search-cell {
  display: flex; align-items: center; gap: 8px;
  justify-content: flex-end;
}
.logs-search {
  position: relative;
  flex: 1;
  max-width: 280px;
}
.logs-search input {
  width: 100%;
  height: 34px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  padding: 0 30px 0 12px;
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
}
.logs-search input::placeholder { color: var(--text-mute); }
.logs-search svg {
  position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-mute);
  pointer-events: none;
}
.logs-filter-btn { width: 34px; height: 34px; }

.logs-rows { display: flex; flex-direction: column; }
.logs-row {
  display: grid;
  grid-template-columns: 168px 80px 92px 1fr;
  gap: 0;
  align-items: center;
  padding: 11px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 12.5px;
}
.logs-row:last-child { border-bottom: none; }
.logs-row:hover { background: rgba(255,255,255,0.015); }
.logs-cell.time { color: var(--text-mute); font-size: 12px; }
.logs-cell.message { color: var(--text); }

/* source badge */
.src-badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--blue);
  color: var(--blue);
  background: transparent;
  min-width: 50px;
}
.src-upbit { color: var(--blue); border-color: var(--blue); }
.src-kis { color: var(--amber); border-color: var(--amber); }

/* pagination */
.logs-pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}
.logs-pg-left { color: var(--text-mute); font-size: 12px; }
.logs-pg-right { display: flex; justify-content: flex-end; }
.logs-pg-pages {
  display: inline-flex; gap: 6px; align-items: center;
}
.pg-btn {
  min-width: 30px; height: 30px;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 8px;
}
.pg-btn:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.pg-btn.pg-active {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  font-weight: 700;
}
.pg-ellipsis { color: var(--text-mute); padding: 0 4px; }

.select-sm {
  height: 32px;
  font-size: 12.5px;
  padding: 0 10px;
  min-width: 140px;
}

/* =================================================================
   SETTINGS PAGE (settings.html)
   ================================================================= */
.page-settings .nav-item.is-active {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.32);
}

.settings-card { padding: 18px 22px 18px; }
.settings-head { margin-bottom: 16px; }
.settings-head h3 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.005em; }
.settings-sub {
  margin: 6px 0 0;
  font-size: 11.5px;
  color: var(--text-mute);
  line-height: 1.5;
}

/* env file table */
.env-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.env-table thead th {
  text-align: left;
  font-weight: 500;
  color: var(--text-mute);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  letter-spacing: 0.02em;
}
.env-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text);
  vertical-align: middle;
}
.env-table tbody tr:last-child td { border-bottom: none; }
.env-table .path {
  color: var(--text-dim);
  font-size: 12px;
}
.env-table .right { text-align: right; }
.exists-dot { display: inline-flex; align-items: center; justify-content: center; }
.exists-dot .dot { width: 10px; height: 10px; }

/* collapsible rows */
.collapsible-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.collapsible-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 12.5px;
  cursor: pointer;
  transition: background .12s ease;
}
.collapsible-row:hover { background: rgba(255,255,255,0.04); }
.collapsible-row .cr-caret { color: var(--text-mute); flex-shrink: 0; }
.collapsible-list-tight .collapsible-row { padding: 10px 14px; }

/* settings sections */
.settings-section { margin-top: 18px; }
.settings-section:first-of-type { margin-top: 4px; }
.section-title {
  margin: 0 0 12px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.005em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.form-grid {
  display: grid;
  gap: 14px 18px;
}
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-check { gap: 10px; padding-top: 22px; }

.text-input {
  width: 100%;
  height: 38px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  padding: 0 12px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  font-variant-numeric: tabular-nums;
}
.text-input:focus { border-color: rgba(78, 168, 255, 0.5); }
.text-input[readonly] { color: var(--text-dim); }

.input-with-suffix {
  position: relative;
  display: flex; align-items: center;
}
.input-with-suffix .text-input { padding-right: 42px; }
.input-with-suffix .suffix {
  position: absolute;
  right: 12px;
  color: var(--text-mute);
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
}

.check {
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-dim);
  user-select: none;
}
.check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background .12s ease, border-color .12s ease;
}
.check input[type="checkbox"]:checked {
  background: var(--green);
  border-color: var(--green);
}
.check input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px; top: 1px;
  width: 4px; height: 8px;
  border: solid #051;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.badge-toggle {
  display: inline-block;
  width: 22px; height: 12px;
  background: var(--green);
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 4px;
  position: relative;
}
.badge-toggle::after {
  content: "";
  position: absolute;
  right: 1px; top: 1px;
  width: 10px; height: 10px;
  background: #fff;
  border-radius: 50%;
}

.settings-save-row {
  display: flex;
  margin-top: 18px;
}
.btn-save-red {
  font-family: inherit;
  background: linear-gradient(180deg, #e0414e, #c1313c);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 20px;
  border-radius: 8px;
  border: 1px solid rgba(239, 79, 91, 0.6);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(239, 79, 91, 0.25);
  transition: filter .15s ease;
}
.btn-save-red:hover { filter: brightness(1.08); }

/* Logs responsive */
@media (max-width: 1240px) {
  .logs-table-head-row { grid-template-columns: 140px 70px 80px 1fr 280px; }
  .logs-row { grid-template-columns: 140px 70px 80px 1fr; }
  .logs-controls { grid-template-columns: 1fr 1fr; }
  .logs-controls > :last-child { grid-column: span 2; }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 880px) {
  .logs-controls { grid-template-columns: 1fr; }
  .logs-controls > :last-child { grid-column: auto; }
  .logs-table-head-row, .logs-row { grid-template-columns: 110px 60px 70px 1fr; }
  .logs-th.search-cell { display: none; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .logs-pagination { grid-template-columns: 1fr; }
  .logs-pg-right { justify-content: flex-start; }
}


/* ============================================================
   auto-traders v1 - Phase 7: light theme + new class hardening
   ============================================================ */

/* Source chip (logs.html top filter) - toggleable */
.source-chip {
  cursor: pointer;
  user-select: none;
  transition: opacity 0.12s ease, filter 0.12s ease;
}
.source-chip.is-on  { opacity: 1; }
.source-chip:not(.is-on) {
  opacity: 0.42;
  filter: grayscale(0.6);
}
.source-chip.source-dashboard {
  background: rgba(168, 122, 255, 0.16);
  color: #c8b6ff;
  border: 1px solid rgba(168, 122, 255, 0.32);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.src-badge.src-dashboard {
  background: rgba(168, 122, 255, 0.16);
  color: #c8b6ff;
  border: 1px solid rgba(168, 122, 255, 0.28);
}

.text-amber { color: var(--amber); }
.text-blue  { color: var(--blue); }
.dot-red { background: var(--red); box-shadow: 0 0 8px rgba(239, 79, 91, 0.45); }

details.collapsible-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}
details.collapsible-row > summary {
  cursor: pointer;
  padding: 10px 12px;
  list-style: none;
  display: flex;
  gap: 8px;
  align-items: center;
}
details.collapsible-row summary::-webkit-details-marker { display: none; }
details.collapsible-row[open] > summary .cr-caret { transform: rotate(90deg); }
details.collapsible-row .cr-caret { transition: transform 0.15s ease; }
details.collapsible-row .table-wrap { padding: 0 12px 12px 12px; }

/* --- Light theme visibility hardening --- */

body.theme-light .select-like,
body.theme-light .number-stepper {
  background: #fffdf5;
  color: #1f2820;
  border: 1px solid rgba(46, 143, 97, 0.32);
}
body.theme-light .select-like span,
body.theme-light .number-stepper input { color: #1f2820; }
body.theme-light .select-like svg,
body.theme-light .number-stepper .stepper-btn { color: #2e8f61; }
body.theme-light .number-stepper input { background: #fffdf5; }
body.theme-light .number-stepper .stepper-btn {
  background: rgba(46, 143, 97, 0.12);
  border-color: rgba(46, 143, 97, 0.28);
}
body.theme-light .number-stepper .stepper-btn:hover { background: rgba(46, 143, 97, 0.22); }

body.theme-light input[type="text"],
body.theme-light input[type="number"],
body.theme-light input[type="search"] {
  background: #fffdf5;
  color: #1f2820;
  border-color: rgba(46, 143, 97, 0.32);
}
body.theme-light input[type="text"]::placeholder,
body.theme-light input[type="number"]::placeholder,
body.theme-light input[type="search"]::placeholder { color: #738073; }

body.theme-light .chips .chip,
body.theme-light .source-chip,
body.theme-light .source-tail .chip-clear,
body.theme-light .btn-ghost-sm {
  background: #fffdf5;
  color: #1f2820;
  border-color: rgba(46, 143, 97, 0.28);
}
body.theme-light .chip-active {
  background: rgba(46, 143, 97, 0.18);
  color: #1f2820;
  border-color: rgba(46, 143, 97, 0.45);
}
body.theme-light .chip-info  { color: #1e63a3; border-color: rgba(30, 99, 163, 0.32); }
body.theme-light .chip-buy   { color: #2e8f61; border-color: rgba(46, 143, 97, 0.32); }
body.theme-light .chip-sell  { color: #b74750; border-color: rgba(183, 71, 80, 0.32); }
body.theme-light .chip-warn  { color: #8b5a08; border-color: rgba(139, 90, 8, 0.32); }
body.theme-light .chip-error { color: #b74750; border-color: rgba(183, 71, 80, 0.4); background: rgba(183, 71, 80, 0.1); }

body.theme-light .source-chip.source-upbit     { color: #1e63a3; background: rgba(30, 99, 163, 0.12); border-color: rgba(30, 99, 163, 0.32); }
body.theme-light .source-chip.source-kis       { color: #8b5a08; background: rgba(139, 90, 8, 0.12); border-color: rgba(139, 90, 8, 0.32); }
body.theme-light .source-chip.source-dashboard { color: #5e3aa7; background: rgba(94, 58, 167, 0.10); border-color: rgba(94, 58, 167, 0.32); }
body.theme-light .src-badge.src-upbit     { color: #1e63a3; background: rgba(30, 99, 163, 0.12); }
body.theme-light .src-badge.src-kis       { color: #8b5a08; background: rgba(139, 90, 8, 0.12); }
body.theme-light .src-badge.src-dashboard { color: #5e3aa7; background: rgba(94, 58, 167, 0.10); }

body.theme-light .lvl-info { color: #1e63a3; background: rgba(30, 99, 163, 0.12); }
body.theme-light .lvl-buy  { color: #2e8f61; background: rgba(46, 143, 97, 0.14); }
body.theme-light .lvl-sell { color: #b74750; background: rgba(183, 71, 80, 0.14); }
body.theme-light .lvl-warn { color: #8b5a08; background: rgba(139, 90, 8, 0.14); }
body.theme-light .lvl-strategy { color: #5e3aa7; background: rgba(94, 58, 167, 0.12); }

body.theme-light .alert-info {
  background: rgba(30, 99, 163, 0.08);
  border: 1px solid rgba(30, 99, 163, 0.28);
  color: #1c2f4a;
}
body.theme-light .alert-warn {
  background: rgba(196, 130, 16, 0.10);
  border: 1px solid rgba(196, 130, 16, 0.34);
  color: #4a3608;
}
body.theme-light .alert code,
body.theme-light .control-notes code,
body.theme-light .settings-card code {
  background: rgba(46, 143, 97, 0.14);
  color: #1f2820;
  border: 1px solid rgba(46, 143, 97, 0.2);
}

body.theme-light .kill-switch {
  background: linear-gradient(180deg, rgba(183, 71, 80, 0.16), rgba(183, 71, 80, 0.08));
  border: 1px solid rgba(183, 71, 80, 0.5);
}
body.theme-light .kill-switch:hover {
  background: linear-gradient(180deg, rgba(183, 71, 80, 0.26), rgba(183, 71, 80, 0.14));
}
body.theme-light .kill-icon { background: rgba(183, 71, 80, 0.18); color: #b74750; }
body.theme-light .kill-title { color: #8a2730; font-weight: 700; }
body.theme-light .kill-sub   { color: #b74750; letter-spacing: 0.08em; }

body.theme-light .btn-save-red {
  background: linear-gradient(180deg, #c63d49, #a52c36);
  color: #fff;
  border: 1px solid rgba(165, 44, 54, 0.6);
}

body.theme-light .env-table thead th,
body.theme-light .settings-head h3,
body.theme-light .settings-sub { color: #1f2820; }
body.theme-light .env-table tbody td {
  color: #1f2820;
  border-bottom-color: rgba(46, 143, 97, 0.12);
}
body.theme-light .env-table .path,
body.theme-light .env-table .mono { color: #2f4438; }

body.theme-light .dot-red { background: #b74750; box-shadow: 0 0 6px rgba(183, 71, 80, 0.5); }

body.theme-light .chip-orange { color: #8b5a08; background: rgba(196, 130, 16, 0.12); border-color: rgba(196, 130, 16, 0.32); }
body.theme-light .chip-green  { color: #2e8f61; background: rgba(46, 143, 97, 0.12); border-color: rgba(46, 143, 97, 0.32); }
body.theme-light .chip-red    { color: #b74750; background: rgba(183, 71, 80, 0.12); border-color: rgba(183, 71, 80, 0.32); }
body.theme-light .chip-blue   { color: #1e63a3; background: rgba(30, 99, 163, 0.12); border-color: rgba(30, 99, 163, 0.32); }

body.theme-light .pg-btn {
  background: #fffdf5;
  color: #1f2820;
  border: 1px solid rgba(46, 143, 97, 0.28);
}
body.theme-light .pg-btn.pg-active {
  background: rgba(46, 143, 97, 0.22);
  color: #1f2820;
  border-color: rgba(46, 143, 97, 0.55);
  font-weight: 700;
}

body.theme-light .status-card,
body.theme-light .bot-status-card,
body.theme-light .sidebar-footer { color: #1f2820; }
body.theme-light .status-value,
body.theme-light .bsc-pid,
body.theme-light .bsc-sub-label,
body.theme-light .status-title { color: #2f4438; }

body.theme-light details.collapsible-row { border: 1px solid rgba(46, 143, 97, 0.2); }
body.theme-light details.collapsible-row > summary { color: #1f2820; }

body.theme-light .logs-row { border-bottom: 1px solid rgba(46, 143, 97, 0.08); }
body.theme-light .logs-rows .logs-row:hover { background: rgba(46, 143, 97, 0.05); }

body.theme-light .btn-start,
body.theme-light .btn-stop,
body.theme-light .btn-restart {
  border: 1px solid rgba(46, 143, 97, 0.32);
  color: #1f2820;
}
body.theme-light .btn-start { background: rgba(46, 143, 97, 0.18); color: #1c5b3d; }
body.theme-light .btn-stop  { background: rgba(183, 71, 80, 0.16); color: #8a2730; border-color: rgba(183, 71, 80, 0.32); }
body.theme-light .btn-restart { background: rgba(30, 99, 163, 0.14); color: #1c2f4a; border-color: rgba(30, 99, 163, 0.32); }

body.theme-light .btn-outline {
  background: #fffdf5;
  color: #1f2820;
  border: 1px solid rgba(46, 143, 97, 0.28);
}
body.theme-light .btn-outline:hover { background: rgba(46, 143, 97, 0.10); }

body.theme-light .pill-green {
  background: rgba(46, 143, 97, 0.16);
  color: #1c5b3d;
  border: 1px solid rgba(46, 143, 97, 0.32);
}

body.theme-light .theme-menu-panel {
  background: #fffdf5;
  border: 1px solid rgba(46, 143, 97, 0.28);
  color: #1f2820;
}
body.theme-light .theme-option { color: #1f2820; }
body.theme-light .theme-option:hover { background: rgba(46, 143, 97, 0.10); }
body.theme-light .theme-option.is-selected {
  background: rgba(46, 143, 97, 0.18);
  color: #1c5b3d;
}


/* ============================================================
   auto-traders v1 - Phase 8: empty-state notices (no mock fallback)
   ============================================================ */

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  color: var(--text-mute);
  font-size: 13px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  border: 1px dashed var(--border-strong);
  padding: 18px 24px;
  text-align: center;
  line-height: 1.55;
}
body.theme-light .empty-state {
  color: #4f5f53;
  background: rgba(46, 143, 97, 0.04);
  border: 1px dashed rgba(46, 143, 97, 0.28);
}

.spark-empty {
  display: inline-block;
  margin-left: 6px;
  font-size: 10.5px;
  color: var(--text-mute);
}

/* Topbar pill states (amber=paper, red=stopped) */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}
.pill-amber {
  background: rgba(244, 183, 64, 0.15);
  color: var(--amber);
  border-color: rgba(244, 183, 64, 0.32);
}
.pill-red {
  background: rgba(239, 79, 91, 0.15);
  color: var(--red);
  border-color: rgba(239, 79, 91, 0.32);
}
body.theme-light .pill-amber {
  background: rgba(196, 130, 16, 0.14);
  color: #8b5a08;
  border-color: rgba(196, 130, 16, 0.34);
}
body.theme-light .pill-red {
  background: rgba(183, 71, 80, 0.12);
  color: #8a2730;
  border-color: rgba(183, 71, 80, 0.34);
}

/* dot-muted (실 상태 미확인 시 회색) */
.dot-muted {
  background: rgba(255, 255, 255, 0.18);
  box-shadow: none;
}
body.theme-light .dot-muted {
  background: rgba(46, 143, 97, 0.25);
}


/* ============================================================
   auto-traders v1 - Phase 9: bottom tab panels + disabled buttons
   ============================================================ */

.tab-panel { display: block; margin-top: 12px; }
.tab-panel.is-hidden { display: none; }

.bottom-tabs .btab { cursor: pointer; user-select: none; }
.bottom-tabs .btab:not(.is-active):hover { color: var(--text); }

.btn-start[disabled],
.btn-stop[disabled],
.btn-restart[disabled],
.btn-outline[disabled],
.btn-outline.btn-sm[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.4);
}
body.theme-light .btn-start[disabled],
body.theme-light .btn-stop[disabled],
body.theme-light .btn-restart[disabled],
body.theme-light .btn-outline[disabled] {
  opacity: 0.55;
}


/* ============================================================
   auto-traders v1 - P1: dropdown / level-chip / aux pre / progress-bar
   ============================================================ */

/* Dropdown popover (정렬·페이지크기) */
.dropdown-wrap { position: relative; }
.dropdown-trigger {
  cursor: pointer;
  background: inherit;
  border: 1px solid var(--border-strong);
  color: inherit;
  font: inherit;
  padding: 6px 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}
.dropdown-trigger:hover { background: rgba(255, 255, 255, 0.04); }
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 140px;
  z-index: 50;
  list-style: none;
  margin: 0;
  padding: 4px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.dropdown-wrap.is-open .dropdown-menu { display: block; }
.dropdown-menu li {
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text);
}
.dropdown-menu li:hover {
  background: rgba(78, 168, 255, 0.14);
  color: var(--blue);
}
body.theme-light .dropdown-trigger:hover { background: rgba(46, 143, 97, 0.08); }
body.theme-light .dropdown-menu {
  background: #fffdf5;
  border: 1px solid rgba(46, 143, 97, 0.28);
  color: #1f2820;
}
body.theme-light .dropdown-menu li { color: #1f2820; }
body.theme-light .dropdown-menu li:hover {
  background: rgba(46, 143, 97, 0.14);
  color: #1c5b3d;
}

/* logs level filter chip */
.level-chip {
  cursor: pointer;
  user-select: none;
  transition: opacity 0.12s ease, filter 0.12s ease;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  border: 1px solid var(--border-strong);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.level-chip.is-on { opacity: 1; }
.level-chip:not(.is-on) { opacity: 0.42; filter: grayscale(0.6); }
.level-chip[data-level="INFO"]    { color: var(--blue);   border-color: rgba(78, 168, 255, 0.32); }
.level-chip[data-level="WARNING"] { color: var(--amber);  border-color: rgba(244, 183, 64, 0.32); }
.level-chip[data-level="ERROR"]   { color: var(--red);    border-color: rgba(239, 79, 91, 0.32); }
.level-chip[data-level="DEBUG"]   { color: var(--purple); border-color: rgba(168, 122, 255, 0.32); }
body.theme-light .level-chip[data-level="INFO"]    { color: #1e63a3; border-color: rgba(30, 99, 163, 0.32); background: rgba(30, 99, 163, 0.10); }
body.theme-light .level-chip[data-level="WARNING"] { color: #8b5a08; border-color: rgba(139, 90, 8, 0.32); background: rgba(196, 130, 16, 0.10); }
body.theme-light .level-chip[data-level="ERROR"]   { color: #b74750; border-color: rgba(183, 71, 80, 0.32); background: rgba(183, 71, 80, 0.10); }
body.theme-light .level-chip[data-level="DEBUG"]   { color: #5e3aa7; border-color: rgba(94, 58, 167, 0.32); background: rgba(94, 58, 167, 0.10); }

/* aux info pre — JSON raw 표시 */
.aux-pre {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 12px 12px;
  font-size: 11.5px;
  line-height: 1.55;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-dim);
}
body.theme-light .aux-pre {
  background: rgba(46, 143, 97, 0.04);
  border: 1px solid rgba(46, 143, 97, 0.18);
  color: #2f4438;
}
.aux-notes {
  list-style: disc inside;
  padding: 0 24px 12px 24px;
  margin: 0;
  font-size: 12.5px;
  color: var(--text-dim);
}
body.theme-light .aux-notes { color: #2f4438; }
.aux-info-card .settings-head { padding: 12px 14px 4px; }

/* progress-fill transition */
.progress-fill { transition: width 0.4s ease; }

/* pg-btn disabled */
.pg-btn[disabled] {
  opacity: 0.42;
  cursor: not-allowed;
  filter: grayscale(0.4);
}
.pg-btn[disabled]:hover { background: inherit; }

/* dot-purple (donut-legend 추가 색상) */
.dot-purple { background: var(--purple); box-shadow: 0 0 8px rgba(168, 122, 255, 0.45); }
.dot-amber  { background: var(--amber);  box-shadow: 0 0 8px rgba(244, 183, 64, 0.45); }
body.theme-light .dot-purple { background: #5e3aa7; box-shadow: 0 0 6px rgba(94, 58, 167, 0.45); }
body.theme-light .dot-amber  { background: #8b5a08; box-shadow: 0 0 6px rgba(139, 90, 8, 0.45); }


/* ============================================================
   auto-traders v1 - P2: login page + auth
   ============================================================ */

.page-login { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-shell {
  width: 100%;
  max-width: 440px;
  padding: 24px;
}
.login-card { padding: 28px 28px 22px; }
.login-head {
  text-align: center;
  margin-bottom: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.login-head .brand-mark {
  color: var(--blue);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(78, 168, 255, 0.14);
}
.login-title { margin: 6px 0 2px; font-size: 20px; font-weight: 700; }
.login-sub { margin: 0; color: var(--text-mute); font-size: 13px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form .field { display: flex; flex-direction: column; gap: 6px; }
.login-form .field-label { font-size: 12px; color: var(--text-mute); font-weight: 500; }
.login-form input[type="text"],
.login-form input[type="password"] {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font: inherit;
}
.login-form input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(78, 168, 255, 0.18);
}
.login-error {
  background: rgba(239, 79, 91, 0.12);
  border: 1px solid rgba(239, 79, 91, 0.34);
  color: var(--red);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
}
.login-submit {
  margin-top: 4px;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.login-submit[disabled] { opacity: 0.55; cursor: progress; }
.login-card .alert { margin-top: 18px; }

body.theme-light .login-head .brand-mark {
  color: #1c5b3d;
  background: rgba(46, 143, 97, 0.14);
}
body.theme-light .login-form input[type="text"],
body.theme-light .login-form input[type="password"] {
  background: #fffdf5;
  color: #1f2820;
  border-color: rgba(46, 143, 97, 0.32);
}
body.theme-light .login-form input:focus {
  border-color: #2e8f61;
  box-shadow: 0 0 0 3px rgba(46, 143, 97, 0.18);
}
body.theme-light .login-error {
  background: rgba(183, 71, 80, 0.12);
  border: 1px solid rgba(183, 71, 80, 0.34);
  color: #8a2730;
}


/* ============================================================
   auto-traders - guest mode banner
   ============================================================ */

.guest-banner {
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: rgba(244, 183, 64, 0.18);
  color: var(--amber);
  border-bottom: 1px solid rgba(244, 183, 64, 0.36);
  font-size: 12.5px;
  font-weight: 500;
}
.guest-banner a {
  color: var(--blue);
  text-decoration: underline;
  font-weight: 600;
}
.guest-badge {
  background: var(--amber);
  color: #0a0e18;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

body.theme-light .guest-banner {
  background: rgba(196, 130, 16, 0.14);
  color: #8b5a08;
  border-bottom: 1px solid rgba(196, 130, 16, 0.36);
}
body.theme-light .guest-banner a { color: #1e63a3; }
body.theme-light .guest-badge {
  background: #c48210;
  color: #fffdf5;
}


/* login.html 의 게스트 버튼 — 로그인 submit 바로 아래 */
.login-guest {
  margin-top: 8px;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  text-align: center;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px dashed var(--border-strong);
}
.login-guest:hover:not([disabled]) {
  background: rgba(78, 168, 255, 0.10);
  border-color: rgba(78, 168, 255, 0.32);
  color: var(--blue);
}
.login-guest[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
body.theme-light .login-guest {
  background: rgba(46, 143, 97, 0.06);
  color: #1f2820;
  border: 1px dashed rgba(46, 143, 97, 0.32);
}
body.theme-light .login-guest:hover:not([disabled]) {
  background: rgba(46, 143, 97, 0.14);
  color: #1c5b3d;
  border-color: rgba(46, 143, 97, 0.48);
}

/* =================================================================
   MOBILE — REAL PHONE (풀스크린, 가짜 시계/노치 없음, sidebar fixed bottom)
   ================================================================= */
body.device-mobile:not(.device-mobile-mock) .app {
  display: block;
  width: 100%;
  min-height: 100vh;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  position: relative;
  overflow: visible;
}
body.device-mobile:not(.device-mobile-mock) .main {
  min-height: 100vh;
  padding: 14px 12px 92px;
  gap: 12px;
  overflow-y: auto;
  scrollbar-width: none;
}
body.device-mobile:not(.device-mobile-mock) .main::-webkit-scrollbar { display: none; }
body.device-mobile:not(.device-mobile-mock) .sidebar {
  position: fixed;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  height: 72px;
  padding: 7px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  border-right: none;
  background: rgba(8, 12, 22, 0.94);
  backdrop-filter: blur(18px);
}
body.device-mobile:not(.device-mobile-mock).theme-light .sidebar {
  background: rgba(255, 253, 247, 0.94);
}

/* =================================================================
   MOBILE APP MOCK MODE
   Activated from the top-right menu. Keeps the same pages but renders
   them inside a phone-sized app shell inspired by the supplied mobile refs.
   ================================================================= */
body.device-mobile.device-mobile-mock {
  min-height: 100vh;
  padding: 18px 0;
  background:
    radial-gradient(760px 520px at 50% -10%, rgba(41, 82, 160, 0.18), transparent 64%),
    #02050b;
}
body.device-mobile.device-mobile-mock .app {
  display: block;
  position: relative;
  width: 390px;
  max-width: calc(100vw - 22px);
  min-height: 844px;
  max-height: calc(100vh - 36px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(120, 140, 180, 0.22);
  border-radius: 34px;
  background: var(--bg-app);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.56), 0 0 0 8px rgba(255,255,255,0.018);
}
body.device-mobile.device-mobile-mock .app::before {
  content: "9:41";
  position: absolute;
  z-index: 25;
  top: 14px;
  left: 28px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}
body.device-mobile.device-mobile-mock .app::after {
  content: "▮▮  ◜◝  ▰";
  position: absolute;
  z-index: 25;
  top: 13px;
  right: 28px;
  color: var(--text);
  font-size: 11px;
  letter-spacing: 1px;
  opacity: 0.92;
}
body.device-mobile.device-mobile-mock .main {
  height: calc(100vh - 36px);
  max-height: 844px;
  min-height: 844px;
  overflow-y: auto;
  padding: 50px 14px 86px;
  gap: 12px;
  scrollbar-width: none;
}
body.device-mobile .main::-webkit-scrollbar { display: none; }
body.device-mobile.device-mobile-mock .sidebar {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  height: 72px;
  padding: 7px 12px 8px;
  border-top: 1px solid var(--border);
  border-right: none;
  background: rgba(8, 12, 22, 0.94);
  backdrop-filter: blur(18px);
}
body.device-mobile.device-mobile-mock.theme-light .sidebar {
  background: rgba(255, 253, 247, 0.94);
}
body.device-mobile .sidebar-top { height: 100%; }
body.device-mobile .brand,
body.device-mobile .bot-status-card,
body.device-mobile .sidebar-bottom {
  display: none;
}
body.device-mobile .nav {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
}
body.device-mobile .nav-item {
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 5px 2px;
  border: 0;
  border-radius: 12px;
  font-size: 10.5px;
  color: var(--text-mute);
  white-space: nowrap;
}
body.device-mobile .nav-item .nav-icon svg {
  width: 18px;
  height: 18px;
}
body.device-mobile .nav-item.is-active {
  background: transparent;
  border: 0;
  color: var(--blue);
}
body.device-mobile .topbar {
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 2px;
}
body.device-mobile .page-title {
  font-size: 19px;
  line-height: 1.22;
}
body.device-mobile .page-subtitle {
  font-size: 11.5px;
}
body.device-mobile .topbar-right {
  margin-left: auto;
  gap: 6px;
}
body.device-mobile .topbar-right .pill {
  padding: 5px 8px;
  font-size: 10.5px;
}
body.device-mobile .btn-outline[data-testid="btn-logout"] {
  padding: 5px 8px;
  font-size: 11px;
  gap: 4px;
}
body.device-mobile .btn-outline[data-testid="btn-logout"] svg {
  width: 12px;
  height: 12px;
}
body.device-mobile .theme-menu-panel {
  width: 226px;
  right: 0;
}
body.device-mobile .top-tabs {
  overflow-x: auto;
  gap: 14px;
  margin: 2px -2px 2px;
  padding: 0 2px;
  scrollbar-width: none;
}
body.device-mobile .top-tabs::-webkit-scrollbar { display: none; }
body.device-mobile .top-tab {
  flex: 0 0 auto;
  padding: 9px 2px 10px;
  font-size: 12px;
}
body.device-mobile .card,
body.device-mobile .status-card,
body.device-mobile .settings-card {
  border-radius: 12px;
}
body.device-mobile .kpi-row,
body.device-mobile .coin-kpi-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
body.device-mobile .engine-row,
body.device-mobile .charts-row,
body.device-mobile .coin-mid-row,
body.device-mobile .stock-main-row,
body.device-mobile .logs-layout,
body.device-mobile .settings-layout {
  grid-template-columns: 1fr;
}
body.device-mobile .risk-strip,
body.device-mobile .engine-grid,
body.device-mobile .coin-status-strip,
body.device-mobile .coin-mid-grid,
body.device-mobile .coin-params-grid,
body.device-mobile .form-grid-2,
body.device-mobile .form-grid-3 {
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
body.device-mobile .coin-kpi,
body.device-mobile .kpi-card {
  padding: 13px 13px 14px;
}
body.device-mobile .kpi-value,
body.device-mobile .ckpi-value {
  font-size: 22px;
}
body.device-mobile .risk-strip {
  padding: 14px;
}
body.device-mobile .chart-card {
  min-height: 178px;
}
body.device-mobile canvas {
  max-width: 100%;
}
body.device-mobile .kill-switch {
  justify-content: center;
  min-height: 52px;
}
body.device-mobile [data-testid="log-card"] .table-wrap {
  overflow: visible;
}
body.device-mobile .log-card {
  padding: 12px;
}
body.device-mobile .log-head,
body.device-mobile .logs-page-head,
body.device-mobile .logs-controls {
  align-items: flex-start;
  flex-direction: column;
  gap: 9px;
}
body.device-mobile .chips {
  width: 100%;
  overflow-x: auto;
  flex: none;
  scrollbar-width: none;
}
body.device-mobile .chips::-webkit-scrollbar { display: none; }
body.device-mobile [data-testid="log-card"] .log-table thead,
body.device-mobile .logs-table-head-row {
  display: none;
}
body.device-mobile [data-testid="log-card"] .log-table,
body.device-mobile [data-testid="log-card"] .log-table tbody,
body.device-mobile [data-testid="log-card"] .log-table tr,
body.device-mobile [data-testid="log-card"] .log-table td {
  display: block;
  width: 100%;
}
body.device-mobile [data-testid="log-card"] .log-table tbody tr,
body.device-mobile .logs-row {
  position: relative;
  display: grid;
  grid-template-columns: 66px 1fr 20px;
  gap: 8px;
  align-items: start;
  margin: 0 0 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
}
body.device-mobile [data-testid="log-card"] .log-table tbody tr::after,
body.device-mobile .logs-row::after {
  content: "›";
  color: var(--text-dim);
  font-size: 24px;
  line-height: 1;
  align-self: center;
}
body.device-mobile [data-testid="log-card"] .log-table tbody td {
  padding: 0;
  border: 0;
}
body.device-mobile [data-testid="log-card"] .log-table tbody td:nth-child(1),
body.device-mobile .logs-cell.time {
  grid-column: 1;
  grid-row: 1;
  color: var(--text);
  font-weight: 700;
  font-size: 11px;
}
body.device-mobile [data-testid="log-card"] .log-table tbody td:nth-child(2),
body.device-mobile .logs-cell.level {
  grid-column: 1;
  grid-row: 2;
}
body.device-mobile [data-testid="log-card"] .log-table tbody td:nth-child(3),
body.device-mobile .logs-cell.source {
  grid-column: 1;
  grid-row: 3;
  color: var(--text-dim);
  font-size: 11px;
}
/* 통합 대시보드 최근 로그 카드의 실제 td 순서: 시간/레벨/소스/모듈/메시지/긴메시지/빈/빈
   모바일에선 모듈명·긴메시지·빈칸 숨기고 nth-child(5) (짧은 메시지) 만 메시지 위치에 배치.
   coin/stock 의 다른 테이블 (장부/주문) 영향 안 가도록 [data-testid="log-card"] 한정. */
body.device-mobile [data-testid="log-card"] .log-table tbody td:nth-child(4) {
  display: none;
}
body.device-mobile [data-testid="log-card"] .log-table tbody td:nth-child(5),
body.device-mobile .logs-cell.message {
  grid-column: 2;
  grid-row: 1 / span 3;
  min-width: 0;
  color: var(--text);
  font-size: 12.2px;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
}
body.device-mobile [data-testid="log-card"] .log-table tbody td:nth-child(6),
body.device-mobile [data-testid="log-card"] .log-table tbody td:nth-child(7),
body.device-mobile [data-testid="log-card"] .log-table tbody td:nth-child(8) {
  display: none;
}
body.device-mobile .logs-cell.module {
  display: none;
}
body.device-mobile .settings-save-row,
body.device-mobile .logs-pagination {
  grid-template-columns: 1fr;
}

/* Mobile page-specific polish */
body.device-mobile .card {
  background: rgba(15, 20, 32, 0.86);
  border-color: rgba(255,255,255,0.065);
}
body.device-mobile.theme-light .card {
  background: rgba(255, 253, 247, 0.88);
}
body.device-mobile .topbar-left {
  min-width: 0;
}
body.device-mobile .page-title {
  max-width: 230px;
}
body.device-mobile:not(.page-coin):not(.page-stock):not(.page-logs):not(.page-settings) .topbar-left::before {
  content: "auto-traders";
  display: inline-flex;
  align-items: center;
  margin-bottom: 16px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}
body.device-mobile:not(.page-coin):not(.page-stock):not(.page-logs):not(.page-settings) .topbar-left::after {
  content: "";
  position: absolute;
}
body.device-mobile:not(.page-coin):not(.page-stock):not(.page-logs):not(.page-settings) .kpi-row {
  grid-template-columns: 1fr 1fr;
}
body.device-mobile:not(.page-coin):not(.page-stock):not(.page-logs):not(.page-settings) .risk-strip {
  grid-template-columns: 1fr;
}
body.device-mobile:not(.page-coin):not(.page-stock):not(.page-logs):not(.page-settings) .engine-row {
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
body.device-mobile:not(.page-coin):not(.page-stock):not(.page-logs):not(.page-settings) .engine-grid {
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}
body.device-mobile:not(.page-coin):not(.page-stock):not(.page-logs):not(.page-settings) .chart-card:nth-child(n+3) {
  display: none;
}
body.device-mobile:not(.page-coin):not(.page-stock):not(.page-logs):not(.page-settings) .log-card {
  margin-bottom: 8px;
}
body.device-mobile .page-coin .top-tabs,
body.device-mobile.page-coin .top-tabs,
body.device-mobile.page-stock .top-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(255,255,255,0.025);
}
body.device-mobile.page-coin .top-tabs .top-tab,
body.device-mobile.page-stock .top-tabs .top-tab {
  display: none;
}
body.device-mobile.page-coin .top-tabs .top-tab:first-child,
body.device-mobile.page-stock .top-tabs .top-tab:first-child {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border: 0;
  border-radius: 10px;
  margin: 0;
  padding: 0;
  font-size: 0;
  color: var(--text-dim);
}
body.device-mobile.page-coin .top-tabs .top-tab:first-child::after,
body.device-mobile.page-stock .top-tabs .top-tab:first-child::after {
  content: "보조 정보";
  font-size: 11.5px;
  font-weight: 700;
}
body.device-mobile.page-coin .top-tabs::before,
body.device-mobile.page-coin .top-tabs::after,
body.device-mobile.page-stock .top-tabs::before,
body.device-mobile.page-stock .top-tabs::after {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 700;
}
body.device-mobile.page-coin .top-tabs::before,
body.device-mobile.page-stock .top-tabs::before {
  content: "상태";
  background: var(--blue-soft);
  color: var(--blue);
}
body.device-mobile.page-coin .top-tabs::after,
body.device-mobile.page-stock .top-tabs::after {
  content: "파라미터";
}
body.device-mobile.page-coin .top-tabs {
  position: relative;
}
body.device-mobile.page-coin .top-tabs + .coin-kpi-row::before,
body.device-mobile.page-stock .top-tabs + .coin-kpi-row::before {
  content: none;
  display: none;
}
body.device-mobile.page-coin .coin-section-title,
body.device-mobile.page-stock .coin-section-title,
body.device-mobile.page-coin .coin-mid-note,
body.device-mobile.page-stock .coin-mid-note {
  display: none;
}
body.device-mobile.page-coin .coin-status-strip,
body.device-mobile.page-stock .coin-status-strip {
  grid-template-columns: 1fr;
  padding: 12px;
}
body.device-mobile.page-coin .coin-control-card,
body.device-mobile.page-stock .coin-control-card {
  order: 20;
}
body.device-mobile.page-coin .log-viewer-card,
body.device-mobile.page-stock .log-viewer-card {
  order: 18;
}
body.device-mobile .log-viewer-head {
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
}
body.device-mobile .log-viewer-actions {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
body.device-mobile .log-viewer-actions .btn-sm {
  justify-content: center;
}
body.device-mobile .log-viewer-body {
  max-height: none;
  background: transparent;
  border: 0;
  padding: 0;
}
body.device-mobile .log-viewer-body .log-row {
  display: grid;
  grid-template-columns: 66px 1fr 18px;
  gap: 7px;
  margin-bottom: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.025);
}
body.device-mobile .log-viewer-body .log-row::after {
  content: "›";
  grid-column: 3;
  grid-row: 1 / span 3;
  align-self: center;
  color: var(--text-dim);
  font-size: 22px;
}
body.device-mobile .log-viewer-body .log-ts {
  grid-column: 1;
  grid-row: 1;
  font-size: 10.5px;
  white-space: normal;
  color: var(--text);
}
body.device-mobile .log-viewer-body .lvl,
body.device-mobile .log-viewer-body .lvl-spacer {
  grid-column: 1;
  grid-row: 2;
  width: fit-content;
}
body.device-mobile .log-viewer-body .log-src {
  grid-column: 1;
  grid-row: 3;
  font-size: 11px;
}
body.device-mobile .log-viewer-body .log-msg {
  grid-column: 2;
  grid-row: 1 / span 3;
  font-size: 12px;
  line-height: 1.45;
  white-space: normal;
}
body.device-mobile.page-coin .bottom-tabs,
body.device-mobile.page-stock .bottom-tabs {
  overflow-x: auto;
  scrollbar-width: none;
}
body.device-mobile.page-coin .bottom-tabs::-webkit-scrollbar,
body.device-mobile.page-stock .bottom-tabs::-webkit-scrollbar {
  display: none;
}
body.device-mobile.page-coin .bottom-tabs .btab,
body.device-mobile.page-stock .bottom-tabs .btab {
  flex: 0 0 auto;
  padding-inline: 12px;
}
body.device-mobile.page-stock .stock-book-table thead {
  display: none;
}
body.device-mobile.page-stock .stock-book-table,
body.device-mobile.page-stock .stock-book-table tbody,
body.device-mobile.page-stock .stock-book-table tr,
body.device-mobile.page-stock .stock-book-table td {
  display: block;
  width: 100%;
}
body.device-mobile.page-stock .stock-book-table tr {
  margin-bottom: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.025);
}
body.device-mobile.page-stock .stock-book-table td {
  border: 0;
  padding: 3px 0;
  text-align: left;
}
body.device-mobile.page-logs .page-head {
  display: none;
}
body.device-mobile.page-logs .top-tabs {
  display: none;
}
body.device-mobile.page-logs .topbar {
  align-items: center;
}
body.device-mobile.page-logs .page-title {
  font-size: 18px;
}
body.device-mobile.page-logs .page-title::before {
  content: "‹ ";
  color: var(--text-dim);
  font-size: 22px;
}
body.device-mobile.page-logs .page-subtitle {
  display: none;
}
body.device-mobile.page-logs .logs-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  padding: 12px;
}
body.device-mobile.page-logs .logs-table-card {
  padding: 0;
  border: 0;
  background: transparent;
}
body.device-mobile.page-logs .logs-row {
  margin-bottom: 9px;
}
body.device-mobile.page-logs .logs-pagination {
  display: none;
}
body.device-mobile.page-settings .page-head {
  display: none;
}
body.device-mobile.page-settings .top-tabs {
  display: none;
}
body.device-mobile.page-settings .page-title::before {
  content: "‹ ";
  color: var(--text-dim);
  font-size: 22px;
}
body.device-mobile.page-settings .settings-card {
  padding: 14px;
}
body.device-mobile.page-settings .env-table thead {
  display: none;
}
body.device-mobile.page-settings .env-table,
body.device-mobile.page-settings .env-table tbody,
body.device-mobile.page-settings .env-table tr,
body.device-mobile.page-settings .env-table td {
  display: block;
  width: 100%;
}
body.device-mobile.page-settings .env-table tr {
  margin-bottom: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.025);
}
body.device-mobile.page-settings .env-table td {
  border: 0;
  padding: 3px 0;
  text-align: left;
}
body.device-mobile.page-settings .env-table .path {
  word-break: break-all;
  color: var(--text-dim);
}
body.device-mobile.page-settings .settings-sub {
  font-size: 11.5px;
}
body.device-mobile.page-settings .form-grid,
body.device-mobile.page-settings .form-grid-2,
body.device-mobile.page-settings .form-grid-3 {
  grid-template-columns: 1fr;
}
body.device-mobile.page-settings .settings-save-row {
  display: grid;
}
