:root {
  --navy: #14213d;
  --navy-2: #22345f;
  --gold: #f2b84b;
  --gold-soft: #f8d48a;

  --bg: var(--tg-theme-secondary-bg-color, #f2f3f7);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #14181f);
  --hint: var(--tg-theme-hint-color, #7c8591);
  --line: rgba(128, 134, 145, 0.26);
  --shadow: 0 1px 2px rgba(20, 33, 61, 0.05), 0 6px 20px rgba(20, 33, 61, 0.06);

  /* Tugma va tanlov rangi Telegram mavzusiga emas, summit brendiga bog'langan */
  --primary: var(--navy);
  --primary-text: #ffffff;
  --danger: var(--tg-theme-destructive-text-color, #d8352a);
  --ok: #12805c;
  --warn: #b54708;
  --err: #cf2a1e;

  --radius: 18px;
  --bottom-inset: var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}

:root[data-scheme="dark"] {
  --primary: var(--gold);
  --primary-text: var(--navy);
  --shadow: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
h1, h2, p, ol { margin: 0; padding: 0; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: var(--tg-viewport-stable-height, 100vh);
  display: flex;
  flex-direction: column;
}

/* ---------- Banner ---------- */

.hero {
  position: relative;
  overflow: hidden;
  padding: 18px 20px 42px;
  background: linear-gradient(155deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #ffffff;
}
.hero::after {
  content: "";
  position: absolute;
  top: -70px;
  right: -60px;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  border: 34px solid rgba(242, 184, 75, 0.14);
  pointer-events: none;
}
.hero-kicker { color: var(--gold-soft); font-size: 13px; font-weight: 600; letter-spacing: 0.01em; }
.hero-title { margin-top: 4px; font-size: 26px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.hero-place { margin-top: 6px; color: rgba(255, 255, 255, 0.72); font-size: 14px; overflow-wrap: anywhere; }
.hero.compact { padding: 14px 20px 18px; }

.steps { display: flex; gap: 6px; margin-top: 16px; list-style: none; }
.steps li { flex: 1; font-size: 12px; color: rgba(255, 255, 255, 0.55); }
.steps li::before {
  content: "";
  display: block;
  height: 4px;
  margin-bottom: 6px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
}
.steps li.done { color: #ffffff; }
.steps li.done::before { background: var(--gold); }

/* ---------- Sahifa ---------- */

.page { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.hero + .page { position: relative; margin-top: -26px; padding-top: 0; }
.hero.compact + .page { margin-top: 0; padding-top: 16px; }
.page.centered { justify-content: center; text-align: center; align-items: center; gap: 10px; }

.enter { animation: rise 0.28s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.pop { animation: pop 0.45s cubic-bezier(0.2, 1.5, 0.4, 1) both; }
@keyframes pop { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .enter, .pop { animation: none; }
}

.title { font-size: 21px; line-height: 1.2; font-weight: 800; letter-spacing: -0.015em; }
.big-emoji { font-size: 54px; line-height: 1; }
.muted { color: var(--hint); font-size: 14px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
}

/* ---------- Anketa ---------- */

.field { display: flex; flex-direction: column; gap: 7px; }
.label { font-size: 14px; font-weight: 700; }
.error { color: var(--danger); font-size: 13px; }
.error:empty { display: none; }

.input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: transparent;
  font-size: 16px; /* iOS 16px dan kichik maydonda sahifani kattalashtirib yuboradi */
  outline: none;
  transition: border-color 0.15s;
}
.input::placeholder { color: var(--hint); }
.input:focus { border-color: var(--primary); }
.input.invalid { border-color: var(--danger); }

.input.search {
  padding-left: 42px;
  background: no-repeat 14px center / 18px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a93a0' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
}

.choices { display: grid; gap: 8px; grid-auto-flow: column; grid-auto-columns: 1fr; }
.choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 50px;
  padding: 8px 6px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: transparent;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.choice:active { transform: scale(0.97); }
.choice[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

.dots { display: flex; gap: 3px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.45; }
.choice[aria-pressed="true"] .dots i { opacity: 1; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 10px 16px;
  border: 0;
  border-radius: 14px;
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.secondary { background: transparent; color: var(--text); font-weight: 600; }
.btn.outline { background: transparent; color: var(--text); border: 1.5px solid var(--line); }
.btn.gold { background: var(--gold); color: var(--navy); }
.btn.huge { min-height: 84px; font-size: 19px; border-radius: 20px; box-shadow: 0 8px 22px rgba(242, 184, 75, 0.32); }
.btn svg { width: 30px; height: 30px; flex: none; }

.footer {
  position: sticky;
  bottom: 0;
  padding: 10px 16px calc(12px + var(--bottom-inset));
  background: linear-gradient(to top, var(--bg) 78%, transparent);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.verified { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; border-radius: 12px; background: rgba(18, 128, 92, 0.1); font-weight: 700; }
.verified::before {
  content: "✓";
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ok);
  color: #ffffff;
  font-size: 13px;
  line-height: 22px;
  text-align: center;
}
.link { background: none; border: 0; padding: 0; color: var(--hint); font-size: 13px; font-weight: 500; cursor: pointer; margin-left: auto; text-decoration: underline; }

/* ---------- Chipta ---------- */

.ticket {
  position: relative;
  overflow: hidden;
  width: 100%;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
}
.ticket-head { padding: 16px 18px; background: linear-gradient(155deg, var(--navy), var(--navy-2)); color: #ffffff; }
.ticket-head small { display: block; color: var(--gold-soft); font-size: 12px; font-weight: 600; }
.ticket-head b { display: block; margin-top: 2px; font-size: 17px; font-weight: 800; overflow-wrap: anywhere; }
.ticket-body { padding: 8px 18px; }
.ticket-tear { position: relative; margin: 0 18px; border-top: 2px dashed var(--line); }
.ticket-tear::before, .ticket-tear::after {
  content: "";
  position: absolute;
  top: -11px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg);
}
.ticket-tear::before { left: -28px; }
.ticket-tear::after { right: -28px; }
.ticket-note { display: flex; align-items: center; gap: 10px; padding: 14px 18px; font-size: 14px; color: var(--hint); }

.rows { display: flex; flex-direction: column; }
.row { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row > :first-child { color: var(--hint); flex: none; }
.row > :last-child { font-weight: 700; text-align: right; overflow-wrap: anywhere; }

/* ---------- Xodim: xulosa ---------- */

.banner {
  padding: 14px 16px;
  border-radius: 16px;
  color: #ffffff;
  font-weight: 700;
  font-size: 16px;
  line-height: 1.3;
}
.banner.err { background: var(--err); }
.banner.ok { background: var(--ok); }
.banner.warn { background: var(--warn); }

.meter-top { display: flex; align-items: baseline; gap: 6px; position: relative; z-index: 1; }
.meter-top b { font-size: 40px; line-height: 1; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.meter-of { color: rgba(255, 255, 255, 0.72); font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.meter-label { color: rgba(255, 255, 255, 0.72); font-size: 14px; }
.meter-bar { position: relative; z-index: 1; height: 8px; margin-top: 12px; border-radius: 4px; background: rgba(255, 255, 255, 0.18); overflow: hidden; }
.meter-bar > div { height: 100%; border-radius: 4px; background: var(--gold); transition: width 0.3s; }
.meter-sub { position: relative; z-index: 1; margin-top: 9px; color: rgba(255, 255, 255, 0.72); font-size: 13px; }
.meter-sub b { color: #ffffff; font-variant-numeric: tabular-nums; }

/* ---------- Xodim: mehmon kartasi ---------- */

.guest-name { font-size: 26px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.guest-phone { display: inline-block; margin-top: 4px; color: var(--hint); text-decoration: none; font-variant-numeric: tabular-nums; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { padding: 5px 11px; border-radius: 999px; background: var(--line); font-size: 13px; font-weight: 600; }

.seats-head { display: flex; justify-content: space-between; align-items: baseline; }
.seats-head b { font-size: 15px; font-variant-numeric: tabular-nums; }
.seats { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; }
.seat, .chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 52px;
  padding: 6px;
  border-radius: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.seat { border: 1.5px dashed var(--line); color: var(--hint); font-size: 13px; font-weight: 500; }
.chip { border: 0; background: rgba(18, 128, 92, 0.14); color: var(--ok); cursor: pointer; }
.chip i { font-style: normal; font-size: 12px; opacity: 0.7; }
:root[data-scheme="dark"] .chip { color: #4cc9a0; }

.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; min-width: 0; }
.inline-form .btn { width: auto; min-height: 48px; flex: none; }

.results { display: flex; flex-direction: column; gap: 8px; }
.result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 13px 16px;
  border: 0;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
}
.result b { display: block; overflow-wrap: anywhere; }
.result small { color: var(--hint); font-variant-numeric: tabular-nums; }
.result .count { flex: none; padding: 4px 10px; border-radius: 999px; background: var(--line); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.result .count.done { background: rgba(18, 128, 92, 0.15); color: var(--ok); }
.result .count.off { background: rgba(207, 42, 30, 0.14); color: var(--err); }

/* ---------- Adminka ---------- */

.admin #app { max-width: 1040px; }
.admin-hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-radius: 0 0 20px 20px; }
.admin-hero > * { position: relative; z-index: 1; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; align-items: start; }

.admin-column { display: flex; flex-direction: column; gap: 14px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--card); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat span { color: var(--hint); font-size: 13px; }

.btn.small { width: auto; min-height: 40px; padding: 8px 14px; border-radius: 10px; font-size: 14px; text-decoration: none; flex: none; }
.btn.on-dark { color: #ffffff; border-color: rgba(255, 255, 255, 0.35); }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.howto { margin: 0; padding-left: 20px; color: var(--hint); font-size: 14px; display: flex; flex-direction: column; gap: 6px; }

.table-wrap { overflow-x: auto; margin: 0 -16px -6px; padding: 0 16px 6px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 8px 10px 8px 0; color: var(--hint); font-size: 12px; font-weight: 600; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
td { padding: 11px 10px 11px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
td b { display: block; font-weight: 700; min-width: 130px; overflow-wrap: anywhere; }
td small { color: var(--hint); }
td.nums { white-space: nowrap; font-variant-numeric: tabular-nums; }
td.empty { padding: 24px 0; color: var(--hint); text-align: center; }
tr.off td { color: var(--hint); }

.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { max-width: 380px; }
.login-body { display: flex; flex-direction: column; gap: 14px; padding: 18px; }
