:root {
  --navy: #143a6b;
  --navy-2: #1e5191;
  --blue: #2b6cb0;
  --blue-soft: #e7f0fb;
  --bg: #eef2f7;
  --card: #ffffff;
  --text: #16263f;
  --muted: #6b7a90;
  --border: #d9e1ec;
  --danger: #e0564f;
  --ok: #2faf6d;
  --grad: linear-gradient(135deg, #1e5191 0%, #143a6b 100%);
  --shadow: 0 6px 20px rgba(20, 58, 107, 0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", Roboto, "Segoe UI", system-ui, sans-serif;
  font-size: 16px; line-height: 1.45;
}
.loading { text-align: center; padding: 70px 0; color: var(--muted); }

/* ── Header ─────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--grad); color: #fff;
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 14px rgba(20, 58, 107, 0.25);
}
.topbar .logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: rgba(255,255,255,0.16); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.topbar .logo svg { width: 22px; height: 22px; stroke: #fff; }
.topbar .t { font-size: 17px; font-weight: 700; letter-spacing: .2px; }
.topbar .s { font-size: 12px; opacity: .8; }

/* ── Layout ─────────────────────────── */
.wrap {
  max-width: 640px; margin: 0 auto; padding: 16px 14px 14px;
  display: flex; flex-direction: column; min-height: calc(100dvh - 66px);
}
/* Klaviatura ochilganda faol kartani yuqoriga ko‘tarish uchun joy */
#steps { padding-bottom: 40vh; }

/* ── Kartalar ───────────────────────── */
.card {
  background: var(--card); border-radius: 16px; padding: 18px 16px;
  box-shadow: var(--shadow); margin-bottom: 14px; border: 1px solid var(--border);
  animation: rise .28s ease both; scroll-margin-top: 78px;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.welcome { border-left: 4px solid var(--blue); }
.welcome .wt { font-weight: 700; font-size: 16px; margin-bottom: 6px; color: var(--navy); }
.welcome .wb { color: var(--muted); font-size: 14px; white-space: pre-line; }

/* Savol kartasi */
.q-head { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 14px; }
.q-badge {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  background: var(--blue-soft); color: var(--navy);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.q-badge svg { width: 17px; height: 17px; stroke: var(--navy); }
.q-title { font-weight: 600; font-size: 15.5px; padding-top: 3px; }
.q-title .opt { color: var(--muted); font-weight: 500; font-size: 13px; }

.field { margin-bottom: 12px; }
.field:last-of-type { margin-bottom: 0; }
.field .sub-label { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 5px; }

input[type=text], textarea, .inp {
  width: 100%; padding: 13px 14px; font-size: 16px; color: var(--text);
  border: 1.5px solid var(--border); border-radius: 12px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, .inp:focus-within {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.12);
}
textarea { resize: vertical; min-height: 52px; }

/* Telefon: +998 prefiks */
.inp.phone { display: flex; align-items: center; padding: 0; overflow: hidden; }
.inp.phone .prefix {
  padding: 13px 12px; background: var(--blue-soft); color: var(--navy); font-weight: 700;
  border-right: 1.5px solid var(--border); flex-shrink: 0;
}
.inp.phone input { border: none; box-shadow: none; flex: 1; padding: 13px 14px; font-size: 16px; }
.inp.phone input:focus { outline: none; }

.field .err { display: none; color: var(--danger); font-size: 13px; margin-top: 6px; }
.field.invalid input, .field.invalid textarea, .field.invalid .inp { border-color: var(--danger); }
.field.invalid .err { display: block; }

/* Rasm yuklash (custom) */
.dropzone {
  border: 2px dashed #b9c8dc; border-radius: 14px; padding: 26px 16px; text-align: center;
  cursor: pointer; background: #f7fafd; transition: background .15s, border-color .15s;
}
.dropzone:active { background: var(--blue-soft); }
.dropzone .up-ic { width: 46px; height: 46px; margin: 0 auto 10px; border-radius: 50%;
  background: var(--blue-soft); display: flex; align-items: center; justify-content: center; }
.dropzone .up-ic svg { width: 24px; height: 24px; stroke: var(--navy); }
.dropzone .t1 { font-weight: 600; color: var(--navy); }
.dropzone .t2 { font-size: 13px; color: var(--muted); margin-top: 3px; }
.dropzone.has-file { border-style: solid; border-color: var(--ok); background: #fff; padding: 14px; }
.dropzone img { display: block; width: auto; height: 180px; max-width: 100%; border-radius: 10px; margin: 0 auto 8px; object-fit: contain; }
.dropzone .fname { font-size: 13px; color: var(--ok); font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.dropzone .fname svg { width: 15px; height: 15px; stroke: var(--ok); }

/* Tugmalar */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px; font-size: 16px; font-weight: 700; cursor: pointer;
  border: none; border-radius: 13px; margin-top: 14px;
}
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(20,58,107,.22); }
.btn.primary:active { transform: translateY(1px); }
.btn.primary:disabled { opacity: .55; box-shadow: none; }
.btn.primary svg { stroke: #fff; }
.btn.ghost { background: var(--blue-soft); color: var(--navy); }
.btn.ghost svg { stroke: var(--navy); }
.btn.danger { background: #fff; color: var(--danger); border: 1.5px solid var(--danger); }
.btn.danger svg { stroke: var(--danger); }

/* Javob berilgan (lock) karta */
.card.locked { opacity: .92; background: #fbfcfe; }
.card.locked .q-badge { background: #e3f5ea; }
.card.locked .q-badge svg { stroke: var(--ok); }
.card.locked .answer-view {
  background: var(--blue-soft); border-radius: 10px; padding: 10px 12px; font-size: 15px;
  color: var(--navy); word-break: break-word; white-space: pre-line;
}
.card.locked .answer-view + .answer-view { margin-top: 8px; }

/* Yakuniy submit karta */
.submit-card { text-align: center; }
.submit-card .big-ic { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%;
  background: var(--grad); display: flex; align-items: center; justify-content: center; }
.submit-card .big-ic svg { width: 28px; height: 28px; stroke: #fff; }
.submit-card h2 { margin: 0 0 6px; font-size: 18px; color: var(--navy); }
.submit-card p { color: var(--muted); font-size: 14px; margin: 0 0 4px; }

/* Holat ekranlari */
.state { text-align: center; padding: 40px 18px; }
.state .ic { width: 70px; height: 70px; margin: 0 auto 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; }
.state .ic svg { width: 36px; height: 36px; }
.state .ic.ok { background: #e3f5ea; } .state .ic.ok svg { stroke: var(--ok); }
.state .ic.info { background: var(--blue-soft); } .state .ic.info svg { stroke: var(--navy); }
.state .ic.warn { background: #fdeceb; } .state .ic.warn svg { stroke: var(--danger); }
.state h1 { font-size: 20px; margin: 0 0 8px; color: var(--navy); }
.state p { color: var(--muted); }

/* ── Modal ──────────────────────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(15,30,55,.55); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  background: #fff; border-radius: 18px; max-width: 360px; width: 100%; padding: 22px 20px;
  text-align: center; transform: scale(.94); transition: transform .2s;
}
.overlay.show .modal { transform: scale(1); }
.modal .m-ic { width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 50%;
  background: #fdf3e7; display: flex; align-items: center; justify-content: center; }
.modal .m-ic svg { width: 28px; height: 28px; stroke: #e0913f; }
.modal h3 { margin: 0 0 8px; font-size: 18px; color: var(--navy); }
.modal p { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.modal .row { display: flex; gap: 10px; }
.modal .row .btn { margin-top: 0; }

/* ── Admin ──────────────────────────── */
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.search-box { flex: 1; display: flex; align-items: center; gap: 8px; background: #fff;
  border: 1.5px solid var(--border); border-radius: 12px; padding: 0 12px; }
.search-box svg { width: 18px; height: 18px; stroke: var(--muted); flex-shrink: 0; }
.search-box input { border: none; padding: 12px 0; font-size: 15px; flex: 1; }
.search-box input:focus { outline: none; }
.count { color: var(--muted); font-size: 13px; margin-bottom: 12px; }

.row-card {
  background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px;
  margin-bottom: 10px; cursor: pointer; display: flex; gap: 12px; align-items: center;
  box-shadow: var(--shadow);
}
.row-card:active { background: var(--blue-soft); }
.row-card .av { width: 42px; height: 42px; border-radius: 12px; background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; font-size: 17px; }
.row-card .meta { flex: 1; min-width: 0; }
.row-card .meta .name { font-weight: 600; }
.row-card .meta .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-card .chev svg { width: 20px; height: 20px; stroke: var(--muted); }

.back-btn { display: inline-flex; align-items: center; gap: 5px; color: var(--navy); background: none;
  border: none; font-size: 15px; font-weight: 600; padding: 4px 0; cursor: pointer; margin-bottom: 8px; }
.back-btn svg { width: 18px; height: 18px; stroke: var(--navy); }
.detail-photo { text-align: center; margin: 6px 0 16px; }
.detail-photo img { max-width: 170px; border-radius: 14px; border: 1px solid var(--border); }

/* Aloqa tugmalari (rahmat ekrani) */
.contacts { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }
.contacts-hint { color: var(--muted); font-size: 13px; margin-bottom: 2px; }
.contacts .btn { margin-top: 0; }

/* Footer — doim eng pastda, tugma ko‘rinishida */
.footer { margin-top: auto; padding-top: 22px; display: flex; justify-content: center; }
.footer .fbtn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 8px 16px; border: 1px solid var(--border); border-radius: 20px;
  background: #fff; box-shadow: var(--shadow);
}
.footer .fbtn i { color: var(--muted); font-size: 12.5px; font-style: italic; }
.footer .fbtn:active { background: var(--blue-soft); border-color: var(--blue); }
.footer .fbtn:active i { color: var(--navy); }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 11px 20px; border-radius: 22px; font-size: 14px;
  opacity: 0; transition: opacity .2s; z-index: 70; pointer-events: none; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.toast.show { opacity: .97; }
