:root {
  --bg: #fff4eb;
  --bg-2: #ffe0ee;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: #fffaf6;
  --text: #20151b;
  --muted: #66515d;
  --primary: #be2f80;
  --primary-2: #8b1e5f;
  --accent: #f05a9c;
  --cream: #f6dfad;
  --berry: #601247;
  --success: #27864c;
  --danger: #b42342;
  --warning: #c47a11;
  --border: rgba(96, 18, 71, 0.18);
  --shadow: 0 18px 55px rgba(96, 18, 71, 0.13);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 12%, rgba(240, 90, 156, 0.28), transparent 26%),
    radial-gradient(circle at 88% 5%, rgba(246, 223, 173, 0.55), transparent 28%),
    linear-gradient(135deg, var(--bg), var(--bg-2) 48%, #fff9f2);
  overflow-x: hidden;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.72rem 1rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(190, 47, 128, 0.22);
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

button:hover { transform: translateY(-1px); box-shadow: 0 16px 34px rgba(190, 47, 128, 0.28); }
button:active { transform: translateY(0); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.button-secondary {
  background: #fff;
  color: var(--primary-2);
  border: 1px solid var(--border);
  box-shadow: none;
}

.button-ghost {
  background: rgba(255, 255, 255, 0.45);
  color: var(--berry);
  border: 1px solid var(--border);
  box-shadow: none;
}

.button-danger {
  background: linear-gradient(135deg, #b42342, #dc355e);
}

.button-success {
  background: linear-gradient(135deg, #16814d, #30a36a);
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.72rem 0.82rem;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  outline: none;
}

textarea { min-height: 44px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(190, 47, 128, 0.12); }
label { font-size: 0.82rem; font-weight: 800; color: var(--berry); display: block; margin-bottom: 0.35rem; }

.app-shell { min-height: 100vh; padding: 22px; position: relative; }
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.56);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo { width: 68px; height: 68px; object-fit: contain; border-radius: 18px; background: #fff; padding: 4px; border: 1px solid var(--border); }
.brand h1 { margin: 0; font-size: clamp(1.2rem, 2.1vw, 2rem); color: var(--berry); line-height: 1.05; }
.brand p { margin: 5px 0 0; color: var(--muted); font-weight: 650; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.tabs { display: flex; gap: 10px; margin: 18px 0; flex-wrap: wrap; }
.tab {
  background: rgba(255, 255, 255, 0.66);
  color: var(--berry);
  border: 1px solid var(--border);
  box-shadow: none;
}
.tab.active { background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; }

.panel {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel h2 { margin: 0 0 16px; color: var(--berry); font-size: 1.5rem; }
.panel h3 { margin: 18px 0 10px; color: var(--berry); }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.help { color: var(--muted); font-size: 0.9rem; line-height: 1.4; }
.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  border-radius: 999px; padding: 0.45rem 0.72rem;
  background: rgba(255, 255, 255, 0.72); color: var(--berry); border: 1px solid var(--border); font-weight: 800;
}
.status-pill.good { color: var(--success); }
.status-pill.warn { color: var(--warning); }
.status-pill.danger { color: var(--danger); }

.admin-card { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.admin-card .pin-input { max-width: 150px; }

.table-wrap { overflow-x: auto; border-radius: 22px; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.55); }
table { width: 100%; border-collapse: collapse; min-width: 1160px; }
th, td { padding: 10px; border-bottom: 1px solid rgba(96, 18, 71, 0.10); text-align: left; vertical-align: middle; }
th { color: var(--berry); font-size: 0.78rem; text-transform: uppercase; letter-spacing: .04em; background: rgba(246, 223, 173, 0.28); }
td { font-size: 0.92rem; }
.rank-cell { font-weight: 950; color: var(--primary-2); text-align: center; font-size: 1.1rem; }
.score-cell { font-weight: 950; font-size: 1.05rem; color: var(--berry); }
.small-btn { padding: 0.48rem 0.68rem; font-size: 0.86rem; min-width: 38px; }
.qty-control { display: grid; grid-template-columns: 40px 76px 40px; gap: 6px; align-items: center; }
.qty-control input { text-align: center; padding: 0.58rem 0.4rem; }
.quick-row { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.action-row { display: flex; gap: 6px; flex-wrap: wrap; }
.warning-text { color: var(--danger); font-weight: 800; font-size: 0.8rem; margin-top: 4px; }

.dashboard-page, .dashboard-only-page {
  min-height: calc(100vh - 44px);
  position: relative;
}
.dashboard-only-page { padding: 18px; min-height: 100vh; }
.dashboard-stage {
  position: relative;
  overflow: hidden;
  min-height: 72vh;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 80px);
  margin: 0 auto;
  border-radius: 36px;
  border: 5px solid rgba(96, 18, 71, 0.32);
  background:
    radial-gradient(circle at 14% 14%, rgba(240, 90, 156, .22), transparent 23%),
    radial-gradient(circle at 88% 20%, rgba(246, 223, 173, .50), transparent 25%),
    linear-gradient(135deg, #fff8f2 0%, #ffe5f1 54%, #fff0d6 100%);
  box-shadow: 0 30px 80px rgba(96, 18, 71, 0.22);
  padding: clamp(16px, 2.3vw, 32px);
}
.dashboard-stage:before {
  content: "🍓 🧊 💕 🍾 🍓 🧊 💕 🍾 🍓 🧊 💕 🍾";
  position: absolute;
  inset: auto 22px 18px 22px;
  font-size: clamp(1.1rem, 2vw, 2rem);
  opacity: 0.20;
  letter-spacing: .7rem;
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
}
.dashboard-stage:after {
  content: "🍾 🍓 🧊 💕 🍾 🍓 🧊 💕";
  position: absolute;
  top: 22px;
  right: 24px;
  bottom: 22px;
  writing-mode: vertical-rl;
  font-size: clamp(1rem, 1.8vw, 1.8rem);
  opacity: 0.15;
  pointer-events: none;
}
.dash-top { display: grid; grid-template-columns: 96px 1fr auto; align-items: center; gap: 16px; position: relative; z-index: 1; }
.dash-logo { width: clamp(64px, 7vw, 96px); height: clamp(64px, 7vw, 96px); object-fit: contain; border-radius: 24px; background: #fff; padding: 5px; border: 1px solid var(--border); }
.dash-title { text-align: center; color: var(--berry); margin: 0; font-size: clamp(2rem, 5vw, 5.6rem); line-height: 1; text-shadow: 0 4px 0 rgba(255,255,255,.85); }
.countdown-card { min-width: 190px; background: rgba(255,255,255,.76); border: 1px solid var(--border); border-radius: 22px; padding: 12px 16px; text-align: center; box-shadow: 0 10px 25px rgba(96,18,71,.12); }
.countdown-card strong { display: block; color: var(--berry); font-size: clamp(1.1rem, 2vw, 2rem); }
.countdown-card span { color: var(--muted); font-weight: 800; font-size: .82rem; }
.ended-banner { margin: 14px auto 0; width: fit-content; position: relative; z-index: 1; background: linear-gradient(135deg, #b42342, #f05a9c); color: white; border-radius: 999px; padding: 0.7rem 1.3rem; font-weight: 950; box-shadow: 0 14px 35px rgba(180,35,66,.28); }
.dashboard-content { display: grid; grid-template-columns: 1.1fr 1.3fr; gap: clamp(12px, 2vw, 24px); margin-top: clamp(14px, 2vw, 26px); position: relative; z-index: 1; }
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 12px; min-height: 360px; }
.podium-card { background: rgba(255,255,255,.82); border: 1px solid var(--border); border-radius: 26px; padding: 16px; text-align: center; box-shadow: 0 18px 42px rgba(96,18,71,.13); min-height: 190px; display: flex; flex-direction: column; justify-content: space-between; }
.podium-card.rank-1 { min-height: 310px; background: linear-gradient(180deg, #fff8d6, #fff); border-color: rgba(196,122,17,.28); transform: translateY(-20px); }
.podium-card.rank-2 { min-height: 250px; }
.podium-card.rank-3 { min-height: 220px; }
.podium-rank { font-size: clamp(1.8rem, 3vw, 3rem); font-weight: 950; color: var(--primary); }
.podium-name { font-size: clamp(1rem, 1.8vw, 1.7rem); font-weight: 950; color: var(--berry); overflow-wrap: anywhere; }
.podium-club { color: var(--muted); font-weight: 750; font-size: .9rem; }
.podium-score { font-size: clamp(1.4rem, 2.8vw, 3rem); font-weight: 950; color: var(--primary-2); }
.leaderboard { display: grid; gap: 10px; align-content: start; }
.leader-row { display: grid; grid-template-columns: 60px 1fr auto; align-items: center; gap: 12px; background: rgba(255,255,255,.78); border: 1px solid var(--border); border-radius: 20px; padding: 10px 14px; box-shadow: 0 10px 24px rgba(96,18,71,.10); transition: transform .22s ease; }
.leader-row:hover { transform: translateY(-1px); }
.leader-rank { font-size: 1.3rem; font-weight: 950; color: var(--primary); text-align: center; }
.leader-name { font-weight: 950; color: var(--berry); font-size: clamp(.95rem, 1.4vw, 1.35rem); }
.leader-meta { color: var(--muted); font-weight: 700; font-size: .82rem; }
.leader-score { font-size: clamp(1.1rem, 1.8vw, 1.8rem); font-weight: 950; color: var(--primary-2); }
.bottles { display: flex; gap: 2px; margin-top: 4px; opacity: .88; overflow: hidden; max-width: 100%; }
.bottle { filter: drop-shadow(0 2px 3px rgba(96,18,71,.14)); font-size: .92rem; }
.empty-state { min-height: 280px; display: grid; place-items: center; color: var(--muted); font-weight: 850; text-align: center; }

.archive-list { display: grid; gap: 10px; }
.archive-item { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--border); border-radius: 20px; background: rgba(255,255,255,.66); }
.archive-item h3 { margin: 0 0 4px; }
.archive-detail { margin-top: 16px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(32,21,27,.45); display: grid; place-items: center; padding: 20px; }
.modal { width: min(760px, 100%); max-height: 90vh; overflow: auto; border-radius: 28px; background: #fffaf6; border: 1px solid var(--border); box-shadow: 0 30px 90px rgba(32,21,27,.35); padding: 22px; }
.modal h2 { color: var(--berry); margin: 0 0 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.tie-card { border: 1px solid var(--border); border-radius: 18px; padding: 12px; margin: 8px 0; background: rgba(255,255,255,.8); }
.tie-card.selected { outline: 4px solid rgba(190,47,128,.16); border-color: var(--primary); }

.watermark { position: fixed; right: 13px; bottom: 10px; z-index: 120; color: rgba(96,18,71,.52); font-weight: 900; font-size: .76rem; pointer-events: none; text-shadow: 0 1px 0 rgba(255,255,255,.7); }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 150; background: var(--berry); color: #fff; padding: .8rem 1.1rem; border-radius: 999px; box-shadow: 0 14px 35px rgba(96,18,71,.28); font-weight: 850; }
.hidden { display: none !important; }

@media (max-width: 980px) {
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .header { align-items: flex-start; flex-direction: column; }
  .dashboard-stage { aspect-ratio: auto; max-height: none; }
  .dash-top { grid-template-columns: 72px 1fr; }
  .countdown-card { grid-column: 1 / -1; justify-self: stretch; }
  .dashboard-content { grid-template-columns: 1fr; }
  .podium { min-height: auto; }
  .podium-card.rank-1 { transform: none; }
}

@media (max-width: 640px) {
  .app-shell { padding: 12px; }
  .panel { padding: 16px; border-radius: 22px; }
  .podium { grid-template-columns: 1fr; }
  .leader-row { grid-template-columns: 42px 1fr; }
  .leader-score { grid-column: 2; }
}

@media print {
  body { background: white; }
  .no-print, .tabs, .header-actions, .watermark { display: none !important; }
  .panel, .header { box-shadow: none; border: 1px solid #ccc; background: #fff; }
}

.dash-title-wrap { text-align: center; min-width: 0; }
.dash-subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-weight: 900;
  font-size: clamp(1rem, 2vw, 1.8rem);
  text-shadow: 0 2px 0 rgba(255,255,255,.7);
}
