/* ── Palette ── */
:root {
  --up-dark: #111827;
  --up-charcoal: #1f2937;
  --up-teal: #10b981;
  --up-teal-hover: #059669;
  --up-amber: #f59e0b;
  --up-amber-hover: #d97706;
  --up-muted: #9ca3af;
  --up-light: #f9fafb;
  --up-white: #ffffff;
  --up-border: #e5e7eb;
  --up-text: #111827;
  --up-text-secondary: #6b7280;
  --up-exact: #10b981;
  --up-prefix: #f59e0b;
  --up-contains: #9ca3af;
  --up-radius: 0.75rem;
  --up-radius-sm: 0.5rem;
  --up-shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --up-shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --up-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
}

/* ── Base ── */
html {
  font-size: 15px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html { font-size: 16px; }
}

body {
  margin: 0;
  background: var(--up-light);
  color: var(--up-text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

/* ── Header ── */
.site-header {
  background: linear-gradient(135deg, var(--up-dark) 0%, var(--up-charcoal) 100%);
  color: #fff;
  padding: 1rem 0;
  border-bottom: 2px solid var(--up-teal);
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  position: sticky;
  top: 0;
  z-index: 1030;
  backdrop-filter: blur(8px);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
  text-decoration: none;
  transition: opacity 0.15s;
}

.header-brand:hover { color: #fff; opacity: 0.85; }

.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  background: var(--up-teal);
  border-radius: var(--up-radius-sm);
  font-size: 1.1rem;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.site-header h1 {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0;
  line-height: 1.2;
}

.site-header p {
  font-size: 0.75rem;
  margin: 0;
  color: var(--up-muted);
  font-weight: 400;
  line-height: 1.3;
}

.site-header a { color: #fff; text-decoration: none; }
.site-header a:hover { color: var(--up-teal); }

/* ── Buttons ── */
.btn-up {
  background: var(--up-teal);
  color: #fff;
  border: none;
  font-weight: 600;
  border-radius: var(--up-radius-sm);
  transition: background 0.15s, box-shadow 0.15s;
}

.btn-up:hover, .btn-up:focus {
  background: var(--up-teal-hover);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

.btn:focus, .btn:active:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
  border-color: var(--up-teal);
}

.form-control {
  border-radius: var(--up-radius-sm);
  border: 1px solid var(--up-border);
  transition: border-color 0.15s, box-shadow 0.15s;
}

/* ── Spinner ── */
.spinner-border.spinner-up {
  color: var(--up-teal);
}

/* ── Cards & Surfaces ── */
.card-surface {
  background: var(--up-white);
  border-radius: var(--up-radius);
  box-shadow: var(--up-shadow);
  border: 1px solid var(--up-border);
}

/* ── Results table ── */
.table-up {
  background: var(--up-white);
  border-radius: var(--up-radius-sm);
  overflow: hidden;
  box-shadow: var(--up-shadow-sm);
}

.table-up thead {
  background: var(--up-charcoal);
  color: #fff;
}

.table-up thead th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: none;
  padding: 0.65rem 0.85rem;
}

.table-up tbody tr {
  border-bottom: 1px solid var(--up-border);
  transition: background 0.1s;
}

.table-up tbody tr:last-child {
  border-bottom: none;
}

.table-up tbody td {
  padding: 0.6rem 0.85rem;
  vertical-align: middle;
  font-size: 0.9rem;
}

/* ── Badges ── */
.badge {
  font-weight: 600;
  font-size: 0.7rem;
  padding: 0.25em 0.55em;
  border-radius: 0.35rem;
}

.badge-exact { background: var(--up-exact); color: #fff; }
.badge-prefix { background: var(--up-prefix); color: #fff; }
.badge-contains { background: var(--up-contains); color: #fff; }

/* ── Same extension highlight ── */
.row-same-ext {
  background: rgba(16, 185, 129, 0.06) !important;
  border-left: 3px solid var(--up-teal);
}

.badge-same-ext {
  background: var(--up-teal);
  color: #fff;
  font-size: 0.65rem;
  margin-left: 0.35rem;
}

/* ── Hint text ── */
.hint-text {
  color: var(--up-text-secondary);
  font-size: 0.8rem;
}

/* ── Extension badge group — joined pill ── */
.ext-group {
  display: inline-flex;
  align-items: stretch;
  margin-bottom: 0.25rem;
  border-radius: 0.35rem;
  overflow: hidden;
  border: 1px solid var(--up-border);
  background: var(--up-white);
}

.ext-group .badge {
  border-radius: 0;
  margin: 0;
  border: none;
  font-size: 0.65rem;
  padding: 0.2rem 0.45rem;
}

.ext-btn {
  font-size: 0.6rem;
  text-decoration: none;
  color: var(--up-text-secondary);
  padding: 0.15rem 0.4rem;
  border-left: 1px solid var(--up-border);
  line-height: 1.4;
  white-space: nowrap;
  background: var(--up-white);
  display: flex;
  align-items: center;
  transition: background 0.1s, color 0.1s;
}

.ext-btn:hover {
  color: #fff;
  background: var(--up-teal);
  text-decoration: none;
}

/* ── Extension sections ── */
.ext-section {
  border-radius: var(--up-radius-sm);
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.35rem;
}

.ext-section-high {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.ext-section-prospect {
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.ext-section-unlikely {
  background: rgba(156, 163, 175, 0.06);
  border: 1px solid var(--up-border);
}

.ext-section-header {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--up-amber);
  margin-bottom: 0.35rem;
}

.ext-section-header-high { color: var(--up-teal); }
.ext-section-header-muted { color: var(--up-muted); }

.ext-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
}

/* ── High potential — teal accent ── */
.badge-ext-high {
  background: var(--up-teal);
  color: #fff;
  font-size: 0.65rem;
}

.ext-section-high .ext-group {
  border-color: rgba(16, 185, 129, 0.4);
}

/* ── Upgrade opportunity — amber accent ── */
.badge-ext-upgrade {
  background: var(--up-amber);
  color: #fff;
  font-size: 0.65rem;
}

.ext-section-prospect .ext-group {
  border-color: rgba(245, 158, 11, 0.4);
}

/* ── Already owned — muted ── */
.badge-ext-owned {
  background: var(--up-light);
  color: var(--up-muted);
  font-size: 0.65rem;
}

/* ── Matrix indicator ── */
.matrix-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: var(--up-radius-sm);
  margin-bottom: 0.35rem;
}
.matrix-likely {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--up-teal);
}
.matrix-unlikely {
  background: rgba(156, 163, 175, 0.08);
  border: 1px solid var(--up-border);
  color: var(--up-muted);
}

/* ── Section headings ── */
h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ── Admin list group ── */
.list-group-item {
  border-color: var(--up-border);
  border-radius: 0;
  transition: background 0.1s;
}

.list-group-item:first-child {
  border-top-left-radius: var(--up-radius-sm);
  border-top-right-radius: var(--up-radius-sm);
}

.list-group-item:last-child {
  border-bottom-left-radius: var(--up-radius-sm);
  border-bottom-right-radius: var(--up-radius-sm);
}

.list-group-item:hover { background: var(--up-light); }

/* ── Alerts ── */
.alert { border-radius: var(--up-radius-sm); font-size: 0.9rem; }

/* ── Modal ── */
.modal-content {
  border-radius: var(--up-radius);
  border: none;
  box-shadow: var(--up-shadow-lg);
}
.modal-header { border-bottom: 1px solid var(--up-border); }
.modal-footer { border-top: 1px solid var(--up-border); }

/* ── Utility ── */
strong { font-weight: 700; }

/* ══════════════════════════════════════════
   NEW — Tabular Results Redesign
   ══════════════════════════════════════════ */

/* ── Compact search bar after results ── */
.search-compact {
  min-height: auto !important;
  padding: 1rem 0 0.5rem;
}
.search-compact .hint-text { display: none; }

/* ── Stats bar ── */
.stats-bar {
  display: flex;
  gap: 1.5rem;
  padding: 0.85rem 1.25rem;
  background: var(--up-white);
  border: 1px solid var(--up-border);
  border-radius: var(--up-radius);
  box-shadow: var(--up-shadow-sm);
  flex-wrap: wrap;
}
.stat-item { text-align: center; min-width: 70px; }
.stat-value { display: block; font-size: 1.4rem; font-weight: 800; color: var(--up-text); line-height: 1.2; }
.stat-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--up-text-secondary); }
.stat-hot { color: var(--up-teal); }
.stat-warm { color: var(--up-amber); }
.stat-cold { color: var(--up-muted); }

/* ── Toolbar ── */
.toolbar .btn-group .btn.active {
  background: var(--up-charcoal);
  color: #fff;
  border-color: var(--up-charcoal);
}

/* ── Table wrapper ── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--up-radius);
  box-shadow: var(--up-shadow);
  border: 1px solid var(--up-border);
  background: var(--up-white);
}

.table-wrap .table-up {
  box-shadow: none;
  border-radius: 0;
  margin-bottom: 0;
}

/* ── Sortable columns ── */
th.sortable { cursor: pointer; user-select: none; position: relative; }
th.sortable:hover { background: rgba(255,255,255,0.08); }
th.sortable::after {
  content: '\2195';
  margin-left: 0.3rem;
  opacity: 0.35;
  font-size: 0.65rem;
}
th.sortable.sort-asc::after { content: '\2191'; opacity: 1; }
th.sortable.sort-desc::after { content: '\2193'; opacity: 1; }

/* ── Inline score bar ── */
.score-bar-inline {
  width: 56px;
  height: 6px;
  background: var(--up-border);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}
.score-fill-inline {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}
.score-num {
  font-weight: 700;
  font-size: 0.85rem;
  min-width: 24px;
  text-align: right;
}
.score-hot { color: var(--up-teal); }
.score-warm { color: var(--up-amber); }
.score-cold { color: var(--up-muted); }

/* ── Group header rows ── */
.group-header td {
  background: var(--up-light) !important;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.55rem 0.85rem !important;
  border-bottom: 2px solid var(--up-border) !important;
  border-top: 2px solid var(--up-border) !important;
  color: var(--up-text-secondary);
}
.group-header td:first-child {
  border-left: 4px solid var(--up-muted) !important;
}
.group-header.group-hot td:first-child { border-left-color: var(--up-teal) !important; }
.group-header.group-warm td:first-child { border-left-color: var(--up-amber) !important; }
.group-header.group-cold td:first-child { border-left-color: var(--up-muted) !important; }
/* Indent data rows under group headers */
.prospect-row > td:first-child {
  padding-left: 1.5rem !important;
  border-left: 4px solid transparent;
}
.group-hot ~ .prospect-row > td:first-child { border-left-color: rgba(16, 185, 129, 0.15); }
.group-warm ~ .prospect-row > td:first-child { border-left-color: rgba(217, 119, 6, 0.15); }
.group-cold ~ .prospect-row > td:first-child { border-left-color: rgba(156, 163, 175, 0.15); }
tr.score-extra.score-hidden {
  display: none;
}
.btn-score-expand {
  background: none;
  border: 1px solid var(--up-border);
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--up-teal);
  cursor: pointer;
  padding: 1px 8px;
  margin-left: 8px;
  vertical-align: middle;
}
.btn-score-expand:hover {
  background: var(--up-teal);
  color: #fff;
}
.group-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
}
.dot-hot { background: var(--up-teal); }
.dot-warm { background: var(--up-amber); }
.dot-cold { background: var(--up-muted); }

/* ── Prospect rows ── */
.prospect-row { cursor: pointer; }
.prospect-row:hover { background: rgba(16, 185, 129, 0.04) !important; }
.prospect-row.row-same-ext:hover { background: rgba(16, 185, 129, 0.09) !important; }

/* ── Expand button ── */
.btn-expand {
  background: none;
  border: none;
  color: var(--up-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.2s;
  padding: 0.2rem 0.4rem;
  line-height: 1;
}
.btn-expand.expanded { transform: rotate(180deg); }

/* ── Detail row ── */
.detail-row > td {
  padding: 0 !important;
  border-bottom: 2px solid var(--up-border) !important;
}
.detail-panel {
  display: grid;
  /*grid-template-columns: 1fr 1fr 1fr;*/
  gap: 1.25rem;
  padding: 1.25rem;
  background: var(--up-light);
}
@media (max-width: 767px) {
  .detail-panel { grid-template-columns: 1fr; }
}
.detail-section h6 {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--up-text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 700;
}
.detail-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.8rem;
}
.detail-section ul li {
  padding: 0.15rem 0;
  color: var(--up-text-secondary);
}

/* ── Compact extension pills for table cells ── */
.ext-pill {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.12rem 0.35rem;
  border-radius: 0.25rem;
  background: var(--up-light);
  border: 1px solid var(--up-border);
  color: var(--up-text-secondary);
  margin: 1px;
  line-height: 1.3;
}
.ext-pill.ext-upgrade {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--up-amber-hover);
}

/* ── Matrix dot ── */
.matrix-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.matrix-dot-likely {
  background: var(--up-teal);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}
.matrix-dot-unlikely {
  background: var(--up-border);
}
