:root {
  --teal: #0E4E4E; --teal2: #2FA099; --coral: #F4715A; --coral-d: #C9513C;
  --cream: #FAF8F3; --mint: #EAF5F2; --peach: #FDEAE4; --amber: #E3A33B; --amber-bg: #FCF1DC;
  --ink: #1F2D2D; --muted: #6B7B7A; --line: #DCE5E3; --white: #fff; --grey: #A3AEAD;
  --radius: 12px; --top: 56px; --tabs: 0px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink); -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--cream); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; color: var(--teal); }
.muted { color: var(--muted); }
.center { text-align: center; padding: 16px; }
.err { color: var(--coral-d); min-height: 1.2em; margin: 0; font-size: 14px; }
input, textarea, select, button { font: inherit; color: inherit; }
input, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--white);
  font-size: 16px; /* без зума на iOS */
}
input:focus, textarea:focus { outline: 2px solid var(--teal2); outline-offset: 0; border-color: var(--teal2); }
textarea { resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 14px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--white); cursor: pointer; text-decoration: none; color: inherit;
  font-size: 15px; white-space: nowrap;
}
.btn:hover { border-color: var(--teal2); }
.btn.primary { background: var(--coral); border-color: var(--coral); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--coral-d); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--teal); }
a.btn { color: var(--teal); }
a.btn.primary { color: #fff; }
.btn.ghost:hover { background: var(--mint); }
.btn.danger { color: var(--coral-d); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: progress; }

/* бренд */
.brand-mark { width: 44px; height: 44px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--coral);
  position: relative; margin: 0 auto 6px; }
.brand-mark::after { content: ""; position: absolute; inset: 30%; border-radius: 50%; background: #fff; }
.brand-mark.sm { width: 22px; height: 22px; margin: 0; }

/* вход */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--mint), var(--cream) 60%); }
.login-card { width: min(380px, 100%); background: var(--white); border-radius: 18px; padding: 28px 24px; display: grid; gap: 14px;
  box-shadow: 0 10px 30px rgba(14,78,78,.10); text-align: center; }
.login-card label { display: grid; gap: 6px; text-align: left; font-size: 14px; color: var(--muted); }
.login-card p { margin: 0; }

/* каркас */
/* каркас админки */
.shell { height: 100%; display: grid; grid-template-columns: 216px 1fr; }
.side { background: var(--teal); color: #fff; display: flex; flex-direction: column; padding: 14px 10px; gap: 18px; z-index: 1500; }
.side-brand { display: flex; align-items: center; gap: 8px; padding: 2px 8px; font-size: 17px; }
.env { margin-left: auto; font-size: 11px; font-weight: 700; letter-spacing: .06em; background: var(--coral); color: #fff; border-radius: 6px; padding: 2px 6px; }
.env:empty { display: none; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 10px; border-radius: 10px; color: #CFE5E2; text-decoration: none; font-size: 15px; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.on { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--coral); }
.nav .ico { width: 20px; height: 20px; flex: none; opacity: .9; }
.side-foot { margin-top: auto; display: grid; gap: 4px; padding: 0 8px; font-size: 14px; color: #CFE5E2; }
.btn.ghost.inv { color: #fff; justify-content: flex-start; padding-left: 0; }
.btn.ghost.inv:hover { background: transparent; text-decoration: underline; }
.scrim { position: fixed; inset: 0; background: rgba(14,78,78,.35); z-index: 1400; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
.top { height: var(--top); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--white);
  border-bottom: 1px solid var(--line); }
.menu-btn { display: none; font-size: 20px; padding: 6px 10px; }
.sec-title { font-size: 18px; }
.top-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.sec { flex: 1; min-height: 0; }
.sec-places { display: flex; flex-direction: column; }
.sec-page { overflow-y: auto; }
.subbar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--white); border-bottom: 1px solid var(--line); }
.subbar .summary { justify-content: flex-start; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--teal); }
.brand b { font-size: 17px; }
.brand .muted { font-size: 13px; }
.summary { display: flex; gap: 6px; flex: 1; justify-content: center; overflow-x: auto; scrollbar-width: none; }
.summary::-webkit-scrollbar { display: none; }
.pill { display: inline-flex; gap: 4px; align-items: baseline; padding: 4px 10px; border-radius: 999px; background: var(--mint);
  font-size: 13px; white-space: nowrap; color: var(--teal); }
.pill b { font-size: 15px; }
.pill.ok { background: #D8F0E4; color: #1E6B45; }
.pill.bad { background: var(--peach); color: var(--coral-d); }
.top-actions { display: flex; align-items: center; gap: 4px; }
.who { font-size: 14px; color: var(--muted); padding: 0 6px; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 420px 1fr; }
.panel { overflow-y: auto; background: var(--cream); border-right: 1px solid var(--line); padding: 14px; }
.map-wrap { position: relative; min-height: 0; }
.map { position: absolute; inset: 0; }
.tabs { display: none; }

/* список */
.list-tools { display: grid; gap: 10px; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--white); border-radius: 999px; padding: 7px 12px; font-size: 14px; cursor: pointer;
  min-height: 36px; text-align: left; }
.chip[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: #fff; }
.chip .n { opacity: .7; margin-left: 4px; }
.add { margin-bottom: 12px; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 12px 10px 14px; cursor: pointer;
  display: grid; gap: 4px; border-left: 4px solid var(--grey); }
.card:hover, .card.sel { border-color: var(--teal2); }
.card.st-published { border-left-color: var(--teal2); }
.card.st-draft { border-left-color: var(--amber); }
.card.st-hidden { opacity: .7; }
.card-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.card-name { font-weight: 600; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge.published { background: #D8F0E4; color: #1E6B45; }
.badge.draft { background: var(--amber-bg); color: #8A5A0B; }
.badge.hidden { background: #ECEFEF; color: var(--muted); }
.card-sub { font-size: 13px; color: var(--muted); }
.card-warn { font-size: 13px; color: var(--coral-d); }

/* карточка места */
.editor-head { display: flex; align-items: center; gap: 6px; margin: -4px 0 10px -8px; }
.editor-head h2 { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#placeForm { display: grid; gap: 16px; padding-bottom: 24px; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend { font-size: 14px; font-weight: 600; color: var(--teal); padding: 0; display: flex; justify-content: space-between; gap: 8px; }
.field i { color: var(--coral); font-style: normal; }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.counter { font-weight: 400; color: var(--muted); }
.counter.over { color: var(--coral-d); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.pick-map { height: 240px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.pick-tools { display: flex; gap: 8px; }
.pick-tools input { flex: 1; min-width: 0; font-size: 14px; }
.coords { margin: 0; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.warn { margin: 0; font-size: 13px; padding: 8px 10px; border-radius: 8px; background: var(--amber-bg); color: #6F4A08; }

.amen { display: grid; gap: 6px; }
.amen-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; font-size: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--white); }
.seg button { border: 0; background: transparent; padding: 7px 12px; min-height: 36px; cursor: pointer; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--teal); color: #fff; }
.seg button[data-v="no"][aria-pressed="true"] { background: var(--coral-d); }
.seg button[data-v="unknown"][aria-pressed="true"] { background: var(--grey); }
#statusSeg button[data-v="published"][aria-pressed="true"] { background: var(--teal2); }
#statusSeg button[data-v="draft"][aria-pressed="true"] { background: var(--amber); }
#statusSeg button[data-v="hidden"][aria-pressed="true"] { background: var(--grey); }

.photo { display: grid; gap: 8px; }
.photo img { width: 100%; max-height: 220px; object-fit: cover; border-radius: var(--radius); background: var(--mint); }
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#photoRights { display: grid; gap: 6px; }
.photo-meta { display: grid; gap: 10px; margin-top: 4px; }

.missing { font-size: 14px; padding: 10px 12px; border-radius: 10px; background: var(--peach); color: var(--coral-d); }
.missing.ok { background: #D8F0E4; color: #1E6B45; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; position: sticky; bottom: -14px; background: var(--cream);
  padding: 10px 0 14px; border-top: 1px solid var(--line); }
.form-actions .primary { flex: 1; min-height: 46px; font-size: 16px; }
.meta { font-size: 12px; margin: 0; flex-basis: 100%; }
.form-extra { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-top: -6px; }
.form-extra .btn { padding-left: 0; }
.pill .s { display: none; }

/* карта: метки */
.pin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.pin.published { background: var(--teal2); }
.pin.draft { background: var(--amber); }
.pin.hidden { background: var(--grey); }
.pin.sel { width: 22px; height: 22px; outline: 3px solid var(--coral); }
.pick-pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--coral);
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.leaflet-tooltip.lbl { font-size: 12px; padding: 2px 6px; }
.leaflet-container { font: inherit; background: var(--mint); }

/* история */
.dlg { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100% - 24px)); max-height: 80vh; }
.dlg::backdrop { background: rgba(14,78,78,.35); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--white); }
.hist { margin: 0; padding: 8px 16px 16px 36px; display: grid; gap: 12px; font-size: 14px; }
.hist .when { color: var(--muted); font-size: 13px; }
.hist ul { margin: 4px 0 0; padding-left: 18px; color: var(--ink); }

.toast { position: fixed; left: 50%; bottom: calc(24px + var(--tabs)); transform: translateX(-50%); background: var(--teal); color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); z-index: 2000; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.bad { background: var(--coral-d); }
.toast button { margin-left: 10px; background: #fff; color: var(--teal); border: 0; border-radius: 6px; padding: 4px 8px; cursor: pointer; }

/* телефон */
@media (max-width: 899px) {
  :root { --top: 52px; --tabs: 56px; }
  .hide-sm { display: none !important; }
  .summary { justify-content: flex-start; }
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; top: 0; bottom: 0; left: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 30px rgba(0,0,0,.25); }
  .menu-btn { display: inline-flex; margin-left: -8px; }
  .top { padding: 0 10px; }
  .subbar { padding: 6px 10px; }
  .layout { grid-template-columns: 1fr; padding-bottom: var(--tabs); }
  .panel { border-right: 0; }
  .layout[data-view="list"] .map-wrap { display: none; }
  .layout[data-view="map"] #listPanel { display: none; }
  .layout.editing .map-wrap { display: none; }
  .layout.editing ~ .tabs { display: none; }
  .layout.editing { padding-bottom: 0; }
  .tabs { display: grid; grid-template-columns: 1fr 1fr; position: fixed; left: 0; right: 0; bottom: 0; height: var(--tabs);
    background: var(--white); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 1000; }
  .tabs button { border: 0; background: transparent; font-size: 15px; color: var(--muted); }
  .tabs button.on { color: var(--teal); font-weight: 700; box-shadow: inset 0 3px 0 var(--coral); }
  .pick-map { height: 260px; }
  .pill .l { display: none; }
  .pill .s { display: inline; }
  .top { gap: 8px; }
}

/* страницы разделов */
.page { padding: 16px; display: grid; gap: 14px; max-width: 1200px; }
.page.narrow { max-width: 760px; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 16px; min-width: 0; }
.card h2 { font-size: 18px; margin-bottom: 8px; }
.card p { margin: 6px 0; line-height: 1.5; }
.card ul { margin: 6px 0; padding-left: 20px; line-height: 1.6; }
.notice { border-color: var(--amber); background: var(--amber-bg); }
.small { font-size: 12px; }
.sec-h { font-size: 15px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 10px 0 -4px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
#svBody { display: grid; gap: 14px; }
#svBody.loading { opacity: .55; transition: opacity .2s; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; background: var(--white); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px; position: sticky; top: 0; z-index: 5; }
.tb-field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.tb-field input, .tb-field select { font-size: 14px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); min-height: 36px; }
.tb-field.grow { flex: 1; min-width: 200px; }
.tb-field.grow select { width: 100%; }
.tb-check { display: flex; gap: 6px; align-items: center; font-size: 14px; min-height: 36px; }
.tb-check input { width: 18px; height: 18px; accent-color: var(--teal); }
.tb-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.tile { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.tile-n { font-size: 34px; font-weight: 700; color: var(--teal); line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-l { font-size: 14px; color: var(--ink); margin-top: 2px; }
.tile-s { font-size: 12px; color: var(--muted); margin-top: 4px; }

.q-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.q-head h3 { font-size: 15px; }
.q-head .muted { font-size: 12px; }

.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hbars > li { display: grid; grid-template-columns: minmax(120px, 42%) 1fr 72px; align-items: center; gap: 10px; font-size: 13px; }
.hb-label { line-height: 1.3; }
.hb-track { height: 12px; background: var(--mint); border-radius: 4px; overflow: hidden; }
.hb-bar { display: block; height: 100%; background: var(--teal2); border-radius: 0 4px 4px 0; min-width: 2px; }
.hb-val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hb-val small { font-weight: 400; color: var(--muted); }
.hbars.matrix > li { grid-template-columns: minmax(160px, 45%) 1fr 108px; }
.hbars > li:hover .hb-bar { background: var(--teal); }

.days { display: grid; gap: 4px; }
.days-plot { height: 150px; display: flex; align-items: flex-end; gap: 3px; border-bottom: 1px solid var(--line); }
.day { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; }
.day-bar { width: 100%; max-width: 36px; background: var(--teal2); border-radius: 4px 4px 0 0; min-height: 1px; }
.day:hover .day-bar { background: var(--teal); }
.day-n { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.days-axis { display: flex; gap: 3px; }
.days-axis span { flex: 1; font-size: 11px; color: var(--muted); text-align: center; white-space: nowrap; overflow: visible; min-width: 0; }

details.mini { margin-top: 6px; font-size: 13px; }
details.mini summary { cursor: pointer; color: var(--teal); }
details.mini ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink); }
.quotes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 360px; overflow-y: auto; }
.quotes li { background: var(--cream); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.quotes li p { margin: 0 0 2px; white-space: pre-wrap; }
.quotes li span { font-size: 12px; }

.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr.hl td { background: var(--amber-bg); }
.cmd { background: var(--cream); border-radius: 10px; padding: 10px 12px; font-size: 12px; overflow-x: auto; margin: 12px 0 0; }

@media (max-width: 899px) {
  .page { padding: 10px; gap: 10px; }
  .toolbar { position: static; }
  .grid2 { grid-template-columns: 1fr; }
  .hbars > li, .hbars.matrix > li { grid-template-columns: 1fr auto; gap: 4px 10px; }
  .hb-val small { font-size: 11px; }
  .hbars > li .hb-label { grid-column: 1 / -1; }
  .tile-n { font-size: 28px; }
}
