/* ── Variables ── */
:root {
  --burgundy:    #5C1A1A;
  --burgundy2:   #7a2323;
  --burgundy-dk: #3a0e0e;
  --gold:        #C9A84C;
  --gold-lt:     #e8c96a;
  --bg:          #4a1a1a;
  --surface:     #381414;
  --surface2:    #421818;
  --border:      #5a2a2a;
  --text:        #f0e6e6;
  --muted:       #8a6060;
  --good:        #4caf7d;
  --warn:        #e0a030;
  --bad:         #e05050;
  --radius:      6px;
  --font:        system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, var(--burgundy-dk) 0%, var(--burgundy) 100%);
  border-bottom: 2px solid var(--gold);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(0,0,0,.6);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.logo-wrap {
  display: flex;
  justify-content: flex-start;
  width: 100%;
  max-width: 1800px;
}
.logo { height: 144px; width: auto; mix-blend-mode: screen; display: block; }
.header-inner {
  max-width: 1800px;
  width: 100%;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--gold);
  text-shadow: 0 1px 6px rgba(0,0,0,.5);
}
.header-meta { font-size: 14px; color: rgba(201,168,76,.65); }

/* ── Main ── */
main { max-width: 1800px; margin: 0 auto; padding: 1.25rem 1.5rem; }

/* ── Stats row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .75rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 900px) { .stats-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 520px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--gold);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.stat-val  { font-size: 1.7rem; font-weight: 800; color: var(--gold); line-height: 1; }
.stat-label { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* ── Controls ── */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  align-items: center;
  margin-bottom: .9rem;
}
#search {
  flex: 1 1 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .75rem;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
#search:focus { border-color: var(--gold); }
#search::placeholder { color: var(--muted); }

.type-filters { display: flex; flex-wrap: wrap; gap: .35rem; }
.filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .28rem .75rem;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
.filter-btn:hover  { border-color: var(--gold); color: var(--text); }
.filter-btn.active { background: var(--burgundy); border-color: var(--gold); color: var(--gold); }

.sort-secondary label {
  font-size: 14px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: .4rem;
}
.sort-secondary select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .28rem .5rem;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  outline: none;
}

/* ── Table ── */
.table-container {
  position: relative;
}
.table-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(500px, 80%);
  aspect-ratio: 1;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.08;
  pointer-events: none;
  z-index: 1;
}
.table-wrap {
  position: relative;
  z-index: 2;
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  white-space: nowrap;
}
thead { position: sticky; top: 170px; z-index: 10; }
th {
  background: var(--burgundy-dk);
  color: rgba(201,168,76,.75);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 14px;
  letter-spacing: .07em;
  padding: .6rem .75rem;
  text-align: left;
  border-bottom: 1px solid var(--gold);
  cursor: pointer;
  user-select: none;
}
th:hover { color: var(--gold); }
th.sorted-asc::after  { content: ' ↑'; color: var(--gold-lt); }
th.sorted-desc::after { content: ' ↓'; color: var(--gold-lt); }
th.num { text-align: right; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(92,26,26,.35); }

td {
  padding: .5rem .75rem;
  vertical-align: middle;
  color: var(--text);
  font-size: 14px;
}
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Score pills ── */
.score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.6rem;
  padding: .15rem .4rem;
  border-radius: 4px;
  font-weight: 800;
  font-size: 14px;
  line-height: 1;
}
.score-high  { background: rgba(76,175,125,.18); color: var(--good);  border: 1px solid rgba(76,175,125,.4); }
.score-mid   { background: rgba(224,160,48,.18);  color: var(--warn);  border: 1px solid rgba(224,160,48,.4); }
.score-low   { background: rgba(224,80,80,.18);   color: var(--bad);   border: 1px solid rgba(224,80,80,.4); }
.score-none  { color: var(--muted); font-size: 14px; }

/* ── Drink window ── */
.drink-badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: 14px;
  padding: .12rem .45rem;
  border-radius: 20px;
  font-weight: 600;
}
.dw-peak   { background: rgba(76,175,125,.15); color: var(--good); border: 1px solid rgba(76,175,125,.35); }
.dw-soon   { background: rgba(224,160,48,.15); color: var(--warn); border: 1px solid rgba(224,160,48,.35); }
.dw-hold   { background: rgba(100,100,200,.12); color: #8888dd; border: 1px solid rgba(100,100,200,.25); }
.dw-over   { background: rgba(100,50,50,.2); color: #a06060; border: 1px solid rgba(160,96,96,.25); text-decoration: line-through; }

/* ── Other cell types ── */
.wine-name    { font-weight: 600; color: #f5ecec; min-width: 160px; white-space: normal; }
.food-pair    { max-width: 200px; font-size: 13px; color: var(--muted); white-space: normal; line-height: 1.35; }
.cellar-note  { max-width: 220px; font-size: 13px; font-style: italic; color: rgba(240,230,230,.7); white-space: normal; line-height: 1.35; }
.qty-badge    { font-weight: 800; color: var(--gold); }

td.loading, td.empty {
  text-align: center;
  padding: 3rem;
  color: var(--muted);
  font-style: italic;
}
td.error { text-align: center; padding: 2rem; color: var(--bad); }

/* ── Pagination ── */
.pagination {
  display: flex;
  gap: .35rem;
  justify-content: center;
  margin-top: .9rem;
  flex-wrap: wrap;
}
.page-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .3rem .65rem;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  transition: .15s;
}
.page-btn:hover  { border-color: var(--gold); color: var(--text); }
.page-btn.active { background: var(--burgundy); border-color: var(--gold); color: var(--gold); font-weight: 700; }

/* ── Mobile ── */
@media (max-width: 680px) {
  main { padding: .75rem; }
  .logo { height: 80px; }
  .header-inner { height: 20px; }
  .site-title { font-size: 1rem; }
  th, td { padding: .4rem .55rem; font-size: 14px; }
}
