:root {
  --bg: #f4faf6;
  --surface: #ffffff;
  --border: #e3eee8;
  --text: #22302a;
  --muted: #6b8278;
  --primary: #2e9e6b;
  --primary-dark: #238055;
  --primary-soft: #e4f4ec;
  --danger: #e53935;
  --ok: #2e9e6b;
  --shadow: 0 2px 12px rgba(40, 110, 80, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- ĐĂNG NHẬP ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #c8ecd8, #f4faf6);
}
.login-box {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 36px 28px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-emoji { font-size: 54px; }
.login-box h1 { margin: 8px 0 2px; font-size: 24px; }
.login-sub { color: var(--muted); margin: 0 0 22px; }
.login-box input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  outline: none;
}
.login-box input:focus { border-color: var(--primary); }
.login-box button {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 12px;
  cursor: pointer;
}
.login-box button:hover { background: var(--primary-dark); }
.login-error { color: var(--danger); min-height: 20px; margin: 10px 0 0; font-size: 14px; }

/* ---------- KHUNG CHÍNH ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-size: 19px; font-weight: 800; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 55px;
  z-index: 9;
  overflow-x: auto;
}
.tab {
  flex: 1 0 auto;
  white-space: nowrap;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
}
.tab.active { background: var(--primary-soft); color: var(--primary-dark); }

.container { max-width: 760px; margin: 0 auto; padding: 18px 16px 60px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head h2 { font-size: 20px; margin: 0; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }

/* ---------- NÚT ---------- */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary.big { font-size: 18px; padding: 14px 34px; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost:hover { background: #eef6f1; }
.icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 17px;
  padding: 4px 6px;
  border-radius: 8px;
  line-height: 1;
}
.icon-btn:hover { background: #eef6f1; }

/* ---------- DANH MỤC & MÓN ---------- */
.category-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--primary-soft);
}
.category-title { font-size: 17px; font-weight: 700; }
.category-actions { display: flex; gap: 2px; }
.dishes { padding: 6px 10px 12px; }
.dish-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 6px;
  border-bottom: 1px dashed var(--border);
}
.dish-row:last-child { border-bottom: none; }
.dish-main { flex: 1; min-width: 0; }
.dish-name { font-weight: 600; }
.dish-note { color: var(--muted); font-size: 13px; margin-top: 2px; }
.dish-actions { display: flex; gap: 2px; flex-shrink: 0; }
.add-dish-btn {
  margin: 4px 6px 0;
  background: transparent;
  border: 1px dashed var(--primary);
  color: var(--primary-dark);
  padding: 8px;
  width: calc(100% - 12px);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}
.add-dish-btn:hover { background: var(--primary-soft); }

/* ---------- QUAY RANDOM ---------- */
.random-cats { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  background: var(--surface);
}
.cat-chip.selected { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }
.wheel-wrap { position: relative; width: min(330px, 82vw); aspect-ratio: 1; margin: 6px auto 20px; }
.wheel {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
  box-shadow: var(--shadow);
  border: 6px solid #fff;
  outline: 3px solid var(--primary-soft);
}
.wheel-pointer {
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
  border-top: 26px solid var(--primary-dark);
  z-index: 2;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
}
.random-actions { text-align: center; margin: 10px 0 24px; }
.random-results { display: grid; gap: 12px; }
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  animation: pop 0.3s ease;
}
@keyframes pop { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.result-cat { color: var(--muted); font-size: 13px; }
.result-dish { font-size: 20px; font-weight: 800; margin-top: 2px; }
.result-note { color: var(--muted); font-size: 14px; margin-top: 4px; }
.spinning .result-dish { opacity: 0.5; }

/* ---------- QUÁN ĐÃ LƯU ---------- */
.places-list { display: grid; gap: 12px; }
.place-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.place-dish { font-size: 17px; font-weight: 700; }
.place-name { color: var(--text); margin-top: 2px; }
.place-meta { color: var(--muted); font-size: 13px; margin-top: 6px; }
.place-note { margin-top: 8px; font-size: 14px; background: #eef6f1; padding: 8px 10px; border-radius: 10px; }
.place-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.map-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
}
.map-link:hover { background: #c8ecd8; }

/* ---------- HỘP THOẠI ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(40, 25, 20, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: 18px;
  width: 100%;
  max-width: 420px;
  padding: 22px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}
.modal h3 { margin: 0 0 16px; font-size: 19px; }
.modal label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 6px; }
.modal input, .modal textarea, .modal select {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  border: 2px solid var(--border);
  border-radius: 10px;
  outline: none;
  font-family: inherit;
}
.modal input:focus, .modal textarea:focus, .modal select:focus { border-color: var(--primary); }
.modal textarea { min-height: 70px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.gps-status { font-size: 13px; color: var(--muted); margin-top: 6px; }
.gps-ok { color: var(--ok); }

/* ---------- TOAST ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #2b2320;
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

@media (max-width: 480px) {
  .brand { font-size: 17px; }
  .section-head h2 { font-size: 18px; }
}
