:root {
  --bg: #101828;
  --panel: #1e2939;
  --border: #364153;
  --text: #ffffff;
  --muted: #99a1af;
  --muted-2: #d1d5dc;
  --red: #ff6568;
  --red-bg: rgba(130, 24, 26, 0.5);
  --blue: #54a2ff;
  --blue-bg: rgba(28, 57, 142, 0.5);
  --yellow: #fac800;
  --yellow-soft: rgba(115, 62, 10, 0.4);
  --green: #7bf1a8;
  --green-soft: rgba(13, 84, 43, 0.4);
  --purple: #d9b3ff;
  --purple-soft: rgba(89, 22, 139, 0.4);
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
}

body {
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

.loading-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page {
  min-height: 100vh;
  padding: 16px;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
}

.header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.title {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  background: linear-gradient(to right, #fb2c36, #fe6e00);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(13, 84, 43, 0.4);
  border: 1px solid #016630;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.meta-text {
  color: var(--muted);
  font-size: 12px;
}

.meta-sep {
  color: #6a7282;
  font-size: 12px;
}

.subtle-meta {
  gap: 6px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 24px;
}

.filters .search-wrap {
  grid-column: span 2;
}

.control {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.15s ease;
}

.control:focus {
  border-color: #fb2c36;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 12px;
}

.empty p {
  margin: 0;
}

.empty p + p {
  margin-top: 8px;
  font-size: 14px;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.stock-card {
  display: block;
  height: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  transition: all 0.15s ease;
}

.stock-card:hover {
  border-color: #fb2c36;
  box-shadow: 0 10px 20px rgba(251, 44, 54, 0.15);
}

.stock-card:hover .stock-name {
  color: var(--red);
}

.stock-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.stock-top > div:first-child {
  flex: 1;
  min-width: 0;
}

.stock-name {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  transition: color 0.15s ease;
}

.ticker {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.change-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.change-up {
  color: var(--red);
  background: var(--red-bg);
}

.change-down {
  color: var(--blue);
  background: var(--blue-bg);
}

.metric-list {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.metric {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.metric-label {
  color: var(--muted);
}

.metric-value {
  color: var(--muted-2);
  text-align: right;
}

.metric-value.mono {
  font-variant-numeric: tabular-nums;
}

.metric-value.hot {
  color: var(--red);
  font-weight: 800;
}

.metric-value.highlight {
  color: var(--yellow);
}

.tag-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid transparent;
}

.tag-purple {
  color: var(--purple);
  background: var(--purple-soft);
  border-color: #6e11b0;
}

.tag-yellow {
  color: #ffe02a;
  background: var(--yellow-soft);
  border-color: #874b00;
}

.tag-green {
  color: var(--green);
  background: var(--green-soft);
  border-color: #016630;
}

.detail-shell {
  display: grid;
  gap: 20px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  margin-bottom: 8px;
}

.back-link:hover {
  color: var(--text);
  text-decoration: underline;
}

.detail-panel,
.summary-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.detail-title {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
}

.detail-code {
  margin-top: 8px;
  color: var(--muted);
}

.big-price {
  margin: 18px 0 0;
  font-size: 36px;
  font-weight: 800;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.detail-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 16px;
  padding: 16px;
}

.detail-item .metric-label {
  display: block;
  margin-bottom: 10px;
}

.detail-item .metric-value {
  font-size: 20px;
  font-weight: 700;
  text-align: left;
}

.summary-title {
  margin: 0 0 12px;
  font-size: 18px;
}

.summary-list {
  display: grid;
  gap: 10px;
  color: var(--muted-2);
  padding-left: 18px;
}

.summary-list li strong {
  color: var(--text);
}

.not-found {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.not-found-card {
  max-width: 520px;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
  text-align: center;
}

.not-found-card h1 {
  margin: 0 0 8px;
}

.not-found-card p {
  margin: 0 0 20px;
  color: var(--muted);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-radius: 12px;
  background: #fb2c36;
  color: white;
  font-weight: 700;
}

.detail-nav {
  margin-bottom: 16px;
}

.detail-back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: color 0.15s ease;
}

.detail-back-button:hover {
  color: var(--text);
}

.detail-loading-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  color: var(--muted);
}

.detail-source-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.detail-hero-card,
.detail-chart-card,
.detail-side-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.detail-hero-card {
  padding: 20px;
}

.detail-hero-inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-title-row,
.detail-price-row,
.detail-badge-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.gradient {
  background: linear-gradient(to right, #fb2c36, #fe6e00);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.detail-ticker {
  color: var(--muted);
  font-size: 20px;
}

.detail-change {
  font-size: 18px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.text-up {
  color: #fb2c36;
}

.text-down {
  color: #54a2ff;
}

.detail-fzone-tag {
  color: #90c5ff;
  background: rgba(28, 57, 142, 0.4);
  border-color: rgba(25, 60, 184, 1);
}

.large-tag {
  font-size: 14px;
  padding: 8px 12px;
}

.detail-chart-card {
  overflow: hidden;
}

.detail-card-header {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(54, 65, 83, 0.5);
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-wrap {
  padding: 8px;
  display: flex;
  flex-direction: column;
}

.detail-chart {
  width: 100%;
  height: 420px;
  display: block;
}

.chart-empty {
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  order: -1;
  padding: 4px 8px 10px;
  font-size: 12px;
  color: var(--muted);
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 6px;
}

.legend-red { background: #ef4444; }
.legend-blue { background: rgba(59, 130, 246, 0.6); }
.legend-yellow { background: #fbbf24; }
.legend-purple { background: #a855f7; }

.detail-side-stack {
  display: grid;
  gap: 16px;
}

.detail-side-card {
  padding: 20px;
}

.detail-badge-row {
  justify-content: flex-start;
}

.detail-side-card-blue {
  border-color: rgba(28, 57, 142, 0.5);
}

.detail-side-title {
  margin: 0 0 16px;
  font-size: 18px;
  color: #e5e7eb;
}

.detail-signal-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-stat-list,
.detail-mini-list {
  display: grid;
  gap: 14px;
}

.detail-stat-row,
.detail-mini-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.detail-stat-row .metric-value,
.detail-mini-row .metric-value,
.big-price {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.detail-stat-row {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.text-blue {
  color: #54a2ff;
}

.text-blue-soft {
  color: #90c5ff;
}

.text-green {
  color: #7bf1a8;
}

.detail-divider {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.detail-note {
  margin: 0;
  font-size: 12px;
  color: var(--gray-500, #6a7282);
}

.signal-list {
  list-style: none;
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.signal-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.signal-dot {
  display: block;
  width: 6px;
  height: 6px;
  min-width: 6px;
  border-radius: 999px;
  margin-top: 7px;
}

.signal-dot.purple { background: #ac4bff; }
.signal-dot.yellow { background: #edb200; }

.inline-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
}

@media (min-width: 768px) {
  .page {
    padding: 32px;
  }

  .header {
    margin-bottom: 32px;
  }

  .title {
    font-size: 30px;
  }

  .filters {
    grid-template-columns: minmax(0, 1fr) 220px 220px;
    gap: 16px;
    margin-bottom: 32px;
  }

  .filters .search-wrap {
    grid-column: span 1;
  }

  .control {
    padding: 12px 16px;
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
  }

  .change-badge {
    min-width: 100px;
    height: 36px;
    font-size: 14px;
  }

  .detail-hero-card,
  .detail-side-card {
    padding: 24px;
  }

  .detail-hero-inner {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .detail-shell {
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    align-items: start;
  }
}

@media (min-width: 1100px) {
  .card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .detail-source-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .detail-hero-card {
    grid-column: span 3;
  }

  .detail-chart-card {
    grid-column: span 2;
    min-height: 500px;
  }

  .detail-side-stack {
    grid-column: span 1;
    align-content: start;
  }
}

@media (max-width: 767px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-head {
    flex-direction: column;
  }

  .big-price {
    font-size: 32px;
  }

  .detail-title {
    font-size: 32px;
  }

  .detail-ticker {
    font-size: 18px;
  }

  .detail-card-header,
  .detail-side-title {
    font-size: 18px;
  }
}
