/* ════════════════════════════════════════════════════════════
   NPS Tracker — "기금 전광판" 디자인
   먹남색 레이어 + 한국 증시 관례(상승 빨강 / 하락 파랑) + 금 악센트
   ════════════════════════════════════════════════════════════ */
@font-face {
  font-family: "GmarketSans";
  src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2001@1.1/GmarketSansBold.woff") format("woff");
  font-weight: 700; font-display: swap;
}

:root {
  /* 팔레트 */
  --ink-0: #0B1220;      /* 최심층 배경 */
  --ink-1: #101a2c;      /* 패널 */
  --ink-2: #16233b;      /* 패널 상승층 */
  --line:  #24334e;      /* 경계선 */
  --text:  #E9EEF7;
  --mute:  #8b96ab;
  --gold:  #E8B44C;      /* 연금의 金 */
  --gold-soft: #e8b44c22;
  --up:    #ff5d6e;      /* 상승·매수 (KR 관례: 빨강) */
  --up-soft: #ff5d6e1c;
  --down:  #5b95ff;      /* 하락·매도 (KR 관례: 파랑) */
  --down-soft: #5b95ff1c;
  --radius: 14px;
  --font-body: "Pretendard Variable", Pretendard, -apple-system, sans-serif;
  --font-disp: "GmarketSans", "Pretendard Variable", sans-serif;
  --font-num: "SF Mono", "Roboto Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 500px at 80% -10%, #1a2c4d55, transparent 60%),
    radial-gradient(900px 400px at -10% 110%, #3a2c0e33, transparent 55%),
    var(--ink-0);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
[hidden] { display: none !important; }

/* ── 공용 버튼/폼 ─────────────────────────── */
.btn {
  border: 0; border-radius: 10px; padding: 13px 18px;
  font-size: 15px; font-weight: 700; letter-spacing: -0.01em;
  transition: transform .12s ease, filter .15s ease, box-shadow .15s;
}
.btn:active { transform: translateY(1px) scale(.995); }
.btn-block { width: 100%; display: block; text-align: center; }
.btn-primary {
  color: #141004;
  background: linear-gradient(135deg, #f2c96b, var(--gold) 55%, #c9922e);
  box-shadow: 0 6px 18px -6px #e8b44c66;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-gold {
  color: var(--gold); background: var(--gold-soft);
  border: 1px solid #e8b44c55; text-decoration: none;
  margin-top: 14px; padding: 13px;
}
.btn-gold:hover { background: #e8b44c33; }
.btn-ghost {
  background: none; border: 0; color: var(--mute);
  font-size: 13px; text-decoration: underline; text-underline-offset: 3px;
}
.btn-ghost:hover { color: var(--text); }
.btn-social {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; background: #fff; color: #1a1a1a; border: 1px solid #d8dce4;
}
.btn-kakao { background: #FEE500; border-color: #FEE500; }

.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 12.5px; color: var(--mute); margin-bottom: 6px; }
.field input, .coupon-input {
  width: 100%; padding: 13px 14px; font-size: 15px;
  background: var(--ink-0); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .coupon-input:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.form-error { color: var(--up); font-size: 13.5px; margin: 10px 0; }
.form-error.ok { color: #6fd98f; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ════════ 인증 화면 ════════ */
.screen-auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-stage {
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 56px;
  max-width: 980px; width: 100%; align-items: center;
}
.brand-mark {
  width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center;
  font-family: var(--font-disp); font-size: 30px; color: #141004;
  background: linear-gradient(135deg, #f2c96b, var(--gold), #c9922e);
  box-shadow: 0 10px 30px -8px #e8b44c66;
  animation: coin-in .7s cubic-bezier(.2,.9,.3,1.2) both;
}
@keyframes coin-in { from { transform: rotateY(90deg) scale(.6); opacity: 0; } }
.brand-title {
  font-family: var(--font-disp); font-size: clamp(38px, 5vw, 54px);
  margin: 22px 0 12px; letter-spacing: -0.02em;
}
.brand-title em { font-style: normal; color: var(--gold); }
.brand-sub { color: var(--mute); font-size: 17px; line-height: 1.65; }
.brand-points { list-style: none; margin-top: 26px; display: grid; gap: 12px; }
.brand-points li { display: flex; align-items: center; gap: 10px; font-size: 15px; color: #c3ccdd; }
.pt-dot { width: 9px; height: 9px; border-radius: 50%; }
.pt-dot.up { background: var(--up); box-shadow: 0 0 10px var(--up); }
.pt-dot.down { background: var(--down); box-shadow: 0 0 10px var(--down); }
.pt-dot.gold { background: var(--gold); box-shadow: 0 0 10px var(--gold); }

.auth-card {
  background: linear-gradient(180deg, var(--ink-2), var(--ink-1));
  border: 1px solid var(--line); border-radius: 20px; padding: 28px;
  box-shadow: 0 30px 80px -30px #00000090;
  animation: card-up .5s ease both .15s;
}
@keyframes card-up { from { transform: translateY(16px); opacity: 0; } }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--ink-0); border-radius: 11px; padding: 5px; margin-bottom: 22px; }
.auth-tab { border: 0; background: none; color: var(--mute); padding: 10px; border-radius: 8px; font-weight: 700; font-size: 14.5px; }
.auth-tab.is-active { background: var(--ink-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--mute); font-size: 12px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.social-row { display: grid; gap: 10px; }
.auth-fine { margin-top: 18px; font-size: 12px; color: var(--mute); text-align: center; }

/* ════════ 이용권 화면 ════════ */
.screen-license { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.license-card {
  width: 100%; max-width: 460px; text-align: center;
  background: linear-gradient(180deg, var(--ink-2), var(--ink-1));
  border: 1px solid var(--line); border-radius: 20px; padding: 36px 30px;
  animation: card-up .45s ease both;
}
.license-badge {
  display: inline-block; font-size: 12px; font-weight: 800; letter-spacing: .08em;
  color: var(--gold); background: var(--gold-soft); border: 1px solid #e8b44c44;
  padding: 6px 12px; border-radius: 99px; margin-bottom: 16px;
}
.license-title { font-family: var(--font-disp); font-size: 24px; margin-bottom: 10px; }
.license-desc { color: var(--mute); font-size: 14.5px; line-height: 1.6; margin-bottom: 22px; }
.coupon-form { display: flex; gap: 8px; }
.coupon-input { flex: 1; text-transform: uppercase; letter-spacing: .06em; font-family: var(--font-num); }
#btn-license-logout { margin-top: 18px; }

/* ════════ 앱 골격 ════════ */
.screen-app { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px clamp(14px, 3vw, 28px);
}
.brand-mini { font-size: 16px; letter-spacing: -0.01em; color: var(--mute); }
.brand-mini b { color: var(--gold); font-family: var(--font-disp); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.basis-chip {
  font-size: 12px; color: var(--mute); background: var(--ink-1);
  border: 1px solid var(--line); padding: 6px 11px; border-radius: 99px;
  font-family: var(--font-num);
}
.basis-chip.gold { color: var(--gold); border-color: #e8b44c44; }

/* ── 시그니처: 공시 전광판 ── */
.ticker {
  overflow: hidden; border-block: 1px solid var(--line);
  background: linear-gradient(90deg, var(--ink-0), var(--ink-1) 15%, var(--ink-1) 85%, var(--ink-0));
  mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}
.ticker-track {
  display: inline-flex; gap: 34px; padding: 11px 0; white-space: nowrap;
  animation: ticker 60s linear infinite; will-change: transform;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes ticker { to { transform: translateX(-50%); } }
.tk {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-family: var(--font-num);
}
.tk .tk-name { color: var(--text); font-family: var(--font-body); font-weight: 700; }
.tk .tk-date { color: var(--mute); font-size: 11.5px; }
.tk .tk-val.up { color: var(--up); } .tk .tk-val.down { color: var(--down); }
.tk .tk-new { color: var(--gold); font-size: 11px; border: 1px solid #e8b44c55; border-radius: 5px; padding: 1px 5px; }

/* ── 탭 ── */
.tabs {
  display: flex; gap: 4px; padding: 12px clamp(14px, 3vw, 28px) 0;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 1px solid transparent; background: none; color: var(--mute);
  font-size: 14px; font-weight: 700; padding: 9px 15px; border-radius: 10px 10px 0 0;
  white-space: nowrap; transition: color .15s, background .15s;
}
.tab:hover { color: var(--text); }
.tab.is-active {
  color: var(--gold); background: var(--ink-1);
  border-color: var(--line); border-bottom-color: var(--ink-1);
  position: relative;
}
.tab.is-active::after {
  content: ""; position: absolute; inset-inline: 14px; top: 0; height: 2px;
  background: var(--gold); border-radius: 2px;
}

.main {
  flex: 1; background: var(--ink-1);
  border-top: 1px solid var(--line);
  padding: clamp(16px, 3vw, 28px);
}
.panel { display: none; animation: panel-in .28s ease; }
.panel.is-active { display: block; }
@keyframes panel-in { from { opacity: 0; transform: translateY(8px); } }

/* ── 패널 공용 컴포넌트 ── */
.p-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 18px; }
.p-title { font-family: var(--font-disp); font-size: 21px; letter-spacing: -0.01em; }
.p-title small { display: block; font-family: var(--font-body); font-weight: 400; color: var(--mute); font-size: 13px; margin-top: 5px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; }
.seg { display: inline-flex; background: var(--ink-0); border: 1px solid var(--line); border-radius: 10px; padding: 4px; gap: 3px; }
.seg button {
  border: 0; background: none; color: var(--mute); font-size: 13px; font-weight: 700;
  padding: 7px 12px; border-radius: 7px;
}
.seg button.is-on { background: var(--ink-2); color: var(--gold); box-shadow: inset 0 0 0 1px var(--line); }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  background: linear-gradient(180deg, var(--ink-2), #131e33);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.kpi .kpi-label { font-size: 12.5px; color: var(--mute); margin-bottom: 8px; }
.kpi .kpi-value { font-family: var(--font-num); font-size: clamp(22px, 2.6vw, 30px); font-weight: 700; letter-spacing: -0.02em; }
.kpi .kpi-sub { font-size: 12px; color: var(--mute); margin-top: 6px; }
.kpi.hot { border-color: #e8b44c44; background: linear-gradient(180deg, #1d2438, #16203a), var(--ink-2); }

/* 표 */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
thead th {
  position: sticky; top: 0; text-align: right; font-weight: 600; font-size: 12px;
  color: var(--mute); background: var(--ink-2); padding: 11px 14px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
thead th:first-child, tbody td:first-child { text-align: left; }
thead th.l { text-align: left; }
tbody td { padding: 11px 14px; border-bottom: 1px solid #1c2942; text-align: right; font-family: var(--font-num); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #ffffff08; }
td.name { font-family: var(--font-body); font-weight: 700; text-align: left; }
td.name .mkt { font-size: 10.5px; color: var(--mute); font-weight: 400; margin-left: 6px; }
td.name a { color: inherit; text-decoration: none; }
td.name a:hover { color: var(--gold); }
.rank { color: var(--mute); font-size: 12px; width: 34px; }
.rank.top3 { color: var(--gold); font-weight: 800; }
.v-up { color: var(--up); } .v-down { color: var(--down); } .v-flat { color: var(--mute); }
.chip {
  display: inline-block; font-size: 11px; font-family: var(--font-body);
  border-radius: 6px; padding: 2px 7px; font-weight: 700;
}
.chip.new { color: var(--gold); background: var(--gold-soft); }
.chip.up { color: var(--up); background: var(--up-soft); }
.chip.down { color: var(--down); background: var(--down-soft); }
.chip.mut { color: var(--mute); background: #ffffff0c; }
.flag { font-size: 10.5px; color: var(--gold); cursor: help; }

/* 수급 게이지 바 (표 안 미니 바) */
.bar { position: relative; height: 5px; border-radius: 3px; background: #ffffff10; width: 92px; margin-left: auto; }
.bar i { position: absolute; inset-block: 0; border-radius: 3px; }
.bar.up i { background: linear-gradient(90deg, #ff5d6e66, var(--up)); }
.bar.down i { background: linear-gradient(90deg, #5b95ff66, var(--down)); }

/* 성과 매트릭스 */
.matrix { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.mx {
  border: 1px solid var(--line); border-radius: 12px; padding: 13px; text-align: center;
  background: var(--ink-0);
}
.mx .mx-w { font-size: 11.5px; color: var(--mute); }
.mx .mx-r { font-family: var(--font-num); font-size: 19px; font-weight: 700; margin: 6px 0 3px; }
.mx .mx-wr { font-size: 11.5px; color: var(--mute); font-family: var(--font-num); }

/* 타임라인 SVG */
.tl-chart { width: 100%; height: 240px; }
.tl-chart .axis { stroke: var(--line); stroke-width: 1; }
.tl-chart .lbl { fill: var(--mute); font-size: 10px; font-family: var(--font-num); }
.tl-chart .step { fill: none; stroke: var(--gold); stroke-width: 2; }
.tl-chart .dot-up { fill: var(--up); } .tl-chart .dot-down { fill: var(--down); }
.tl-chart .area { fill: url(#tl-grad); opacity: .5; }

/* 검색 */
.search-row { display: flex; gap: 8px; margin-bottom: 16px; }
.search-row input { flex: 1; }
.stock-hits { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.stock-hit {
  border: 1px solid var(--line); background: var(--ink-0); color: var(--text);
  border-radius: 99px; padding: 8px 14px; font-size: 13px; font-weight: 700;
}
.stock-hit:hover, .stock-hit.is-on { border-color: var(--gold); color: var(--gold); }

/* 스켈레톤 */
.skel { border-radius: 8px; background: linear-gradient(90deg, #ffffff08 25%, #ffffff14 40%, #ffffff08 55%); background-size: 300% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -300% 0; } }

.empty { text-align: center; color: var(--mute); padding: 44px 0; font-size: 14px; }
.note { font-size: 12px; color: var(--mute); margin-top: 10px; line-height: 1.6; }

/* 푸터(출처·면책 — 필수 표기) */
.foot {
  background: var(--ink-0); border-top: 1px solid var(--line);
  padding: 22px clamp(14px, 3vw, 28px); color: var(--mute); font-size: 12px; line-height: 1.7;
}
.foot ul { margin-top: 8px; padding-left: 16px; }

/* 로더 */
.loader {
  position: fixed; inset: 0; display: grid; place-items: center; align-content: center; gap: 14px;
  background: #0b1220e6; backdrop-filter: blur(4px); z-index: 50;
}
.loader-coin {
  width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center;
  font-family: var(--font-disp); font-size: 26px; color: #141004;
  background: linear-gradient(135deg, #f2c96b, var(--gold), #c9922e);
  animation: flip 1.1s ease-in-out infinite;
}
@keyframes flip { 50% { transform: rotateY(180deg); } }
.loader p { color: var(--mute); font-size: 13.5px; }

/* ── 반응형 ── */
@media (max-width: 860px) {
  .auth-stage { grid-template-columns: 1fr; gap: 34px; max-width: 460px; }
  .auth-brand { text-align: center; }
  .brand-mark { margin-inline: auto; }
  .brand-points { justify-items: center; }
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 8px; }
}
@media (max-width: 520px) {
  .grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .coupon-form { flex-direction: column; }
  .p-head { flex-direction: column; align-items: stretch; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .ticker-track { animation: none; }
}
