/* ============================================================================
   자동매매 대시보드 — 2세대 디자인 시스템
   ----------------------------------------------------------------------------
   방향: 트레이딩뷰의 '데이터가 주인공' 원칙 + 정돈된 카드 레이아웃.
   - 다크(기본) / 라이트 두 테마. 모든 색은 토큰으로만 쓴다(하드코딩 금지).
   - 수익/손실 색은 트레이딩뷰 계열(청록 초록 · 빨강) 유지 — 적록색약에서 구분되는
     조합으로 검증됐고(ΔE 11.6 deutan), 항상 +/- 부호·화살표를 함께 표기한다.
   - 숫자는 전부 등폭(tabular-nums) — 자릿수가 흔들리지 않아야 비교가 된다.
   - 폰: 하단 탭바 · 44px 이상 터치 영역 · 시트형 대화상자.
   ========================================================================== */

/* ── 토큰: 다크(기본) ───────────────────────────────────────────────────── */
:root {
  color-scheme: dark;
  --bg:          #0c0f16;
  --bg-glow:     radial-gradient(1200px 500px at 20% -10%, rgba(41,98,255,.10), transparent 60%);
  --surface:     #131824;   /* 카드 */
  --surface-2:   #181e2c;   /* 카드 머리·입력 */
  --surface-3:   #202838;   /* 호버 */
  --elev:        #1a2131;   /* 팝오버·대화상자 */
  --border:      #222a3a;
  --border-lt:   #2d3648;
  --ink:         #e7eaf0;
  --ink-mute:    #9aa3b4;
  --ink-dim:     #677084;
  --up:          #26a69a;
  --up-weak:     rgba(38,166,154,.14);
  --up-line:     rgba(38,166,154,.42);
  --down:        #ef5350;
  --down-weak:   rgba(239,83,80,.14);
  --down-line:   rgba(239,83,80,.42);
  --accent:      #4c7dff;
  --accent-2:    #7b5cff;
  --accent-weak: rgba(76,125,255,.15);
  --accent-line: rgba(76,125,255,.5);
  --warn:        #f0b43c;
  --warn-weak:   rgba(240,180,60,.13);
  --warn-line:   rgba(240,180,60,.42);
  --gold:        #d9a53a;            /* 창고(장기 보유분) */
  --gold-weak:   rgba(217,165,58,.14);
  --shadow-sm:   0 1px 2px rgba(0,0,0,.35);
  --shadow:      0 8px 24px rgba(0,0,0,.35), 0 1px 0 rgba(255,255,255,.02) inset;
  --shadow-lg:   0 24px 60px rgba(0,0,0,.55);
  --scrim:       rgba(5,7,12,.66);
  --chart-bg:    #131824;
  --chart-text:  #8b93a5;
  --chart-grid:  rgba(40,48,64,.5);
  --chart-border:#222a3a;
  --chart-cross: #4a5366;

  --r-lg: 14px;
  --r:    10px;
  --r-sm: 7px;
  --r-xs: 5px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
          "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --sidebar-w: 232px;
  --topbar-h: 60px;
  --ease: cubic-bezier(.2,.8,.2,1);

  /* 예전 이름 호환 — 인라인 스타일·과거 규칙이 쓰던 이름 */
  --muted: var(--ink-mute);
  --text:  var(--ink);
}

/* ── 토큰: 라이트 ───────────────────────────────────────────────────────── */
[data-theme="light"] {
  color-scheme: light;
  --bg:          #f3f5f9;
  --bg-glow:     radial-gradient(1200px 500px at 20% -10%, rgba(41,98,255,.07), transparent 60%);
  --surface:     #ffffff;
  --surface-2:   #f7f8fb;
  --surface-3:   #eef1f6;
  --elev:        #ffffff;
  --border:      #e4e8ef;
  --border-lt:   #d5dbe5;
  --ink:         #141824;
  --ink-mute:    #596276;
  --ink-dim:     #8a93a5;
  --up:          #089981;
  --up-weak:     rgba(8,153,129,.10);
  --up-line:     rgba(8,153,129,.38);
  --down:        #e5303e;
  --down-weak:   rgba(229,48,62,.08);
  --down-line:   rgba(229,48,62,.34);
  --accent:      #2962ff;
  --accent-2:    #6a3cff;
  --accent-weak: rgba(41,98,255,.09);
  --accent-line: rgba(41,98,255,.45);
  --warn:        #b7791f;
  --warn-weak:   rgba(221,153,20,.12);
  --warn-line:   rgba(183,121,31,.38);
  --gold:        #a8770f;
  --gold-weak:   rgba(203,145,20,.12);
  --shadow-sm:   0 1px 2px rgba(20,24,36,.06);
  --shadow:      0 6px 20px rgba(20,24,36,.07), 0 1px 2px rgba(20,24,36,.05);
  --shadow-lg:   0 24px 60px rgba(20,24,36,.18);
  --scrim:       rgba(20,24,36,.38);
  --chart-bg:    #ffffff;
  --chart-text:  #5d6678;
  --chart-grid:  rgba(220,225,233,.7);
  --chart-border:#e4e8ef;
  --chart-cross: #9aa3b4;
}

/* ── 기본 ───────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); background-image: var(--bg-glow); background-attachment: fixed;
  color: var(--ink); font-family: var(--font); font-size: 13.5px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "tnum";
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
b, strong { font-weight: 650; }
.num, td.num, .val, .kpi-val, table td:not(.txt), .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .95em; }
::selection { background: var(--accent-weak); }
:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
button:focus:not(:focus-visible) { outline: none; }

.ico { display: inline-block; width: 1em; height: 1em; vertical-align: -0.14em; flex: none; }
.ico svg { width: 100%; height: 100%; display: block; }

.row { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.muted { color: var(--ink-mute); }
.dim { color: var(--ink-dim); }
.hint { color: var(--ink-mute); font-size: 12.5px; line-height: 1.65; }
.up { color: var(--up); }
.down { color: var(--down); }
.warn-t { color: var(--warn); }
.sym { font-weight: 650; letter-spacing: -.01em; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 스크롤바 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-lt); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-dim); }

/* ── 앱 셸: 사이드바 + 본문 ─────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.app.collapsed { --sidebar-w: 72px; }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-right: 1px solid var(--border); padding: 14px 12px; gap: 4px; z-index: 40;
  backdrop-filter: blur(10px);
}
.brand {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; font-weight: 750;
  font-size: 15px; letter-spacing: -.02em; white-space: nowrap; overflow: hidden;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 6px 16px rgba(76,125,255,.35);
}
.brand-mark .ico { width: 18px; height: 18px; }
.brand-sub { display: block; font-size: 10.5px; font-weight: 500; color: var(--ink-dim); letter-spacing: 0; }
.nav-sec { font-size: 10.5px; font-weight: 600; color: var(--ink-dim); text-transform: uppercase;
  letter-spacing: .08em; padding: 12px 10px 6px; white-space: nowrap; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 10px; border-radius: var(--r-sm);
  background: transparent; border: 0; color: var(--ink-mute); font: inherit; font-size: 13.5px;
  font-weight: 550; cursor: pointer; text-align: left; white-space: nowrap; position: relative;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-item .ico { width: 18px; height: 18px; }
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item.active { background: var(--accent-weak); color: var(--ink); }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-item.active .ico { color: var(--accent); }
.nav-badge { margin-left: auto; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  background: var(--down); color: #fff; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 10px;
  border-top: 1px solid var(--border); }
.side-status { display: flex; flex-direction: column; gap: 6px; padding: 8px 4px; }
.app.collapsed .nav-item span.lbl, .app.collapsed .brand-text, .app.collapsed .nav-sec,
.app.collapsed .side-status .lbl, .app.collapsed .nav-badge { display: none; }
.app.collapsed .nav-item { justify-content: center; padding: 10px; }
.app.collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.page-title { display: flex; flex-direction: column; min-width: 0; }
.page-title h1 { font-size: 17px; line-height: 1.2; }
.page-title .sub { font-size: 11.5px; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-chips { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: var(--r-sm);
  background: transparent; border: 1px solid transparent; color: var(--ink-mute); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn .ico { width: 18px; height: 18px; }
.content { padding: 22px 24px 40px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* 모바일 전용 요소 — 데스크톱에서만 숨긴다 */
@media (min-width: 761px) { .m-only { display: none !important; } }
.bottom-nav { display: none; }

/* ── 버튼 ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--border-lt);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .08s, box-shadow .15s;
}
.btn .ico { width: 15px; height: 15px; }
.btn:hover { background: var(--surface-3); border-color: var(--ink-dim); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #fff), var(--accent));
  border-color: transparent; color: #fff; box-shadow: 0 4px 14px rgba(76,125,255,.28);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.green { background: var(--up); border-color: transparent; color: #fff; }
.btn.green:hover { filter: brightness(1.07); }
.btn.red { background: transparent; border-color: var(--down-line); color: var(--down); }
.btn.red:hover { background: var(--down-weak); border-color: var(--down); }
.btn.danger { background: var(--down); border-color: transparent; color: #fff; }
.btn.danger:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: var(--border-lt); }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
.btn.icon { width: 30px; padding: 0; }
.btn.block { width: 100%; }

/* ── 입력 ──────────────────────────────────────────────────────────────── */
input, select, textarea {
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--border-lt);
  border-radius: var(--r-sm); height: 36px; padding: 0 11px; font: inherit; font-size: 13px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { height: auto; padding: 9px 11px; }
input:hover, select:hover { border-color: var(--ink-dim); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak);
}
input::placeholder { color: var(--ink-dim); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa3b4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 15px;
}
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--accent); width: 16px; height: 16px; padding: 0; cursor: pointer; flex: none;
}
input[type="date"] { padding: 0 9px; }
label { cursor: pointer; }

/* ── 카드 ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  margin-bottom: 18px; overflow: hidden; box-shadow: var(--shadow-sm);
}
.card > .card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card > .card-head h2 {
  font-size: 14px; font-weight: 650; display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
}
.card > .card-head h2 > .ico { width: 17px; height: 17px; color: var(--accent); }
.card > .card-body { padding: 16px 18px; }
.card.flush > .card-body { padding: 0; }
.card.plain { background: transparent; border: 0; box-shadow: none; }

.section-title {
  display: flex; align-items: center; gap: 10px; margin: 26px 0 12px;
  font-size: 13px; font-weight: 650; color: var(--ink-mute);
}
.section-title .ico { width: 16px; height: 16px; color: var(--accent); }
.section-title .line { flex: 1; height: 1px; background: var(--border); }

/* ── KPI ───────────────────────────────────────────────────────────────── */
.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px;
}
.kpi {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px 16px 13px; box-shadow: var(--shadow-sm); min-width: 0;
  overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; left: 0; top: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent 70%); opacity: .55;
}
.kpi-label {
  color: var(--ink-mute); font-size: 11.5px; font-weight: 550;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.kpi-val { font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: -.025em; line-height: 1.15; }
.kpi-sub { color: var(--ink-dim); font-size: 11.5px; margin-top: 5px; line-height: 1.5; }

/* ── 폼 그리드 ─────────────────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label {
  font-size: 12px; color: var(--ink-mute); font-weight: 550;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; line-height: 1.4;
}
.field input, .field select { width: 100%; }
.field input[type="checkbox"], label input[type="checkbox"] { width: 16px; }
.field label .ell { max-width: 90px; }
.field.changed input, .field.changed select { border-color: var(--accent); }
.field.invalid input { border-color: var(--down); }
.conv { color: var(--accent); font-size: 11.5px; font-weight: 550; }
.pin .conv { white-space: nowrap; }   /* 파라미터 환산값만 한 줄 — 설정 화면 안내문은 줄바꿈 */
.tip { color: var(--ink-dim); cursor: help; font-size: 12px; }

/* ── 표 ────────────────────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th {
  color: var(--ink-dim); font-weight: 600; font-size: 11px; letter-spacing: .04em; white-space: nowrap;
  background: var(--surface-2); position: sticky; top: 0; z-index: 1;
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-3) 55%, transparent); }
tbody tr:last-child td { border-bottom: none; }
td.right, th.right { text-align: right; }
td.center, th.center { text-align: center; }
tr.venue-row > td {
  background: var(--surface-2); padding: 8px 16px !important; font-size: 12px;
  border-top: 1px solid var(--border); color: var(--ink-mute);
}
tr.venue-row > td b { color: var(--ink); margin-right: 8px; }

/* ── 태그·배지·점 ──────────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; line-height: 1.55; white-space: nowrap;
  background: var(--surface-3); color: var(--ink-mute); border: 1px solid transparent;
}
.pill.on  { background: var(--up-weak); color: var(--up); }
.pill.off { background: var(--surface-3); color: var(--ink-mute); }
.pill.venue-binance { background: var(--warn-weak); color: var(--warn); }
.pill .dot { width: 6px; height: 6px; }
.pill.venue-kis     { background: var(--accent-weak); color: var(--accent); }
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px;
  font-size: 12px; font-weight: 600; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--border-lt); color: var(--ink-mute); background: var(--surface-2);
}
.badge.testnet { color: var(--warn); border-color: var(--warn-line); background: var(--warn-weak); }
.badge.live    { color: var(--down); border-color: var(--down-line); background: var(--down-weak); }
.badge.ok      { color: var(--up); border-color: var(--up-line); background: var(--up-weak); }
.badge.bad     { color: var(--down); border-color: var(--down-line); background: var(--down-weak); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.dot.pulse { animation: pulse 2s ease-in-out infinite; box-shadow: 0 0 0 0 currentColor; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.res-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; background: var(--gold-weak); color: var(--gold); white-space: nowrap;
}

/* ── 배너 ──────────────────────────────────────────────────────────────── */
.banner {
  display: flex; gap: 11px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r);
  font-size: 13px; border: 1px solid; margin-bottom: 12px; line-height: 1.6;
}
/* 첫 칸(이모지)을 테마에 맞는 아이콘으로 바꾼다 — 호출부 24곳을 건드리지 않고 통일 */
.banner > span:first-child {
  font-size: 0; width: 18px; height: 18px; flex: none; margin-top: 1px; background: currentColor;
  -webkit-mask: var(--bi) center / contain no-repeat; mask: var(--bi) center / contain no-repeat;
}
.banner.warn { background: var(--warn-weak); border-color: var(--warn-line); color: var(--warn);
  --bi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E"); }
.banner.info { background: var(--accent-weak); border-color: var(--accent-line); color: var(--accent);
  --bi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4M12 8h.01'/%3E%3C/svg%3E"); }
.banner.bad  { background: var(--down-weak); border-color: var(--down-line); color: var(--down);
  --bi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7.9 2h8.2L22 7.9v8.2L16.1 22H7.9L2 16.1V7.9z'/%3E%3Cpath d='M15 9l-6 6M9 9l6 6'/%3E%3C/svg%3E"); }
.banner.ok   { background: var(--up-weak); border-color: var(--up-line); color: var(--up);
  --bi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m8 12 3 3 5-6'/%3E%3C/svg%3E"); }
.banner > span:last-child { color: var(--ink); }
.banner b { color: inherit; }
.banner.warn > span:last-child b { color: var(--warn); }
.banner.bad > span:last-child b { color: var(--down); }
.banner.info > span:last-child b { color: var(--accent); }
.banner.ok > span:last-child b { color: var(--up); }

/* ── 빈 상태 · 스켈레톤 ────────────────────────────────────────────────── */
.empty { text-align: center; padding: 40px 20px; color: var(--ink-dim); font-size: 13px; }
.empty .ico { font-size: 34px; width: auto; height: auto; opacity: .55; display: block; margin: 0 auto 10px; }
.skel {
  border-radius: var(--r-sm); min-height: 14px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 45%, var(--surface-2) 65%);
  background-size: 300% 100%; animation: shimmer 1.3s infinite linear;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.skel-card { height: 176px; border-radius: var(--r-lg); }

/* ── 대화상자(모달) · 시트 ─────────────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 32px 16px;
  z-index: 100; animation: fade .18s var(--ease);
}
.modal {
  background: var(--elev); border: 1px solid var(--border-lt); border-radius: var(--r-lg);
  width: 100%; max-width: 780px; box-shadow: var(--shadow-lg); overflow: hidden;
  display: flex; flex-direction: column; max-height: calc(100vh - 64px);
  animation: pop .22s var(--ease);
}
.modal > .modal-head, .modal > .modal-foot { flex: none; }
.modal > .modal-body { overflow-y: auto; flex: 1 1 auto; padding: 18px 20px; }
.modal > .modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal > .modal-head h2 { font-size: 15px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; min-width: 0; }
.modal > .modal-foot {
  display: flex; align-items: center; gap: 10px; padding: 14px 20px;
  border-top: 1px solid var(--border); background: var(--surface-2);
}
.x-close {
  width: 34px; height: 34px; display: grid; place-items: center; flex: none;
  background: transparent; border: none; color: var(--ink-mute); cursor: pointer;
  font-size: 22px; line-height: 1; border-radius: var(--r-sm);
}
.x-close:hover { background: var(--surface-3); color: var(--ink); }
.modal .toolbar {
  position: sticky; top: -18px; background: var(--elev); padding: 0 0 14px; z-index: 2;
  margin-top: -2px; border-bottom: 1px solid var(--border); margin-bottom: 14px;
}
/* 오른쪽 시트(관리 메뉴처럼 짧은 목록) */
.modal-bg.sheet { justify-content: flex-end; align-items: stretch; padding: 0; }
.modal-bg.sheet > .modal {
  max-width: 420px; max-height: none; height: 100%; border-radius: 0;
  border-width: 0 0 0 1px; animation: slideL .26s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes slideL { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideU { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

/* 확인 대화상자 */
.dlg-ico {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 14px;
  background: var(--accent-weak); color: var(--accent);
}
.dlg-ico.danger { background: var(--down-weak); color: var(--down); }
.dlg-ico.warn { background: var(--warn-weak); color: var(--warn); }
.dlg-ico .ico { width: 22px; height: 22px; }
.dlg-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.dlg-body { color: var(--ink-mute); font-size: 13.5px; line-height: 1.65; white-space: pre-line; }

/* 관리 메뉴 항목 */
.act-list { display: flex; flex-direction: column; gap: 6px; }
.act {
  display: flex; align-items: center; gap: 13px; width: 100%; padding: 12px 13px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); cursor: pointer;
  color: var(--ink); font: inherit; transition: background .15s, border-color .15s, transform .1s;
}
.act:hover { background: var(--surface-3); border-color: var(--border-lt); }
.act:active { transform: scale(.995); }
.act .act-ico {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--accent-weak); color: var(--accent);
}
.act .act-ico .ico { width: 18px; height: 18px; }
.act.danger .act-ico { background: var(--down-weak); color: var(--down); }
.act.gold .act-ico { background: var(--gold-weak); color: var(--gold); }
.act b { display: block; font-size: 13.5px; }
.act small { display: block; color: var(--ink-dim); font-size: 12px; margin-top: 1px; }
.act .chev { margin-left: auto; color: var(--ink-dim); }

/* ── 토스트 ────────────────────────────────────────────────────────────── */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; min-width: 260px; max-width: 420px;
  padding: 12px 14px; border-radius: var(--r); background: var(--elev); border: 1px solid var(--border-lt);
  box-shadow: var(--shadow-lg); font-size: 13px; animation: slideU .25s var(--ease);
}
.toast .ico { width: 18px; height: 18px; margin-top: 1px; }
.toast.ok .ico { color: var(--up); }
.toast.bad .ico { color: var(--down); }
.toast.warn .ico { color: var(--warn); }
.toast.info .ico { color: var(--accent); }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .2s; }

/* ── 세그먼트 컨트롤 ───────────────────────────────────────────────────── */
.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.seg button {
  height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent;
  color: var(--ink-mute); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; transition: background .15s, color .15s;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
[data-theme="light"] .seg button.on { background: #fff; }
.seg .cnt { font-size: 11px; color: var(--ink-dim); font-weight: 600; }

/* 검색 입력 */
.search { position: relative; }
.search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-dim); width: 15px; height: 15px; pointer-events: none; }
.search input { padding-left: 34px; width: 100%; }

/* ── 개요(홈) ──────────────────────────────────────────────────────────── */
.hero {
  position: relative; border-radius: var(--r-lg); padding: 22px 24px; margin-bottom: 18px; overflow: hidden;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, var(--surface)), var(--surface) 55%);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.hero::after {
  content: ""; position: absolute; right: -80px; top: -120px; width: 360px; height: 360px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent-2) 22%, transparent), transparent 70%);
  pointer-events: none;
}
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero h2 { font-size: 20px; }
.hero .sub { color: var(--ink-mute); font-size: 12.5px; margin-top: 3px; }
.hero-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 18px; position: relative; z-index: 1; }
.hstat { background: color-mix(in srgb, var(--surface) 70%, transparent); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px 14px; backdrop-filter: blur(6px); min-width: 0; }
.hstat .l { font-size: 11.5px; color: var(--ink-mute); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.hstat .l .ico { width: 14px; height: 14px; }
.hstat .v { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; line-height: 1.2; }
.hstat .s { font-size: 11.5px; color: var(--ink-dim); margin-top: 3px; }

.cols { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; align-items: start; }

/* 계좌 카드 */
.accts { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; margin-bottom: 18px; }
.acct { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.acct-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.acct-logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; font-weight: 800; font-size: 13px; }
.acct-logo.binance { background: var(--warn-weak); color: var(--warn); }
.acct-logo.kis { background: var(--accent-weak); color: var(--accent); }
.acct-head b { font-size: 14px; }
.acct-head small { display: block; color: var(--ink-dim); font-size: 11.5px; }
.acct-cur { border-top: 1px dashed var(--border); padding-top: 11px; margin-top: 11px; }
.acct-cur:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.acct-line { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13px; padding: 2px 0; }
.acct-line span:first-child { color: var(--ink-mute); font-size: 12px; }
.acct-big { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.meter { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: 8px 0 4px; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--up), color-mix(in srgb, var(--up) 60%, var(--warn))); transition: width .6s var(--ease); }
.meter.hot > i { background: linear-gradient(90deg, var(--warn), var(--down)); }
.meter-legend { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-dim); }

/* 보유 포지션 목록 */
.plist { display: flex; flex-direction: column; }
.prow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.prow:last-child { border-bottom: 0; }
.prow:hover { background: var(--surface-2); }
.prow .n { font-weight: 650; display: flex; align-items: center; gap: 7px; min-width: 0; }
.prow .n .ell { max-width: 180px; }
.prow .q { font-size: 12px; color: var(--ink-dim); }
.prow .p { text-align: right; font-weight: 700; }
.prow .pp { text-align: right; font-size: 12px; }

/* 최근 체결 */
.tlist .trow { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.tlist .trow:last-child { border-bottom: 0; }
.tside { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.tside.buy { background: var(--up-weak); color: var(--up); }
.tside.sell { background: var(--down-weak); color: var(--down); }
.tside .ico { width: 15px; height: 15px; }
.trow .tm { flex: 1; min-width: 0; }
.trow .tm b { display: block; font-size: 13px; }
.trow .tm small { color: var(--ink-dim); font-size: 11.5px; }
.trow .tv { text-align: right; white-space: nowrap; }

/* ── 전략 카드 ─────────────────────────────────────────────────────────── */
.strat-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.strat-bar .search { flex: 1 1 220px; max-width: 320px; }
.sgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.sgroup { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; margin: 8px 0 -2px; font-size: 12.5px; color: var(--ink-mute); font-weight: 600; }
.sgroup:first-child { margin-top: 0; }
.sgroup .line { flex: 1; height: 1px; background: var(--border); }
.scard {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); transition: border-color .18s var(--ease), transform .18s var(--ease), box-shadow .18s;
  overflow: hidden;
}
.scard:hover { border-color: var(--border-lt); box-shadow: var(--shadow); transform: translateY(-1px); }
.scard.off { opacity: .8; }
.scard.off .sc-body { filter: saturate(.6); }
.scard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: transparent; }
.scard.state-up::before { background: var(--up); }
.scard.state-down::before { background: var(--down); }
.sc-head { display: flex; align-items: flex-start; gap: 10px; padding: 15px 16px 10px; }
.sc-title { min-width: 0; flex: 1; }
.sc-title .nm { font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.sc-title .nm .ell { max-width: 100%; }
.sc-title .meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; font-size: 11.5px; color: var(--ink-dim); }
.sc-body { padding: 2px 16px 12px; display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; align-items: end; }
.sc-pnl .v { font-size: 22px; font-weight: 750; letter-spacing: -.02em; line-height: 1.15; }
.sc-pnl .l { font-size: 11px; color: var(--ink-dim); font-weight: 550; margin-bottom: 2px; }
.sc-pnl .s { font-size: 12px; margin-top: 2px; }
.sc-px { text-align: right; font-size: 12px; color: var(--ink-mute); }
.sc-px b { display: block; font-size: 15px; color: var(--ink); font-weight: 650; }
.sc-pos { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.qchip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-mute); }
.qchip b { color: var(--ink); font-weight: 650; }
.qchip.gold { background: var(--gold-weak); border-color: transparent; color: var(--gold); }
.qchip.gold b { color: var(--gold); }
.tpbar { grid-column: 1 / -1; }
.tpbar .track { position: relative; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: visible; }
.tpbar .fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.tpbar .fill.up { background: linear-gradient(90deg, color-mix(in srgb, var(--up) 45%, transparent), var(--up)); }
.tpbar .fill.down { background: linear-gradient(270deg, color-mix(in srgb, var(--down) 45%, transparent), var(--down)); }
.tpbar .zero { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink-dim); border-radius: 1px; }
.tpbar .lg { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink-dim); margin-top: 5px; }
/* 청산 스위치 3개 (익절·매도조건·트레일링) */
.sc-exits { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 0 16px 12px; }
.sc-exits .lab { font-size: 11px; font-weight: 650; color: var(--ink-dim); margin-right: 2px; cursor: help; }
.xchip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px 0 8px; border-radius: 999px;
  border: 1px solid var(--border-lt); background: transparent; color: var(--ink-mute); font: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.xchip i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-dim); flex: none; }
.xchip b { font-size: 10.5px; font-weight: 750; letter-spacing: .03em; opacity: .85; }
.xchip:hover { background: var(--surface-3); color: var(--ink); }
.xchip.on { background: var(--up-weak); border-color: var(--up-line); color: var(--ink); }
.xchip.on i { background: var(--up); box-shadow: 0 0 0 3px var(--up-weak); }
.xchip.on b { color: var(--up); }
.xchip.off { text-decoration: line-through; text-decoration-color: var(--ink-dim); }
.xchip.off b { color: var(--down); text-decoration: none; display: inline-block; }
.xchip.dep { background: var(--warn-weak); border-color: var(--warn-line); }
.xchip.dep i { background: var(--warn); box-shadow: none; }
.xchip.dep b { color: var(--warn); }
.xchip:disabled { opacity: .5; cursor: wait; }
.sc-exits .xwarn { font-size: 11px; font-weight: 650; color: var(--down); background: var(--down-weak); border-radius: 999px; padding: 2px 8px; }
.sc-foot { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-top: 1px solid var(--border); background: var(--surface-2); margin-top: auto; font-size: 12px; }
.sc-foot .sig { color: var(--ink-mute); min-width: 0; flex: 1; }
.sc-foot .sig b { color: var(--ink); font-weight: 600; }
.sc-empty { grid-column: 1 / -1; color: var(--ink-dim); font-size: 12.5px; padding: 6px 0 4px; }
.scard .tgl { margin-left: auto; }

/* 사전점검 배지 */
.pf { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.pf .ico { width: 12px; height: 12px; }
.pf.danger { background: var(--down-weak); color: var(--down); }
.pf.warn { background: var(--warn-weak); color: var(--warn); }

/* ── 이벤트 피드 ───────────────────────────────────────────────────────── */
.evt { display: flex; align-items: flex-start; gap: 11px; padding: 10px 2px; border-bottom: 1px solid var(--border); font-size: 13px; }
.evt:last-child { border-bottom: none; }
.evt-ico { width: 26px; height: 26px; flex: none; border-radius: 8px; display: grid; place-items: center; font-size: 0; }
.evt-ico::before { content: ""; width: 14px; height: 14px; background: currentColor;
  -webkit-mask: var(--ei) center / contain no-repeat; mask: var(--ei) center / contain no-repeat; }
.evt-danger .evt-ico { background: var(--down-weak); color: var(--down);
  --ei: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M12 8v5M12 16.5h.01'/%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3C/svg%3E"); }
.evt-warn .evt-ico { background: var(--warn-weak); color: var(--warn);
  --ei: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E"); }
.evt-info .evt-ico { background: var(--surface-3); color: var(--ink-mute);
  --ei: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='M12 16v-4M12 8h.01'/%3E%3C/svg%3E"); }
.evt-body { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; line-height: 1.55; }
.evt-cat { display: inline-block; font-size: 11px; font-weight: 650; padding: 0 7px; margin-right: 7px; border-radius: 6px; background: var(--surface-3); color: var(--ink-mute); }
.evt-danger .evt-cat { background: var(--down-weak); color: var(--down); }
.evt-warn .evt-cat { background: var(--warn-weak); color: var(--warn); }
.evt-cnt { margin-left: 6px; font-size: 11px; color: var(--ink-dim); font-weight: 600; }
.evt-when { flex: 0 0 auto; font-size: 11.5px; color: var(--ink-dim); white-space: nowrap; padding-top: 3px; }
.evt.new { background: linear-gradient(90deg, var(--accent-weak), transparent 70%); border-radius: var(--r-sm); }
.evt-more { margin-top: 10px; }
.evt-more summary { cursor: pointer; font-size: 12.5px; color: var(--ink-mute); padding: 4px 0; font-weight: 550; }

/* ── 파라미터 편집 ─────────────────────────────────────────────────────── */
.pgroup { border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 8px; overflow: hidden; background: var(--surface); }
.pgroup > .phead {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; cursor: pointer; user-select: none; font-weight: 650; font-size: 13px;
  transition: background .12s;
}
.pgroup > .phead:hover { background: var(--surface-2); }
.pgroup > .phead .caret { color: var(--ink-dim); transition: transform .2s var(--ease); display: inline-block; }
.pgroup.open > .phead { border-bottom: 1px solid var(--border); background: var(--surface-2); }
.pgroup.open > .phead .caret { transform: rotate(90deg); }
.pgroup > .pbody { padding: 2px 0; display: none; }
.pgroup.open > .pbody { display: block; }
.pgroup .pcount { font-size: 11px; color: var(--ink-dim); font-weight: 600; background: var(--surface-3); border-radius: 999px; padding: 1px 8px; margin-left: 6px; }
.pgroup .chgbadge { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-weak); border-radius: 999px; padding: 1px 8px; margin-left: 6px; }
.pfield {
  display: grid; grid-template-columns: minmax(160px, 280px) 1fr; align-items: center; gap: 16px;
  padding: 9px 14px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.pfield:last-child { border-bottom: none; }
.pfield:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.plabel { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); min-width: 0; flex-wrap: wrap; }
.plabel > span:first-child { overflow-wrap: anywhere; }
.pin { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pin > input, .pin > select { width: 100%; max-width: 210px; }
.pin.pair { gap: 10px; flex-wrap: wrap; }
.pmod {
  display: flex; align-items: center; width: 210px; height: 36px; background: var(--surface-2);
  border: 1px solid var(--border-lt); border-radius: var(--r-sm); overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.pmod:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.pmod input, .pmod select { border: none; background-color: transparent; box-shadow: none; width: 100%; min-width: 0; height: 34px; }
.pmod input:focus, .pmod select:focus { box-shadow: none; }
.pmod .modtag {
  font-size: 10.5px; font-weight: 750; letter-spacing: .04em; color: var(--ink-mute);
  background: var(--surface-3); border-right: 1px solid var(--border-lt); padding: 0 8px; flex: none;
  align-self: stretch; display: flex; align-items: center;
}
.pmod:has(.switch) { background: transparent; border-color: transparent; width: auto; }
.pmod:has(.switch) .modtag { background: var(--surface-3); border: 0; border-radius: 5px; padding: 1px 6px; margin-right: 8px; align-self: center; }
.unit { font-size: 11.5px; color: var(--ink-dim); flex: none; }
.pfield.changed > .pin > input, .pfield.changed > .pin > select, .pmod.changed input, .pmod.changed select { color: var(--accent); }
.pfield.changed > .pin > input, .pfield.changed > .pin > select, .pmod.changed { border-color: var(--accent); }
.pfield.has-changed > .plabel > span:first-child, .pfield.changed > .plabel > span:first-child { color: var(--accent); font-weight: 650; }
.pfield.invalid input, .pmod.invalid input { border-color: var(--down); background: var(--down-weak); }
.revert { background: transparent; border: 1px solid var(--border-lt); color: var(--ink-mute); border-radius: 6px;
  font-size: 11px; height: 24px; padding: 0 7px; cursor: pointer; font-family: inherit; }
.revert:hover { color: var(--ink); border-color: var(--accent); }
.pfield.disabled .plabel > span:first-child { color: var(--ink-dim); }
.pmod.disabled, .pin > input:disabled, .pin > select:disabled { opacity: .45; }
.pfield.disabled { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.depnote { font-size: 11px; color: var(--ink-dim); font-weight: 500; }
input:disabled, select:disabled { cursor: not-allowed; }

/* 스위치 */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; position: relative; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 38px; height: 22px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-lt);
  position: relative; transition: background .2s var(--ease), border-color .2s; flex: none;
}
.switch .knob {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--ink-dim); transition: transform .2s var(--ease), background .2s; box-shadow: var(--shadow-sm);
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track .knob { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-weak); }
.switch input:disabled ~ .track, .switch input:disabled ~ .swtext { opacity: .45; }
.swtext { font-size: 11.5px; font-weight: 700; color: var(--ink-dim); min-width: 26px; }
.switch input:checked ~ .swtext { color: var(--accent); }
.switch.big .track { width: 44px; height: 25px; }
.switch.big .knob { width: 19px; height: 19px; }
.switch.big input:checked + .track .knob { transform: translateX(19px); }
.switch.green input:checked + .track { background: var(--up); border-color: var(--up); }

/* ── 차트 화면 (트레이딩뷰 배치, 2026-09-30) ─────────────────────────────── */
.content.wide { max-width: none; padding: 12px 14px 14px; }
.tvc {
  --right-w: 320px; --bottom-h: 230px;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: calc(100vh - var(--topbar-h) - 26px); min-height: 520px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-sm);
}
.tvc-top {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--border);
  background: var(--surface); min-width: 0; flex-wrap: wrap;
}
.tvc-top .tb-div, .tvc-bar .tb-div { width: 1px; height: 22px; background: var(--border); margin: 0 3px; flex: none; }
.tvc-top .spacer, .tvc-bar .spacer, .tvb-head .spacer, .jmod-h .spacer, .jc .spacer, .rp-head .spacer, .tvb-bar .spacer { flex: 1; }
.tv-sym {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px 0 10px; border-radius: var(--r-sm);
  background: transparent; border: 1px solid transparent; color: var(--ink); font: inherit; cursor: pointer; max-width: 320px; min-width: 0;
}
.tv-sym:hover { background: var(--surface-3); }
.tv-sym .ico { width: 15px; height: 15px; color: var(--ink-mute); flex: none; }
.tv-sym b { font-size: 14.5px; letter-spacing: .01em; }
.tv-sym-sub { font-size: 12px; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tv-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: var(--r-sm);
  background: transparent; border: 0; color: var(--ink-mute); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.tv-btn:hover { background: var(--surface-3); color: var(--ink); }
.tv-btn .ico { width: 16px; height: 16px; }
.tv-btn.icon { width: 32px; padding: 0; justify-content: center; }
.tvc-top .pill.tv-auto { height: 28px; padding: 0 10px; font-size: 12px; cursor: pointer; border: 1px solid var(--border-lt); color: var(--ink-mute); background: transparent; user-select: none; }
.tvc-top .pill.tv-auto.on { background: var(--accent-weak); border-color: var(--accent-line); color: var(--ink); }
.tb-tf { display: inline-flex; padding: 2px; gap: 1px; border-radius: 8px; }
.tf-btn {
  position: relative; height: 30px; min-width: 36px; padding: 0 9px; border: 0; border-radius: 6px; cursor: pointer;
  background: transparent; color: var(--ink-mute); font: inherit; font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums;
}
.tf-btn:hover { color: var(--ink); background: var(--surface-3); }
.tf-btn.on { color: var(--accent); background: var(--accent-weak); }
.tf-btn i { position: absolute; top: 4px; right: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--warn); }
.tb-menu { position: relative; }
.tb-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; background: var(--elev);
  border: 1px solid var(--border-lt); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 6px;
  display: flex; flex-direction: column; min-width: 190px; animation: pop .14s var(--ease);
}
.tb-pop.wide { min-width: 260px; padding: 8px 10px 10px; }
.tb-pop.up { top: auto; bottom: calc(100% + 6px); }
.tb-pop[hidden] { display: none !important; }
.pop-item { text-align: left; background: transparent; border: 0; color: var(--ink); font: inherit; font-size: 13px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.pop-item:hover { background: var(--surface-3); }
.pop-item.on { color: var(--accent); font-weight: 650; }
.pop-sec { font-size: 11px; font-weight: 700; color: var(--ink-dim); letter-spacing: .04em; margin: 8px 2px 4px; }
.pop-sec:first-child { margin-top: 2px; }
.pop-chk { display: flex; align-items: center; gap: 9px; padding: 6px 4px; border-radius: 6px; font-size: 13px; }
.pop-chk:hover { background: var(--surface-3); }

.tvc-mid { display: grid; grid-template-columns: minmax(0, 1fr) var(--right-w); min-height: 0; }
.tvc.no-right .tvc-mid { grid-template-columns: minmax(0, 1fr) 0; }
.tvc.no-right .tvc-right { display: none; }
.tvc-chartcol { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tvc-chart { position: relative; flex: 1; min-height: 0; }
#tvChart { position: absolute; inset: 0; }
.tv-legend {
  position: absolute; top: 6px; left: 10px; right: 90px; z-index: 5; pointer-events: none;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; font-size: 12px; font-variant-numeric: tabular-nums;
}
.tv-legend .lg-head { display: flex; align-items: baseline; gap: 5px; flex-wrap: wrap; font-size: 13px; color: var(--ink); }
.tv-legend .lg-head b { font-size: 14px; }
.tv-legend .lg-dot { color: var(--ink-dim); }
.lg-ohlc { display: inline-flex; gap: 4px; flex-wrap: wrap; margin-left: 8px; font-size: 12px; }
.lg-ohlc .k { color: var(--ink-dim); margin-left: 4px; }
.lg-ohlc .k:first-child { margin-left: 0; }
.lg-frozen { margin-left: 8px; font-size: 11px; color: var(--warn); background: var(--warn-weak); border-radius: 5px; padding: 0 6px; }
.lg-row, .tv-plg { display: flex; align-items: center; gap: 6px; min-height: 20px; width: max-content; max-width: 100%; border-radius: 5px; padding: 0 4px; margin-left: -4px; pointer-events: auto; }
.lg-row .lg-name, .tv-plg .lg-name { color: var(--ink-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-vals { display: inline-flex; gap: 6px; }
.lg-sw { width: 10px; height: 3px; border-radius: 2px; flex: none; }
.lg-eye { display: none; width: 18px; height: 18px; border: 0; border-radius: 4px; background: var(--surface-3); color: var(--ink-mute); cursor: pointer; padding: 0; align-items: center; justify-content: center; }
.lg-eye .ico { width: 11px; height: 11px; }
.lg-row:hover, .tv-plg:hover { background: color-mix(in srgb, var(--surface-3) 80%, transparent); }
.lg-row:hover .lg-eye, .tv-plg:hover .lg-eye { display: inline-flex; }
.lg-eye:hover { color: var(--down); }
.tv-plg { position: absolute; left: 10px; z-index: 5; font-size: 11.5px; font-variant-numeric: tabular-nums; }
[data-theme="light"] .tv-legend, [data-theme="light"] .tv-plg { text-shadow: 0 0 3px #fff, 0 0 5px #fff; }
:root:not([data-theme="light"]) .tv-legend, :root:not([data-theme="light"]) .tv-plg { text-shadow: 0 1px 2px rgba(0,0,0,.8); }
.tv-tip {
  position: absolute; z-index: 8; pointer-events: none; min-width: 170px; max-width: 230px; padding: 7px 9px;
  background: var(--elev); border: 1px solid var(--border-lt); border-radius: 8px; box-shadow: var(--shadow); font-size: 12px; line-height: 1.5;
}
.tv-tip .tt-row + .tt-row { border-top: 1px solid var(--border); margin-top: 5px; padding-top: 5px; }
.tv-tip .tt-k { font-weight: 700; margin-right: 4px; }
.tv-count {
  position: absolute; right: 2px; z-index: 6; pointer-events: none; font-size: 10.5px; font-weight: 600;
  font-variant-numeric: tabular-nums; background: var(--surface-3); color: var(--ink-mute); border-radius: 3px; padding: 0 5px; line-height: 16px;
}
.tv-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--ink-mute); font-size: 14px; line-height: 1.7; z-index: 4; background: color-mix(in srgb, var(--chart-bg) 70%, transparent); }
.tv-msg[hidden] { display: none; }
.tv-typer {
  position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); z-index: 20; width: 220px;
  background: var(--elev); border: 1px solid var(--border-lt); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 12px;
}
.tv-typer input { width: 100%; font-size: 20px; font-weight: 700; height: 44px; text-align: center; text-transform: uppercase; }
.tvt-t { font-size: 12px; color: var(--ink-mute); margin-bottom: 6px; font-weight: 650; }
.tvt-h { font-size: 11px; color: var(--ink-dim); margin-top: 6px; }
.tvc-bar {
  flex: none; display: flex; align-items: center; gap: 2px; padding: 3px 6px; border-top: 1px solid var(--border);
  background: var(--surface); font-size: 12px; min-width: 0;
}
.tv-ranges { display: flex; align-items: center; gap: 1px; flex-wrap: nowrap; }
.tv-ranges button, .tv-tz, .tv-sc, #tvGoBtn {
  height: 26px; min-width: 30px; padding: 0 7px; border: 0; background: transparent; color: var(--ink-mute);
  font: inherit; font-size: 12px; font-weight: 600; border-radius: 5px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.tv-ranges button:hover, .tv-tz:hover, .tv-sc:hover, #tvGoBtn:hover { background: var(--surface-3); color: var(--ink); }
#tvGoBtn .ico { width: 14px; height: 14px; }
.tv-sc.on { color: var(--accent); }
.tv-status { font-size: 11.5px; color: var(--ink-mute); margin-right: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 오른쪽 패널 */
.tvc-right { border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--surface); }
.tvr-tabs { display: flex; border-bottom: 1px solid var(--border); flex: none; }
.tvr-tabs button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; height: 38px; border: 0; background: transparent;
  color: var(--ink-mute); font: inherit; font-size: 12.5px; font-weight: 650; cursor: pointer; border-bottom: 2px solid transparent;
}
.tvr-tabs button .ico { width: 15px; height: 15px; }
.tvr-tabs button:hover { color: var(--ink); background: var(--surface-2); }
.tvr-tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tvr-body { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.wl-head { display: grid; grid-template-columns: 1fr 88px 64px; gap: 6px; padding: 7px 12px; font-size: 11px; color: var(--ink-dim); font-weight: 650; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.wl-row {
  display: grid; grid-template-columns: 1fr 88px 64px; gap: 2px 6px; align-items: center; width: 100%; text-align: left;
  padding: 8px 12px; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  background: transparent; color: var(--ink); font: inherit; font-size: 12.5px; cursor: pointer;
}
.wl-row:hover { background: var(--surface-2); }
.wl-row.on { background: var(--accent-weak); box-shadow: inset 2px 0 0 var(--accent); }
.wl-sym { display: flex; align-items: center; gap: 6px; min-width: 0; }
.wl-sym b { font-size: 12.5px; }
.wl-name { color: var(--ink-dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.wl-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-dim); flex: none; }
.wl-dot.on { background: var(--up); box-shadow: 0 0 0 3px var(--up-weak); }
.wl-pos { grid-column: 1 / -1; font-size: 11px; color: var(--ink-mute); padding-left: 12px; }
.wl-row .mono, .dw .mono, .tvb-tbl .mono { font-family: inherit; font-variant-numeric: tabular-nums; }
.dw { padding: 10px 12px 16px; font-size: 12.5px; }
.dw-time { font-weight: 650; margin-bottom: 6px; }
.dw-sec { font-size: 11px; font-weight: 700; color: var(--ink-dim); letter-spacing: .03em; margin: 12px 0 5px; }
.dw-t { width: 100%; border-collapse: collapse; }
.dw-t td { padding: 3px 0; border: 0; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.dw-t td:first-child { color: var(--ink-mute); padding-right: 10px; }
.dw-hint { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--ink-mute); line-height: 1.6; background: var(--surface-2); border: 1px dashed var(--border-lt); border-radius: var(--r-sm); padding: 10px 12px; margin-top: 12px; }
.dw-hint .ico { width: 15px; height: 15px; flex: none; margin-top: 2px; color: var(--accent); }
.jm { display: flex; flex-direction: column; gap: 4px; background: var(--surface-2); border-radius: var(--r-sm); padding: 8px 10px; }
.jm .warn { color: var(--warn); }
.jmod { margin-top: 8px; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 7px 10px; }
.jmod-h { display: flex; align-items: center; gap: 6px; font-size: 12.5px; margin-bottom: 2px; }
.jmod-h .warn { color: var(--warn); }
.jc { display: flex; align-items: center; gap: 7px; padding: 3px 0; font-size: 12.5px; }
.jc > span:nth-child(2) { white-space: nowrap; }
.jc .mono { font-size: 11.5px; text-align: right; }
.jk { width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; }
.jk .ico { width: 11px; height: 11px; }
.jk.ok { background: var(--up-weak); color: var(--up); }
.jk.no { background: var(--down-weak); color: var(--down); }
.rp-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); flex: none; font-size: 12px; }
.rp-ed { flex: 1; min-height: 0; overflow: auto; }
.rp-foot { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--border); flex: none; background: var(--surface); }
.rp-foot select { height: 30px; font-size: 12px; padding: 0 26px 0 8px; flex: 0 0 auto; }
.rp-foot .btn { flex: 1; }

/* 아래 패널 */
.tvc-bottom { display: none; position: relative; border-top: 1px solid var(--border); min-height: 0; flex-direction: column; background: var(--surface); }
.tvc.bottom-open .tvc-bottom { display: flex; }
.tvc.bottom-open { grid-template-rows: auto minmax(0, 1fr) var(--bottom-h); }
.tvb-grip { position: absolute; left: 0; right: 0; top: -4px; height: 8px; cursor: ns-resize; z-index: 3; }
.tvb-grip:hover { background: var(--accent-line); }
.tvb-head { display: flex; align-items: center; padding: 0 6px; border-bottom: 1px solid var(--border); flex: none; }
.tvb-head #tvBottomClose .ico { transform: rotate(90deg); }
.tvb-tabs { display: flex; }
.tvb-tabs button { height: 34px; padding: 0 12px; border: 0; background: transparent; color: var(--ink-mute); font: inherit; font-size: 12.5px; font-weight: 650; cursor: pointer; border-bottom: 2px solid transparent; }
.tvb-tabs button:hover { color: var(--ink); }
.tvb-tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tvb-body { flex: 1; min-height: 0; overflow: auto; }
.tvb-bar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; flex-wrap: wrap; font-size: 12.5px; }
.tvb-bar select { height: 30px; font-size: 12.5px; }
.tvb-tbl table { font-size: 12.5px; }
.tvb-tbl th { position: sticky; top: 0; background: var(--surface-2); z-index: 1; }
.tvb-tbl td, .tvb-tbl th { padding: 6px 14px; }
.tvb-row { cursor: pointer; }
.tvb-row:hover td { background: var(--surface-2); }
.tvb-row.on td { background: var(--accent-weak); }
.tvb-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1px; background: var(--border); border-block: 1px solid var(--border); margin: 6px 0 0; }
.tvb-kpis > div { background: var(--surface); padding: 8px 14px; display: flex; flex-direction: column; gap: 2px; }
.tvb-kpis span { font-size: 11px; color: var(--ink-dim); font-weight: 600; }
.tvb-kpis b { font-size: 15px; font-variant-numeric: tabular-nums; }
.tvb-kpis em { font-style: normal; font-size: 11px; color: var(--ink-mute); }
.tvb-cmp { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; padding: 0 14px 14px; }

/* 종목 검색 */
.tv-search-bg { align-items: flex-start; padding-top: 10vh; }
.modal.tv-search { overflow: hidden; }
.tvs-in { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.tvs-in .ico { width: 18px; height: 18px; color: var(--ink-mute); }
.tvs-in input { flex: 1; border: 0; background: transparent; box-shadow: none !important; font-size: 16px; height: 36px; padding: 0; }
.tvs-list { max-height: 50vh; overflow: auto; padding: 6px; }
.tvs-row { display: grid; grid-template-columns: 120px 1fr; gap: 2px 12px; width: 100%; text-align: left; padding: 9px 12px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); font: inherit; cursor: pointer; }
.tvs-row b { font-size: 14px; }
.tvs-row .tvs-name { font-size: 13px; }
.tvs-row .tvs-sub { grid-column: 2; font-size: 11.5px; color: var(--ink-dim); }
.tvs-row:hover, .tvs-row.on { background: var(--surface-3); }
.tvs-foot { padding: 8px 16px; font-size: 11.5px; color: var(--ink-dim); border-top: 1px solid var(--border); }

/* ── 파라미터 편집기 (트레이딩뷰 설정 창) ──────────────────────────────────── */
.modal-body.pe-host { padding: 0; display: flex; position: relative; overflow: hidden; }
.pe-host > #peRoot { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.peditor { display: flex; flex-direction: column; min-height: 0; }
.pe-search { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); flex: none; background: var(--surface); }
.pe-sico .ico { width: 15px; height: 15px; color: var(--ink-dim); }
.pe-search .pe-q { flex: 1; min-width: 0; height: 32px; }
.pe-only { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-mute); white-space: nowrap; }
.pe-body { flex: 1; min-height: 0; display: flex; }
.pe-tabs { flex: 0 0 210px; border-right: 1px solid var(--border); overflow: auto; padding: 8px; background: var(--surface-2); }
.ptab { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 9px 11px; border: 0; border-radius: 7px; background: transparent; color: var(--ink-mute); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.ptab:hover { background: var(--surface-3); color: var(--ink); }
.ptab.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.ptab .ptab-name { flex: 1; min-width: 0; }
.ptab .chgbadge { font-size: 10.5px; font-weight: 750; color: #fff; background: var(--accent); border-radius: 999px; min-width: 18px; height: 18px; display: inline-grid; place-items: center; padding: 0 5px; }
.ptab .chgbadge[hidden] { display: none; }
.pe-content { flex: 1; min-width: 0; overflow: auto; padding: 6px 4px 20px; }
.pe-modal .pgroup { border: 0; border-radius: 0; margin: 0; background: transparent; display: none; }
.pe-modal .pgroup.on { display: block; }
.pe-modal .pgroup > .phead { cursor: default; padding: 12px 14px 8px; font-size: 14px; background: transparent !important; border: 0 !important; }
.pe-modal .pgroup > .phead .caret, .pe-modal .pgroup > .phead .chgbadge { display: none; }
.pe-modal .pgroup > .pbody { display: block; }
/* 검색 중엔 탭과 상관없이 맞는 항목을 그룹 제목과 함께 전부 */
.pe-modal.filtering .pgroup { display: none; }
.pe-modal.filtering .pgroup.hit { display: block; }
.pe-modal.filtering .ptab { opacity: .5; }
.pe-panel .pe-search { padding: 8px 10px; }
.pe-panel .pe-only { display: none; }
.pe-panel .pe-content { padding: 6px; }
.pe-panel .pgroup { margin-bottom: 6px; }
.pe-panel .pgroup > .phead { padding: 9px 11px; font-size: 12.5px; }
.pe-panel .pfield { grid-template-columns: 1fr; gap: 5px; padding: 8px 10px; }
.pe-panel .plabel { font-size: 12.5px; }
.pe-panel .pin > input, .pe-panel .pin > select { max-width: none; height: 32px; }
.pe-panel .pmod { width: auto; flex: 1 1 0; min-width: 0; height: 32px; }
.pe-panel .pmod input, .pe-panel .pmod select { height: 30px; }
.pe-panel .pmod:has(.switch) { flex: 0 0 auto; }
.pe-panel .pin.pair { flex-wrap: nowrap; gap: 6px; }
.pe-empty { padding: 20px; }
.pe-empty[hidden] { display: none; }
.pe-cmp {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 100%); z-index: 6; overflow: auto;
  background: var(--elev); border-left: 1px solid var(--border-lt); box-shadow: var(--shadow-lg); padding: 12px 16px 20px; animation: pop .16s var(--ease);
}
.pe-cmp[hidden] { display: none; }
.pe-cmp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 14px; }
.pe-cmp-sub { font-size: 11.5px; font-weight: 700; color: var(--ink-dim); margin: 14px 0 6px; letter-spacing: .03em; }
table.cmp { font-size: 12.5px; }
table.cmp td, table.cmp th { padding: 6px 10px; }
table.cmp thead th { background: var(--surface-2); }
.chglist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.chglist li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 8px; border-radius: 6px; background: var(--surface-2); }
.chglist .cl-k { color: var(--ink-mute); min-width: 0; overflow-wrap: anywhere; }
.chglist .cl-v { white-space: nowrap; font-variant-numeric: tabular-nums; }
.chglist s { color: var(--ink-dim); }
.chglist b { color: var(--accent); }
.dlg-body .chglist { max-height: 42vh; overflow: auto; text-align: left; }
.pe-foot-l { display: flex; align-items: center; gap: 10px; position: relative; }
.pe-preset-pop { bottom: calc(100% + 6px); top: auto; left: 0; min-width: 280px; padding: 8px; gap: 2px; }
.rp-head .pe-preset-pop { top: calc(100% + 6px); bottom: auto; left: auto; right: 0; }
.pp-title { font-size: 11px; font-weight: 700; color: var(--ink-dim); margin: 2px 4px 6px; }
.pp-row { display: flex; align-items: center; gap: 4px; }
.pp-load { flex: 1; text-align: left; background: transparent; border: 0; color: var(--ink); font: inherit; font-size: 13px; padding: 7px 8px; border-radius: 6px; cursor: pointer; }
.pp-load:hover { background: var(--surface-3); }
.pp-sep { height: 1px; background: var(--border); margin: 6px 0; }
.pe-preset-pop .btn { justify-content: flex-start; margin-top: 3px; }
.modal-foot select.sm { height: 34px; font-size: 12.5px; }

/* ── 로그 ──────────────────────────────────────────────────────────────── */
.log-row td { font-size: 12.5px; padding: 9px 16px; }
.log-row td:first-child { font-family: var(--mono); font-size: 11.5px; }
.lv-INFO, .lv-WARNING, .lv-ERROR, .lv-CRITICAL, .lv-DEBUG { font-weight: 700; font-size: 11px; }
td.lv-INFO::before, td.lv-WARNING::before, td.lv-ERROR::before, td.lv-CRITICAL::before, td.lv-DEBUG::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; background: currentColor; vertical-align: 1px;
}
.lv-INFO, .lv-DEBUG { color: var(--ink-dim); }
.lv-WARNING { color: var(--warn); }
.lv-ERROR, .lv-CRITICAL { color: var(--down); }
.log-row td.msg {
  color: var(--ink); white-space: pre-wrap; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer;
}
.log-row td.msg.open { -webkit-line-clamp: unset; }

/* ── 설정 ──────────────────────────────────────────────────────────────── */
.set-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.set-tab {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: var(--r);
  border: 1px solid var(--border); background: var(--surface); color: var(--ink); cursor: pointer;
  text-align: left; font: inherit; transition: border-color .15s, background .15s, transform .12s; box-shadow: var(--shadow-sm);
}
.set-tab:hover { border-color: var(--border-lt); transform: translateY(-1px); }
.set-tab .st-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-mute); flex: none; }
.set-tab .st-ico .ico { width: 18px; height: 18px; }
.set-tab b { display: block; font-size: 13.5px; }
.set-tab span.d { display: block; font-size: 11.5px; color: var(--ink-dim); margin-top: 1px; }
.set-tab.on { border-color: var(--accent-line); background: var(--accent-weak); }
.set-tab.on .st-ico { background: var(--accent); color: #fff; }
.ph-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.ph-when { font-size: 12px; color: var(--ink-dim); margin-bottom: 5px; font-family: var(--mono); }
.ph-row { font-size: 13px; padding: 2px 0; }
.ph-lab { display: inline-block; min-width: 200px; color: var(--ink); }

/* ── 로그인 ────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.login-wrap::before {
  content: ""; position: absolute; inset: -30%;
  background: radial-gradient(600px 400px at 30% 30%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
              radial-gradient(500px 380px at 75% 70%, color-mix(in srgb, var(--accent-2) 18%, transparent), transparent 60%);
  filter: blur(10px); pointer-events: none;
}
.login-card {
  position: relative; width: 100%; max-width: 380px; padding: 34px 30px 28px; border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 86%, transparent); border: 1px solid var(--border-lt);
  box-shadow: var(--shadow-lg); backdrop-filter: blur(14px); text-align: left;
}
.login-card .brand-mark { width: 46px; height: 46px; border-radius: 13px; margin-bottom: 18px; }
.login-card .brand-mark .ico { width: 24px; height: 24px; }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card p { color: var(--ink-mute); margin: 0 0 22px; font-size: 13px; }
.login-card input { width: 100%; height: 44px; margin-bottom: 12px; font-size: 14px; }
.login-card .btn { width: 100%; height: 44px; font-size: 14px; }
.login-card .foot { margin-top: 18px; font-size: 11.5px; color: var(--ink-dim); display: flex; align-items: center; gap: 6px; }
.err { color: var(--down); font-size: 12.5px; min-height: 18px; margin-bottom: 6px; }

/* ── 반응형: 태블릿 ────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 1023px) and (min-width: 761px) {
  .app { --sidebar-w: 72px; }
  .app .nav-item span.lbl, .app .brand-text, .app .nav-sec, .app .side-status .lbl, .app .nav-badge { display: none; }
  .app .nav-item { justify-content: center; padding: 10px; }
  .app .brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .set-tabs { grid-template-columns: repeat(2, 1fr); }
}

/* ── 반응형: 폰 (≤760px) ───────────────────────────────────────────────── */
@media (max-width: 760px) {
  body { font-size: 14.5px; background-attachment: scroll; }
  .app { display: block; }
  .sidebar { display: none; }
  .d-only { display: none !important; }
  .topbar { height: 56px; padding: 0 14px; }
  .page-title h1 { font-size: 17px; }
  .top-chips .badge { height: 26px; padding: 0 9px; font-size: 11.5px; }
  .top-chips .badge .lbl { display: none; }
  .content { padding: 14px 12px calc(84px + env(safe-area-inset-bottom)); }

  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
  }
  .bn {
    display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0 4px; border: 0;
    background: transparent; color: var(--ink-dim); font: inherit; font-size: 10.5px; font-weight: 600; cursor: pointer;
    border-radius: 10px; position: relative;
  }
  .bn .ico { width: 21px; height: 21px; }
  .bn.active { color: var(--accent); }
  .bn.active::after { content: ""; position: absolute; top: -7px; width: 22px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
  .bn .nb { position: absolute; top: 2px; right: calc(50% - 20px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--down); color: #fff; font-size: 10px; display: grid; place-items: center; }

  .card { border-radius: var(--r); margin-bottom: 14px; }
  .card > .card-head { padding: 12px 14px; }
  .card > .card-body { padding: 13px 14px; }
  table { white-space: nowrap; }
  th, td { padding: 10px 12px; }
  .grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .kpi { padding: 12px 13px; }
  .kpi-val { font-size: 19px; }
  .hero { padding: 18px 16px; }
  .hero h2 { font-size: 18px; }
  .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .hstat { padding: 10px 12px; }
  .hstat .v { font-size: 18px; }
  .accts { grid-template-columns: 1fr; }
  .sgrid { grid-template-columns: 1fr; gap: 11px; }
  .strat-bar .search { max-width: none; flex-basis: 100%; }
  .strat-bar .seg { overflow-x: auto; max-width: 100%; }
  .row > input:not([type=checkbox]):not([type=radio]), .row > select { flex: 1 1 100%; min-width: 0; }
  .btn { height: 40px; }
  .btn.sm { height: 34px; }
  input, select { height: 42px; font-size: 15px; }
  input[type="checkbox"] { width: 20px; height: 20px; }
  .set-tabs { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .set-tab { padding: 11px; gap: 10px; }
  .set-tab span.d { display: none; }
  .toasts { left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); }
  .toast { min-width: 0; max-width: none; }

  /* 대화상자 → 아래에서 올라오는 시트 */
  .modal-bg, .modal-bg.sheet { padding: 0; align-items: flex-end; justify-content: stretch; }
  .modal, .modal-bg.sheet > .modal {
    max-width: 100% !important; width: 100%; max-height: 92vh; height: auto; border-radius: 18px 18px 0 0;
    border-width: 1px 0 0; animation: slideU .28s var(--ease);
  }
  .modal.full { height: 100vh; max-height: 100vh; border-radius: 0; }
  .modal > .modal-head { padding: 14px 16px; }
  .modal > .modal-head h2 { font-size: 15px; overflow-wrap: anywhere; }
  .modal > .modal-body { padding: 14px 16px; overflow-x: hidden; }
  .modal > .modal-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .modal > .modal-foot .btn { flex: 1 1 auto; }
  .modal-head::before { content: ""; position: absolute; left: 50%; top: 6px; width: 36px; height: 4px; margin-left: -18px; border-radius: 4px; background: var(--border-lt); }
  .modal > .modal-head { position: relative; }
  .modal .toolbar { top: -14px; }

  /* 표 → 카드형 */
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: auto; }
  table.stack thead { display: none; }
  table.stack { white-space: normal; }
  table.stack tr { border: 1px solid var(--border); border-radius: var(--r); margin: 10px; padding: 3px 0; background: var(--surface-2); }
  table.stack td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); text-align: right; padding: 9px 13px; }
  table.stack td:last-child { border-bottom: none; }
  table.stack td::before { content: attr(data-label); color: var(--ink-dim); font-size: 12px; font-weight: 550; text-align: left; flex: none; }
  table.stack tr.venue-row { background: transparent; border: 0; margin: 12px 12px 0; padding: 0; }
  table.stack tr.venue-row > td { border: 0; padding: 0 !important; background: transparent; display: block; text-align: left; }
  table.stack tr.venue-row > td::before { display: none; }

  /* 파라미터: 라벨 위 · 입력 아래 */
  .pfield { grid-template-columns: 1fr; gap: 7px; padding: 11px 12px; }
  .pin > input, .pin > select { max-width: none; }
  .pmod { width: auto; flex: 1 1 0; min-width: 0; height: 42px; }
  .pmod input, .pmod select { height: 40px; font-size: 15px; }
  .pmod:has(.switch) { flex: 0 0 auto; }
  .revert { height: 32px; padding: 0 10px; }
  .modal .row { flex-wrap: wrap; gap: 8px; }
  .modal .row > select, .modal .row > input:not([type=checkbox]):not([type=radio]) { flex: 1 1 100%; min-width: 0; }

  /* 차트 — 폰: 오른쪽 패널은 위로 덮는 시트, 아래 패널은 짧게 */
  .content.wide { padding: 8px 8px 10px; }
  .tvc { height: calc(100vh - 56px - 96px); min-height: 400px; border-radius: var(--r); --bottom-h: 200px !important; }
  .tvc-top { gap: 2px; padding: 4px; }
  .tvc-top .tb-div, .tvc-top .spacer, .tv-btn .lbl, .tv-sym-sub, .tvc-top .pill.tv-auto { display: none; }
  .tb-tf { order: 5; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .tf-btn { flex: 1 0 auto; height: 32px; }
  .tv-sym { flex: 1 1 auto; }
  .tb-menu { position: static; }
  .tb-pop, .tb-pop.wide { left: 8px; right: 8px; min-width: 0; }
  .tvc-mid { grid-template-columns: minmax(0, 1fr) 0 !important; position: relative; }
  .tvc-right { position: absolute; inset: 0 0 0 auto; width: min(340px, 92%); z-index: 12; box-shadow: var(--shadow-lg); }
  .tv-legend { right: 60px; font-size: 11px; }
  .tv-legend .lg-row:nth-child(n+4) { display: none; }
  .lg-ohlc { margin-left: 0; font-size: 11px; }
  .tv-ranges > button:nth-child(n+5) { display: none; }
  .tv-status { display: none; }
  .tvb-cmp { grid-template-columns: 1fr; }
  .pe-tabs { flex: none; display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 6px; gap: 4px; }
  .pe-body { flex-direction: column; }
  .ptab { white-space: nowrap; width: auto; }
  .pe-cmp { width: 100%; }
  .modal-foot select.sm { flex: 0 0 auto !important; }

  /* 로그 */
  table:has(#logBody) thead { display: none; }
  #logBody, #logBody tr, #logBody td { display: block; width: auto; }
  #logBody tr.log-row { padding: 11px 13px; border-bottom: 1px solid var(--border); }
  #logBody td { border: none; padding: 0; white-space: normal; }
  #logBody td:nth-child(1), #logBody td:nth-child(2), #logBody td:nth-child(3) { display: inline-block; margin-right: 8px; font-size: 11.5px; }
  #logBody td.msg { margin-top: 5px; font-size: 13px; overflow-wrap: anywhere; white-space: normal; }

  .evt { font-size: 13px; }
  .evt-when { display: none; }
  .ph-lab { display: block; min-width: 0; }
  .prow { padding: 12px 14px; }
  .tlist .trow { padding: 10px 14px; }
}

@supports (height: 100dvh) {
  @media (max-width: 760px) {
    .tvc { height: calc(100dvh - 56px - 96px - env(safe-area-inset-bottom)); }
    .modal { max-height: 92dvh; }
    .modal.full { height: 100dvh; max-height: 100dvh; }
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
