:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #1b1f24;
  --muted: #65707d;
  --line: #dde3ea;
  --accent: #176b87;
  --up: #0f8a5f;
  --down: #c23a3a;
  --chart-bg: #fbfcfd;
  --shadow: 0 10px 30px rgba(22, 32, 44, 0.08);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111418;
  --surface: #191d23;
  --ink: #f1f4f8;
  --muted: #a5afbc;
  --line: #313946;
  --accent: #5ab4c7;
  --up: #59c79a;
  --down: #ef7777;
  --chart-bg: #15191f;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  max-width: 100%;
  min-width: 0;
}

button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 700;
  min-height: 42px;
  padding: 0 14px;
}

button.secondary {
  background: #263849;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

button.text-button {
  background: transparent;
  color: var(--muted);
  min-height: auto;
  padding: 0;
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
}

input[type="date"] {
  appearance: none;
  -webkit-appearance: none;
  line-height: 1.2;
  text-align: left;
}

input[type="date"]::-webkit-date-and-time-value {
  margin: 0;
  min-width: 0;
  text-align: left;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  margin: 0;
  padding: 0;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar h1,
.login-panel h1 {
  margin: 4px 0 8px;
  font-size: 30px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.muted {
  margin: 0;
  color: var(--muted);
}

.auto-update-status {
  margin-top: 6px;
  font-size: 13px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  padding: 22px clamp(18px, 4vw, 44px) 44px;
}

.market-block {
  margin-bottom: 28px;
}

.performance-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 28px;
  padding: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 12px;
}

.section-head h2,
.panel h2 {
  margin: 0;
  font-size: 18px;
}

.section-head span {
  color: var(--muted);
  font-size: 13px;
}

.chart-head {
  align-items: start;
  gap: 16px;
}

.chart-head p {
  margin-top: 6px;
}

.period-tabs,
.event-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.period-tabs button,
.event-buttons button {
  background: #eef1f4;
  color: var(--muted);
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.period-tabs button.active,
.event-buttons button.active {
  background: var(--accent);
  color: white;
}

.event-buttons {
  justify-content: flex-start;
  margin: 12px 0 0;
}

.chart-mode {
  display: inline-flex;
  gap: 6px;
  margin-top: 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--chart-bg);
}

.chart-mode button {
  min-height: 32px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.chart-mode button.active {
  background: var(--accent);
  color: white;
}

body[data-theme="dark"] .period-tabs button,
body[data-theme="dark"] .event-buttons button {
  background: #252c35;
}

.date-range {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 220px)) max-content;
  align-items: end;
  gap: 10px;
  margin: 12px 0;
  max-width: 100%;
  min-width: 0;
}

.date-range label {
  display: grid;
  min-width: 0;
}

.date-range input {
  min-width: 0;
  width: 100%;
}

.date-range button {
  min-height: 42px;
  min-width: 88px;
  justify-self: start;
  width: auto;
}

.chart-wrap {
  position: relative;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--chart-bg);
  overflow: hidden;
}

.performance-chart {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 430px;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.chart-empty[hidden] {
  display: none;
}

.grid-line {
  stroke: #dfe5eb;
  stroke-width: 1;
}

.axis-label,
.date-label,
.event-label {
  fill: var(--muted);
  font-size: 12px;
}

.event-band {
  fill: #f3d9b1;
  opacity: 0.38;
}

.event-label {
  font-weight: 800;
}

.hover-line {
  stroke: #1b1f24;
  stroke-dasharray: 4 4;
  stroke-width: 1.2;
  opacity: 0.65;
  pointer-events: none;
}

.hit-area {
  fill: transparent;
  cursor: crosshair;
}

.chart-legend,
.chart-summary {
  display: flex;
  gap: 10px 16px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.legend-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.legend-actions button {
  min-height: 34px;
  padding: 0 11px;
  font-size: 13px;
}

.chart-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: start;
  justify-items: stretch;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--chart-bg);
}

.chart-legend span,
.chart-summary span {
  color: var(--muted);
  font-size: 13px;
}

.legend-item {
  display: grid;
  grid-template-columns: auto 10px minmax(0, 1fr) auto;
  align-items: start;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
  text-align: left;
}

.legend-item input {
  width: 15px;
  min-height: 15px;
  margin-top: 2px;
}

.legend-item span {
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: normal;
}

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

.chart-summary strong,
.chart-legend strong {
  color: var(--ink);
}

.chart-legend strong {
  justify-self: end;
  white-space: nowrap;
}

.chart-details {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--chart-bg);
  padding: 12px;
}

.detail-date {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px 12px;
}

.detail-grid span {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.detail-grid i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.detail-grid strong {
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-grid em {
  color: var(--ink);
  font-style: normal;
  font-weight: 800;
}

.detail-grid small {
  grid-column: 2 / 4;
  color: var(--muted);
}

.event-insights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.event-insights article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--chart-bg);
}

.event-insights h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.event-insights p {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.event-insights small {
  color: var(--muted);
  line-height: 1.45;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 14px;
}

.asset-card,
.panel,
.login-panel,
.notice {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.asset-card {
  padding: 16px;
  min-height: 190px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.asset-card.graph-muted {
  opacity: 0.58;
}

.asset-head,
.asset-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.asset-head h3 {
  margin: 0 0 5px;
  font-size: 16px;
  line-height: 1.25;
}

.asset-head p,
.asset-foot {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.change {
  align-self: start;
  border-radius: 999px;
  padding: 5px 8px;
  background: #eef1f4;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

body[data-theme="dark"] .change {
  background: #252c35;
}

.change.up {
  background: #e5f5ee;
  color: var(--up);
}

.change.down {
  background: #f9e7e7;
  color: var(--down);
}

.price {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.spark {
  width: 100%;
  height: 44px;
  color: #416b86;
  background: var(--chart-bg);
  border-radius: 7px;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel,
.login-panel,
.notice {
  padding: 18px;
}

.stack {
  display: grid;
  gap: 12px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.notice {
  margin-bottom: 18px;
  color: var(--accent);
  font-weight: 700;
}

.notice.danger {
  color: var(--down);
}

.error-list p {
  border-top: 1px solid var(--line);
  margin: 0;
  padding: 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-panel {
  width: min(420px, 100%);
}

@media (max-width: 900px) {
  .topbar,
  .layout {
    display: block;
  }

  .actions {
    margin-top: 18px;
  }

  .side {
    margin-top: 18px;
  }

  .chart-head {
    display: block;
  }

  .period-tabs,
  .event-buttons {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .date-range label {
    width: 100%;
  }

  .date-range {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 901px) and (max-width: 1180px) {
  .date-range {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .date-range button {
    grid-column: 1 / -1;
    min-width: 88px;
    padding: 0 18px;
    width: auto;
  }
}

@media (max-width: 720px) {
  .date-range {
    grid-template-columns: 1fr;
  }

  .date-range button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .topbar {
    padding: 20px 12px;
  }

  .layout {
    padding: 14px 10px 32px;
  }

  .performance-panel,
  .panel,
  .notice {
    padding: 12px;
  }

  .period-tabs button,
  .event-buttons button {
    min-height: 32px;
    padding: 0 9px;
  }

  .date-range {
    gap: 8px;
    margin: 12px 0 14px;
    overflow: hidden;
    width: 100%;
  }

  .date-range input,
  .date-range button {
    border-radius: 7px;
    min-height: 44px;
  }

  .date-range input[type="date"] {
    font-size: 16px;
    padding-left: 10px;
    padding-right: 6px;
  }

  .chart-wrap {
    min-height: 420px;
  }

  .performance-chart {
    min-height: 420px;
  }

  .modebar-container {
    display: none;
  }
}
