/* Markets browse page — reuses dashboard CSS variables */

:root {
  --blue: #1e3a5f;
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-600: #2563eb;
  --border: #e2e8f0;
  --text: #2c3e50;
  --muted: #475569;
  --muted-light: #64748b;
  --red: #922b21;
  --light-red: #fadbd8;
  --green: #1e8449;
  --light-green: #d5f5e3;
  --white: #fff;
  --gold: #b7950b;
  --light-gold: #fef9e7;
  --page-bg: #f1f3f5;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  line-height: 1.5;
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 20px;
  background: var(--page-bg);
}

/* Header */
header {
  background: var(--blue);
  color: #fff;
  padding: 6px 20px;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
}
.header-left { display: flex; align-items: center; gap: 12px; }
header h1 { font-size: 0.95rem; margin: 0; }
header h2 { font-size: 0.85rem; font-weight: 500; margin: 0; opacity: 0.85; }
.header-link { color: #fff; text-decoration: none; }
.header-link:hover { text-decoration: underline; }
.header-divider { opacity: 0.4; }
.header-stat { font-size: 0.72rem; opacity: 0.7; }

/* Controls bar */
.controls {
  background: var(--white);
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.controls-left { display: flex; gap: 8px; }
.controls select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--text);
  background: var(--white);
}
.market-count { font-size: 0.75rem; color: var(--muted-light); }

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  padding: 12px 0;
}

.market-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.market-card:hover {
  border-color: var(--blue);
  box-shadow: 0 2px 8px rgba(30, 58, 95, 0.1);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.card-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--blue);
}
.card-county {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--blue-50);
  color: var(--blue);
  white-space: nowrap;
}
.card-description {
  font-size: 0.72rem;
  color: var(--muted-light);
  margin-bottom: 10px;
}

/* Metrics row */
.card-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.metric {
  text-align: center;
}
.metric-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.metric-label {
  font-size: 0.62rem;
  color: var(--muted-light);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.metric-sub {
  font-size: 0.62rem;
  color: var(--muted-light);
}

/* Second metrics row */
.card-metrics-secondary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* Trend indicators */
.trend-up { color: var(--green); }
.trend-down { color: var(--red); }
.trend-flat { color: var(--muted-light); }

/* Distress highlight */
.distress-hot { color: var(--red); font-weight: 600; }

/* Insufficient data */
.insufficient { color: var(--muted-light); font-style: italic; font-size: 0.72rem; }

/* Property type bar */
.type-bar {
  display: flex;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}
.type-bar-segment { height: 100%; }
.type-retail { background: var(--blue); }
.type-office { background: var(--green); }
.type-industrial { background: var(--gold); }
.type-multifamily { background: #8e44ad; }
.type-other { background: var(--border); }

.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
  color: var(--muted-light);
  font-size: 0.85rem;
}

footer {
  text-align: center;
  padding: 16px;
  font-size: 0.7rem;
  color: var(--muted-light);
}

/* Benchmark freshness — same dot idiom as the dashboard's freshness badge.
   The banner is injected by markets.js only when /api/markets reports stale. */
.freshness-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  color: var(--muted-light);
}
.freshness-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex: 0 0 auto;
}
.freshness-dot.stale { background: var(--gold); }

.stale-banner {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 10px 0 0;
  padding: 7px 12px;
  border: 1px solid var(--gold);
  border-radius: 4px;
  background: var(--light-gold);
  color: var(--muted);
  font-size: 0.74rem;
}
