/* ===================================================================
   HR test tizimi — umumiy uslublar
   Ranglar bitta manbadan (tokens). Mobil birinchi navbatda.
   =================================================================== */

:root {
  --bg:         #f6f7f9;
  --surface:    #ffffff;
  --surface-2:  #f0f2f5;
  --border:     #dde1e7;
  --text:       #1b1f24;
  --text-dim:   #667085;

  --brand:      #7a4b2a;   /* to'q yog'och rangi — Mashitta uslubi */
  --brand-soft: #f3e9e1;
  --accent:     #2c5fb3;

  --ok:         #1e8449;
  --warn:       #d68910;
  --danger:     #c0392b;

  --r:          12px;
  --r-sm:       8px;
  --shadow:     0 1px 3px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a; --surface: #1c2025; --surface-2: #23282e; --border: #2f353c;
    --text: #e7eaee; --text-dim: #98a2b3; --brand-soft: #2a2018;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* `hidden` atributi har doim g'olib bo'lsin. Aks holda `.topbar { display:flex }`
   kabi klass qoidalari brauzerning [hidden] qoidasini bekor qiladi. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  padding: 0;
  /* iOS da input fokuslanganda sahifa sakramasligi uchun */
  min-height: 100vh;
}

.wrap { max-width: 640px; margin: 0 auto; padding: 16px; }
.wrap-wide { max-width: 1200px; margin: 0 auto; padding: 16px; }

/* ------------------------------------------------------------ tipografika */

h1 { font-size: 22px; line-height: 1.25; margin-bottom: 6px; }
h2 { font-size: 18px; margin-bottom: 10px; }
h3 { font-size: 15px; margin-bottom: 6px; }
p  { margin-bottom: 10px; }
.dim { color: var(--text-dim); }
.small { font-size: 13px; }
.center { text-align: center; }

/* ----------------------------------------------------------------- kartalar */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

/* ------------------------------------------------------------------ tugmalar */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600;
  padding: 13px 20px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--brand); color: #fff;
  cursor: pointer;
  transition: filter .15s, opacity .15s;
  /* mobil uchun minimal teginish maydoni */
  min-height: 46px;
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); filter: none; }
.btn-sm { padding: 7px 12px; min-height: 34px; font-size: 13px; }
.btn-danger { background: var(--danger); }

/* -------------------------------------------------------------------- forma */

.field { margin-bottom: 14px; }
.field > label {
  display: block; font-size: 13px; font-weight: 600;
  margin-bottom: 5px; color: var(--text);
}
.field .hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.req::after { content: ' *'; color: var(--danger); }

input[type=text], input[type=tel], input[type=date], input[type=time],
input[type=number], input[type=password], select, textarea {
  width: 100%;
  font: inherit;
  /* 16px dan kichik bo'lsa iOS Safari fokuslanganda zoom qiladi */
  font-size: 16px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

/* tanlanadigan "chip" tugmalar (kunlar) */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 9px 14px; border: 1px solid var(--border); border-radius: 20px;
  background: var(--surface); cursor: pointer; user-select: none; font-size: 14px;
}
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ------------------------------------------------------------------- rasm */

.photo-box {
  display: flex; gap: 14px; align-items: center;
  padding: 14px; border: 2px dashed var(--border); border-radius: var(--r);
  background: var(--surface-2);
}
.photo-box.filled { border-style: solid; border-color: var(--ok); }
.photo-preview {
  width: 84px; height: 104px; flex: none; border-radius: var(--r-sm);
  object-fit: cover; background: var(--border);
}
.photo-placeholder {
  width: 84px; height: 104px; flex: none; border-radius: var(--r-sm);
  background: var(--border); display: flex; align-items: center; justify-content: center;
  font-size: 30px;
}

/* ---------------------------------------------------------------- xabarlar */

.alert { padding: 11px 14px; border-radius: var(--r-sm); font-size: 14px; margin-bottom: 12px; }
.alert-err  { background: #fdecea; color: #922b21; border: 1px solid #f5c6cb; }
.alert-ok   { background: #e8f6ef; color: #14653a; border: 1px solid #b7e0cb; }
.alert-warn { background: #fef5e7; color: #8a5b00; border: 1px solid #f6d99a; }
@media (prefers-color-scheme: dark) {
  .alert-err  { background: #3a1d1a; color: #f5b7b1; border-color: #6b2f28; }
  .alert-ok   { background: #12301f; color: #a9dfbf; border-color: #1e5b38; }
  .alert-warn { background: #33280f; color: #f8d477; border-color: #6b5417; }
}

/* -------------------------------------------------------------- test oqimi */

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.progress { flex: 1; height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); transition: width .25s; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }
.timer.low { color: var(--danger); }

.q-num { font-size: 12px; font-weight: 700; color: var(--brand); letter-spacing: .06em; }
.q-text { font-size: 18px; line-height: 1.4; margin: 6px 0 18px; }

.opt {
  display: block; width: 100%; text-align: left;
  font: inherit; font-size: 15px; line-height: 1.4;
  padding: 14px 16px; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: background .12s, border-color .12s, transform .08s;
}
.opt:hover { border-color: var(--brand); background: var(--brand-soft); }
.opt:active { transform: scale(.99); }
.opt.picked { border-color: var(--brand); background: var(--brand); color: #fff; }

.charcount { font-size: 12px; color: var(--text-dim); text-align: right; margin-top: 4px; }
.charcount.ok { color: var(--ok); }

/* ------------------------------------------------------------ admin jadval */

table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th, table.list td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); }
table.list th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); white-space: nowrap; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: var(--surface-2); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.g-A { background: #d5f5e3; color: #145a32; }
.g-B { background: #d6eaf8; color: #1a5276; }
.g-C { background: #fdebd0; color: #7e5109; }
.g-D { background: #fadbd8; color: #922b21; }

.avatar { width: 34px; height: 42px; border-radius: 6px; object-fit: cover; background: var(--surface-2); display: block; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 12px; }
.filters .field { margin: 0; min-width: 130px; flex: 1; }
.filters select, .filters input { font-size: 14px; padding: 8px 10px; }

/* modal */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 16px; overflow-y: auto;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--surface); border-radius: var(--r); max-width: 900px; width: 100%;
  padding: 20px; margin: auto 0; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.x { margin-left: auto; background: none; border: none; font-size: 26px; line-height: 1;
     cursor: pointer; color: var(--text-dim); padding: 0 6px; }

/* shkala bari */
.bar-row { display: flex; align-items: center; gap: 10px; margin: 5px 0; font-size: 14px; }
.bar-label { width: 165px; flex: none; }
.bar-track { flex: 1; height: 11px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 6px; }
.bar-val { width: 42px; text-align: right; font-weight: 700; flex: none; font-variant-numeric: tabular-nums; }

.flagbox { background: #fdecea; border-left: 4px solid var(--danger); color: #922b21;
           padding: 9px 13px; border-radius: 0 var(--r-sm) var(--r-sm) 0; margin: 8px 0; font-size: 14px; }
@media (prefers-color-scheme: dark) { .flagbox { background: #3a1d1a; color: #f5b7b1; } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tab { padding: 9px 14px; border: none; background: none; font: inherit; font-size: 14px;
       color: var(--text-dim); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.stat-row { display: flex; gap: 14px; flex-wrap: wrap; }
.stat { flex: 1; min-width: 110px; background: var(--surface-2); border-radius: var(--r-sm); padding: 12px 14px; }
.stat b { display: block; font-size: 24px; line-height: 1.2; }
.stat span { font-size: 12px; color: var(--text-dim); }

.link-item { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.link-item code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
                  background: var(--surface-2); padding: 5px 8px; border-radius: 5px; font-size: 12px; }

.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.35);
           border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  .bar-label { width: 120px; font-size: 13px; }
  .row { flex-direction: column; gap: 14px; }
  .modal { padding: 0; }
  .modal-box { border-radius: 0; min-height: 100vh; }
}
