/* swing-trading dashboard — modern dark theme
   ---------------------------------------------
   영감: Linear · Vercel · GitHub Dark
   - Inter (UI) / JetBrains Mono (code)
   - tabular-nums on numbers
   - 4/8/12/16/20/24/32/48 spacing scale
*/

:root {
  /* base surfaces */
  --bg-base:       #0a0b0f;
  --bg-elev-1:     #11131a;
  --bg-elev-2:     #181b24;
  --bg-card:       #161924;
  --bg-card-hover: #1c2030;
  --bg-inline:     #1e2230;

  /* borders */
  --border-1: rgba(255, 255, 255, 0.06);
  --border-2: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.14);

  /* text */
  --text:       #e8ebf0;
  --text-muted: #8b91a3;
  --text-dim:   #5a6072;

  /* brand accent — periwinkle */
  --accent:        #7c87ff;
  --accent-hover:  #939dff;
  --accent-soft:   rgba(124, 135, 255, 0.12);
  --accent-ring:   rgba(124, 135, 255, 0.35);

  /* grade palette — emerald / sky / amber */
  --grade-a:       #34d399;
  --grade-a-soft:  rgba(52, 211, 153, 0.12);
  --grade-a-ring:  rgba(52, 211, 153, 0.30);
  --grade-b:       #60a5fa;
  --grade-b-soft:  rgba(96, 165, 250, 0.12);
  --grade-b-ring:  rgba(96, 165, 250, 0.30);
  --grade-c:       #fbbf24;
  --grade-c-soft:  rgba(251, 191, 36, 0.12);
  --grade-c-ring:  rgba(251, 191, 36, 0.30);
  --grade-off:     #6b7280;
  --grade-off-soft: rgba(107, 114, 128, 0.16);

  /* shadows — very subtle */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.35);

  /* radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  /* motion */
  --t-fast: 120ms ease;
  --t-base: 180ms cubic-bezier(.2, .6, .2, 1);
}

* { box-sizing: border-box; }

html { background: var(--bg-base); }

body {
  margin: 0;
  background:
    radial-gradient(1100px 600px at 18% -10%, rgba(124, 135, 255, 0.08), transparent 60%),
    radial-gradient(900px 500px at 92% 0%, rgba(52, 211, 153, 0.05), transparent 60%),
    var(--bg-base);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
               'Pretendard', 'Noto Sans KR', Roboto, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  font-feature-settings: 'ss01', 'cv11';
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--accent-hover); }

code, .mono {
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 0.88em;
  background: var(--bg-inline);
  padding: 2px 7px;
  border-radius: var(--r-sm);
  color: #c9ced9;
  border: 1px solid var(--border-1);
}

h1, h2, h3, h4 { letter-spacing: -0.015em; font-weight: 600; }
h2 { font-size: 1.5em; }
h3 { font-size: 1.05em; font-weight: 600; }

.muted { color: var(--text-muted); }
.dim   { color: var(--text-dim); }
.small { font-size: 0.86em; }
.num   { text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.comment { max-width: 36ch; }

/* ----------- topnav ----------- */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: rgba(17, 19, 26, 0.7);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border-1);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
  font-size: 1.02em;
  letter-spacing: -0.01em;
}
.brand-link:hover { color: var(--text); }
.brand-mark {
  display: inline-block;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  object-fit: contain;
  background: #fff;  /* 로고 외곽 여백 — 다크 테마에서도 자체 색감 그대로 보이도록 */
  padding: 1px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08) inset,
    0 4px 12px rgba(124, 135, 255, 0.25);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.brand-link:hover .brand-mark {
  transform: scale(1.04);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12) inset,
    0 6px 18px rgba(124, 135, 255, 0.35);
}

.topnav nav { display: flex; gap: 4px; }
.nav-link {
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--r-sm);
  font-weight: 500;
  font-size: 0.93em;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-link:hover {
  color: var(--text);
  background: var(--bg-elev-2);
  text-decoration: none;
}

main {
  max-width: 1280px;
  margin: 32px auto;
  padding: 0 32px;
}

footer {
  max-width: 1280px;
  margin: 56px auto 32px;
  padding: 20px 32px 0;
  border-top: 1px solid var(--border-1);
  font-size: 0.84em;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--text-muted);
}
footer code { font-size: 0.94em; }
.dot {
  display: inline-block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-dim);
}

/* ----------- hero ----------- */
.hero {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, transparent 100%),
    var(--bg-card);
  border: 1px solid var(--border-1);
  border-radius: var(--r-xl);
  padding: 24px 28px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -10%;
  width: 420px;
  height: 420px;
  background: radial-gradient(closest-side, var(--accent-soft), transparent 70%);
  pointer-events: none;
}
.hero-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
  position: relative;
}
.hero-head h2 {
  margin: 0;
  font-size: 1.45em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ----------- metrics grid ----------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  position: relative;
}
.metric {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform var(--t-base), border-color var(--t-base);
}
.metric:hover {
  transform: translateY(-1px);
  border-color: var(--border-2);
}
.m-label {
  color: var(--text-muted);
  font-size: 0.78em;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.m-value {
  font-size: 1.6em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.m-value.small { font-size: 1.05em; font-weight: 500; }

.metric.grade-a { border-color: var(--grade-a-ring); background: linear-gradient(180deg, var(--grade-a-soft), var(--bg-elev-2)); }
.metric.grade-a .m-value { color: var(--grade-a); }
.metric.grade-b { border-color: var(--grade-b-ring); background: linear-gradient(180deg, var(--grade-b-soft), var(--bg-elev-2)); }
.metric.grade-b .m-value { color: var(--grade-b); }
.metric.grade-c { border-color: var(--grade-c-ring); background: linear-gradient(180deg, var(--grade-c-soft), var(--bg-elev-2)); }
.metric.grade-c .m-value { color: var(--grade-c); }

.providers {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  position: relative;
}

.chip {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-1);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.82em;
  color: var(--text-muted);
  font-weight: 500;
}
.chip.solid {
  background: var(--accent-soft);
  border-color: var(--accent-ring);
  color: var(--accent);
}

/* ----------- section / table ----------- */
section { margin-bottom: 32px; }
section > h3 {
  margin: 0 0 14px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
section > h3::before {
  content: '';
  width: 3px;
  height: 14px;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0.7;
}

.two-col {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 28px;
}
.three-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
@media (max-width: 860px) {
  .two-col { grid-template-columns: 1fr; }
  main { padding: 0 20px; }
  .topnav { padding: 12px 20px; }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-1);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.card h3 { margin-top: 0; }

table.stocks, table.compact {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-1);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table.stocks th, table.compact th {
  text-align: left;
  font-weight: 500;
  font-size: 0.76em;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  background: var(--bg-elev-1);
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-1);
}
table.stocks td, table.compact td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-1);
  vertical-align: top;
  color: var(--text);
}
table.stocks tr:last-child td, table.compact tr:last-child td { border-bottom: 0; }
table.stocks tbody tr { transition: background var(--t-fast); }
table.stocks tbody tr:hover { background: rgba(255, 255, 255, 0.025); }

table.stocks a, table.compact a { color: var(--text); font-weight: 500; }
table.stocks a:hover, table.compact a:hover { color: var(--accent); text-decoration: none; }

/* ----------- badges ----------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 0.82em;
  background: var(--bg-elev-2);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
  line-height: 1.4;
}

.badge.grade-a { background: var(--grade-a-soft); color: var(--grade-a); border-color: var(--grade-a-ring); }
.badge.grade-b { background: var(--grade-b-soft); color: var(--grade-b); border-color: var(--grade-b-ring); }
.badge.grade-c { background: var(--grade-c-soft); color: var(--grade-c); border-color: var(--grade-c-ring); }
.badge.grade-off { background: var(--grade-off-soft); color: var(--grade-off); }

.num.grade-a { color: var(--grade-a); font-weight: 600; }
.num.grade-b { color: var(--grade-b); font-weight: 600; }
.num.grade-c { color: var(--grade-c); font-weight: 600; }

/* ----------- buttons / tabs ----------- */
.btn, .tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 0.9em;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.btn:hover, .tab:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  text-decoration: none;
  transform: translateY(-1px);
}
.btn:active, .tab:active { transform: translateY(0); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg-elev-2); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0b0f;
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #0a0b0f; }
.btn.small, .tab.small { padding: 5px 11px; font-size: 0.85em; }

.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  padding: 4px 0;
}
.filter-bar > .muted { font-size: 0.86em; margin-right: 4px; }

.tab.active {
  background: var(--accent);
  color: #0a0b0f;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.tab.grade-a.active { background: var(--grade-a); color: #0a0b0f; border-color: var(--grade-a); box-shadow: 0 0 0 3px var(--grade-a-ring); }
.tab.grade-b.active { background: var(--grade-b); color: #0a0b0f; border-color: var(--grade-b); box-shadow: 0 0 0 3px var(--grade-b-ring); }
.tab.grade-c.active { background: var(--grade-c); color: #0a0b0f; border-color: var(--grade-c); box-shadow: 0 0 0 3px var(--grade-c-ring); }

.badge-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.badge-list li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

/* ----------- empty state ----------- */
.empty {
  background: var(--bg-card);
  border: 1px dashed var(--border-2);
  border-radius: var(--r-xl);
  padding: 56px 32px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.empty h2 { margin: 0 0 10px; }
.empty p { color: var(--text-muted); margin: 0; max-width: 50ch; margin-inline: auto; }

/* ----------- charts ----------- */
.chart-wrap {
  position: relative;
  height: 220px;
  width: 100%;
}
.chart-wrap.tall { height: 280px; }
.chart-wrap.short { height: 160px; }

.chart-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.chart-header .label {
  font-size: 0.82em;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

/* ----------- stock detail specifics ----------- */
.title-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.title-stack .sub {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85em;
  color: var(--text-muted);
}
.signals-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.signal-pill {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-1);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.76em;
  font-weight: 500;
}

/* ----------- 외부 링크 (네이버 증권 등) ----------- */
.name-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ext-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--bg-elev-1);
  border: 1px solid var(--border-1);
  border-radius: 50%;
  text-decoration: none;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast),
              border-color var(--t-fast);
  vertical-align: middle;
  flex-shrink: 0;
}
.ext-link:hover {
  color: var(--accent-hover);
  background: var(--accent-soft);
  border-color: var(--accent-ring);
}
.ext-link:active {
  transform: translateY(1px);
}
.ext-link-sm {
  width: 15px;
  height: 15px;
  font-size: 10px;
}
.ext-link-md {
  width: 20px;
  height: 20px;
  font-size: 13px;
  margin-left: 6px;
}

/* ----------- focus ring ----------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ----------- topnav: 사용자 칩 + 로그아웃 ----------- */
.nav-user {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-ring);
  color: var(--accent-hover);
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.logout-form {
  display: inline-flex;
  margin: 0;
}
.btn.small {
  padding: 5px 10px;
  font-size: 0.78em;
  border-radius: var(--r-sm);
}

/* ----------- 로그인 화면 ----------- */
.login-body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 600px at 20% 10%, rgba(124, 135, 255, 0.16), transparent 60%),
    radial-gradient(700px 500px at 85% 90%, rgba(52, 211, 153, 0.10), transparent 60%),
    var(--bg-base);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Pretendard',
               'Noto Sans KR', sans-serif;
  -webkit-font-smoothing: antialiased;
}
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg,
              rgba(22, 25, 36, 0.92) 0%,
              rgba(17, 19, 26, 0.92) 100%);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px 28px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.login-card h2 {
  margin: 18px 0 6px;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}
.login-card .muted {
  margin: 0 0 18px;
  font-size: 0.9em;
}
.brand-large {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.brand-large .brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  padding: 2px;
}
.brand-large .brand-name {
  font-size: 1.05em;
  font-weight: 700;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 6px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field > span {
  font-size: 0.8em;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.field input {
  background: var(--bg-elev-1);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 0.95em;
  color: var(--text);
  font-family: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast),
              background var(--t-fast);
}
.field input:focus {
  outline: none;
  border-color: var(--accent-ring);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--bg-elev-2);
}
.btn.block {
  display: inline-flex;
  justify-content: center;
  width: 100%;
  margin-top: 6px;
}
.login-error {
  background: rgba(248, 113, 113, 0.10);
  border: 1px solid rgba(248, 113, 113, 0.32);
  color: #fca5a5;
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: 0.88em;
  margin-bottom: 14px;
}
.login-footnote {
  margin: 18px 0 0;
  text-align: center;
}
