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

:root {
  --green:   #2d6a2d;
  --green-l: #e8f5e9;
  --red:     #c62828;
  --grey:    #f5f5f5;
  --border:  #e0e0e0;
  --text:    #212121;
  --muted:   #757575;
  --radius:  6px;
  --shadow:  0 1px 3px rgba(0,0,0,.12);
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: #fafafa;
}

/* ── Header ── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1.25rem;
  background: var(--green);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  letter-spacing: .5px;
}
.site-header nav a {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  margin-left: 1.25rem;
  font-size: .9rem;
}
.site-header nav a:hover { color: #fff; }

/* ── Layout ── */
main { padding: 1rem; }

.layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.25rem;
  max-width: 1000px;
  margin: 0 auto;
}
@media (max-width: 700px) {
  .layout { grid-template-columns: 1fr; }
}

/* ── Search ── */
.search-form input {
  width: 100%;
  padding: .65rem .9rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  background: #fff;
}
.search-form input:focus { border-color: var(--green); }

.htmx-indicator { display: none; color: var(--muted); font-size: .85rem; margin-top: .4rem; }
.htmx-request .htmx-indicator { display: block; }

.hint { color: var(--muted); margin-top: 1rem; font-size: .9rem; }

/* ── Product list ── */
.product-list {
  list-style: none;
  margin-top: .75rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.product-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .55rem .75rem;
  box-shadow: var(--shadow);
}
.product-info {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  flex: 1;
  min-width: 0;
}
.product-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-ppu { font-size: .8rem; color: var(--green); font-weight: 600; }

/* ── Buttons ── */
.btn-add {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: .5rem;
  line-height: 1;
}
.btn-add:hover { background: #1b5e20; }

.btn-primary {
  display: inline-block;
  background: var(--green);
  color: #fff;
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: .9rem;
  border: none;
  cursor: pointer;
}
.btn-primary:hover { background: #1b5e20; }

.btn-secondary {
  display: inline-block;
  background: transparent;
  color: var(--green);
  padding: .5rem 1rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: .9rem;
  border: 1px solid var(--green);
  cursor: pointer;
}
.btn-secondary:hover { background: var(--green-l); }

.btn-remove {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 .2rem;
  line-height: 1;
}
.btn-remove:hover { color: var(--red); }

/* ── Cart panel ── */
#cart-panel h2 { font-size: 1rem; margin-bottom: .5rem; }

.cart-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: .75rem;
}
.cart-slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--green-l);
  border-radius: var(--radius);
  padding: .45rem .65rem;
  font-size: .9rem;
}
.slot-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cart-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }

/* ── Compare page ── */
.compare-page { max-width: 800px; margin: 0 auto; }
.compare-page h1 { margin-bottom: 1rem; }

.compare-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.compare-table th, .compare-table td {
  padding: .6rem .8rem;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
  vertical-align: top;
}
.compare-table th { background: var(--grey); font-weight: 600; }
.compare-table .slot-name { font-weight: 500; }
.compare-table .cheapest { background: var(--green-l); }
.compare-table .missing { color: var(--muted); }
.compare-table .price { display: block; font-weight: 600; }
.compare-table .ppu  { display: block; font-size: .78rem; color: var(--green); }
.compare-table .match-name { display: block; font-size: .75rem; color: var(--muted); }

.totals-row td { font-weight: 700; background: var(--grey); }
.best-total { color: var(--green); }

.winner-card {
  background: var(--green-l);
  border: 1px solid var(--green);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.winner-card strong { font-size: 1.05rem; display: block; margin-bottom: .25rem; }
.winner-actions { margin-top: .75rem; }

/* ── Auth page ── */
.auth-page { max-width: 600px; margin: 0 auto; }
.auth-page h1 { margin-bottom: .75rem; }
.auth-page > p { color: var(--muted); font-size: .9rem; margin-bottom: 1.25rem; }
.auth-section { margin-bottom: 1.5rem; }
.auth-section h2 { font-size: 1rem; margin-bottom: .5rem; }
.auth-section textarea {
  width: 100%;
  font-family: monospace;
  font-size: .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem;
  resize: vertical;
  margin-bottom: .4rem;
}
.badge-ok  { font-size: .78rem; color: var(--green); font-weight: normal; margin-left: .4rem; }
.badge-no  { font-size: .78rem; color: var(--muted); font-weight: normal; margin-left: .4rem; }

/* ── Autocart result ── */
.autocart-page { max-width: 600px; margin: 0 auto; }
.autocart-page h1 { margin-bottom: 1rem; }
.alert-warn {
  background: #fff3e0;
  border: 1px solid #ff9800;
  border-radius: var(--radius);
  padding: .65rem .9rem;
  margin-bottom: 1rem;
  font-size: .9rem;
}
.result-list { list-style: none; margin-bottom: 1rem; }
.result-item {
  display: flex;
  justify-content: space-between;
  padding: .5rem .75rem;
  margin-bottom: .35rem;
  border-radius: var(--radius);
  font-size: .9rem;
}
.result-ok     { background: var(--green-l); }
.result-error  { background: #ffebee; }
.result-missing{ background: var(--grey); }
.result-slot   { font-weight: 500; }
.result-detail { color: var(--muted); font-size: .82rem; }
.result-actions { display: flex; gap: .5rem; }
