:root {
  --bg: #f6f7f1;
  --panel: #fffefa;
  --text: #111316;
  --muted: #5d6773;
  --line: #d8d6ce;
  --accent: #1169ff;
  --accent-2: #00a878;
  --danger: #d04a34;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  background: radial-gradient(circle at 10% 10%, #fff5ce 0, transparent 40%), var(--bg);
  color: var(--text);
}

.bg-shape {
  position: fixed;
  z-index: 0;
  border-radius: 999px;
  filter: blur(40px);
}

.bg-a {
  width: 260px;
  height: 260px;
  background: #8bc4ff88;
  right: -80px;
  top: -80px;
}

.bg-b {
  width: 320px;
  height: 320px;
  background: #89f0d388;
  left: -120px;
  bottom: -120px;
}

.app {
  position: relative;
  z-index: 2;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.top h1 {
  margin: 0;
  font-size: 2rem;
}

.top p {
  color: var(--muted);
  margin: 8px 0 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 8px 24px #191e2a12;
  margin-bottom: 16px;
}

.tabs {
  display: flex;
  gap: 8px;
}

.tab {
  border: 1px solid var(--line);
  background: #f8f9f2;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}

.tab.active {
  background: var(--text);
  color: white;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: reveal 220ms ease;
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}

input, select, button {
  font-family: inherit;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 9px 10px;
}

button {
  background: var(--accent);
  color: white;
  border: 0;
  font-weight: 700;
  cursor: pointer;
}

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

.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: #ffffff;
}

.chart-card {
  min-height: 250px;
}

.chart-svg {
  width: 100%;
  height: 220px;
  background: linear-gradient(180deg, #f8fbff, #f0f4f9);
  border: 1px solid #d7dfec;
  border-radius: 12px;
}

.item-head {
  display: flex;
  gap: 10px;
  align-items: center;
}

.item-head img {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  background: #f2f1ec;
  border-radius: 8px;
}

.mono {
  font-family: "IBM Plex Mono", monospace;
  color: var(--muted);
  font-size: 12px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-entry {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
}

.contents {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
}

.content-chip {
  border: 1px solid var(--line);
  background: #f7f8ff;
  border-radius: 10px;
  padding: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.content-chip img {
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
}

.trend-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.compact .card {
  padding: 8px;
}

.meta {
  color: var(--muted);
  margin-bottom: 10px;
  overflow-wrap: anywhere;
}

.hidden {
  display: none !important;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.kpi-grid > * {
  min-width: 0;
}

.kpi {
  border: 1px solid #d8e0ea;
  border-radius: 12px;
  padding: 10px;
  background: linear-gradient(160deg, #fdfefe, #f3f7ff);
}

.kpi .label {
  color: var(--muted);
  font-size: 12px;
}

.kpi .value {
  font-size: clamp(1rem, 1.8vw, 1.5rem);
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.market-table {
  display: grid;
  gap: 6px;
}

.market-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 90px 90px 110px 80px;
  gap: 8px;
  align-items: center;
  border: 1px solid #d8e0ea;
  background: #fcfdff;
  border-radius: 10px;
  padding: 8px;
}

.market-row.header {
  font-weight: 700;
  background: #edf3ff;
}

.market-row.clickable {
  cursor: pointer;
}

.market-row.clickable:hover {
  border-color: #8ab2ff;
}

.market-search-row {
  grid-template-columns: minmax(180px, 1fr) 120px 90px 90px 160px;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  background: #eef3f8;
}

.meta-chips {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill.up {
  background: #dff7ea;
  color: #1c7f4e;
}

.pill.down {
  background: #ffe7e2;
  color: #b4452f;
}

.share-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 1fr 52px;
  gap: 8px;
  align-items: center;
}

.share-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.tiny {
  width: 18px !important;
  height: 18px !important;
  border-radius: 4px !important;
  background: #eef3f8 !important;
}

.share-track {
  height: 10px;
  border-radius: 999px;
  background: #e8edf5;
  overflow: hidden;
}

.share-fill {
  height: 100%;
  background: linear-gradient(90deg, #1f6dff, #00a878);
}

.item-detail.hidden {
  display: none;
}

#item-detail-header {
  margin-bottom: 8px;
}

#item-detail-header .item-head {
  align-items: center;
}

.item-subsection {
  margin-top: 10px;
}

@media (max-width: 640px) {
  .top h1 {
    font-size: 1.5rem;
  }
}
