/* ==========================================================================
   BENTO GRID LAYOUT & FEATURE MODULE CARDS
   ========================================================================== */

/* Hero Price Card */
.hero-card {
  background: var(--surface-glass-strong);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  padding: 22px 20px;
  box-shadow: var(--shadow-md);
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 50% 10%, var(--gold-tint) 0%, transparent 60%);
  pointer-events: none;
}

.hero-eyebrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-sm);
  color: var(--gold-primary);
  margin-bottom: 8px;
  min-height: 32px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero-price-wrap {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.hero-price {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-hero);
  color: var(--ink-primary);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.change-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 700;
}
.change-badge.up { background: var(--good-bg); color: var(--good); border: 1px solid var(--good-border); }
.change-badge.down { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad-border); }
.change-badge.same { background: var(--surface-sunken); color: var(--ink-secondary); border: 1px solid var(--border-subtle); }

.hero-sub-stats {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-top: 14px;
  margin-top: 12px;
  border-top: 1px solid var(--border-subtle);
  font-size: var(--fs-sm);
}
.stat-col { display: flex; flex-direction: column; gap: 3px; }
.stat-col.text-right { text-align: right; align-items: flex-end; }
.stat-label { font-size: var(--fs-2xs); color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; line-height: 1.2; }
.stat-val { font-weight: 700; color: var(--ink-primary); min-height: 22px; display: inline-flex; align-items: center; gap: 4px; line-height: 1.2; }

/* Bento Layout */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 14px;
  width: 100%;
  box-sizing: border-box;
}

.bento-card {
  background: var(--surface-glass);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 14px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.bento-card.full-width {
  grid-column: span 2;
}

.card-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 6px;
  min-height: 22px;
  width: 100%;
  box-sizing: border-box;
}
.card-label {
  font-size: var(--fs-2xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  line-height: 1.2;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-sub-label {
  font-size: var(--fs-3xs);
  color: var(--ink-muted);
  line-height: 1.2;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Fix Timeline Chips */
.fix-chips-wrap {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.fix-chip {
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 72px;
  min-width: 0;
  box-sizing: border-box;
}
.fix-chip.confirmed {
  border-color: var(--gold-primary);
  background: var(--gold-tint);
}
.fix-chip-title {
  font-size: var(--fs-3xs);
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.fix-chip-rate {
  font-family: var(--font-display);
  font-size: clamp(14px, 4vw, 17px);
  font-weight: 700;
  color: var(--ink-primary);
  margin: 2px 0;
  white-space: nowrap;
  line-height: 1.2;
}
.fix-chip-time {
  font-size: var(--fs-3xs);
  color: var(--ink-secondary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.next-fix-line {
  margin-top: 8px;
  font-size: var(--fs-2xs);
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
  line-height: 1.3;
}
.next-fix-line svg {
  flex-shrink: 0;
}

/* Purity Benchmark Row */
.purity-row-bento {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}
.purity-col {
  text-align: center;
  padding: 8px 4px;
  background: var(--surface-sunken);
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  min-height: 78px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.purity-col.highlight {
  border-color: var(--gold-primary);
  background: var(--gold-tint);
}
.purity-carat {
  font-size: var(--fs-2xs);
  font-weight: 700;
  color: var(--ink-secondary);
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.15;
  width: 100%;
}
.purity-rate {
  font-family: var(--font-display);
  font-size: clamp(12px, 3.4vw, 15px);
  font-weight: 700;
  color: var(--ink-primary);
  margin: 2px 0;
  white-space: nowrap;
  line-height: 1.2;
}
.purity-fineness {
  font-size: var(--fs-3xs);
  color: var(--ink-muted);
  line-height: 1.1;
  white-space: nowrap;
}

/* Regional Parity Horizontal Carousel */
.carousel-track {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.carousel-track::-webkit-scrollbar {
  display: none;
}
.carousel-item {
  scroll-snap-align: start;
  min-width: 140px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}
.city-name { font-size: var(--fs-xs); font-weight: 700; color: var(--ink-primary); }
.city-rate { font-family: var(--font-display); font-size: var(--fs-base); font-weight: 700; color: var(--gold-primary); }
.city-basis { font-size: var(--fs-2xs); font-weight: 600; color: var(--good); }

/* Submarket Basis Grid (Sowcarpet vs T. Nagar) */
.basis-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.basis-box {
  background: var(--surface-sunken);
  padding: 10px 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 76px;
  min-width: 0;
  box-sizing: border-box;
}
.basis-title {
  font-size: var(--fs-3xs);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
  line-height: 1.2;
  height: 24px;
  display: flex;
  align-items: center;
}
.basis-rate {
  font-family: var(--font-display);
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--ink-primary);
  margin: 3px 0 1px;
  white-space: nowrap;
}
.basis-sub {
  font-size: 8.5px;
  line-height: 1.2;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.arbitrage-spread-line {
  font-size: var(--fs-2xs);
  color: var(--ink-secondary);
  margin-bottom: 8px;
}

/* National Wholesale IBJA Spread Grid */
.national-spread-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}
.national-col {
  background: var(--surface-sunken);
  padding: 8px 6px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 68px;
  min-width: 0;
  box-sizing: border-box;
}
.national-label {
  font-size: var(--fs-3xs);
  color: var(--ink-muted);
  font-weight: 600;
  line-height: 1.15;
  height: 24px;
  display: flex;
  align-items: center;
  overflow: hidden;
}
.national-val {
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 700;
  margin: 3px 0 1px;
  white-space: nowrap;
}
.national-sub {
  font-size: 8.5px;
  color: var(--ink-faint);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Analytics View Cards */
.chart-container {
  background: var(--surface-glass);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  padding: 18px 16px;
  margin-bottom: 14px;
}
.timeframe-pill-group {
  display: flex;
  background: var(--surface-sunken);
  border-radius: var(--r-full);
  padding: 3px;
  gap: 2px;
}
.tf-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: var(--r-full);
  padding: 5px 8px;
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.tf-btn.active {
  background: var(--surface-raised);
  color: var(--gold-primary);
  box-shadow: var(--shadow-sm);
}

/* ML Forecast Card */
.ml-forecast-card {
  background: var(--surface-glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 14px;
}
.forecast-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.forecast-col {
  background: var(--surface-sunken);
  border-radius: var(--r-md);
  padding: 8px 6px;
  text-align: center;
}
.fc-horizon { font-size: var(--fs-3xs); font-weight: 700; color: var(--ink-muted); text-transform: uppercase; }
.fc-rate { font-family: var(--font-display); font-size: var(--fs-sm); font-weight: 700; color: var(--ink-primary); margin: 3px 0; }
.fc-delta { font-size: var(--fs-3xs); font-weight: 700; }
.fc-delta.up { color: var(--good); }
.fc-delta.down { color: var(--bad); }

/* Calculator Forms & Inputs */
.calc-card {
  background: var(--surface-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  padding: 18px 16px;
  margin-bottom: 14px;
}
.calc-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.calc-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-secondary);
}
.calc-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  outline: none;
  transition: border-color var(--transition-fast);
}
.calc-input:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 2px var(--gold-tint);
}

/* Quotation Total Box */
.quote-box {
  background: var(--gold-tint);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  margin-top: 14px;
}
.quote-line {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--ink-secondary);
  padding: 3px 0;
}
.quote-total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 10px;
  margin-top: 8px;
  border-top: 1px dashed var(--border-strong);
}
.quote-total-label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--gold-primary);
}
.quote-total-val {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--gold-primary);
}

/* Action buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 18px;
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, #f4dca0 0%, var(--gold-primary) 55%, var(--gold-deep) 100%);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: 700;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-spring);
  margin-top: 12px;
}
.btn-primary:active { transform: scale(0.98); }

html[data-theme="oled"] .btn-primary {
  background: linear-gradient(135deg, #fff2a8 0%, #ffd700 55%, #b39200 100%);
  color: #000000;
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.4);
}

/* ==========================================================================
   RESTORED FEATURE MODULES & RESPONSIVE MOBILE ALIGNMENT
   ========================================================================== */

/* Segmented Control (Pills) - Strict 7-Column Grid on Mobile */
.segment-ctrl {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  width: 100%;
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  padding: 3px;
  gap: 2px;
  margin-bottom: 12px;
}
.segment-ctrl button {
  width: 100%;
  min-width: 0;
  background: transparent;
  border: none;
  border-radius: var(--r-full);
  padding: 6px 2px;
  font-family: var(--font-sans);
  font-size: clamp(9px, 2.5vw, 11px);
  font-weight: 600;
  color: var(--ink-secondary);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.segment-ctrl button.active {
  background: var(--surface-raised);
  color: var(--gold-primary);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
}

.calc-segmented-mode {
  position: relative;
  display: flex;
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  padding: 3px;
  gap: 2px;
  margin-bottom: 12px;
}
.calc-mode-btn {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  border-radius: var(--r-full);
  padding: 6px 10px;
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-align: center;
}
.calc-mode-btn.active {
  background: var(--surface-raised);
  color: var(--gold-primary);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
}

/* Interactive Financial Chart Panel */
.chart-panel {
  background: var(--surface-glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  padding: 16px;
  margin-bottom: 14px;
}
.chart-mode-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}
.chart-mode-switch {
  display: inline-flex;
  background: var(--surface-sunken);
  border-radius: var(--r-full);
  padding: 2px;
  gap: 2px;
}
.chart-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: var(--fs-2xs);
  font-weight: 600;
  border: none;
  background: transparent;
  border-radius: var(--r-full);
  color: var(--ink-secondary);
  cursor: pointer;
}
.chart-mode-btn.active {
  background: var(--surface-raised);
  color: var(--gold-primary);
  box-shadow: var(--shadow-sm);
}
.chart-header-metrics {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0 12px;
}
.primary-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.primary-metric span {
  font-size: var(--fs-2xs);
  color: var(--ink-muted);
  text-transform: uppercase;
  font-weight: 600;
}
.primary-metric strong {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--ink-primary);
}
.secondary-metrics {
  display: flex;
  gap: 12px;
}
.sec-metric {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.sec-metric span {
  font-size: var(--fs-3xs);
  color: var(--ink-muted);
  text-transform: uppercase;
}
.sec-metric b {
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink-primary);
}
.chartwrap {
  position: relative;
  width: 100%;
  height: 220px;
  margin: 6px 0;
}
.chartwrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-glass-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 6px 10px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 10;
  transform: none;
}
.chart-tooltip[hidden] {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}
.chart-tooltip-date {
  font-size: var(--fs-3xs);
  color: var(--ink-muted);
  font-weight: 600;
}
.chart-tooltip strong {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  color: var(--gold-primary);
}
.chartmeta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-3xs);
  color: var(--ink-muted);
  padding-top: 6px;
}
.chart-legend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}
.chart-legend::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 2px;
  background: var(--gold-primary);
  border-radius: 1px;
}

/* Quantitative Risk Metric Grid */
.quant-risk-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.quant-risk-box {
  background: var(--surface-sunken);
  padding: 8px 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 58px;
  min-width: 0;
}
.quant-risk-label {
  font-size: var(--fs-2xs);
  color: var(--ink-muted);
  font-weight: 600;
  line-height: 1.2;
}
.quant-risk-val {
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink-primary);
  margin-top: 2px;
  line-height: 1.2;
}

/* Technical Sentiment & RSI Meter Grid */
.technical-meter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}
.tech-meter-box {
  background: var(--surface-sunken);
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 124px;
  min-width: 0;
}
.tech-meter-box.text-center {
  text-align: center;
}
.tech-meter-title {
  font-size: var(--fs-3xs);
  color: var(--ink-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.sentiment-label-text {
  font-size: var(--fs-2xs);
  font-weight: 700;
  color: var(--ink-primary);
}

/* Collapsible Accordion Cards */
.collapsible {
  background: var(--surface-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color var(--transition-normal);
}
.collapsible[open] {
  border-color: var(--glass-border);
}
.collapsible summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.collapsible summary::-webkit-details-marker {
  display: none;
}
.summary-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.summary-title h3 {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink-primary);
}
.summary-title span {
  font-size: var(--fs-2xs);
  color: var(--ink-muted);
}
.chevron {
  font-size: 10px;
  color: var(--ink-muted);
  transition: transform var(--transition-normal);
}
.collapsible[open] .chevron {
  transform: rotate(180deg);
}
.collapsible-content {
  padding: 0 16px 16px;
}

/* Returns by Period Grid */
.horizon-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
@media (min-width: 540px) {
  .horizon-grid { grid-template-columns: repeat(6, 1fr); }
}
.horizon-box {
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 8px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.horizon-box small {
  font-size: var(--fs-3xs);
  color: var(--ink-muted);
  font-weight: 700;
  text-transform: uppercase;
}
.horizon-box b {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--ink-primary);
}

/* 30-Day Moving Average & Last Movement */
.sma-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface-sunken);
  border-radius: var(--r-md);
}
.sma-label {
  font-size: var(--fs-2xs);
  color: var(--ink-muted);
  text-transform: uppercase;
  font-weight: 600;
}
.sma-value {
  font-family: var(--font-display);
  font-size: var(--fs-base);
  color: var(--ink-primary);
  font-weight: 700;
}
.last-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-sunken);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-top: 8px;
}
.last-box h4 {
  font-size: var(--fs-2xs);
  color: var(--ink-muted);
  text-transform: uppercase;
}
.last-box p {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-primary);
}
.last-box-sub {
  font-size: var(--fs-3xs) !important;
  color: var(--ink-secondary) !important;
}
.last-box .amount {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--gold-primary);
}

/* Compare Dates Tool */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.compare-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.compare-field label {
  font-size: var(--fs-2xs);
  color: var(--ink-muted);
  font-weight: 600;
  text-transform: uppercase;
}
.compare-result-panel {
  background: var(--surface-sunken);
  border-radius: var(--r-md);
  padding: 12px;
  text-align: center;
}
.compare-result-label {
  font-size: var(--fs-3xs);
  color: var(--ink-muted);
  text-transform: uppercase;
  font-weight: 700;
}
.compare-result-card {
  margin-top: 4px;
}
.compare-result-top {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--ink-primary);
}
.compare-result-sub {
  font-size: var(--fs-xs);
  color: var(--ink-secondary);
}
.compare-visual {
  margin-top: 10px;
}
.compare-visual-head {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-2xs);
  font-weight: 700;
  color: var(--ink-secondary);
  margin-bottom: 4px;
}
.compare-track {
  position: relative;
  height: 6px;
  background: var(--border-subtle);
  border-radius: var(--r-full);
  overflow: hidden;
}
.compare-track span {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--gold-primary);
}
.compare-visual-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-3xs);
  color: var(--ink-muted);
  margin-top: 3px;
}

/* Preset Chips */
.chip-container {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  margin-bottom: 10px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.chip-container::-webkit-scrollbar {
  display: none;
}

/* Strict 4-Column Preset Chip Grid for Calculator & Forms */
#weightChips, #makingChips, .chip-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  overflow: visible;
  padding-bottom: 0;
  margin-bottom: 10px;
}
#weightChips .chip, #makingChips .chip, .chip-grid-4 .chip {
  width: 100%;
  min-width: 0;
  padding: 7px 2px;
  font-size: clamp(9px, 2.4vw, 11px);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#portWeightChips {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  width: 100%;
  overflow: visible;
  padding-bottom: 0;
  margin-bottom: 0;
}
#portWeightChips .chip {
  width: 100%;
  min-width: 0;
  padding: 6px 2px;
  font-size: clamp(8.5px, 2.2vw, 10.5px);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip {
  flex: 1;
  min-width: max-content;
  padding: 6px 10px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.chip.active {
  background: var(--gold-tint);
  color: var(--gold-primary);
  border-color: var(--gold-primary);
}
.calc-group-label {
  display: block;
  font-size: var(--fs-2xs);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

/* Calculator Grid Form (Consistent 2-column layout on all viewports) */
.calc-grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.calc-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.calc-field label {
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--ink-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Exchange Drawer */
.exchange-drawer {
  background: var(--surface-sunken);
  border-radius: var(--r-md);
  padding: 12px;
  margin: 10px 0;
}
.exchange-header {
  display: block;
  font-size: var(--fs-2xs);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--gold-primary);
  margin-bottom: 8px;
}

/* Receipt Card */
.receipt-card {
  background: var(--surface-glass);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: 16px;
  margin-top: 14px;
}
.receipt-title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--gold-primary);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
  margin-bottom: 8px;
}
.receipt-line {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--ink-secondary);
  padding: 3px 0;
}
.receipt-line.deduction span:last-child {
  color: var(--good);
  font-weight: 700;
}
.receipt-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-top: 1px dashed var(--border-strong);
  padding-top: 10px;
  margin-top: 8px;
}
.receipt-total .label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink-primary);
}
.receipt-total .final-val {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--gold-primary);
}
.calc-sub {
  font-size: var(--fs-3xs);
  color: var(--ink-muted);
  margin-top: 4px;
}
.receipt-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.quote-btn {
  padding: 9px 12px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.quote-btn:active { transform: scale(0.97); }
.share-link-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  background: var(--gold-tint);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--gold-primary);
  cursor: pointer;
}

/* Jeweller Bill Verifier & Auditor */
.auditor-card {
  background: var(--surface-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auditor-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 540px) {
  .auditor-grid { grid-template-columns: 1fr 1fr; }
}
.auditor-input-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.auditor-input-box label {
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--ink-secondary);
}
.meter-container {
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.meter-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.meter-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.meter-badge {
  font-size: var(--fs-3xs);
  font-weight: 800;
  padding: 3px 8px;
  border-radius: var(--r-full);
  text-transform: uppercase;
}
.meter-badge.fair { background: var(--good-bg); color: var(--good); border: 1px solid var(--good-border); }
.meter-badge.moderate { background: var(--gold-tint); color: var(--gold-primary); border: 1px solid var(--border-strong); }
.meter-badge.overpriced { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad-border); }
.meter-breakdown {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
@media (min-width: 500px) {
  .meter-breakdown { grid-template-columns: repeat(4, 1fr); }
}
.meter-metric-item {
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  padding: 8px 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 56px;
  min-width: 0;
}
.meter-metric-item span {
  font-size: 8.5px;
  color: var(--ink-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.meter-metric-item b {
  font-family: var(--font-display);
  color: var(--ink-primary);
  font-size: var(--fs-sm);
  line-height: 1.2;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bargain-tip {
  font-size: var(--fs-xs);
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-raised);
  border-left: 3px solid var(--gold-primary);
  color: var(--ink-secondary);
  line-height: 1.4;
}

/* Portfolio Section */
.port-summary-card {
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 12px;
  margin-bottom: 12px;
}
.port-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
@media (min-width: 540px) {
  .port-summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.port-metric {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 64px;
  min-width: 0;
}
.port-metric span {
  font-size: 8.5px;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  line-height: 1.2;
}
.port-metric strong {
  font-family: var(--font-display);
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--ink-primary);
  line-height: 1.2;
  white-space: nowrap;
}
.port-metric small {
  font-size: var(--fs-3xs);
  color: var(--ink-secondary);
}
.port-metric .profit-val.positive { color: var(--good); }
.port-metric .profit-val.negative { color: var(--bad); }

.port-form-box {
  background: var(--surface-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 12px;
  margin-bottom: 12px;
}
.port-form-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--ink-primary);
  margin-bottom: 8px;
}
.port-form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.btn-gold {
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--gold-primary) 0%, var(--gold-deep) 100%);
  color: #fff;
  font-weight: 700;
  font-size: var(--fs-xs);
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-gold:active { transform: scale(0.97); }

.port-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.port-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-xs);
}
.port-table th {
  text-align: left;
  padding: 8px 6px;
  font-weight: 600;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
}
.port-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--ink-primary);
}
.port-del-btn {
  background: none;
  border: none;
  color: var(--bad);
  cursor: pointer;
  font-size: var(--fs-base);
  padding: 2px 6px;
  opacity: 0.7;
}

/* Historical Log Table */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-xs);
}
.history-table th {
  text-align: left;
  padding: 8px;
  font-weight: 700;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--border-subtle);
  text-transform: uppercase;
  font-size: var(--fs-2xs);
}
.history-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--ink-primary);
}
.history-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.export-csv-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--ink-secondary);
  cursor: pointer;
}

/* Target Alert Modal / Card */
.target-card {
  background: var(--surface-glass);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 14px;
  margin-bottom: 12px;
}
.target-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.target-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink-primary);
}
.target-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ==========================================================================
   MOBILE RESPONSIVENESS OVERHAUL (< 640px)
   ========================================================================== */
@media (max-width: 640px) {
  .bento-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .bento-card.full-width {
    grid-column: span 1;
  }
  .hero-card {
    padding: 14px 14px;
    margin-bottom: 10px;
  }
  .hero-price {
    font-size: clamp(30px, 8.5vw, 42px);
  }
  .hero-price-wrap {
    gap: 8px;
  }
  .hero-sub-stats {
    padding-top: 10px;
    margin-top: 10px;
  }
  .purity-row-bento {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
  }
  .purity-col {
    padding: 8px 4px;
    min-width: 0;
    min-height: 76px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    width: 100%;
    overflow: hidden;
  }
  .purity-carat {
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-3xs);
    line-height: 1.15;
    text-align: center;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .purity-rate {
    font-size: clamp(11px, 3.2vw, 13.5px);
    margin: 2px 0;
    white-space: nowrap;
  }
  .purity-fineness {
    font-size: 8.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  .fix-chips-wrap {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }
  .fix-chip {
    padding: 6px 6px;
    min-height: 68px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }
  .fix-chip-title {
    font-size: clamp(8px, 2.2vw, 9.5px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .fix-chip-rate {
    font-size: clamp(13px, 3.8vw, 15px);
    margin: 1px 0;
    white-space: nowrap;
  }
  .fix-chip-time {
    font-size: clamp(8px, 2vw, 9.5px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .basis-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }
  .basis-box {
    padding: 8px 6px;
    min-height: 72px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }
  .basis-title {
    font-size: clamp(8px, 2.2vw, 9.5px);
    height: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .basis-rate {
    font-size: clamp(13px, 3.8vw, 15px);
    margin: 1px 0;
    white-space: nowrap;
  }
  .basis-sub {
    font-size: clamp(7.5px, 2vw, 8.5px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .forecast-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  .chartwrap {
    height: 190px;
  }
  .receipt-actions-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
}
