:root {
  color-scheme: dark;
  --base: #10100f;
  --panel: #191816;
  --ink: #f7f3ed;
  --muted: #beb5a8;
  --rule: #3b352d;
  --gold: #edb84e;
  font: 100%/1.5 system-ui, sans-serif;
  background: var(--base);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: var(--gold); text-underline-offset: .2em; }
p, h1, h2, h3, dl, dd { margin: 0; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.025em; }
h1 { font-size: clamp(1.9rem, 5vw, 2.7rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.03rem; }
p { margin-block: .5rem; }

.portal-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1.2rem;
  padding: 1rem max(1rem, calc((100% - 68rem) / 2));
  border-bottom: 1px solid var(--rule);
}
.portal-brand { color: var(--ink); text-decoration: none; font-weight: 750; }
.portal-brand span { display: block; color: var(--muted); font-size: .82rem; font-weight: 500; }
.portal-header nav { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .9rem; }
.portal-header nav a { padding-block: .65rem; }
.portal-header nav form { margin: 0; }
.portal-main { width: min(100% - 2rem, 68rem); margin: 2.4rem auto 3.5rem; }
.portal-guest { width: min(100% - 2rem, 31rem); }

.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: .55rem; padding: clamp(.85rem, 3vw, 1.65rem); }
.auth-panel h1 { margin-bottom: 1.2rem; }
.auth-panel label { display: block; margin-top: .9rem; }
.auth-panel button { width: 100%; margin-top: 1rem; }
.auth-links { margin-top: 1rem; }
.hint { color: var(--muted); font-size: .88rem; }
.message { margin-block: 0 1rem; padding: .7rem .9rem; background: #262013; border-left: 3px solid var(--gold); }
.error { color: #ffd6cf; background: #30201d; border-left-color: #ef9e88; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.8rem;
  padding: .65rem .85rem;
  border: 1px solid transparent;
  border-radius: .38rem;
  background: var(--gold);
  color: #211708;
  font: 700 .92rem/1.25 system-ui, sans-serif;
  text-decoration: none;
}
button:hover, .button:hover { background: #ffd277; }
button:disabled { opacity: .5; }
.quiet { border-color: var(--rule); background: var(--panel); color: var(--ink); }
.quiet:hover { background: #252016; }
label { font-size: .9rem; font-weight: 650; }
input:not([type="checkbox"]), textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 2.8rem;
  margin-top: .25rem;
  padding: .55rem .65rem;
  border: 1px solid var(--rule);
  border-radius: .38rem;
  background: #131312;
  color: var(--ink);
  font: inherit;
}
textarea { resize: vertical; }

.page-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .85rem; margin-bottom: 1.35rem; }
.page-heading p { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; margin-bottom: 1.8rem; }
.stats dt { font-size: .9rem; font-weight: 650; }
.stats dd { margin-top: .3rem; font-size: clamp(1.4rem, 3.2vw, 2rem); font-variant-numeric: tabular-nums; font-weight: 750; overflow-wrap: anywhere; }
.stats p { margin-bottom: 0; color: var(--muted); font-size: .82rem; }
.result { border-color: #72572a; background: #241e15; }
.result dd { color: var(--gold); }

.order-history h2 { margin-bottom: .7rem; }
.order {
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) minmax(17rem, 1.05fr) auto;
  align-items: center;
  gap: .8rem 1rem;
  padding: .9rem 0;
  border-top: 1px solid var(--rule);
}
.order-wines { overflow-wrap: anywhere; }
.order-wines ul { list-style: none; margin: .35rem 0 0; padding: 0; }
.order-wines li { font-size: .9rem; }
.order-wines li span { color: var(--muted); margin-left: .24rem; }
.buyer-details { margin-top: .55rem; font-size: .9rem; }
.buyer-details summary { color: var(--gold); cursor: pointer; }
.buyer-details p { margin-bottom: 0; white-space: pre-wrap; }
.order-actions { display: grid; justify-items: start; gap: .35rem; font-size: .88rem; }
.danger { background: #f0a99e; color: #321310; }
.results-heading { margin-bottom: .8rem; }
.results-filter { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.results-filter select { padding: .6rem; border: 1px solid var(--rule); border-radius: .38rem; font: inherit; }
.results-table { overflow-x: auto; }
.results-table table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.results-table caption { text-align: left; font-weight: 700; padding-bottom: .6rem; }
.results-table th, .results-table td { padding: .55rem .4rem; border-bottom: 1px solid var(--rule); text-align: right; white-space: nowrap; }
.results-table th:first-child { text-align: left; }
.supplier-results + .supplier-results { margin-top: 1.25rem; }
.supplier-results tfoot { font-weight: 700; }
.supplier-results th:first-child { white-space: normal; min-width: 9rem; }
.results-by-member { margin-top: 1.25rem; }
.results-by-member summary { cursor: pointer; font-weight: 700; }
.results-by-member[open] summary { margin-bottom: .75rem; }

section[aria-labelledby="wilddiner-heading"], section[aria-labelledby="combined-heading"] { margin-top: 1.8rem; }
.stats.campaign-stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); }
.wilddiner-manage { margin-top: 1rem; }
.wilddiner-order-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); gap: .9rem; }
.wilddiner-order { display: flex; flex-direction: column; gap: .65rem; overflow-wrap: anywhere; }
.wilddiner-order-header { display: flex; justify-content: space-between; align-items: flex-start; gap: .65rem; }
.wilddiner-order-header p { margin: .2rem 0 0; }
.wilddiner-order-header .button { flex-shrink: 0; }
.wilddiner-buyer-details { white-space: pre-wrap; margin: 0; font-size: .9rem; }
.wilddiner-order-wines { list-style: none; margin: 0; padding: 0; }
.wilddiner-order-wines li { display: flex; justify-content: space-between; gap: .65rem; padding: .3rem 0; }
.wilddiner-order-wines li span:last-child { color: var(--muted); text-align: right; white-space: nowrap; }
.wilddiner-order-numbers { display: grid; grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr)); gap: .55rem; margin-top: auto; padding-top: .55rem; border-top: 1px solid var(--rule); font-variant-numeric: tabular-nums; }
.wilddiner-order-numbers dt { color: var(--muted); font-size: .76rem; }
.wilddiner-order-numbers dd { font-weight: 700; }
.auth-panel select { display: block; width: 100%; padding: .55rem; font: inherit; }
.order-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .4rem .65rem; font-variant-numeric: tabular-nums; }
.order-meta dt { color: var(--muted); font-size: .75rem; }
.order-meta dd { font-size: .86rem; overflow-wrap: anywhere; }

.order-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.order-fields { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: .7rem; margin-bottom: 1rem; }
.buyer-details-field { grid-column: 1 / -1; }
.buyer-details-field .hint { margin-block: .15rem .25rem; }
.wine-field { margin: 0; border: 0; min-inline-size: 0; padding: 0; }
.wine-field legend { padding: 0; font-weight: 700; }
.wine-choice { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .6rem; border-top: 1px solid var(--rule); padding: .45rem 0; }
.wine-check { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .55rem; align-items: center; min-height: 2.8rem; }
.wine-check input { width: 1.2rem; height: 1.2rem; margin: 0; accent-color: var(--gold); }
.wine-check small { display: block; color: var(--muted); font-size: .78rem; font-weight: 500; }
.wine-counts { display: flex; gap: .5rem; }
.wine-counts > div { width: 4.35rem; }
.wine-counts label { color: var(--muted); font-size: .78rem; }
.order-estimate button { width: 100%; margin-top: .7rem; }
.order-estimate dl { margin-top: .8rem; }
.order-estimate dl div { display: flex; justify-content: space-between; gap: .4rem; padding-block: .3rem; font-variant-numeric: tabular-nums; }
.order-estimate dl div:last-child { border-top: 1px solid #72572a; font-weight: 750; }

.members { list-style: none; padding: 0; margin: 0; }
.members li { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: .55rem 1rem; border-top: 1px solid var(--rule); padding-block: .85rem; }
.members p { margin: .15rem 0 0; }
.admin-invite { margin-bottom: 1rem; }
.admin-invite h2 { margin-bottom: .55rem; }

@media (max-width: 680px) {
  .order-grid, .order { grid-template-columns: minmax(0, 1fr); }
  .order > .button { justify-self: start; }
  .portal-main { margin-top: 1.5rem; }
}
@media (max-width: 460px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats .result { grid-column: 1 / -1; }
  .order-fields, .wine-choice { grid-template-columns: minmax(0, 1fr); }
  .wine-counts { padding-left: 1.75rem; }
}
