:root {
  /* Brand Palette: Trustworthy Navy and Mint */
  --brand-primary: #1e3a8a;       /* Deep Trustworthy Navy */
  --brand-secondary: #06b6d4;     /* Bright Mint/Cyan for accents */
  --bg-main: #f8fafc;             /* Crisp cool light gray background */
  --bg-card: #ffffff;             /* Crisp white for result blocks */
  --bg-accent: #f1f5f9;           /* Soft gray-blue for secondary buttons/heads */
  --bg-cheapest: #ecfeff;         /* Super soft mint tint for the cheapest option */
  
  /* Text and Accents */
  --text-main: #1e293b;           /* Deep Slate for high legibility */
  --text-soft: #64748b;           /* Muted slate for notes and labels */
  --text-highlight: #0891b2;      /* Clear deep mint for savings callouts */
  --line: #e2e8f0;                /* Soft line border color */
  
  /* Layout Corners */
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  
  /* Font System */
  --font-heading: 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Inter', sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  padding-bottom: 40px;
}

/* UI Elements using the sharp heading font */
.display, button, input, .brand-name, .logo-mark, .package-name, .lab-name, .price-value, .chip {
  font-family: var(--font-heading);
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--brand-secondary);
  outline-offset: 2px;
}

/* ============ HEADER ============ */
.app-header {
  background: var(--brand-primary);
  color: #ffffff;
  padding: 20px 16px 22px;
}
.header-inner { max-width: 900px; margin: 0 auto; }

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
}
.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--brand-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: var(--brand-primary);
  flex-shrink: 0;
}
.brand-name {
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
}
.tagline {
  font-size: 13px;
  color: #93c5fd;
  margin: 0 0 18px 42px;
  font-weight: 500;
}

.search-row {
  display: flex;
  gap: 8px;
}
.search-field, .pincode-field {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  padding: 0 12px;
  transition: border-color 0.15s;
}
.search-field:focus-within, .pincode-field:focus-within {
  border-color: var(--brand-secondary);
}
.search-field { flex: 1; min-width: 0; }
.pincode-field { width: 110px; flex-shrink: 0; }
.field-icon { font-size: 14px; margin-right: 6px; opacity: 0.9; }

.search-field input, .pincode-field input {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 14px;
  padding: 11px 0;
  width: 100%;
  min-width: 0;
}
.search-field input::placeholder, .pincode-field input::placeholder {
  color: #93c5fd;
  opacity: 0.8;
}
.search-field input:focus, .pincode-field input:focus {
  outline: none;
}

/* ============ MAIN ============ */
.app-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 16px 0 4px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  padding: 8px 16px;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.chip:hover { border-color: var(--brand-primary); color: var(--text-main); }
.chip.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

.results-meta {
  font-size: 13px;
  color: var(--text-soft);
  padding: 12px 2px 4px;
  font-weight: 500;
}

/* ============ COMPARISON GROUPS ============ */
.results-container {
  padding: 8px 0 24px;
}

.package-group {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin-bottom: 18px;
  overflow: hidden;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.package-head {
  padding: 16px 18px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.package-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.package-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--bg-accent);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

/* Table header row - desktop only */
.offer-table-head {
  display: none;
  grid-template-columns: 1.8fr 1fr 1fr 1fr 0.9fr;
  padding: 10px 18px;
  background: var(--bg-accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.offer-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  position: relative;
}
.offer-row:first-of-type { border-top: none; }
.offer-row.cheapest { background: var(--bg-cheapest); }

.offer-cell { display: flex; justify-content: space-between; align-items: center; }
.offer-cell .cell-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
}
.offer-cell .cell-value { text-align: right; }

.lab-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.lab-name {
  font-weight: 700;
  font-size: 15px;
}
.badge-best {
  font-size: 10px;
  font-weight: 700;
  background: var(--brand-primary);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 5px;
  letter-spacing: 0.02em;
}
.lab-their-name {
  font-size: 12px;
  color: var(--text-soft);
  font-style: italic;
}

.price-value {
  font-weight: 700;
  font-size: 20px;
  color: var(--brand-primary);
}
.fee-note {
  font-size: 11px;
  color: var(--text-soft);
}

.test-count-value {
  font-weight: 600;
  font-size: 14px;
}

.row-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.expand-btn {
  flex: 1;
  background: var(--bg-accent);
  border: 1px solid var(--line);
  color: var(--brand-primary);
  font-weight: 600;
  font-size: 13px;
  padding: 9px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s;
}
.book-btn {
  flex: 1.4;
  background: var(--brand-primary);
  border: none;
  color: #ffffff;
  font-weight: 600;
  font-size: 13px;
  padding: 9px;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s;
}
.book-btn:hover { background: #172554; }
.expand-btn:hover { background: var(--line); }

.test-detail-panel {
  margin-top: 10px;
  background: var(--bg-accent);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.5;
}
.test-detail-panel.hidden { display: none; }
.test-detail-panel ul { margin: 6px 0 0; padding-left: 18px; }
.test-detail-panel li { margin-bottom: 4px; }
.test-detail-empty { color: var(--text-soft); font-style: italic; font-size: 13px; }

.save-strip {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-highlight);
  background: #e0f2fe;
  text-align: center;
  padding: 8px;
  border-top: 1px dashed var(--line);
}

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-title {
  font-weight: 700;
  font-size: 16px;
  margin: 0 0 6px;
}
.empty-sub {
  color: var(--text-soft);
  font-size: 14px;
  max-width: 320px;
  margin: 0 auto;
  line-height: 1.4;
}

/* ============ FOOTER ============ */
.app-footer {
  max-width: 900px;
  margin: 20px auto 0;
  padding: 16px 16px 0;
  border-top: 1px solid var(--line);
}
.app-footer p {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.6;
}

/* ============ INSTALL BANNER ============ */
.install-banner {
  position: fixed;
  bottom: 14px;
  left: 14px;
  right: 14px;
  max-width: 500px;
  margin: 0 auto;
  background: var(--text-main);
  color: #ffffff;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  z-index: 50;
}
.install-banner span { flex: 1; font-weight: 500; }
#installBtn {
  background: var(--brand-secondary);
  color: var(--brand-primary);
  border: none;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
}
.dismiss-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
  padding: 0 2px;
}

/* ============ DESKTOP ============ */
@media (min-width: 720px) {
  .app-header { padding: 26px 24px 28px; }
  .brand-name { font-size: 22px; }
  .search-row { max-width: 560px; }

  .app-main { padding: 0 24px; }

  .offer-table-head { display: grid; }

  .offer-row {
    grid-template-columns: 1.8fr 1fr 1fr 1fr 0.9fr;
    align-items: center;
    gap: 0;
  }
  .offer-cell { display: block; }
  .offer-cell .cell-label { display: none; }
  .offer-cell .cell-value { text-align: left; }
  .lab-name-cell { margin-bottom: 2px; }
  .row-actions { margin-top: 0; justify-content: flex-end; }
  .expand-btn { flex: none; padding: 8px 12px; }
  .book-btn { flex: none; padding: 8px 16px; }
  .test-detail-panel { grid-column: 1 / -1; margin-top: 12px; }
  .save-strip { text-align: left; padding-left: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}