/* ===========================================================
 * 06-market.css — APPEND to your style.css
 * Drop-in replacement for the legacy market styles. Scoped via
 * .mkt-root-host on #pageRoot.
 * =========================================================== */

#pageRoot.mkt-root-host { padding: 12px 14px 100px; }

/* ── Feature cards ── */
.mkt-feature-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 14px;
}
.mkt-feat {
  position: relative; overflow: hidden;
  text-align: left; border: 1px solid var(--border-soft, #EEF0EA);
  background: var(--surface, #fff); border-radius: 16px;
  padding: 12px; min-height: 132px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
  cursor: pointer;
}
.mkt-feat-bg {
  position: absolute; inset: 0; pointer-events: none;
}
.mkt-feat-head, .mkt-feat-num, .mkt-feat-row, .mkt-feat-period {
  position: relative; z-index: 1;
}
.mkt-feat-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.mkt-feat-name {
  flex: 1; min-width: 0;
  font-size: 13px; font-weight: 700;
  color: var(--text, #111827);
}
.mkt-feat-num {
  font-family: "Inter", "IBM Plex Sans Thai", sans-serif;
  font-size: 26px; font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.mkt-feat-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px;
}
.mkt-feat-unit { font-size: 10.5px; color: var(--faint, #9CA3AF); font-weight: 500; }
.mkt-feat-delta {
  font-size: 11.5px; font-weight: 700;
  padding: 2px 7px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.mkt-feat-delta.is-up { color: #15803D; background: rgba(22,163,74,0.10); }
.mkt-feat-delta.is-down { color: #B91C1C; background: rgba(239,68,68,0.10); }
.mkt-feat-period { font-size: 10px; color: var(--faint, #9CA3AF); margin-top: 6px; }

/* ── Entry card ── */
.mkt-entry-card {
  background: linear-gradient(135deg, #ECFDF5 0%, var(--surface, #fff) 100%);
  border: 1.5px solid #BBF7D0;
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(15,86,32,0.04);
}
.mkt-entry-h {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.mkt-entry-icon {
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--primary, #16A34A); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
}
.mkt-entry-h h3 { font-size: 14px; font-weight: 700; margin: 0; color: #064E3B; }
.mkt-entry-h p { font-size: 11px; color: #166534; margin: 1px 0 0; opacity: 0.85; line-height: 1.4; }

.mkt-entry-row { display: flex; gap: 8px; margin-bottom: 8px; }
.mkt-entry-pill {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #E7E9E3);
  border-radius: 11px;
  font-size: 13.5px; font-weight: 600;
  color: var(--text, #111827);
  cursor: pointer;
}
.mkt-entry-pill > span:nth-of-type(1) { flex: 1; text-align: left; }
.mkt-entry-chev { color: var(--muted, #6B7280); }
.mkt-entry-price {
  display: flex; align-items: center; gap: 4px;
  padding: 0 12px;
  background: var(--surface, #fff);
  border: 1.5px solid var(--primary, #16A34A);
  border-radius: 11px;
  box-shadow: 0 0 0 3px rgba(22,163,74,0.10);
}
.mkt-entry-price input {
  width: 60px; height: 42px;
  border: 0; background: transparent;
  font-size: 17px; font-weight: 800;
  text-align: right;
  color: #064E3B;
  font-variant-numeric: tabular-nums;
  outline: none;
  font-family: "Inter", sans-serif;
}
.mkt-entry-price span { font-size: 11px; color: var(--muted, #6B7280); font-weight: 600; }

.mkt-entry-meta { align-items: center; }
.mkt-entry-date {
  flex: 1;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--muted, #6B7280);
  padding: 6px 10px;
  background: rgba(255,255,255,0.6);
  border-radius: 8px;
}
.mkt-entry-submit {
  padding: 0 18px; height: 36px;
  background: var(--primary, #16A34A); border: 0; border-radius: 10px;
  color: #fff; font-size: 13px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(22,163,74,0.24);
  cursor: pointer;
}

.mkt-entry-quickadd {
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px dashed rgba(15,122,53,0.18);
  margin-top: 6px;
}
.mkt-entry-quickadd > span {
  font-size: 10.5px; color: #166534; font-weight: 600; margin-right: 2px;
}
.mkt-entry-quickadd button {
  padding: 3px 9px;
  background: rgba(15,122,53,0.08);
  border: 0; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  color: #15803D;
  cursor: pointer;
}
.mkt-entry-quickadd button.is-active {
  background: var(--primary, #16A34A); color: #fff;
}

/* ── Controls ── */
.mkt-controls {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.mkt-range-row {
  flex: 1;
  display: flex; gap: 3px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #E7E9E3);
  border-radius: 10px;
  padding: 3px;
}
.mkt-range {
  flex: 1;
  background: transparent; border: 0;
  padding: 5px 4px; border-radius: 7px;
  font-size: 11.5px; font-weight: 700;
  color: var(--muted, #6B7280);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.mkt-range.is-active {
  background: var(--primary, #16A34A); color: #fff;
}
.mkt-export-btn {
  padding: 0 10px; height: 34px;
  background: var(--surface, #fff); border: 1px solid var(--border, #E7E9E3);
  border-radius: 10px;
  color: var(--text-2, #374151);
  font-size: 11.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
  cursor: pointer;
}

.mkt-legend {
  display: flex; gap: 5px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.mkt-legend-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  background: var(--surface, #fff);
  border: 1.5px solid var(--border-soft, #E7E9E3);
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  color: var(--faint, #9CA3AF);
  opacity: 0.6;
  cursor: pointer;
}
.mkt-legend-btn.is-on { opacity: 1; color: var(--text, #111827); }
.mkt-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── Chart card ── */
.mkt-chart-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border-soft, #EEF0EA);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 10px;
}
.mkt-chart-h {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 12px;
  gap: 10px;
}
.mkt-chart-title { font-size: 13px; font-weight: 700; }
.mkt-chart-sub { font-size: 11px; color: var(--muted, #6B7280); margin-top: 1px; }
.mkt-cursor-info {
  text-align: right;
  padding: 5px 11px;
  background: #111827; color: #fff;
  border-radius: 8px;
  flex-shrink: 0;
}
.mkt-cursor-info span { font-size: 9px; opacity: 0.7; display: block; }
.mkt-cursor-info strong {
  font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.mkt-chart-wrap { position: relative; touch-action: pan-y; }
.mkt-chart-svg {
  width: 100%; height: auto;
  display: block;
  cursor: crosshair;
  user-select: none;
}

/* readout list under chart */
.mkt-readout {
  background: linear-gradient(135deg, #EFF6FF 0%, transparent 100%);
  border-top: 1px solid #BFDBFE;
  padding: 10px 0 0;
  margin-top: 10px;
}
.mkt-readout-h {
  font-size: 11px; color: #1E40AF;
  margin-bottom: 6px;
}
.mkt-readout-h strong { color: #1E3A8A; font-weight: 700; }
.mkt-readout-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0;
  font-size: 12.5px;
}
.mkt-readout-row + .mkt-readout-row { border-top: 1px solid rgba(30,64,175,0.08); }
.mkt-readout-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.mkt-readout-name { flex: 1; font-weight: 600; color: var(--text, #111827); }
.mkt-readout-val {
  font-family: "Inter", "IBM Plex Sans Thai", sans-serif;
  font-size: 13.5px; font-weight: 800;
  color: var(--text, #111827);
  font-variant-numeric: tabular-nums;
}
.mkt-readout-val span { font-size: 10px; opacity: 0.5; font-weight: 600; }
.mkt-readout-delta {
  font-size: 10.5px; font-weight: 700;
  padding: 2px 6px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
  min-width: 50px; text-align: center;
}
.mkt-readout-delta.is-up { color: #15803D; background: rgba(22,163,74,0.10); }
.mkt-readout-delta.is-down { color: #B91C1C; background: rgba(239,68,68,0.10); }

/* ── Overview (placeholder for future zoom bar) ── */
.mkt-overview-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border-soft, #EEF0EA);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.mkt-overview-h h3 { font-size: 12.5px; font-weight: 700; margin: 0; }
.mkt-overview-h p { font-size: 10.5px; color: var(--muted, #6B7280); margin: 1px 0 0; }

/* ── Section heading ── */
#pageRoot.mkt-root-host .mkt-section-h {
  display: flex; justify-content: space-between; align-items: center;
  margin: 0 4px 10px;
}
#pageRoot.mkt-root-host .mkt-section-h h2 { font-size: 14px; font-weight: 700; margin: 0; }
#pageRoot.mkt-root-host .mkt-section-link {
  background: transparent; border: 0;
  color: #15803D; font-size: 11.5px; font-weight: 600;
  cursor: pointer;
}

/* ── Recent entries ── */
.mkt-recent {
  background: var(--surface, #fff); border: 1px solid var(--border-soft, #EEF0EA);
  border-radius: 14px;
  overflow: hidden;
}
.mkt-recent-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
}
.mkt-recent-row + .mkt-recent-row { border-top: 1px solid #F1F2EE; }
.mkt-recent-body { flex: 1; min-width: 0; }
.mkt-recent-name { font-size: 13.5px; font-weight: 600; color: var(--text, #111827); }
.mkt-recent-date { font-size: 10.5px; color: var(--faint, #9CA3AF); margin-top: 1px; }
.mkt-recent-price {
  font-family: "Inter", sans-serif;
  font-size: 15px; font-weight: 800;
  color: #064E3B;
  font-variant-numeric: tabular-nums;
}
.mkt-recent-price span { font-size: 10px; opacity: 0.6; font-weight: 600; }
.mkt-recent-edit {
  width: 26px; height: 26px;
  background: #F1F2EE; border: 0; border-radius: 7px;
  color: var(--muted, #6B7280);
  cursor: pointer;
  font-size: 14px;
}
.mkt-recent-edit:hover { background: #FEE2E2; color: #B91C1C; }

.mkt-empty-item {
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--faint, #9CA3AF);
}

.mkt-empty {
  padding: 32px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--muted, #6B7280);
  background: var(--surface, #fff);
  border: 1px dashed var(--border, #E7E9E3);
  border-radius: 14px;
}
