/* Рекрутинг УДЗ — мобільна оболонка. Light default + dark. Акцент: «польова зелень». */
:root {
  --bg: #f3f5f2; --surface: #ffffff; --surface-2: #f7f9f6;
  --ink: #1f2a37; --text: #18212e; --muted: #647184; --faint: #93a0b2;
  --line: #e4e8e3; --line-2: #eef1ec;
  --accent: #2f6b4f; --accent-2: #3d8b66; --accent-ink: #ffffff;
  --danger: #dc2626; --warn: #b45309; --ok: #16a34a; --pend: #2563eb;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16,24,32,.06), 0 6px 18px rgba(16,24,32,.05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
[data-theme="dark"] {
  --bg: #0e151b; --surface: #18222b; --surface-2: #131c24;
  --ink: #0b1218; --text: #e7edf2; --muted: #8a99a8; --faint: #5f6f7e;
  --line: #243039; --line-2: #1d2730;
  --accent: #3d8b66; --accent-2: #4fa97c; --accent-ink: #08120c;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 22px rgba(0,0,0,.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.4;
  overscroll-behavior-y: none;
}
input, select, textarea, button { font: inherit; color: inherit; }

#app { display: flex; flex-direction: column; min-height: 100dvh; }

/* ---------- Header ---------- */
.header { position: sticky; top: 0; z-index: 30; background: var(--ink); padding-top: var(--safe-t); }
.topbar { display: flex; align-items: center; justify-content: space-between; height: 54px; padding: 0 14px; }
.tb-left { display: flex; align-items: center; gap: 10px; }
.brand-dot { width: 12px; height: 12px; border-radius: 4px; background: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(61,139,102,.25); }
.tb-title { color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.tb-right { display: flex; align-items: center; gap: 8px; }
.topbar-edge { height: 2px; background: linear-gradient(90deg, var(--accent-2), transparent 70%); }

.sync-chip { display: inline-flex; align-items: center; gap: 6px; border: none; cursor: pointer;
  background: rgba(255,255,255,.12); color: #fff; padding: 6px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.sync-chip svg { display: block; }
.sync-chip.off { background: rgba(220,38,38,.25); }
.sync-chip.busy { background: rgba(37,99,235,.3); }
.sync-chip.pending { background: rgba(180,83,9,.35); }
.sync-chip.ok { background: rgba(61,139,102,.35); }

/* ---------- Content ---------- */
.content { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding-bottom: 84px; }
.page { padding: 12px 12px 0; max-width: 760px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.section-title { font-size: 12px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ''; width: 3px; height: 14px; border-radius: 2px; background: var(--accent); }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.empty { text-align: center; color: var(--faint); padding: 40px 0; }
.ver { text-align: center; color: var(--faint); font-size: 11.5px; padding: 16px 0 28px; }

/* ---------- Region pills ---------- */
.pills { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 4px; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill { flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 8px 13px; border-radius: 999px; font-weight: 600; font-size: 14px; cursor: pointer; display: flex; align-items: center; gap: 7px; }
.pill i { font-style: normal; font-size: 11.5px; font-weight: 700; background: var(--surface-2); color: var(--muted); padding: 1px 7px; border-radius: 999px; }
.pill.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pill.active i { background: rgba(255,255,255,.22); color: #fff; }

/* ---------- Search + filters ---------- */
.filters { margin-bottom: 8px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 12px; box-shadow: var(--shadow); }
.search-ic { color: var(--faint); display: flex; }
.search-inp { flex: 1; border: none; background: transparent; outline: none; padding: 12px 0; font-size: 15px; }
.chips { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 6px 12px; border-radius: 999px; font-size: 13px; cursor: pointer; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip-select { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.list-meta { color: var(--muted); font-size: 12.5px; margin: 6px 2px 10px; font-weight: 600; }

/* ---------- Record cards ---------- */
.rec-list { display: flex; flex-direction: column; gap: 10px; }
.rec { display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--accent));
  border-radius: var(--radius); padding: 12px 12px 12px 14px; box-shadow: var(--shadow); cursor: pointer; align-items: stretch; }
.rec:active { transform: scale(.995); }
.rec-main { flex: 1; min-width: 0; }
.rec-name { font-weight: 700; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-sub { color: var(--muted); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-tags { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.badge { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; color: var(--bc, #555);
  background: color-mix(in srgb, var(--bc, #888) 14%, transparent); border: 1px solid color-mix(in srgb, var(--bc, #888) 30%, transparent); }
.mut { font-size: 11.5px; color: var(--faint); }
.rec-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 8px; }
.crm { display: inline-flex; width: 26px; height: 26px; border-radius: 999px; align-items: center; justify-content: center; }
.crm.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.crm.err { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.crm.pend { color: var(--pend); background: color-mix(in srgb, var(--pend) 14%, transparent); }
.crm.none { color: var(--faint); background: var(--surface-2); }
.crm.verify { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.mini-send.verify { border-color: var(--warn); color: var(--warn); }
.mini-send.verify:active { background: var(--warn); color: #fff; }
.btn.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.btn[disabled] { opacity: .85; cursor: default; }
.mini-send { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--accent); color: var(--accent); background: transparent;
  padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; cursor: pointer; }
.mini-send:active { background: var(--accent); color: var(--accent-ink); }
.sent-at { font-size: 11px; color: var(--faint); }

/* ---------- Stats ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 10px; text-align: center; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 26px; font-weight: 800; color: var(--accent); }
.kpi span { font-size: 12px; color: var(--muted); }
.bar-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; margin: 0 -6px; border-radius: 10px; cursor: pointer; }
.bar-row:active { background: var(--surface-2); }
.bar-lbl { width: 118px; flex: 0 0 auto; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 9px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; min-width: 3px; transition: width .3s; }
.bar-val { width: 34px; text-align: right; font-weight: 700; font-size: 13px; }
.bar-go { color: var(--faint); display: flex; align-items: center; }
.bar-go svg { transform: rotate(180deg); }
.kpi.tappable { cursor: pointer; }
.kpi.tappable:active { background: var(--surface-2); }

/* ---------- Settings ---------- */
.fld { display: block; margin-bottom: 12px; }
.fld-lbl { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.crm-tag { font-style: normal; font-size: 9.5px; font-weight: 800; letter-spacing: .5px; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, transparent); padding: 1px 5px; border-radius: 5px; margin-left: 6px; vertical-align: middle; }
.inp { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 11px 12px; font-size: 15px; outline: none; }
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.inp.ta { resize: vertical; min-height: 44px; }
select.inp { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23647184' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.sel-wrap { position: relative; }

.btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 12px 16px; border-radius: var(--radius-sm); font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn + .btn { margin-top: 10px; }

/* ---------- Bottom nav ---------- */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: space-around; align-items: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); height: calc(62px + var(--safe-b)); }
.tab { flex: 1; border: none; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0; font-size: 11px; font-weight: 600; cursor: pointer; }
.tab.active { color: var(--accent); }
.tab-add { color: #fff; }
.tab-add svg { background: var(--accent); border-radius: 999px; padding: 7px; box-sizing: content-box; box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 45%, transparent); margin-top: -18px; }
.tab-add span { color: var(--muted); }

/* ---------- Form overlay ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .22s ease; padding-top: var(--safe-t); }
.overlay.in { transform: translateY(0); }
.form-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--ink); }
.form-head .form-title { flex: 1; color: #fff; font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.icon-btn { border: none; background: rgba(255,255,255,.12); color: #fff; width: 38px; height: 38px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn.danger { background: rgba(220,38,38,.25); }
.form-body { flex: 1; overflow-y: auto; padding: 12px; max-width: 760px; margin: 0 auto; width: 100%; }
.form-sec { padding: 14px; }
.fld-input { margin-top: 0; }
.fld.req .fld-lbl::after { content: ' *'; color: var(--danger); }
.crm-box { border-radius: var(--radius); padding: 12px 14px; font-size: 13px; font-weight: 600; margin-bottom: 12px; border: 1px solid var(--line); }
.crm-box.none { background: var(--surface-2); color: var(--muted); }
.crm-box.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.crm-box.err { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.crm-box.pend { background: color-mix(in srgb, var(--pend) 12%, transparent); color: var(--pend); }
.form-foot { display: flex; flex-direction: column; gap: 0; padding: 12px; border-top: 1px solid var(--line); background: var(--surface); padding-bottom: calc(12px + var(--safe-b)); }
.form-foot .btn { margin-top: 0; }
.form-foot .btn + .btn { margin-top: 10px; }

/* ---------- Login ---------- */
.login-screen { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; padding-top: calc(24px + var(--safe-t)); background: var(--bg); }
.login-card { width: 100%; max-width: 340px; text-align: center; }
.login-logo { width: 88px; height: 88px; border-radius: 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.login-title { font-size: 24px; font-weight: 800; margin: 0 0 4px; }
.login-sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.login-inp { text-align: center; font-size: 18px; letter-spacing: 3px; margin-bottom: 12px; }
.login-err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 12px; font-weight: 600; }

/* ---------- Modal + toast ---------- */
.modal-back { position: fixed; inset: 0; z-index: 80; background: rgba(8,14,20,.45); display: flex; align-items: center; justify-content: center; padding: 18px; opacity: 0; transition: opacity .18s; }
.modal-back.in { opacity: 1; }
.modal-card { background: var(--surface); border-radius: 16px; width: 100%; max-width: 420px; max-height: 84vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .icon-btn { background: var(--surface-2); color: var(--muted); width: 32px; height: 32px; }
.modal-body { padding: 16px; overflow-y: auto; }
.confirm-msg { margin: 0; }
.modal-foot { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }
.modal-foot .btn { flex: 1; margin: 0; }

.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(76px + var(--safe-b)); z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 13.5px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.25); opacity: 0; transform: translateY(10px); transition: all .22s; max-width: 92%; text-align: center; }
.toast.in { opacity: 1; transform: translateY(0); }
.toast.err { background: var(--danger); }
.toast.warn { background: var(--warn); }
.toast.ok { background: var(--accent); }

@media (min-width: 760px) {
  .tabbar { max-width: 760px; left: 50%; transform: translateX(-50%); border-radius: 16px 16px 0 0; }
}
