:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --header-bg: #1a1a2e;
  --accent: #4361ee;
  --accent-hover: #3a56d4;
  --text: #2d3436;
  --text-secondary: #636e72;
  --border: #dfe6e9;
  --great: #10b981;
  --good: #34d399;
  --fair: #fbbf24;
  --high: #f97316;
  --over: #ef4444;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* Header */
header { background: var(--header-bg); color: #fff; padding: 16px 0; }
header .container { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
#user-bar { display: flex; align-items: center; gap: 10px; }
#user-bar span { color: #a0a0c0; font-size: 13px; }
header h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
header span { color: #a0a0c0; font-size: 13px; }

/* Layout */
.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.panel { display: none; }
.panel.active { display: block; }

/* Buttons */
.btn { padding: 12px 24px; border: none; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.btn-primary { background: var(--accent); color: #fff; width: 100%; margin-top: 8px; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 6px 14px; font-size: 12px; }

/* Login */
.login-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px; margin: 80px auto; max-width: 380px; }
.login-card h2 { font-size: 18px; margin-bottom: 20px; text-align: center; }
.login-error { color: var(--over); font-size: 13px; margin-top: 10px; text-align: center; }

/* Search Form */
.search-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px; margin: 40px auto; max-width: 600px; }
.search-card h2 { font-size: 18px; margin-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.form-group input, .form-group select {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; outline: none; transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--accent); }

/* Loading */
.loading-box { text-align: center; padding: 60px 20px; }
.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-secondary); font-size: 14px; }

/* Results */
.results-header { display: flex; justify-content: space-between; align-items: center; margin: 24px 0 16px; flex-wrap: wrap; gap: 12px; }
.results-header h2 { font-size: 18px; }
.results-meta { display: flex; gap: 16px; align-items: center; font-size: 13px; color: var(--text-secondary); }
.warn-badge { background: #fef3c7; color: #92400e; padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.filter-bar { margin-bottom: 12px; }
.filter-bar input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }

/* Table */
.table-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: #f8f9fa; padding: 10px 12px; text-align: left; font-weight: 600; color: var(--text-secondary); cursor: pointer; user-select: none; white-space: nowrap; border-bottom: 2px solid var(--border); }
th:hover { color: var(--accent); }
th .sort-arrow { font-size: 10px; margin-left: 4px; }
td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; white-space: nowrap; }
tr:hover td { background: #f8f9ff; }
.price-col { font-weight: 600; color: var(--text); }
.mileage-col { color: var(--text-secondary); }

/* Deal badges */
.deal-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; color: #fff; }
.deal-Great { background: var(--great); }
.deal-Good { background: var(--good); color: #065f46; }
.deal-Fair { background: var(--fair); color: #78350f; }
.deal-High { background: var(--high); }
.deal-Overpriced { background: var(--over); }

/* Source tags */
.source-tag { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 10px; background: #e8eaf6; color: #3949ab; margin-right: 2px; }

/* Intel button */
.btn-intel { background: var(--accent); color: #fff; border: none; padding: 4px 12px; border-radius: 4px; font-size: 11px; cursor: pointer; font-weight: 600; }
.btn-intel:hover { background: var(--accent-hover); }

/* Brief */
.brief-header { display: flex; align-items: flex-start; gap: 20px; margin: 24px 0 20px; }
.brief-gallery { flex-shrink: 0; }
.brief-hero-img { width: 320px; height: 220px; object-fit: cover; border-radius: var(--radius); background: var(--border); display: block; }
.brief-thumbs { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.brief-thumb { width: 50px; height: 36px; object-fit: cover; border-radius: 4px; cursor: pointer; border: 2px solid transparent; opacity: 0.7; transition: all 0.2s; }
.brief-thumb:hover, .brief-thumb.active { opacity: 1; border-color: var(--accent); }
.thumb-more { display: inline-flex; align-items: center; justify-content: center; width: 50px; height: 36px; background: var(--border); border-radius: 4px; font-size: 11px; color: var(--text-secondary); }
.brief-hero-info h2 { font-size: 22px; margin-bottom: 4px; }
.brief-hero-info .price-big { font-size: 28px; font-weight: 700; color: var(--accent); }
.brief-hero-info .meta-line { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* Dimension cards */
.dim-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; margin-bottom: 24px; }
.dim-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.dim-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.dim-num { background: var(--accent); color: #fff; font-size: 11px; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.dim-card .row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.dim-card .row .label { color: var(--text-secondary); }
.dim-card .row .value { font-weight: 600; }
.percentile-bar { height: 8px; background: var(--border); border-radius: 4px; margin-top: 8px; position: relative; }
.percentile-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.5s; }

/* BATNA table */
.batna-table { width: 100%; font-size: 12px; border-collapse: collapse; }
.batna-table th { font-size: 11px; padding: 4px 6px; }
.batna-table td { padding: 4px 6px; border-bottom: 1px solid #f0f0f0; }

/* Misc */
.recall-warn { color: var(--over); font-weight: 600; }
.collapse-toggle { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 600; margin-top: 16px; }
.collapse-content { display: none; margin-top: 12px; }
.collapse-content.open { display: block; }
.llm-prompt { background: #f8f9fa; padding: 16px; border-radius: 6px; font-family: monospace; font-size: 12px; white-space: pre-wrap; word-break: break-word; max-height: 500px; overflow-y: auto; }
.copy-btn { font-size: 11px; padding: 4px 10px; margin-left: 8px; }
.error-banner { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 12px 16px; border-radius: var(--radius); margin: 16px 0; }
.empty-state { text-align: center; padding: 40px; color: var(--text-secondary); }

/* Comparables section */
.comparables-section { margin-bottom: 24px; }
.comparables-section h3 { font-size: 16px; margin-bottom: 12px; }
.comp-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.comp-table th { background: #f8f9fa; padding: 8px 10px; text-align: left; font-weight: 600; color: var(--text-secondary); white-space: nowrap; border-bottom: 2px solid var(--border); font-size: 11px; }
.comp-table td { padding: 8px 10px; border-bottom: 1px solid #f0f0f0; white-space: nowrap; }
.comp-table tr:hover td { background: #f8f9ff; }

/* Features grid */
.features-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.feature-tag { display: inline-block; padding: 3px 10px; background: #f0f4ff; color: var(--accent); border-radius: 12px; font-size: 11px; font-weight: 500; }

/* Links */
.link-ext { color: var(--accent); text-decoration: none; font-size: 12px; font-weight: 500; }
.link-ext:hover { text-decoration: underline; }
