/* ============================================================
   stock.hahyo.kr — 분기 리밸런싱 계기판
   측정 도구의 문법을 씁니다. 차트가 아니라 계측 눈금.
   ============================================================ */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard-dynamic-subset.css');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  /* 계기판 표면 */
  --ink:      #10141c;
  --panel:    #171d28;
  --panel-2:  #1e2634;
  --inset:    #0b0e14;
  --edge:     #2a3444;
  --edge-hi:  #3a4658;

  /* 놋쇠 눈금 — 이 페이지의 주조색 */
  --brass:    #d4a24c;
  --brass-dk: #8a6a2f;
  --brass-gl: rgba(212, 162, 76, .14);

  /* 국내 시장 관례: 상승 빨강 / 하락 파랑 */
  --up:       #ef6259;
  --down:     #4b8fe8;
  --lock:     #9c8ed0;

  --text:     #e4e8f0;
  --text-2:   #b3bccb;
  --muted:    #8c96a7;

  --sans: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

  --r: 4px;
  --rail: 232px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* 숫자는 전부 등폭. 눈금이 흔들리면 계기판이 아닙니다. */
.num, td.num, .metric-value, .gauge-read {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

a { color: var(--brass); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ── 레이아웃 ─────────────────────────────────────────────── */

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

.rail {
  width: var(--rail);
  flex: 0 0 var(--rail);
  background: var(--panel);
  border-right: 1px solid var(--edge);
  padding: 22px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 0 22px 20px;
  border-bottom: 1px solid var(--edge);
  margin-bottom: 14px;
}
.brand-mark {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .18em;
  color: var(--brass);
  text-transform: uppercase;
  display: block;
}
.brand-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-top: 3px;
}
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

.nav { display: flex; flex-direction: column; gap: 1px; padding: 0 12px; }
.nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r);
  color: var(--text-2);
  font-size: 14px;
  text-decoration: none;
  border-left: 2px solid transparent;
}
.nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav a.on {
  background: var(--panel-2);
  color: var(--text);
  border-left-color: var(--brass);
}
.nav .badge {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--up);
  color: #fff;
  border-radius: 9px;
  padding: 1px 7px;
  font-weight: 700;
}

.rail-foot {
  margin-top: auto;
  padding: 16px 22px 0;
  border-top: 1px solid var(--edge);
  font-size: 12px;
  color: var(--muted);
}

.main { flex: 1; min-width: 0; padding: 30px 36px 72px; max-width: 1180px; }

/* ── 페이지 머리 ───────────────────────────────────────────── */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--edge);
  margin-bottom: 26px;
}
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .16em;
  color: var(--brass);
  text-transform: uppercase;
}
.page-title {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -.03em;
  margin: 5px 0 0;
}
.page-note { color: var(--muted); font-size: 13px; margin-top: 5px; }

/* ── 지표 스트립 ───────────────────────────────────────────── */

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 1px;
  background: var(--edge);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 30px;
}
.metric { background: var(--panel); padding: 15px 18px; }
.metric-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .08em;
  text-transform: uppercase;
  font-family: var(--mono);
}
.metric-value {
  font-size: 23px;
  font-weight: 500;
  letter-spacing: -.02em;
  margin-top: 5px;
  line-height: 1.15;
}
.metric-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

.up   { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }

/* ── 섹션 ──────────────────────────────────────────────────── */

.section { margin-bottom: 34px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 13px;
}
.section-title { font-size: 15px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.section-note { font-size: 12px; color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  overflow: hidden;
}

/* ============================================================
   시그니처 — 밴드 게이지
   목표 눈금(놋쇠 틱), 허용 밴드(밝은 구간), 현재 위치(마커).
   밴드를 벗어나면 마커가 발광하고 이탈 구간이 그어집니다.
   ============================================================ */

.gauge-list { display: flex; flex-direction: column; }

.gauge {
  display: grid;
  grid-template-columns: 152px 1fr 116px;
  align-items: center;
  gap: 18px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--edge);
}
.gauge:last-child { border-bottom: 0; }
.gauge.is-breached { background: linear-gradient(90deg, rgba(232,83,75,.06), transparent 42%); }
.gauge.is-locked   { background: linear-gradient(90deg, rgba(139,123,196,.06), transparent 42%); }

.gauge-name { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.gauge-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.lock-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .1em;
  color: var(--lock);
  border: 1px solid currentColor;
  border-radius: 2px;
  padding: 0 4px;
  margin-left: 5px;
  vertical-align: 1px;
}

/* 트랙: 눈금 새긴 오목한 홈 */
.track {
  position: relative;
  height: 34px;
  background: var(--inset);
  border: 1px solid var(--edge);
  border-radius: 2px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .55);
  overflow: hidden;
}

/* 배경 눈금자 — 10% 간격 */
.track::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to right,
    var(--edge) 0 1px,
    transparent 1px 10%
  );
  opacity: .5;
}

/* 허용 밴드 */
.band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--brass-gl);
  border-left: 1px solid rgba(212,162,76,.3);
  border-right: 1px solid rgba(212,162,76,.3);
}

/* 목표 눈금 */
.tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--brass);
  transform: translateX(-1px);
}
.tick::after {
  content: '';
  position: absolute;
  top: -1px; left: -2px;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-top: 4px solid var(--brass);
}

/* 현재 위치 마커 */
.marker {
  position: absolute;
  top: 50%;
  width: 13px;
  height: 13px;
  margin: -6.5px 0 0 -6.5px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--panel);
  box-shadow: 0 0 0 1px var(--edge-hi);
  transition: left .5s cubic-bezier(.22,.8,.3,1);
  z-index: 2;
}
.gauge.is-breached .marker {
  background: var(--up);
  box-shadow: 0 0 0 1px var(--up), 0 0 14px 2px rgba(239,98,89,.45);
}
.gauge.is-breached.dir-add .marker {
  background: var(--down);
  box-shadow: 0 0 0 1px var(--down), 0 0 14px 2px rgba(75,143,232,.45);
}
.gauge.is-locked .marker { background: var(--lock); box-shadow: 0 0 0 1px var(--lock); }

/* 이탈 구간 */
.overflow {
  position: absolute;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  background: repeating-linear-gradient(
    90deg, var(--up) 0 4px, transparent 4px 7px
  );
  z-index: 1;
}
.gauge.dir-add .overflow {
  background: repeating-linear-gradient(
    90deg, var(--down) 0 4px, transparent 4px 7px
  );
}

.gauge-read { text-align: right; }
.gauge-actual { font-size: 18px; font-weight: 500; letter-spacing: -.02em; }
.gauge-drift { font-size: 11px; margin-top: 1px; }

.gauge-verdict {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  padding: 1px 6px;
  border-radius: 2px;
  margin-top: 4px;
}
.v-hold { color: var(--muted); border: 1px solid var(--edge-hi); }
.v-trim { color: var(--up);   border: 1px solid currentColor; }
.v-add  { color: var(--down); border: 1px solid currentColor; }

/* ── 조정 순서 (단계 카드) ─────────────────────────────────── */

.steps { display: flex; flex-direction: column; gap: 12px; }

.step {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  overflow: hidden;
}
.step-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--edge);
}
.step-num {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--brass);
  color: var(--ink);
  flex: 0 0 24px;
}
.step-title { font-size: 14px; font-weight: 700; }
.step-tax {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .08em;
  padding: 2px 8px;
  border-radius: 2px;
}
.tax-free { color: #5cc4a8; border: 1px solid currentColor; }
.tax-hit  { color: var(--brass); border: 1px solid currentColor; }

.step-item {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  gap: 14px;
  align-items: baseline;
  padding: 12px 18px;
  border-bottom: 1px solid var(--edge);
}
.step-item:last-child { border-bottom: 0; }
.verb {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-align: center;
  padding: 3px 0;
  border-radius: 2px;
}
.verb-sell { background: rgba(239,98,89,.16); color: var(--up); }
.verb-buy  { background: rgba(75,143,232,.14); color: var(--down); }
.step-what { font-size: 14px; font-weight: 600; }
.step-why  { font-size: 12px; color: var(--muted); margin-top: 2px; }
.step-amt  { font-family: var(--mono); font-size: 15px; text-align: right; white-space: nowrap; }

.blocked { color: var(--brass); font-size: 12px; }

/* ── 계좌 카드 ─────────────────────────────────────────────── */

.accounts { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px,1fr)); gap: 12px; }
.acct {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  padding: 15px 17px;
  border-top: 2px solid var(--brass-dk);
}
.acct.taxable { border-top-color: var(--up); }
.acct-kind { font-size: 14px; font-weight: 700; }
.acct-flag { font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: .06em; }
.acct-value { font-family: var(--mono); font-size: 19px; margin-top: 9px; letter-spacing: -.02em; }
.acct-ret { font-family: var(--mono); font-size: 12px; margin-top: 1px; }

.capbar {
  margin-top: 11px;
  height: 4px;
  background: var(--inset);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.capbar i { display: block; height: 100%; background: var(--brass); }
.capbar.near i { background: var(--up); }
.cap-note { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 4px; }

/* ── 공제 게이지 ───────────────────────────────────────────── */

.deduction {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  padding: 17px 20px;
}
.ded-bar {
  height: 10px;
  background: var(--inset);
  border: 1px solid var(--edge);
  border-radius: 2px;
  overflow: hidden;
  margin: 11px 0 7px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.5);
}
.ded-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brass-dk), var(--brass));
}
.ded-bar.over i { background: linear-gradient(90deg, var(--brass), var(--up)); }

/* ── 표 ────────────────────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  padding: 10px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--edge);
  white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--edge); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--panel-2); }
td.num, th.num { text-align: right; }

/* ── 폼 ────────────────────────────────────────────────────── */

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px,1fr)); gap: 14px; padding: 18px; }
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.form-row .helptext { font-size: 11px; color: var(--muted); }

.field {
  background: var(--inset);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 10px;
  width: 100%;
}
.field:focus { border-color: var(--brass); outline: none; }
.field-select { font-family: var(--sans); }
.field-check { width: 16px; height: 16px; accent-color: var(--brass); }

.btn {
  display: inline-block;
  background: var(--brass);
  color: var(--ink);
  border: 0;
  border-radius: var(--r);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  padding: 9px 18px;
  cursor: pointer;
}
.btn:hover { background: #e0b25e; text-decoration: none; }
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--edge-hi);
}
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-danger { background: transparent; color: var(--up); border: 1px solid currentColor; }
.form-actions { padding: 0 18px 18px; display: flex; gap: 10px; }

/* ── 메시지 · 빈 상태 ──────────────────────────────────────── */

.msg {
  border-left: 2px solid var(--brass);
  background: var(--panel);
  padding: 11px 16px;
  border-radius: 0 var(--r) var(--r) 0;
  font-size: 13px;
  margin-bottom: 16px;
}
.empty { padding: 44px 20px; text-align: center; color: var(--muted); font-size: 13.5px; }
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 5px; }

.warn {
  border-left: 2px solid var(--up);
  background: rgba(232,83,75,.07);
  padding: 12px 16px;
  font-size: 13px;
  border-radius: 0 var(--r) var(--r) 0;
  margin-bottom: 16px;
}

/* ── 로그인 ────────────────────────────────────────────────── */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-top: 2px solid var(--brass);
  border-radius: var(--r);
  padding: 30px 26px;
}

/* ── 반응형 ────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .rail {
    width: 100%; flex: none; height: auto;
    position: static;
    padding: 15px 0 10px;
    border-right: 0;
    border-bottom: 1px solid var(--edge);
  }
  .brand { padding: 0 18px 13px; }
  .nav { flex-direction: row; overflow-x: auto; padding: 0 12px; gap: 5px; }
  .nav a { border-left: 0; border-bottom: 2px solid transparent; white-space: nowrap; }
  .nav a.on { border-left: 0; border-bottom-color: var(--brass); }
  .rail-foot { display: none; }
  .main { padding: 22px 16px 60px; }

  .gauge {
    grid-template-columns: 1fr auto;
    grid-template-areas: "name read" "track track";
    gap: 10px;
  }
  .gauge-name-cell { grid-area: name; }
  .track { grid-area: track; }
  .gauge-read { grid-area: read; }

  .step-item { grid-template-columns: 54px 1fr; }
  .step-amt { grid-column: 2; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
