/* MMSI Gaaza survey site. Palette from mmsi-gaaza.ru. */

@font-face { font-family: "PT Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../vendor/pt-sans/pt-sans-cyrillic-400-normal.f2664d403038.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "PT Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../vendor/pt-sans/pt-sans-latin-400-normal.3f66ddcf744f.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "PT Sans"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../vendor/pt-sans/pt-sans-cyrillic-700-normal.5e1ae1c98141.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "PT Sans"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../vendor/pt-sans/pt-sans-latin-700-normal.35e5705c45cf.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "PT Sans"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("../vendor/pt-sans/pt-sans-cyrillic-400-italic.b1ff89aab632.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "PT Sans"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("../vendor/pt-sans/pt-sans-latin-400-italic.b4f5899e5748.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --green: #3a6640;
  --green-dark: #384f34;
  --green-light: #eaf2eb;
  --orange: #eea734;
  --orange-dark: #d98f1a;
  --brown: #884c16;
  --text: #333333;
  --muted: #6e6e6e;
  --line: #e0e0e0;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --warning-bg: #fff6e5;
  --data: #3f7f48;          /* chart marks: brand green, validated chroma */
  --radius: 6px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 1px 6px rgba(0, 0, 0, .04);
  --focus: 0 0 0 3px rgba(58, 102, 64, .3);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font-family: "PT Sans", "Segoe UI", Arial, sans-serif; font-size: 16px; line-height: 1.5;
  color: var(--text); background: var(--bg);
}
[x-cloak] { display: none !important; }
a { color: var(--green); }
a:hover { color: var(--green-dark); }
h1, h2, h3 { color: var(--brown); line-height: 1.25; margin: 0 0 .6em; font-weight: 700; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.pre-line { white-space: pre-line; }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* --- layout ------------------------------------------------------------------------- */
.topbar { background: var(--green); height: 6px; }
.header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header__inner { display: flex; align-items: center; gap: 24px; padding: 12px 16px; max-width: 1200px; margin: 0 auto; flex-wrap: wrap; }
.header__logo img { display: block; height: 64px; width: auto; max-width: 100%; }
.nav { display: flex; gap: 4px 18px; margin-left: auto; flex-wrap: wrap; align-items: center; }
.nav a, .nav button.linklike { color: var(--text); text-decoration: none; font-weight: 700; font-size: .95rem; text-transform: uppercase; letter-spacing: .02em; }
.nav a:hover, .nav a.active { color: var(--green); }
.nav__user { color: var(--muted); font-size: .875rem; }
main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 28px 16px 48px; }
main.narrow { max-width: 760px; }
.footer { background: var(--green-dark); color: #dfe7de; font-size: .875rem; }
.footer__inner { max-width: 1200px; margin: 0 auto; padding: 18px 16px; display: flex; gap: 8px 24px; flex-wrap: wrap; justify-content: space-between; }
.footer a { color: #fff; }

.page-head { display: flex; gap: 12px 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card--flat { box-shadow: none; border: 1px solid var(--line); }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* --- buttons & forms ----------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px;
  border: 1px solid transparent; border-radius: var(--radius); font: inherit; font-weight: 700; line-height: 1.2;
  cursor: pointer; text-decoration: none; background: var(--green); color: #fff; transition: background .15s; }
.btn:hover { background: var(--green-dark); color: #fff; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .choice input:focus-visible + span { outline: none; box-shadow: var(--focus); }
.btn--accent { background: var(--orange); color: #2b1d05; }
.btn--accent:hover { background: var(--orange-dark); color: #2b1d05; }
.btn--ghost { background: transparent; color: var(--green); border-color: var(--green); }
.btn--ghost:hover { background: var(--green-light); color: var(--green-dark); }
.btn--plain { background: transparent; color: var(--text); border-color: var(--line); }
.btn--plain:hover { background: var(--bg); color: var(--text); }
.btn--danger { background: transparent; color: var(--danger); border-color: #e4b4b0; }
.btn--danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn--small { min-height: 32px; padding: 4px 10px; font-size: .875rem; }
.btn--icon { min-height: 32px; width: 32px; padding: 0; font-size: 1rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
button.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--green); cursor: pointer; text-decoration: underline; }

label { font-weight: 700; display: block; margin-bottom: 4px; }
.field { margin-bottom: 16px; }
.field__help { color: var(--muted); font-size: .875rem; margin-top: 4px; }
.field__error, .errorlist { color: var(--danger); font-size: .9rem; margin: 6px 0 0; padding: 0; list-style: none; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; font: inherit; color: var(--text); background: #fff;
  border: 1px solid #c9c9c9; border-radius: var(--radius); min-height: 42px;
}
textarea { min-height: 96px; resize: vertical; }
input[aria-invalid=true], select[aria-invalid=true], textarea[aria-invalid=true] { border-color: var(--danger); }
input[type=checkbox], input[type=radio] { accent-color: var(--green); width: 18px; height: 18px; margin: 0; flex: none; }
.checkbox { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.checkbox input { margin-top: 3px; }
.form-row { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* --- messages ----------------------------------------------------------------------- */
.messages { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 8px; }
.alert { padding: 12px 16px; border-radius: var(--radius); border-left: 4px solid var(--green); background: var(--green-light); }
.alert--error { border-color: var(--danger); background: var(--danger-bg); }
.alert--warning { border-color: var(--orange); background: var(--warning-bg); }

/* --- tables & badges ----------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; }
.table tr:hover td { background: #fafafa; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #eee; color: #555; white-space: nowrap; }
.badge--published { background: var(--green-light); color: var(--green-dark); }
.badge--closed { background: #f1e6dc; color: var(--brown); }
.badge--draft { background: #eeeeee; color: #555; }
.badge--scheduled { background: var(--warning-bg); color: #8a5a00; }
.badge--locked { background: var(--warning-bg); color: #8a5a00; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 20px; flex-wrap: wrap; }
.tabs a { padding: 10px 16px; text-decoration: none; color: var(--muted); font-weight: 700; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a.active { color: var(--green); border-color: var(--green); }

.pagination { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

/* --- public survey form ---------------------------------------------------------------- */
.survey-head { margin-bottom: 20px; }
.survey-head h1 { font-size: 1.9rem; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 8px 0 20px; }
.progress__bar { height: 100%; background: var(--orange); transition: width .25s; }
.question { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 14px; border-left: 4px solid transparent; }
.question--error { border-left-color: var(--danger); }
.question__title { font-weight: 700; font-size: 1.08rem; margin-bottom: 4px; white-space: pre-line; }
.question__required { color: var(--danger); margin-left: 2px; }
.question__help { color: var(--muted); font-size: .92rem; margin-bottom: 10px; white-space: pre-line; }
.question--info { background: var(--green-light); box-shadow: none; white-space: pre-line; }
.choices { display: grid; gap: 6px; margin-top: 10px; }
.choice { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; margin: 0; }
.choice:hover { border-color: var(--green); background: #fbfdfb; }
.choice input { margin-top: 3px; }
.choice--checked { border-color: var(--green); background: var(--green-light); }
.other-input { margin: 4px 0 0 30px; width: calc(100% - 30px); }
.scale { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.scale__item { flex: 1 0 44px; max-width: 64px; }
.scale__item input { position: absolute; opacity: 0; pointer-events: none; }
.scale__item span { display: flex; align-items: center; justify-content: center; height: 44px; border: 1px solid #c9c9c9; border-radius: var(--radius); cursor: pointer; font-weight: 700; }
.scale__item input:checked + span { background: var(--green); border-color: var(--green); color: #fff; }
.scale__item input:focus-visible + span { box-shadow: var(--focus); }
.scale__labels { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: .875rem; margin-top: 6px; }
.matrix { width: 100%; border-collapse: collapse; margin-top: 10px; }
.matrix th, .matrix td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: center; }
.matrix th { font-size: .85rem; font-weight: 700; color: var(--muted); }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix label { display: flex; justify-content: center; margin: 0; padding: 6px; cursor: pointer; }
.form-nav { display: flex; gap: 12px; justify-content: space-between; align-items: center; margin-top: 20px; flex-wrap: wrap; }
.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.preview-banner { background: var(--warning-bg); border: 1px dashed var(--orange); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; }
.consent { font-size: .92rem; }
.email-hint { margin-top: 6px; font-size: .9rem; }

@media (max-width: 640px) {
  .header__logo img { height: 48px; }
  .nav { margin-left: 0; }
  h1, .survey-head h1 { font-size: 1.45rem; }
  .question { padding: 16px; }
  /* Matrix: one block per row on phones. */
  .matrix thead { display: none; }
  .matrix, .matrix tbody, .matrix tr, .matrix td { display: block; width: 100%; }
  .matrix tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  .matrix td { border: 0; text-align: left; padding: 2px 0; }
  .matrix td:first-child { font-weight: 700; }
  .matrix label { justify-content: flex-start; gap: 8px; }
  .matrix label::after { content: attr(data-label); font-weight: 400; }
}

/* --- results: charts ----------------------------------------------------------------- */
.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 20px; }
.stat__value { font-size: 2rem; font-weight: 700; color: var(--text); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat__label { color: var(--muted); font-size: .9rem; }
.bars { display: grid; gap: 10px; margin-top: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 2fr) 3fr minmax(90px, auto); gap: 12px; align-items: center; }
.bar-row__label { overflow-wrap: anywhere; }
.bar-track { height: 18px; position: relative; border-left: 1px solid #cfcfcf; }
.bar { height: 100%; max-width: 100%; background: var(--data); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar--zero { min-width: 0; }
.bar-row__value { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-row__value b { margin-right: 6px; }
@media (max-width: 640px) {
  .bar-row { grid-template-columns: 1fr auto; }
  .bar-track { grid-column: 1 / -1; grid-row: 2; }
}
.timeline { display: flex; align-items: flex-end; gap: 2px; height: 120px; border-bottom: 1px solid #cfcfcf; margin-top: 12px; }
.timeline__col { flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; position: relative; min-width: 3px; }
.timeline__col span { display: block; width: 100%; max-width: 24px; margin: 0 auto; background: var(--data); border-radius: 4px 4px 0 0; }
.timeline__col:hover span { background: var(--green-dark); }
.timeline__col .tip { display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 4px 8px; border-radius: 4px; font-size: .8rem; white-space: nowrap; z-index: 2; pointer-events: none; }
.timeline__col:hover .tip, .timeline__col:focus .tip { display: block; }
.timeline__axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; margin-top: 4px; }
.heat td.cell { text-align: center; font-variant-numeric: tabular-nums; background: color-mix(in srgb, var(--data) var(--p), #ffffff); }
.heat td.cell--dark { color: #fff; }
.q-stats__meta { color: var(--muted); font-size: .9rem; margin-bottom: 6px; }
.kv { display: flex; gap: 8px 24px; flex-wrap: wrap; margin: 8px 0; }
.kv div { min-width: 90px; }
.kv b { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.samples { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.samples li { background: var(--bg); padding: 8px 12px; border-radius: var(--radius); white-space: pre-line; overflow-wrap: anywhere; }

/* --- filter panel -------------------------------------------------------------------- */
.filter-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px; }
.filter-panel summary { cursor: pointer; font-weight: 700; color: var(--green); }
.rule { display: grid; grid-template-columns: minmax(180px, 2fr) minmax(140px, 1fr) minmax(160px, 2fr) auto; gap: 8px; align-items: start; margin-bottom: 8px; }
@media (max-width: 760px) { .rule { grid-template-columns: 1fr; } }
.rule__values { display: grid; gap: 4px; max-height: 180px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px; background: #fff; }
.rule__values label { font-weight: 400; display: flex; gap: 6px; align-items: flex-start; margin: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--green-light); color: var(--green-dark); border-radius: 999px; padding: 2px 10px; font-size: .85rem; }

/* --- builder --------------------------------------------------------------------------- */
.builder { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.builder__bar { position: sticky; top: 0; z-index: 10; background: rgba(245, 245, 245, .96); backdrop-filter: blur(4px); padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px 12px; align-items: center; flex-wrap: wrap; }
.save-state { font-size: .9rem; color: var(--muted); }
.save-state--error { color: var(--danger); }
.b-page { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); border-top: 4px solid var(--green); }
.b-page__head { padding: 14px 16px; display: flex; gap: 10px; align-items: flex-start; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.b-page__title { flex: 1 1 260px; }
.b-page__body { padding: 12px 16px 16px; }
.b-page__questions { min-height: 48px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.b-q { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.b-q--open { border-color: var(--green); box-shadow: var(--shadow); }
.b-q__head { display: flex; gap: 10px; align-items: center; padding: 10px 12px; cursor: pointer; }
.b-q__handle, .b-page__handle { cursor: grab; color: #999; user-select: none; font-size: 1.1rem; padding: 2px 4px; }
.b-q__num { font-weight: 700; color: var(--brown); min-width: 32px; }
.b-q__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-q__type { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.b-q__body { padding: 4px 16px 16px; border-top: 1px solid var(--line); }
.b-q__tools { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-top: 12px; }
.b-option { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.b-option input[type=text] { min-height: 36px; padding: 6px 10px; }
.b-logic { background: #fafafa; border: 1px dashed #cfcfcf; border-radius: var(--radius); padding: 10px 12px; margin-top: 12px; }
.b-logic__title { font-weight: 700; font-size: .92rem; color: var(--green-dark); margin-bottom: 6px; }
.sortable-ghost { opacity: .4; }
.sortable-chosen { box-shadow: var(--shadow); }
.b-add { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.b-errors { margin: 0; padding-left: 18px; }
.b-settings { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* --- share ----------------------------------------------------------------------------- */
.share-link { display: flex; gap: 8px; flex-wrap: wrap; }
.share-link input { flex: 1 1 280px; font-family: ui-monospace, monospace; }
.qr { width: 240px; height: 240px; border: 1px solid var(--line); background: #fff; padding: 8px; }

@media print {
  .header .nav, .footer, .tabs, .filter-panel, .actions, .btn { display: none !important; }
  body { background: #fff; }
  .card, .stat, .question { box-shadow: none; border: 1px solid #ddd; }
}

/* --- Russian date / time fields --------------------------------------------------------- */
.date-field { position: relative; display: flex; align-items: stretch; max-width: 220px; }
.date-field input[type=text] { padding-right: 44px; font-variant-numeric: tabular-nums; }
.date-field__btn { position: absolute; right: 1px; top: 1px; bottom: 1px; width: 40px; border: 0; border-left: 1px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) 0; background: #fafafa; color: var(--green); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.date-field__btn:hover { background: var(--green-light); }
.date-field__btn:focus-visible { outline: none; box-shadow: var(--focus); }
.date-field__native { position: absolute; right: 0; bottom: 0; width: 40px; height: 100%; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.datetime-field { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.datetime-field .date-field { flex: 0 1 200px; }
.time-input { max-width: 96px; font-variant-numeric: tabular-nums; }
.b-option__toggle { display: flex; align-items: center; gap: 4px; font-weight: 400; font-size: .85rem; color: var(--muted); white-space: nowrap; margin: 0; cursor: pointer; }
