/* 기본 레이아웃 */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1f2937 0, #020617 50%, #020617 100%);
  color: #0f172a;
}

.app {
  max-width: 960px;
  margin: 24px auto 40px;
  padding: 0 16px;
}

/* 헤더 */
.app-header {
  text-align: left;
  color: #e5e7eb;
  margin-bottom: 20px;
}

.app-header h1 {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 800;
}

.app-header p {
  margin: 0 0 12px;
  color: #9ca3af;
  font-size: 14px;
}

/* ✅ 환율 Pill */
.rate-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.22);
  color: #e5e7eb;
  font-size: 12px;
  margin-bottom: 10px;
}

/* ✅ 에러 텍스트 */
.error-text {
  margin: 6px 0 10px;
  font-size: 12px;
  color: #fca5a5;
}

/* 카드 공통 스타일 */
.card {
  background: #ffffff;
  border-radius: 18px;
  padding: 18px 20px 20px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.card h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: #111827;
}

.helper-text {
  margin: 0 0 12px;
  font-size: 13px;
  color: #6b7280;
}

.helper-text.small {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 8px;
}

/* 폼 요소 */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

label { font-size: 13px; color: #4b5563; }

input[type="number"] {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="number"]:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.25);
}

/* 버튼 */
button {
  cursor: pointer;
  border: none;
  font-size: 14px;
  border-radius: 999px;
  padding: 8px 16px;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease, color 0.1s ease;
}

button:disabled { opacity: 0.6; cursor: default; }

.primary-btn {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #f9fafb;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(79, 70, 229, 0.5);
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 36px rgba(79, 70, 229, 0.6);
}

.secondary-btn {
  background: #0f172a;
  color: #e5e7eb;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.4);
}

.secondary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.45);
}

.full-width { width: 100%; margin-bottom: 10px; }

/* 결과 영역 */
.result {
  margin-top: 6px;
  border-top: 1px dashed #e5e7eb;
  padding-top: 8px;
}

.result p {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 4px 0;
  font-size: 13px;
}

.warning {
  margin-top: 6px;
  font-size: 12px;
  color: #ef4444;
}

/* 푸터 */
.app-footer {
  margin-top: 18px;
  font-size: 12px;
  color: #6b7280;
  text-align: center;
}

/* ───────── 오더북 시각화 ───────── */
.orderbook-container { display: flex; gap: 16px; align-items: stretch; }
.orderbook-side { flex: 1; }

.side-title { font-size: 12px; color: #9ca3af; margin-bottom: 4px; }
.side-title.asks { color: #f97373; }
.side-title.bids { color: #4ade80; }

.levels { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }

.level-row {
  position: relative;
  padding: 2px 6px;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.level-row span { position: relative; z-index: 1; }
.level-row .price,
.level-row .amount { font-variant-numeric: tabular-nums; }

.level-row .amount { color: #6b7280; }

.level-row::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  opacity: 0.2;
}

.level-row.ask::before { right: 0; width: var(--width, 0%); background: #ef4444; }
.level-row.bid::before { left: 0; width: var(--width, 0%); background: #22c55e; }

/* ───────── 요약 카드 ───────── */
.card-summary { border-left: 4px solid #4f46e5; }

.summary-row {
  display: flex;
  gap: 24px;
  margin: 10px 0;
  flex-wrap: wrap;
}

.summary-row > div { min-width: 150px; }

.label { display: block; font-size: 12px; color: #6b7280; margin-bottom: 2px; }
.value { font-size: 16px; font-weight: 600; color: #111827; }
.value.highlight { color: #f97316; }

.updated-time { margin-top: 12px; font-size: 12px; color: #9ca3af; }

.summary-row-extra { flex-direction: column; gap: 4px; }
.summary-row-extra > div { min-width: 100%; }
.summary-row-extra .label { font-size: 11px; }
.summary-row-extra .value { font-size: 14px; }

/* ───────── 전체 오더북 (풀 오더북) ───────── */
.card-fullorder h2 { margin-bottom: 4px; }

.full-ob-container { display: flex; gap: 16px; margin-top: 12px; }
.full-ob-side { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.full-ob-table-wrapper {
  margin-top: 6px;
  max-height: 520px;
  overflow-y: auto;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.full-ob-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }

.full-ob-table th,
.full-ob-table td { padding: 4px 6px; white-space: nowrap; }

.full-ob-table th {
  position: sticky;
  top: 0;
  background: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;
  font-weight: 600;
  font-size: 0.75rem;
  text-align: right;
}

.full-ob-table th:first-child,
.full-ob-table td:first-child { text-align: left; }

.ob-row-ask td {
  color: #111827;
  font-weight: 600;
  background: rgba(248, 113, 113, 0.16);
}

.ob-row-bid td {
  color: #111827;
  font-weight: 600;
  background: rgba(52, 211, 153, 0.16);
}

.full-ob-table tr:nth-child(even) td { background: transparent; }

/* ✅ 섹션 간격 */
main > section.card { margin-bottom: 24px; }

/* ───────── 시뮬레이터 ───────── */
.card-sim .sim-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ghost-btn {
  background: rgba(15, 23, 42, 0.06);
  color: #0f172a;
  font-weight: 700;
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: none;
  padding: 8px 12px;
}

.ghost-btn:hover {
  transform: translateY(-1px);
  background: rgba(15, 23, 42, 0.09);
}

.sim-tabs {
  display: flex;
  gap: 10px;
  margin: 10px 0 12px;
}

.sim-tab-btn {
  flex: 1;
  background: #eef2ff;
  color: #111827;
  font-weight: 800;
  padding: 10px 12px;
}

.sim-tab-btn.active {
  background: #0f172a;
  color: #f9fafb;
}

.sim-panel { display: none; }
.sim-panel.active { display: block; }

.sim-h3 { margin: 10px 0 8px; font-size: 14px; color: #111827; font-weight: 800; }

.sim-input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.muted-inline { color: #9ca3af; font-size: 12px; margin-left: 6px; }

/* 매도 서브탭 */
.sell-subtabs {
  display: flex;
  gap: 10px;
  margin: 10px 0;
}

.sell-subtab-btn {
  flex: 1;
  background: #f3f4f6;
  color: #111827;
  font-weight: 800;
  padding: 10px 12px;
}

.sell-subtab-btn.active {
  background: #0f172a;
  color: #f9fafb;
}

.sell-panel { display: none; }
.sell-panel.active { display: block; }

/* 예시 박스 */
.example-box {
  margin-top: 10px;
  border: 1px dashed #e5e7eb;
  border-radius: 12px;
  padding: 10px 12px;
  background: #fafafa;
}

.example-title {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 6px;
  font-weight: 800;
}

.example-text {
  font-size: 12px;
  color: #111827;
  line-height: 1.45;
}

/* 반응형 */
@media (max-width: 768px) {
  .full-ob-container { flex-direction: column; }
  .orderbook-container { flex-direction: column; }
  .sim-input-grid { grid-template-columns: 1fr; }
}
/* ✅ 가격 구간 집계 탭 버튼 active 표시 강화 */
.range-tab-btn {
  cursor: pointer;
  user-select: none;
  border: 1px solid rgba(0,0,0,0.08);
  background: #f3f4f6;
  transition: transform 0.05s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.range-tab-btn:active {
  transform: translateY(1px);
}

.range-tab-btn.active {
  background: #0f172a;
  color: #fff;
  border-color: rgba(15,23,42,0.7);
  box-shadow: 0 6px 18px rgba(15,23,42,0.18);
}
