:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --ink: #202124;
  --muted: #5f6368;
  --line: #e8eaed;
  --blue: #1a73e8;
  --blue-soft: #e8f0fe;
  --green: #188038;
  --green-soft: #e6f4ea;
  --amber: #f9ab00;
  --amber-soft: #fef7e0;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(60, 64, 67, 0.08), 0 1px 3px rgba(60, 64, 67, 0.12);
  --font: "Inter", "Google Sans", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.45;
}

.app-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}
.brand { display: flex; gap: 0.75rem; align-items: center; }
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.85rem;
}
.brand h1 { margin: 0; font-size: 1.25rem; font-weight: 600; letter-spacing: -0.02em; }
.brand-sub { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.8rem; }
.app-bar-actions { display: flex; align-items: center; gap: 0.65rem; }

.seg {
  display: inline-flex;
  background: var(--bg);
  border-radius: 999px;
  padding: 3px;
  border: 1px solid var(--line);
}
.seg-btn {
  border: 0; background: transparent;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-weight: 600; font-size: 0.9rem;
  color: var(--muted); cursor: pointer;
}
.seg-btn.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg-btn .count { font-weight: 500; color: var(--muted); font-size: 0.8rem; }

.icon-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }

.panel { padding: 1rem 1.25rem 2.5rem; max-width: 1100px; margin: 0 auto; }
.hidden { display: none !important; }

.chips {
  display: flex; gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  margin-bottom: 0.85rem;
  -webkit-overflow-scrolling: touch;
}
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}
.chip.active { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }

.filters-row {
  display: flex; flex-wrap: wrap; gap: 0.75rem;
  margin-bottom: 1rem;
}
.filters-row label {
  display: flex; flex-direction: column; gap: 0.25rem;
  font-size: 0.72rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.filters-row select, .field input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  min-width: 9rem;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
}

.feed { display: flex; flex-direction: column; gap: 0.75rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem 1rem;
  align-items: start;
}
.card-main h3 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.card-meta { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.88rem; }
.why { margin: 0.45rem 0 0; font-size: 0.84rem; color: var(--green); }
.badges { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.55rem; }
.badge {
  display: inline-flex; align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.72rem; font-weight: 700;
}
.badge.deal { background: var(--green-soft); color: var(--green); }
.badge.good { background: var(--blue-soft); color: var(--blue); }
.badge.src { background: #f1f3f4; color: var(--muted); }
.badge.src.live { background: var(--amber-soft); color: #b06000; }

.card-side { text-align: right; min-width: 7.5rem; }
.price {
  font-size: 1.35rem; font-weight: 700; color: var(--ink);
  text-decoration: none; display: block;
}
.price:hover { color: var(--blue); }
.price-sub { color: var(--muted); font-size: 0.78rem; margin-top: 0.15rem; }
.card-actions {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
}

.btn {
  border: 0; border-radius: 999px;
  padding: 0.5rem 1rem;
  font-weight: 600; font-size: 0.88rem;
  cursor: pointer; font-family: inherit;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { filter: brightness(0.95); }
.btn-outline { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-text { background: transparent; color: var(--blue); text-decoration: none; padding: 0.5rem 0.75rem; font-weight: 600; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; }

.pkg-feed { display: flex; flex-direction: column; gap: 0.75rem; }
.pkg-card {
  display: grid;
  grid-template-columns: 140px 110px 1fr auto;
  gap: 1rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.75rem;
}
.pkg-media img, .pkg-media .img-ph {
  width: 140px; height: 100px;
  object-fit: cover; border-radius: 12px;
  background: linear-gradient(135deg, #d2e3fc, #e8f0fe);
  display: block;
}
.pkg-price strong { font-size: 1.25rem; }
.pkg-price span { color: var(--muted); font-size: 0.8rem; }
.pkg-price .old { margin-top: 0.25rem; color: var(--muted); font-size: 0.8rem; display: flex; gap: 0.35rem; align-items: center; }
.pkg-meta h3 { margin: 0; font-size: 1rem; }
.pkg-meta p { margin: 0.2rem 0 0; }
.muted { color: var(--muted); font-size: 0.85rem; }

.sheet {
  border: 0;
  border-radius: 20px;
  padding: 0;
  width: min(28rem, calc(100vw - 1.5rem));
  box-shadow: 0 8px 28px rgba(60,64,67,.28);
  max-height: calc(100vh - 2rem);
}
.sheet.wide { width: min(44rem, calc(100vw - 1.5rem)); }
.sheet::backdrop { background: rgba(32,33,36,.45); }
.sheet-body {
  padding: 1.1rem 1.2rem 1.25rem;
  overflow: auto;
  max-height: calc(100vh - 2rem);
}
.sheet-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.75rem;
}
.sheet-head h2 { margin: 0; font-size: 1.2rem; }
.sheet-section {
  margin: 1.1rem 0 0.55rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.65rem; }
.field span { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.hint { margin: 0 0 0.65rem; color: var(--muted); font-size: 0.85rem; }
.sheet-foot {
  display: flex; justify-content: flex-end; gap: 0.5rem;
  margin-top: 1.1rem; padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}
.row-actions { margin-bottom: 0.5rem; }
.settings-err { color: #c5221f; font-size: 0.85rem; }
.settings-ok { color: var(--green); font-size: 0.85rem; }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-list li {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 0.15rem;
  font-size: 0.9rem;
}

.detail-price { font-size: 2rem; font-weight: 700; margin: 0.25rem 0; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.spark-wrap { margin: 0.75rem 0; }
.spark { width: 100%; height: 48px; }
.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.compare-item.best {
  border-color: #1a73e8;
  background: #e8f0fe;
}
.more-vars { color: #1a73e8 !important; font-weight: 500; }

.empty { color: var(--muted); padding: 1.5rem 0.5rem; text-align: center; }
.foot {
  padding: 0.5rem 1.25rem 2rem;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

@media (max-width: 720px) {
  .pkg-card {
    grid-template-columns: 100px 1fr;
    grid-template-areas:
      "media price"
      "media meta"
      "cta cta";
  }
  .pkg-media { grid-area: media; }
  .pkg-media img, .pkg-media .img-ph { width: 100px; height: 76px; }
  .pkg-price { grid-area: price; }
  .pkg-meta { grid-area: meta; }
  .pkg-card .btn { grid-area: cta; justify-self: start; }
  .card-side { min-width: 0; }
  .sheet, .sheet.wide {
    width: 100vw;
    max-width: 100vw;
    margin: 0;
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
    position: fixed;
    bottom: 0;
    top: auto;
  }
}
