:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --accent: #c8102e;
  --accent-dark: #9c0c22;
  --text: #221c14;
  --muted: #7a7266;
  --border: #e2ddd0;
  --gold: #d4a017;
  --radius: 14px;
  --shadow: rgba(0,0,0,0.08);
  --btCol: white;
}

html[data-theme="dark"] {
  --bg: #17140f;
  --card: #241f18;
  --accent: #e0334f;
  --accent-dark: #b8283f;
  --text: #f1ece2;
  --muted: #a89e8c;
  --border: #3a332a;
  --gold: #e6b84a;
  --shadow: rgba(0,0,0,0.35);
  --btCol: black;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 140px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* --- Login --- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding-bottom: 0;
}
.login-box {
  background: var(--card);
  padding: 40px 32px;
  border-radius: var(--radius);
  box-shadow: 0 4px 24px var(--shadow);
  text-align: center;
  width: 90%;
  max-width: 360px;
}
.login-box h1 { margin-top: 0; }
.login-box input {
  width: 100%;
  padding: 14px;
  font-size: 1.1rem;
  margin: 16px 0;
  border: 2px solid var(--border);
  border-radius: 10px;
}
.login-box button {
  width: 100%;
  padding: 14px;
  font-size: 1.1rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}
.login-box button:active { background: var(--accent-dark); }
.error-text { color: var(--accent); min-height: 1.2em; }

/* --- Topbar --- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 1.3rem; margin: 0; }
.topbar-title { display: flex; align-items: center; min-width: 0; }
.location-select {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 6px 8px;
  margin: -6px -8px;
  cursor: pointer;
  max-width: 62vw;
  text-overflow: ellipsis;
}
.location-select:hover, .location-select:focus {
  background: var(--bg);
  outline: none;
}
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  background: none;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 1.2rem;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text);
}
.icon-btn:active { background: var(--bg); }

/* --- Main grid --- */
main { padding: 16px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.grid-small { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

.drink-btn, .deposit-btn {
  position: relative;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 10px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.05s ease, background 0.15s ease;
}
.drink-btn:active, .deposit-btn:active { transform: scale(0.96); background: var(--bg); }
.drink-btn .name { font-weight: 600; font-size: 1.05rem; display: block; }
.drink-btn .price { color: var(--muted); font-size: 0.9rem; display: block; margin-top: 4px; }
.drink-btn .deposit-hint { color: var(--gold); font-size: 0.78rem; display: block; margin-top: 2px; }
.deposit-btn .name { font-weight: 600; }
.deposit-btn .price { color: var(--muted); font-size: 0.85rem; display: block; margin-top: 4px; }

.badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  min-width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0 4px;
}
.deposit-btn .badge { background: var(--gold); }

.deposit-return-section { margin-top: 28px; }
.deposit-return-section h2 { font-size: 1rem; color: var(--muted); margin-bottom: 10px; }

/* --- Summary bar --- */
.summary-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 12px 18px;
  box-shadow: 0 -2px 12px var(--shadow);
}
.summary-lines {
  max-height: 80px;
  overflow-y: auto;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.summary-lines div { display: flex; justify-content: space-between; }
.summary-total {
  display: flex;
  justify-content: space-between;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 10px;
}
.reset-btn {
  width: 100%;
  padding: 14px;
  background: var(--text);
  color: var(--btCol);
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
}

/* --- Overlay --- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.overlay.hidden { display: none; }
.overlay-content {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
}
.overlay-header { display: flex; justify-content: space-between; align-items: flex-start; }
.overlay-header h2 { margin: 0; }
.overlay-subtitle { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }

.tabs { display: flex; gap: 8px; margin: 14px 0; }
.tab-btn {
  flex: 1;
  padding: 10px;
  background: var(--bg);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}
.tab-btn.active { background: var(--accent); color: white; }
.tab-content { display: none; }
.tab-content.active { display: block; }

.config-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.config-form input, .config-form select {
  flex: 1;
  min-width: 100px;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
}
.form-actions { width: 100%; display: flex; gap: 8px; }
.config-form button {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 600;
}
.config-form button.secondary { background: var(--border); color: var(--text); }

.config-list { list-style: none; padding: 0; margin: 0; }
.config-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}
.config-list .item-info { font-size: 0.95rem; }
.config-list .item-sub { color: var(--muted); font-size: 0.8rem; }
.config-list .item-actions button {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
}

.hidden { display: none !important; }
