/* ── tokens ─────────────────────────────────────────────────────────── */
:root {
  --v-50:  #f6f4ff;
  --v-100: #ece7ff;
  --v-200: #dcd2ff;
  --v-300: #c3b0ff;
  --v-400: #a382fb;
  --v-500: #8b5cf6;
  --v-600: #7c3aed;
  --v-700: #6d28d9;
  --v-800: #5b21b6;
  --v-900: #3b1080;

  --surface: #ffffff;
  --bg:      #f7f5ff;
  --line:    #e8e2fb;
  --text:    #1c1330;
  --muted:   #6d6588;
  --danger:  #d92d20;
  --ok:      #067647;
  --ok-bg:   #ecfdf3;

  --shadow-card: 0 1px 2px rgba(60,20,140,.05), 0 18px 44px -16px rgba(60,20,140,.22);
  --shadow-btn:  0 8px 20px -6px rgba(109,40,217,.55);
  /* The public page must fit one screen, so vertical rhythm scales with
     viewport height as well as width. */
  --pad-y:    clamp(12px, 3vh, 30px);
  --gap-hero: clamp(10px, 2.4vh, 22px);
  --gap-fld:  clamp(9px, 1.9vh, 18px);
  --card-py:  clamp(15px, 2.7vh, 30px);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--v-600); }

/* ══ PUBLIC PAGE — mobile first ═════════════════════════════════════ */
.page-form {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  background: linear-gradient(180deg, var(--v-700) 0%, var(--v-600) 34%, var(--bg) 74%);
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

/* Soft light bloom behind the hero. */
.glow {
  position: fixed;
  top: -180px;
  left: 50%;
  width: 620px;
  height: 460px;
  max-width: 160vw;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(195,176,255,.55), rgba(195,176,255,0) 100%);
  pointer-events: none;
  z-index: 0;
}

.shell {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: var(--pad-y) 16px calc(var(--pad-y) + env(safe-area-inset-bottom));
}

/* ── hero ───────────────────────────────────────────────────────────── */
.hero { text-align: center; color: #fff; margin-bottom: var(--gap-hero); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  color: #fff;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.34);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-radius: 999px;
  padding: clamp(5px, 1vh, 7px) 15px;
  margin-bottom: var(--gap-hero);
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74,222,128,.75);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  70%  { box-shadow: 0 0 0 8px rgba(74,222,128,0); }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}

.hero-title {
  margin: 0 0 var(--gap-hero);
  /* «porusski-gaplashamiz» is long: scale it to the viewport and let it wrap
     rather than push the page wider than the screen. */
  font-size: clamp(19px, min(6.4vw, 3.5vh), 28px);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -.022em;
  overflow-wrap: break-word;
  word-break: break-word;
}

.hero-title .quote { display: block; }
.hero-title .line2 {
  display: block;
  margin-top: 5px;
  white-space: nowrap;
}

.hero-title .ver {
  display: inline-block;
  padding: 1px 11px;
  border-radius: 9px;
  background: #fff;
  color: var(--v-700);
  font-size: .82em;
  vertical-align: middle;
}

.hero-title .kind {
  font-size: clamp(14px, min(4.3vw, 2.3vh), 19px);
  font-weight: 600;
  color: var(--v-200);
  letter-spacing: 0;
  vertical-align: middle;
}

.hero-text {
  margin: 0 auto;
  max-width: 25em;
  font-size: clamp(13px, min(3.9vw, 1.85vh), 16px);
  line-height: 1.5;
  color: rgba(255,255,255,.9);
}

.hero-text b { color: #fff; font-weight: 700; }

/* ── card ───────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-card);
  padding: var(--card-py) 20px;
}

/* ── fields ─────────────────────────────────────────────────────────── */
.field { margin-bottom: var(--gap-fld); }

.field > label {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: clamp(4px, .8vh, 7px);
}

.field input {
  width: 100%;
  font: inherit;
  font-size: 16px; /* keeps iOS Safari from zooming on focus */
  color: var(--text);
  padding: clamp(10px, 1.6vh, 14px) 15px;
  background: #fff;
  border: 1.5px solid var(--v-200);
  border-radius: 13px;
  transition: border-color .15s, box-shadow .15s;
}

.field select {
  width: 100%;
  font: inherit;
  font-size: 16px; /* keeps iOS Safari from zooming on focus */
  color: var(--text);
  padding: clamp(10px, 1.6vh, 14px) 15px;
  padding-right: 44px;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236d28d9' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 17px;
  border: 1.5px solid var(--v-200);
  border-radius: 13px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}

/* Nothing picked yet -> the prompt reads as a placeholder, not as an answer. */
.field select:required:invalid { color: #a49dbc; }
.field select option { color: var(--text); }
.field select option[value=""] { color: #a49dbc; }

.field input::placeholder { color: #a49dbc; }

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--v-500);
  box-shadow: 0 0 0 4px rgba(139,92,246,.18);
}

.field.has-error input,
.field.has-error select { border-color: var(--danger); }
.field.has-error input:focus { box-shadow: 0 0 0 4px rgba(217,45,32,.14); }

.hint, .err { display: block; font-size: 12.5px; margin-top: clamp(3px, .7vh, 6px); }
.hint { color: var(--muted); }
.err  { color: var(--danger); font-weight: 600; }

/* Honeypot — off-screen, never shown to a human. */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.fineprint {
  margin: clamp(9px, 1.6vh, 14px) 0 0;
  font-size: clamp(10.5px, 1.5vh, 12px);
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
}

/* ── buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  padding: clamp(11px, 1.9vh, 15px) 20px;
  border: 1px solid transparent;
  border-radius: 13px;
  cursor: pointer;
  transition: filter .15s, background .15s, border-color .15s, transform .06s;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  width: 100%;
  font-size: 16.5px;
  color: #fff;
  background: linear-gradient(180deg, var(--v-500), var(--v-700));
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover { filter: brightness(1.07); }

.btn-arrow { width: 18px; height: 18px; }
.btn-tg    { width: 19px; height: 19px; }

.btn-secondary { background: var(--v-600); color: #fff; }
.btn-secondary:hover { background: var(--v-700); }

.btn-ghost {
  background: #fff;
  color: var(--v-700);
  border-color: var(--v-200);
  font-weight: 600;
}
.btn-ghost:hover { background: var(--v-50); }

.btn-sm { width: auto; padding: 9px 15px; font-size: 14px; border-radius: 10px; }

.topbar-actions .btn-primary { width: auto; box-shadow: none; }

/* ── alerts ─────────────────────────────────────────────────────────── */
.alert, .notice {
  border-radius: 12px;
  padding: 12px 15px;
  font-size: 14px;
  margin: 0 0 18px;
}

.alert  { background: #fef3f2; border: 1px solid #fecdca; color: #b42318; }
.notice { background: var(--ok-bg); border: 1px solid #abefc6; color: var(--ok); }

/* ── success state ──────────────────────────────────────────────────── */
.card-success { text-align: center; padding: clamp(22px, 4vh, 40px) 22px; }

.success-mark {
  width: clamp(52px, 8vh, 64px);
  height: clamp(52px, 8vh, 64px);
  margin: 0 auto clamp(12px, 2.4vh, 20px);
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(180deg, var(--v-500), var(--v-700));
  border-radius: 50%;
  box-shadow: var(--shadow-btn);
}

.success-mark svg { width: 30px; height: 30px; }

.card-success h1 {
  margin: 0 0 10px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.card-success .lead { margin: 0 0 clamp(14px, 2.6vh, 22px); color: var(--muted); font-size: 15px; }
.card-success .lead strong { color: var(--v-700); }

/* ══ ADMIN ══════════════════════════════════════════════════════════ */
.page-admin { background: var(--bg); }

.shell-narrow { max-width: 420px; }
.shell-narrow .card h1 { margin: 0 0 6px; font-size: 23px; font-weight: 800; }
.shell-narrow .card .lead { margin: 0 0 22px; color: var(--muted); font-size: 14.5px; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand strong { display: block; font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.brand span   { font-size: 13px; color: var(--muted); }

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.admin-shell { max-width: 1120px; margin: 0 auto; padding: 18px 14px 56px; }

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}

.stat-num   { display: block; font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--v-700); }
.stat-label { font-size: 12.5px; color: var(--muted); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.filters input[type="search"] {
  flex: 1 1 200px;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  padding: 10px 13px;
  border: 1.5px solid var(--v-200);
  border-radius: 10px;
}

.filters select {
  font: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1.5px solid var(--v-200);
  border-radius: 10px;
  background: #fff;
}

.filters input:focus, .filters select:focus {
  outline: none;
  border-color: var(--v-500);
  box-shadow: 0 0 0 3px rgba(139,92,246,.16);
}

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.grid { width: 100%; border-collapse: collapse; font-size: 14.5px; }

.grid th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--v-700);
  background: var(--v-50);
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.grid td {
  padding: 13px 14px;
  border-bottom: 1px solid #f3effd;
  vertical-align: middle;
}

.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover { background: var(--v-50); }
.grid tr.is-done .cell-name { color: var(--muted); }

.col-id  { width: 52px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col-act { width: 1%; white-space: nowrap; }

.cell-name { font-weight: 700; }
.cell-date { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.phone {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-decoration: none;
  font-weight: 600;
  color: var(--v-700);
}
.phone:hover { text-decoration: underline; }

.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.fmt {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 8px;
  white-space: nowrap;
  color: var(--v-800);
  background: var(--v-50);
  border: 1px solid var(--v-200);
}

.fmt-mustaqil { color: #0b5f73; background: #ecfbff; border-color: #b8e8f4; }

.tag-new  { color: var(--v-700); background: var(--v-100); }
.tag-done { color: var(--ok);    background: var(--ok-bg); }

.inline { display: flex; gap: 12px; align-items: center; }

.link-btn {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--v-600);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); margin: 0; }

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 13px 16px;
  border-top: 1px solid var(--line);
  background: var(--v-50);
  font-size: 13.5px;
  color: var(--muted);
}

.pager { display: flex; align-items: center; gap: 10px; }
.pager-pos { font-variant-numeric: tabular-nums; }

/* ══ larger screens ═════════════════════════════════════════════════ */
@media (min-width: 560px) {
  .hero-text { font-size: 16px; }
  .card { padding: 32px 30px; }
  .card-success { padding: 40px 32px; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .admin-shell { padding: 26px 20px 60px; }
  .topbar-inner { padding: 14px 20px; }
}

@media (max-width: 719px) {
  .col-act .inline { flex-direction: column; align-items: flex-start; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto; }
}

/* ── very short viewports (landscape phones) ────────────────────────
   The page is locked to one screen everywhere else; below this height the
   form would be clipped, so scrolling is allowed rather than cutting the
   submit button off. */
@media (max-height: 520px) {
  .page-form {
    height: auto;
    min-height: 100%;
    min-height: 100dvh;
    overflow: visible;
  }
  .shell { justify-content: flex-start; }
}
