@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #f5f5f7;
  --bg-card: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(0, 0, 0, 0.06);
  --glass-shadow: 0 2px 12px rgba(0, 0, 0, 0.03);

  --apple-blue: #0071e3;
  --apple-green: #34c759;
  --apple-orange: #ff9f0a;
  --apple-red: #ff3b30;
  --apple-purple: #5856d6;
  --apple-indigo: #4f46e5;
  --apple-cyan: #5ac8fa;

  --text-main: #1d1d1f;
  --text-secondary: #424245;
  --text-muted: #86868b;

  --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', sans-serif;
  --border-radius: 14px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-family);
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  box-shadow: var(--glass-shadow);
  padding: 18px 20px;
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.05);
}

/* ─── Segmented Control Tabs (Apple Style) ─── */
.tabs-container {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.05);
  padding: 3px;
  border-radius: 10px;
  margin-bottom: 20px;
  gap: 2px;
}

.tab-btn {
  padding: 7px 18px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
  background: transparent;
  user-select: none;
}

.tab-btn:hover:not(.active) {
  color: var(--text-main);
}

.tab-btn.active {
  background: #ffffff;
  color: var(--text-main);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ─── Metric Badges & KPIs ─── */
.kpi-title {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.kpi-num {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.trend-badge.positive {
  background: rgba(52, 199, 89, 0.12);
  color: var(--apple-green);
}

.trend-badge.negative {
  background: rgba(255, 59, 48, 0.12);
  color: var(--apple-red);
}

/* ─── Tables ─── */
.table-wrapper {
  overflow-x: auto;
  border-radius: 10px;
}

.dealer-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12.5px;
}

.dealer-table th {
  padding: 8px 12px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.02);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  white-space: nowrap;
}

.dealer-table td {
  padding: 8px 12px;
  font-size: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  color: var(--text-main);
  white-space: nowrap;
}

.dealer-table tr:hover td {
  background: rgba(0, 113, 227, 0.02);
}

.dealer-table tr:last-child td {
  border-bottom: none;
}

/* ─── Form Controls & Selects ─── */
.apple-select {
  appearance: none;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: var(--text-main);
  padding: 6px 26px 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2386868b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: all 0.15s ease;
}

.apple-select:focus {
  border-color: var(--apple-blue);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

/* ─── AI Markdown Summary Box ─── */
.markdown-report {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.markdown-report h2 {
  font-size: 14px;
  font-weight: 700;
  margin-top: 14px;
  margin-bottom: 6px;
  color: var(--text-main);
}

.markdown-report h3 {
  font-size: 13px;
  font-weight: 600;
  margin-top: 12px;
  margin-bottom: 4px;
  color: var(--text-main);
}

.markdown-report ul {
  list-style-type: disc;
  padding-left: 18px;
  margin-bottom: 10px;
}

.markdown-report li {
  margin-bottom: 4px;
}

.markdown-report blockquote {
  border-left: 3px solid var(--apple-blue);
  padding: 8px 14px;
  margin: 10px 0;
  background: rgba(0, 113, 227, 0.05);
  border-radius: 0 8px 8px 0;
  color: var(--text-main);
  font-size: 12.5px;
}

.markdown-report table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 12px;
}

.markdown-report th, .markdown-report td {
  border: 1px solid rgba(0, 0, 0, 0.06);
  padding: 6px 10px;
  text-align: left;
}

.markdown-report th {
  background: rgba(0, 0, 0, 0.03);
  font-weight: 600;
  color: var(--text-muted);
}

/* ─── Scrollbars ─── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.22);
}

/* ─── Print ─── */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #ffffff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; zoom: 0.8 !important; }
  .no-print { display: none !important; }
  .card { box-shadow: none !important; border: 1px solid rgba(0,0,0,0.1) !important; break-inside: avoid !important; margin-bottom: 10px !important; }
  .tab-btn { display: none !important; }
  .tab-content { display: block !important; }
}
