:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg-main: #f5f5f7;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-solid: #ffffff;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: #0071e3;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-muted: #86868b;
  
  --apple-blue: #0071e3;
  --apple-blue-hover: #0077ed;
  --apple-blue-light: rgba(0, 113, 227, 0.08);
  
  --brand-ecovacs: #0066cc;
  --brand-ecovacs-bg: rgba(0, 102, 204, 0.08);
  --brand-roborock: #e02424;
  --brand-roborock-bg: rgba(224, 36, 36, 0.08);
  --brand-dreame: #d97706;
  --brand-dreame-bg: rgba(217, 119, 6, 0.08);
  
  --color-success: #34c759;
  --color-success-bg: rgba(52, 199, 89, 0.1);
  --color-warning: #ff9f0a;
  --color-warning-bg: rgba(255, 159, 10, 0.1);
  --color-danger: #ff3b30;
  --color-danger-bg: rgba(255, 59, 48, 0.1);
  --color-purple: #af52de;
  --color-purple-bg: rgba(175, 82, 222, 0.1);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding: 16px 20px;
  font-size: 13.5px;
}

/* Glassmorphism Panel */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

/* Header Area */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  margin-bottom: 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.92);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0071e3 0%, #4338ca 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
}

.header-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.header-text p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 3px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Language Switcher */
.lang-switcher {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.05);
  padding: 3px;
  border-radius: 20px;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.lang-btn {
  background: transparent;
  border: none;
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-btn.active {
  background: #ffffff;
  color: var(--text-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Action Buttons */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-primary);
  transition: all 0.2s ease;
  text-decoration: none;
}

.action-btn:hover {
  background: #f0f0f2;
  border-color: rgba(0, 0, 0, 0.15);
}

.action-btn.btn-primary {
  background: var(--apple-blue);
  color: white;
  border-color: var(--apple-blue);
}

.action-btn.btn-primary:hover {
  background: var(--apple-blue-hover);
}

/* Navigation & Controls Bar */
.controls-bar {
  padding: 14px 20px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.controls-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* View Mode Switcher */
.view-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.04);
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.view-tab {
  border: none;
  background: transparent;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.view-tab.active {
  background: #ffffff;
  color: var(--apple-blue);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* Search Box */
.search-wrapper {
  position: relative;
  min-width: 240px;
  max-width: 320px;
  flex-grow: 1;
}

.search-input {
  width: 100%;
  padding: 7px 12px 7px 32px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: #ffffff;
  font-size: 12.5px;
  outline: none;
  transition: all 0.2s;
}

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

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Filters Row */
.filters-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.filter-pills-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-right: 4px;
}

.pill-btn {
  border: 1px solid var(--border-color);
  background: #ffffff;
  padding: 4px 11px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.pill-btn:hover {
  background: #f5f5f7;
  color: var(--text-primary);
}

.pill-btn.active {
  background: var(--text-primary);
  color: white;
  border-color: var(--text-primary);
}

/* Toggle Switch */
.toggle-switch-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #e5e5ea;
  transition: .25s;
  border-radius: 22px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .25s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input:checked + .slider {
  background-color: var(--apple-blue);
}

input:checked + .slider:before {
  transform: translateX(16px);
}

.toggle-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  user-select: none;
}

/* Matrix Table View */
.matrix-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #ffffff;
  box-shadow: var(--shadow-sm);
  position: relative;
  max-height: calc(100vh - 220px);
}

.matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

/* Sticky Headers */
.matrix-table thead th {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #ffffff;
  border-bottom: 2px solid var(--border-color);
  padding: 12px 10px;
  text-align: center;
  vertical-align: top;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

/* Sticky Feature Column (First Column) */
.matrix-table th.col-feature,
.matrix-table td.col-feature {
  position: sticky;
  left: 0;
  z-index: 15;
  background: #fdfdfd;
  border-right: 1px solid var(--border-color);
  min-width: 220px;
  max-width: 260px;
  width: 240px;
  text-align: left;
  font-weight: 600;
  padding: 10px 14px;
}

.matrix-table thead th.col-feature {
  z-index: 30;
  background: #f8f9fa;
  min-width: 220px;
  width: 240px;
}

/* Section Header Rows */
.section-row td {
  background: #f1f5f9 !important;
  color: #1e293b;
  font-weight: 700;
  font-size: 12.5px;
  padding: 8px 14px;
  border-top: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
  position: sticky;
  left: 0;
  z-index: 10;
}

/* Data Cells */
.matrix-table tbody tr {
  transition: background-color 0.15s ease;
}

.matrix-table tbody tr:hover {
  background-color: #f8fafc;
}

.matrix-table tbody tr:hover td.col-feature {
  background-color: #f1f5f9;
}

.matrix-table tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  border-right: 1px solid rgba(0, 0, 0, 0.04);
  text-align: center;
  vertical-align: middle;
  min-width: 140px;
  max-width: 200px;
  word-break: break-word;
  line-height: 1.35;
}

/* Highlight difference row */
.row-diff {
  background-color: rgba(254, 243, 199, 0.35);
}

.row-diff td.col-feature {
  border-left: 3px solid #f59e0b;
}

/* Product Header Card */
.model-header-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 130px;
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.brand-badge.ecovacs {
  background: var(--brand-ecovacs-bg);
  color: var(--brand-ecovacs);
}

.brand-badge.roborock {
  background: var(--brand-roborock-bg);
  color: var(--brand-roborock);
}

.brand-badge.dreame {
  background: var(--brand-dreame-bg);
  color: var(--brand-dreame);
}

.model-name-text {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.25;
}

.project-code-tag {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
  background: rgba(0,0,0,0.03);
  padding: 1px 6px;
  border-radius: 6px;
}

.tier-pill {
  font-size: 9.5px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
}

.tier-pill.flagship {
  background: rgba(14, 165, 233, 0.1);
  color: #0369a1;
}

.tier-pill.ultra {
  background: rgba(147, 51, 234, 0.1);
  color: #7e22ce;
}

/* Value Format Badges */
.val-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 11.5px;
}

.val-badge.val-yes {
  background: var(--color-success-bg);
  color: #15803d;
  font-weight: 600;
}

.val-badge.val-no {
  background: rgba(0,0,0,0.04);
  color: #94a3b8;
}

.val-badge.val-highlight {
  background: rgba(0, 113, 227, 0.08);
  color: #0071e3;
  font-weight: 600;
}

.val-badge.val-hot {
  background: rgba(239, 68, 68, 0.08);
  color: #dc2626;
  font-weight: 600;
}

/* Card Grid View */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  padding: 4px;
}

.product-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(0, 113, 227, 0.3);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  padding-bottom: 10px;
}

.card-specs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-spec-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 3px 0;
  border-bottom: 1px dashed rgba(0,0,0,0.04);
}

.card-spec-name {
  color: var(--text-secondary);
  font-weight: 500;
}

.card-spec-value {
  font-weight: 600;
  text-align: right;
  max-width: 60%;
}

.card-usp-box {
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px;
  font-size: 11.5px;
  color: #334155;
  line-height: 1.4;
  border-left: 3px solid var(--apple-blue);
  margin-top: auto;
}

/* Side-by-Side Comparator */
.comparator-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.comparator-selectors {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  background: #ffffff;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.comparator-slot {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comparator-slot label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.comparator-select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  font-size: 12.5px;
  background: #ffffff;
  outline: none;
}

.comparator-select:focus {
  border-color: var(--apple-blue);
}

/* Notes Section */
.notes-section {
  margin-top: 24px;
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 18px 24px;
}

.notes-header {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.note-item {
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  border-left: 3px solid var(--apple-blue);
}

.note-item h4 {
  font-size: 12.5px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
}

.note-item p {
  color: #475569;
  line-height: 1.45;
}

/* Responsive & Print */
@media print {
  body {
    background: #ffffff;
    padding: 0;
  }
  .app-header, .controls-bar {
    box-shadow: none;
    border: none;
  }
  .lang-switcher, .action-btn, .search-wrapper, .view-tabs {
    display: none !important;
  }
  .matrix-container {
    max-height: none !important;
    overflow: visible !important;
    border: none !important;
  }
}

@media (max-width: 768px) {
  body {
    padding: 10px;
  }
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .header-right {
    width: 100%;
    justify-content: space-between;
  }
  .controls-top-row {
    flex-direction: column;
    align-items: stretch;
  }
}
