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

:root {
  --font: Arial, "Helvetica Neue", Helvetica, Ubuntu, sans-serif;
  --bg: #f8f9fa;
  --surface: #ffffff;
  --border: #e0e3e8;
  --text: #1a1c1f;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --nav-h: 44px;
  --header-h: 80px;
  --sidebar-w: 230px;
  --tab-bar-h: 41px;
  --radius: 6px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
}

body {
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--nav-h);
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}

h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 500px;
  min-width: 260px;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  transition: border-color 0.15s;
}
.search-box:focus-within {
  border-color: var(--accent);
  background: var(--surface);
}

.search-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-right: 8px;
}

#search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 14px;
  padding: 9px 0;
  outline: none;
  color: var(--text);
}
#search-input::placeholder { color: #aaa; }

/* ── Search dropdown ────────────────────────────────────────────────────── */
.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  list-style: none;
  z-index: 200;
  overflow: hidden;
}

.search-dropdown li {
  padding: 9px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid var(--border);
}
.search-dropdown li:last-child { border-bottom: none; }
.search-dropdown li:hover,
.search-dropdown li.focused { background: #f0f4ff; }

.dropdown-name  { font-weight: 600; font-size: 13px; }
.dropdown-meta  { font-size: 11px; color: var(--text-muted); }

.no-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-muted);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  z-index: 200;
}

.hidden { display: none !important; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 24px;
  gap: 20px;
  align-items: flex-start;
}

/* ── Property sidebar ───────────────────────────────────────────────────── */
#property-panel {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: sticky;
  top: calc(var(--nav-h) + var(--header-h) + var(--tab-bar-h) + 20px);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.link-btn {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
}
.link-btn:hover { text-decoration: underline; }

.sep { color: var(--border); font-size: 12px; }

.property-list {
  list-style: none;
  padding: 8px 0;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.property-list li {
  padding: 0;
}

.property-list label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.3;
  user-select: none;
  transition: background 0.1s;
}
.property-list label:hover { background: #f5f7fa; }

.property-list input[type="checkbox"] {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.prop-label-text { flex: 1; }
.prop-unit { font-size: 11px; color: #aaa; white-space: nowrap; }

/* ── Main area ──────────────────────────────────────────────────────────── */
#main-area {
  flex: 1;
  min-width: 0;
}

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 80px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
}
.empty-state svg { width: 56px; height: 56px; }

/* ── Table wrapper ──────────────────────────────────────────────────────── */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
  overflow-y: visible;
}

/* ── Comparison table ───────────────────────────────────────────────────── */
#comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: auto;
}

/* Sticky property-name column */
#comparison-table th:first-child,
#comparison-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  min-width: 200px;
  max-width: 240px;
  border-right: 2px solid var(--border);
}

/* Column header rows */
#comparison-table thead tr {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
}

#comparison-table thead th {
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: bottom;
}

/* Top-left corner cell */
#comparison-table thead th:first-child {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Material column headers */
.col-header {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 160px;
}

.col-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.col-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.col-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.col-source-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: #aaa;
  text-decoration: none;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}
.col-source-link:hover { color: var(--accent); background: rgba(37,99,235,0.08); }
.col-source-link svg { width: 12px; height: 12px; }

.col-remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  cursor: pointer;
  color: #bbb;
  border-radius: 3px;
  padding: 0;
  transition: color 0.15s, background 0.15s;
}
.col-remove-btn:hover { color: #e02020; background: rgba(224,32,32,0.08); }
.col-remove-btn svg { width: 12px; height: 12px; }

.col-condition {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.col-category {
  font-size: 11px;
  color: #aaa;
}

/* Data rows */
#comparison-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
#comparison-table tbody tr:last-child { border-bottom: none; }
#comparison-table tbody tr:hover td,
#comparison-table tbody tr:hover th {
  filter: brightness(0.97);
}

#comparison-table tbody th {
  padding: 9px 14px;
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  line-height: 1.3;
}

.prop-th-unit {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: #aaa;
  margin-top: 1px;
}

#comparison-table tbody td {
  padding: 9px 14px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td.value-null {
  color: #ccc;
  text-align: center;
  font-size: 12px;
}

/* ── Column colors ──────────────────────────────────────────────────────── */
/* Applied as inline styles from JS — defined here as reference palette
   Colors are very light pastels; used on both thead th and tbody td. */

/* ── Sources footer ─────────────────────────────────────────────────────── */
.sources-footer {
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: center;
}

.sources-footer strong {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #aaa;
  margin-right: 2px;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 6px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  text-decoration: none;
  color: var(--text-muted);
  transition: border-color 0.15s, color 0.15s;
}
.source-chip:hover { border-color: var(--accent); color: var(--accent); }
.source-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Scrollbar styling (webkit) ─────────────────────────────────────────── */
.table-scroll::-webkit-scrollbar { height: 6px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
.table-scroll::-webkit-scrollbar-thumb { background: #dde; border-radius: 3px; }

.property-list::-webkit-scrollbar { width: 4px; }
.property-list::-webkit-scrollbar-thumb { background: #dde; border-radius: 2px; }

/* ── Tab bar ─────────────────────────────────────────────────────────────── */
.tab-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: calc(var(--nav-h) + var(--header-h));
  z-index: 90;
}

.tab-bar-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 10px 16px;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ── Finder panel ────────────────────────────────────────────────────────── */
#finder-panel {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: sticky;
  top: calc(var(--nav-h) + var(--header-h) + var(--tab-bar-h) + 20px);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--nav-h) - var(--header-h) - var(--tab-bar-h) - 40px);
}

.finder-inputs {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.finder-input-row {
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
}
.finder-input-row:last-child { border-bottom: none; }

.finder-prop-name {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.finder-input-field {
  display: flex;
  align-items: center;
  gap: 6px;
}

.finder-num-input {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  font-family: var(--font);
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  -moz-appearance: textfield;
}
.finder-num-input:focus {
  border-color: var(--accent);
  background: var(--surface);
}
.finder-num-input::-webkit-outer-spin-button,
.finder-num-input::-webkit-inner-spin-button { -webkit-appearance: none; }

.finder-panel-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.find-btn {
  width: 100%;
  padding: 9px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.find-btn:hover { background: #1d4ed8; }

/* ── Finder main area ────────────────────────────────────────────────────── */
#finder-main {
  flex: 1;
  min-width: 0;
}

.finder-count-bar {
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Finder table (mirrors comparison-table styles) ──────────────────────── */
#finder-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: auto;
}

#finder-table th:first-child,
#finder-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  min-width: 200px;
  max-width: 240px;
  border-right: 2px solid var(--border);
}

#finder-table thead tr {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
}

#finder-table thead th {
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: bottom;
}

#finder-table thead th:first-child {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#finder-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
#finder-table tbody tr:last-child { border-bottom: none; }
#finder-table tbody tr:hover td,
#finder-table tbody tr:hover th { filter: brightness(0.97); }

#finder-table tbody th {
  padding: 9px 14px;
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  line-height: 1.3;
}

#finder-table tbody td {
  padding: 9px 14px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Rows where a filter criterion was applied */
#finder-table tbody tr.finder-filtered-row th { background: #f0fdf4; }
#finder-table tbody tr.finder-filtered-row td { background: #f0fdf4; }

/* ── Finder scrollbar ────────────────────────────────────────────────────── */
.finder-inputs::-webkit-scrollbar { width: 4px; }
.finder-inputs::-webkit-scrollbar-thumb { background: #dde; border-radius: 2px; }
