/* ── CSS Custom Properties ─────────────────────────────────────────────── */
:root {
  --bg:           #0f1117;
  --bg-header:    linear-gradient(135deg, #1a1d2e 0%, #16213e 100%);
  --bg-controls:  #13161f;
  --bg-input:     #1e2535;
  --bg-thead:     #13161f;
  --bg-row-hover: #181c2a;
  --bg-bar:       #1e2535;
  --bg-footer-border: #1e2535;

  --border:       #2d3748;
  --border-ctrl:  #2d3748;
  --border-btn:   #374151;
  --border-row:   #1a1d2e;
  --border-thead: #2d3748;

  --text:         #e2e8f0;
  --text-sub:     #94a3b8;
  --text-muted:   #64748b;
  --text-model:   #cbd5e1;
  --text-th:      #94a3b8;
  --text-th-hover:#e2e8f0;
  --text-footer:  #4b5563;
  --text-footer-a:#64748b;
  --text-footer-hover:#94a3b8;

  --accent:       #60a5fa;
  --accent-focus-shadow: rgba(96, 165, 250, 0.12);

  --price-new:    #4ade80;
  --price-used:   #fbbf24;
  --price-na:     #4b5563;
  --affiliate:    #fbbf24;
  --affiliate-hover: #fde68a;

  --badge-2025-bg: #1a2e1a; --badge-2025-fg: #4ade80;
  --badge-2024-bg: #1e2d3d; --badge-2024-fg: #38bdf8;
  --badge-2023-bg: #2d1f3d; --badge-2023-fg: #a78bfa;
  --badge-old-bg:  #2d2010; --badge-old-fg:  #fb923c;

  --no-results:   #4b5563;

  --r-top:  #4ade80;
  --r-good: #60a5fa;
  --r-mid:  #fbbf24;
  --r-low:  #f87171;

  color-scheme: dark;
}

body.light {
  --bg:           #f1f5f9;
  --bg-header:    linear-gradient(135deg, #dbeafe 0%, #ede9fe 100%);
  --bg-controls:  #e2e8f0;
  --bg-input:     #ffffff;
  --bg-thead:     #e2e8f0;
  --bg-row-hover: #f8fafc;
  --bg-bar:       #cbd5e1;
  --bg-footer-border: #cbd5e1;

  --border:       #cbd5e1;
  --border-ctrl:  #cbd5e1;
  --border-btn:   #94a3b8;
  --border-row:   #e2e8f0;
  --border-thead: #94a3b8;

  --text:         #0f172a;
  --text-sub:     #475569;
  --text-muted:   #64748b;
  --text-model:   #1e293b;
  --text-th:      #475569;
  --text-th-hover:#0f172a;
  --text-footer:  #94a3b8;
  --text-footer-a:#64748b;
  --text-footer-hover:#475569;

  --accent:       #3b82f6;
  --accent-focus-shadow: rgba(59, 130, 246, 0.15);

  --price-new:    #16a34a;
  --price-used:   #d97706;
  --price-na:     #94a3b8;
  --affiliate:    #d97706;
  --affiliate-hover: #b45309;

  --badge-2025-bg: #dcfce7; --badge-2025-fg: #166534;
  --badge-2024-bg: #dbeafe; --badge-2024-fg: #1d4ed8;
  --badge-2023-bg: #ede9fe; --badge-2023-fg: #6d28d9;
  --badge-old-bg:  #ffedd5; --badge-old-fg:  #c2410c;

  --no-results:   #94a3b8;

  --r-top:  #16a34a;
  --r-good: #2563eb;
  --r-mid:  #d97706;
  --r-low:  #dc2626;

  color-scheme: light;
}

/* ── Theme Toggle Button ─────────────────────────────────────────────────── */
.btn-theme {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-sub);
  border-radius: 8px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-theme:hover {
  background: var(--bg-controls);
  color: var(--text);
  border-color: var(--accent);
}

/* ── Base ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

body.app-layout {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  padding: 2rem 2rem 1.5rem;
  text-align: center;
  position: relative;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(90deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

header p {
  color: var(--text-sub);
  margin-top: 0.4rem;
  font-size: 0.9rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1.25rem 2rem;
  background: var(--bg-controls);
  border-bottom: 1px solid var(--border);
  align-items: flex-end;
  transition: background 0.2s;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.control-group label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.controls input,
.controls select {
  background: var(--bg-input);
  border: 1px solid var(--border-ctrl);
  color: var(--text);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  height: 36px;
}

.controls input:focus,
.controls select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-focus-shadow);
}

.controls input[type="number"] { width: 90px; }
.controls input[type="text"]   { width: 180px; }

.range-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.range-group span { color: var(--text-muted); font-size: 0.8rem; }

.btn-reset {
  background: var(--bg-input);
  border: 1px solid var(--border-btn);
  color: var(--text-sub);
  padding: 0 1rem;
  border-radius: 8px;
  height: 36px;
  cursor: pointer;
  font-size: 0.82rem;
  align-self: flex-end;
  transition: background 0.15s, color 0.15s;
}

.btn-reset:hover { background: var(--bg-controls); color: var(--text); }

.stats {
  padding: 0.6rem 2rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg);
  transition: background 0.2s;
}

.stats span { color: var(--text-sub); font-weight: 600; }

.table-wrapper {
  overflow: auto;
  flex: 1 1 0;
  min-height: 0;
  padding-bottom: 2rem;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.83rem;
  min-width: 1100px;
}

thead tr {
  background: var(--bg-thead);
  transition: background 0.2s;
}

th {
  padding: 0.85rem 0.9rem;
  text-align: left;
  white-space: nowrap;
  color: var(--text-th);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-thead);
  transition: color 0.15s;
  border-bottom: 2px solid var(--border-thead);
}

th[data-col="brand"] {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 4;
  background: var(--bg-controls);
  width: 110px;
  min-width: 110px;
  max-width: 110px;
}

th[data-col="model"] {
  position: sticky;
  top: 0;
  left: 110px;
  z-index: 4;
  background: var(--bg-controls);
  border-right: 2px solid var(--accent);
}

th:hover { color: var(--text-th-hover); }

th.sort-asc::after  { content: ' ▲'; color: var(--accent); font-size: 0.65rem; }
th.sort-desc::after { content: ' ▼'; color: var(--accent); font-size: 0.65rem; }

tbody tr {
  transition: background 0.12s;
}

tbody tr:hover { background: var(--bg-row-hover); }

td {
  padding: 0.75rem 0.9rem;
  vertical-align: middle;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-row);
}

td.brand {
  font-weight: 700;
  color: var(--text);
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--bg-controls);
  width: 110px;
  min-width: 110px;
  max-width: 110px;
}

td.model {
  color: var(--text-model);
  font-weight: 500;
  position: sticky;
  left: 110px;
  z-index: 1;
  background: var(--bg-controls);
  border-right: 2px solid var(--accent);
}

tbody tr:hover td.brand,
tbody tr:hover td.model {
  background: var(--bg-row-hover);
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.badge-2025  { background: var(--badge-2025-bg); color: var(--badge-2025-fg); }
.badge-2024  { background: var(--badge-2024-bg); color: var(--badge-2024-fg); }
.badge-2023  { background: var(--badge-2023-bg); color: var(--badge-2023-fg); }
.badge-older { background: var(--badge-old-bg);  color: var(--badge-old-fg);  }

.price-new  { color: var(--price-new); font-weight: 600; }
.price-used { color: var(--price-used); font-weight: 500; }
.price-na   { color: var(--price-na); }

.affiliate-link {
  color: var(--affiliate);
  text-decoration: none;
  border-bottom: 1px dashed rgba(251, 191, 36, 0.4);
  transition: color 0.15s, border-color 0.15s;
}

.affiliate-link:hover {
  color: var(--affiliate-hover);
  border-bottom-color: var(--affiliate-hover);
}

.screen-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.bar-outer {
  width: 60px;
  height: 6px;
  background: var(--bg-bar);
  border-radius: 3px;
  overflow: hidden;
}

.bar-inner {
  height: 100%;
  background: linear-gradient(90deg, #60a5fa, #a78bfa);
  border-radius: 3px;
  transition: width 0.3s;
}

/* ── Rating Cells ───────────────────────────────────────────────────────── */
.rating-cell {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.rating-score {
  font-weight: 700;
  font-size: 0.8rem;
  min-width: 14px;
  text-align: right;
}

.rating-bar-outer {
  width: 44px;
  height: 4px;
  background: var(--bg-bar);
  border-radius: 2px;
  overflow: hidden;
}

.rating-bar-inner {
  height: 100%;
  border-radius: 2px;
}

.r-top  { color: var(--r-top);  }
.r-good { color: var(--r-good); }
.r-mid  { color: var(--r-mid);  }
.r-low  { color: var(--r-low);  }

.rating-bar-inner.r-top  { background: var(--r-top);  }
.rating-bar-inner.r-good { background: var(--r-good); }
.rating-bar-inner.r-mid  { background: var(--r-mid);  }
.rating-bar-inner.r-low  { background: var(--r-low);  }

/* ── Phone Silhouette ─────────────────────────────────────────────────────── */
.th-silhouette {
  cursor: default !important;
  text-align: center;
}
.th-silhouette:hover { color: var(--text-th) !important; }

td.phone-cell {
  padding: 0.3rem 0.75rem;
  text-align: center;
  vertical-align: middle;
}

.phone-sil { display: block; margin: auto; overflow: visible; }

.sil-bg {
  fill: none;
  stroke: var(--text-sub);
  stroke-width: 1.25;
}

.sil-fg {
  fill: var(--text-sub);
  opacity: 0.9;
}

.no-results {
  text-align: center;
  padding: 3rem;
  color: var(--no-results);
  font-size: 1rem;
}

footer {
  text-align: center;
  padding: 1.25rem 2rem;
  border-top: 1px solid var(--bg-footer-border);
  font-size: 0.8rem;
  color: var(--text-footer);
  transition: border-color 0.2s;
}

footer a {
  color: var(--text-footer-a);
  text-decoration: none;
  transition: color 0.15s;
}

footer a:hover { color: var(--text-footer-hover); }

footer span { margin: 0 0.5rem; }

@media (max-width: 700px) {
  .controls { padding: 1rem; }
  .table-wrapper { padding-bottom: 2rem; }
  header { padding: 1.5rem 1rem 1rem; }
  header h1 { font-size: 1.4rem; }
  .btn-theme { top: 0.75rem; right: 0.75rem; font-size: 0.75rem; padding: 0.3rem 0.6rem; }
}
