/* 색상은 dataviz 검증 통과한 팔레트 (light/dark 양쪽 PASS).
   series-1 blue = spot, series-2 orange = usdm */
:root {
  color-scheme: light;
  --surface-0: #f4f4f2;
  --surface-1: #fcfcfb;
  --border: #e0e0dc;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #85847e;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --good: #008300;
  --critical: #e34948;
  --warning: #eda100;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #111110;
    --surface-1: #1a1a19;
    --border: #33322f;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e85;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --good: #4caf50;
    --critical: #e66767;
    --warning: #c98500;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #111110;
  --surface-1: #1a1a19;
  --border: #33322f;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #8f8e85;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --good: #4caf50;
  --critical: #e66767;
  --warning: #c98500;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}



.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 22px;
}

.card h2 {
  margin: 0 0 20px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
}

.card h2 .sub { color: var(--text-muted); font-weight: 400; margin-left: 6px; }

.hero { font-size: 52px; font-weight: 650; letter-spacing: -0.02em; margin: 0; }

.as-of { color: var(--text-muted); font-size: 15px; margin-top: 10px; }

.deltas { display: flex; gap: 42px; flex-wrap: wrap; margin-top: 28px; }
.delta-label { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.delta-value { font-size: 22px; font-weight: 600; }
.delta-pct { font-size: 15px; font-weight: 500; }

.up { color: var(--good); }
.down { color: var(--critical); }
.muted { color: var(--text-muted); }
.ok { color: var(--good); font-weight: 600; }
.warn { color: var(--warning); font-weight: 600; }

.chart-box { height: 340px; position: relative; }

.range-row { display: flex; gap: 8px; margin-bottom: 22px; }
.range-row a {
  padding: 8px 18px;
  border-radius: 7px;
  border: 1px solid var(--border);
  font-size: 15px;
  text-decoration: none;
  color: var(--text-secondary);
}
.range-row a.active {
  background: var(--series-1);
  border-color: var(--series-1);
  color: #fff;
}

.legend { display: flex; gap: 24px; flex-wrap: wrap; font-size: 14px;
  color: var(--text-secondary); margin-bottom: 16px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sw-spot { background: var(--series-1); }
.sw-usdm { background: var(--series-2); }

/* 인접 세그먼트 사이 2px 서피스 갭 (dataviz mark spec) */
.bar { display: flex; height: 36px; border-radius: 8px; overflow: hidden; gap: 2px; }
.seg { height: 100%; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.5; }
th {
  text-align: right; font-weight: 500; color: var(--text-muted);
  padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px;
  white-space: nowrap;
}
th:nth-child(1), th:nth-child(2),
td:nth-child(1), td:nth-child(2) { text-align: left; }
td {
  padding: 14px 14px; border-bottom: 1px solid var(--border);
  color: var(--text-secondary); text-align: right; white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
td.asset { color: var(--text-primary); font-weight: 500; }
td.value { color: var(--text-primary); }

.chip { display: inline-block; padding: 4px 10px; border-radius: 5px;
  font-size: 12px; font-weight: 500; }
.chip-spot { background: color-mix(in srgb, var(--series-1) 16%, transparent);
  color: var(--series-1); }
.chip-usdm { background: color-mix(in srgb, var(--series-2) 16%, transparent);
  color: var(--series-2); }

.banner {
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent);
  border-radius: 10px; padding: 16px 20px; font-size: 15px;
  margin-bottom: 22px; line-height: 1.6;
}

.status-line { font-size: 15px; color: var(--text-secondary); }
.fail-head { color: var(--text-muted); font-size: 15px; margin: 12px 0 6px; }
.fail-list { margin: 0; padding-left: 20px; line-height: 2;
  font-size: 15px; color: var(--text-secondary); }

.empty { color: var(--text-muted); font-size: 15px; padding: 44px 0; text-align: center; }

@media (max-width: 640px) {
  .hero { font-size: 38px; }
  .deltas { gap: 18px; }
  .wrap { padding: 20px 16px 48px; }
}

/* ── CMS 셸: 고정 사이드바 + 콘텐츠 ─────────────────────────────────────── */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 408px;
  flex: 0 0 408px;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: block;
  padding: 26px 22px 20px;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  text-decoration: none;
}

.side-nav { flex: 1; overflow-y: auto; padding: 0 14px 14px; }

.side-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 20px 16px 10px;
}

.side-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 13px 16px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.35;
}
.side-item:hover { background: var(--surface-0); }
.side-item.active {
  background: color-mix(in srgb, var(--series-1) 14%, transparent);
  color: var(--text-primary);
  font-weight: 500;
}
.side-item.off { opacity: 0.45; }
.side-all { margin-bottom: 2px; }

.side-name {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-sub {
  font-size: 14px;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }
.dot-ok   { background: var(--good); }
.dot-warn { background: var(--warning); }
.dot-off  { background: var(--text-muted); opacity: 0.5; }

.side-add {
  display: block;
  margin: 0 18px 22px;
  padding: 13px 16px;
  font-size: 15px;
  text-align: center;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-0);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 15px;
}
.side-add:hover { color: var(--text-primary); }

/* 콘텐츠 */
.content { flex: 1; min-width: 0; }

.content-head {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  padding: 26px 40px 0;
  position: sticky;
  top: 0;
  z-index: 5;
}
.content-head h1 {
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin: 0;
}

.head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 20px;
}
.head-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.head-note { font-style: italic; }
.head-actions { display: flex; align-items: center; gap: 8px; }

.tabs { display: flex; gap: 2px; }
.tabs a {
  padding: 13px 20px;
  font-size: 15px;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--text-primary); }
.tabs a.active {
  color: var(--text-primary);
  font-weight: 500;
  border-bottom-color: var(--series-1);
}

.content-body { padding: 32px 40px 80px; max-width: 1120px; }

/* 공통 컨트롤 */
.btn, .btn-sm, .btn-xs, .btn-ghost {
  display: inline-block;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-0);
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}
.btn { padding: 11px 24px; font-size: 16px; font-weight: 500;
       background: var(--series-1); border-color: var(--series-1); color: #fff; }
.btn-sm { padding: 8px 16px; font-size: 14px; }
.btn-xs { padding: 6px 13px; font-size: 13px; }
.btn-ghost { padding: 8px 16px; font-size: 16px; }
.btn:hover, .btn-sm:hover, .btn-xs:hover { filter: brightness(1.1); }
form.inline { display: inline; }

.acct-id {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
}

.flash {
  background: color-mix(in srgb, var(--good) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--good) 40%, transparent);
  color: var(--text-primary);
  border-radius: 10px;
  padding: 15px 20px;
  font-size: 15px;
  margin-bottom: 22px;
}

.warn-banner {
  background: color-mix(in srgb, var(--critical) 12%, transparent);
  border-color: color-mix(in srgb, var(--critical) 40%, transparent);
}
.warn-banner a { color: var(--text-primary); }

.hint { font-size: 13px; color: var(--text-muted); margin: 10px 0 0; line-height: 1.6; }

table.accounts td { vertical-align: middle; }
.acct-link { color: var(--text-primary); font-weight: 500;
             text-decoration: none; margin-right: 8px; }
.acct-link:hover { text-decoration: underline; }
.row-off { opacity: 0.5; }
.dim { color: var(--text-muted); }
.actions { white-space: nowrap; }

.chip-ok   { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.chip-warn { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }
.chip-off  { background: var(--surface-0); color: var(--text-muted);
             border: 1px solid var(--border); }

/* 폼 */
.form label { display: block; margin-bottom: 22px; }
.form label > span { display: block; font-size: 15px;
                     color: var(--text-secondary); margin-bottom: 6px; }
.form input[type="text"], .form input[type="password"] {
  width: 100%; padding: 12px 14px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface-0);
  color: var(--text-primary); font-family: inherit; font-size: 16px;
}
.form input:focus {
  outline: 2px solid color-mix(in srgb, var(--series-1) 45%, transparent);
  outline-offset: -1px;
}
.form input:disabled { color: var(--text-muted); }
.form small { display: block; font-size: 13px; color: var(--text-muted); margin-top: 5px; }
.form fieldset { border: 1px solid var(--border); border-radius: 10px;
                 padding: 24px; margin: 0 0 22px; }
.form legend { font-size: 14px; color: var(--text-secondary); padding: 0 10px;
               display: flex; align-items: center; gap: 10px; font-weight: 500; }
.form fieldset .hint { margin: 0 0 20px; max-width: 62ch; }
.form fieldset label:last-of-type { margin-bottom: 0; }
.form-actions { display: flex; align-items: center; gap: 10px; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; flex: none; height: auto; position: static;
             border-right: none; border-bottom: 1px solid var(--border); }
  .side-nav { max-height: 210px; }
  .content-head { padding: 16px 16px 0; position: static; }
  .content-body { padding: 18px 16px 48px; }
}

/* Portfolio Margin 지갑 */
.sw-pm { background: var(--series-3, #1baf7a); }
.chip-pm { background: color-mix(in srgb, var(--series-3, #1baf7a) 16%, transparent);
           color: var(--series-3, #1baf7a); }


/* ═══ 개요: 3단 위계 ═══════════════════════════════════════════════════════
   1단 메인 — 테두리 없음, 배경만. 큰 숫자가 주인공
   2단 보조 — 구분선만
   3단 목록 — 카드 (테두리 있음)
   ────────────────────────────────────────────────────────────────────── */

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tag {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 5px;
  white-space: nowrap;
}

.dim { color: var(--text-muted); }

/* ── 1단 ── */
.primary {
  background: var(--surface-1);
  border-radius: 14px;
  padding: 30px 32px 26px;
  margin-bottom: 20px;
}
.primary-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
}
.primary-value {
  font-size: 54px;
  font-weight: 640;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-top: 10px;
  color: var(--text-primary);
}
.primary-meta { font-size: 13px; color: var(--text-muted); margin-top: 8px; }

.primary-deltas { display: flex; gap: 36px; margin-top: 20px; flex-wrap: wrap; }
.pd { display: flex; flex-direction: column; gap: 6px; }
.pd-label { font-size: 12px; color: var(--text-muted); }
.pd-value { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.pd-pct {
  font-size: 12px;
  font-weight: 500;
  opacity: 0.75;
  margin-left: 3px;
}

.primary-chartrow {
  display: flex;
  justify-content: flex-end;
  margin-top: 22px;
}
.ranges { display: flex; gap: 2px; background: var(--surface-0);
          border-radius: 8px; padding: 3px; }
.ranges a {
  padding: 6px 15px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-muted);
}
.ranges a.on { background: var(--surface-1); color: var(--text-primary); }
.ranges a:hover:not(.on) { color: var(--text-secondary); }

.primary-chart { height: 240px; margin-top: 24px; }

/* 총자산 — 맨 위 한 줄. 가로로 눕혀서 높이를 덜 쓴다 */
.totalbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 0 4px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.tb-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  display: block;
}
.tb-value {
  font-size: 34px;
  font-weight: 640;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  line-height: 1.1;
  margin-top: 8px;
}
.tb-deltas { display: flex; gap: 20px; flex-wrap: wrap; font-size: 13px;
             padding-bottom: 4px; }
.tb-d { display: inline-flex; gap: 6px; font-weight: 500; }

/* 담보 자산 — USDT 아래 나란히 */
.collateral {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.col-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px 16px;
}
.col-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.col-asset {
  font-size: 15px;
  font-weight: 650;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}
.col-usd { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.col-qty {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 28px;
  font-weight: 640;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-top: 12px;
  line-height: 1.1;
}
.col-chg { font-size: 14px; font-weight: 600; }
.col-chart { height: 96px; margin-top: 14px; }

/* ── 3단 ── */
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-head h2 { margin: 0 !important; }
.count { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

table.lean th {
  font-size: 12px;
  padding: 0 14px 12px;
  border-bottom: 1px solid var(--border);
}
table.lean td { padding: 15px 14px; }
table.lean tbody tr:hover { background: var(--surface-0); }
td.sym { color: var(--text-primary); font-weight: 600; letter-spacing: -0.01em; }

.side {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 5px;
}
.side.long  { background: color-mix(in srgb, var(--good) 16%, transparent);
              color: var(--good); }
.side.short { background: color-mix(in srgb, var(--critical) 16%, transparent);
              color: var(--critical); }
.lev { font-size: 11px; color: var(--text-muted); margin-left: 6px; }

.fill {
  display: inline-block;
  width: 46px;
  height: 5px;
  border-radius: 3px;
  background: var(--surface-0);
  border: 1px solid var(--border);
  overflow: hidden;
  vertical-align: middle;
  margin-right: 7px;
}
.fill i { display: block; height: 100%; background: var(--series-1); }

.empty-line {
  font-size: 14px;
  color: var(--text-muted);
  padding: 14px 0 6px;
}

@media (max-width: 720px) {
  .primary { padding: 24px 20px 20px; }
  .primary-value { font-size: 40px; }
  .primary-deltas { gap: 22px; }
  .primary-chart { height: 210px; }
}

/* ── 로그인 ────────────────────────────────────────────────────────────── */
.login-body { background: var(--surface-0); }
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 32px 32px;
}
.login-brand {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.login-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin: 8px 0 26px;
  line-height: 1.6;
}
.login-field { display: block; margin-bottom: 20px; }
.login-field > span {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.login-field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
}
.login-field input:focus {
  outline: 2px solid color-mix(in srgb, var(--series-1) 45%, transparent);
  outline-offset: -1px;
}
.login-btn { width: 100%; padding: 12px; font-size: 15px; }
.login-error {
  background: color-mix(in srgb, var(--critical) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--critical) 40%, transparent);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 13px;
  margin-bottom: 18px;
}
.side-logout { margin: 0 18px 20px; }
.side-logout button { width: 100%; cursor: pointer; font-family: inherit;
                      background: transparent; }
.logout {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 7px;
  border: 1px solid var(--border);
}
.logout:hover { color: var(--text-primary); }
