:root {
  --navy: #14243b;
  --navy-2: #203853;
  --paper: #f6f1e8;
  --card: #fffdf8;
  --gold: #c4933f;
  --gold-soft: #f0dfbd;
  --plum: #7a4663;
  --blue: #477fa2;
  --green: #3f7a5c;
  --red: #a44747;
  --muted: #6f7780;
  --line: #dcd5c8;
  --shadow: 0 12px 30px rgba(20,36,59,.14);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: var(--paper); color: var(--navy); }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; overscroll-behavior: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(196,147,63,.38); outline-offset: 2px; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#app { width: 100%; height: 100dvh; overflow: hidden; display: grid; grid-template-rows: auto auto auto auto minmax(0, 1fr) auto; }
.topbar {
  padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 10px;
  background: linear-gradient(135deg, var(--navy), #1e3d5e);
  color: white;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.eyebrow { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; opacity: .72; font-weight: 800; }
.topbar h1, .sheet-title h2 { margin: 2px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: 25px; line-height: 1.1; }
.icon-button {
  width: 44px; height: 44px; border: 1px solid rgba(255,255,255,.26); border-radius: 14px;
  background: rgba(255,255,255,.09); color: white; display: grid; place-items: center; position: relative;
}
.icon-button svg { width: 23px; height: 23px; }
.icon-button.plain { color: var(--navy); border-color: var(--line); background: var(--card); font-size: 28px; line-height: 1; }
.filter-badge {
  position: absolute; right: -4px; top: -5px; min-width: 20px; height: 20px; padding: 0 5px;
  display: grid; place-items: center; background: var(--gold); color: var(--navy); border-radius: 10px;
  font-size: 11px; font-weight: 900; border: 2px solid var(--navy);
}

.summary { display: grid; grid-template-columns: repeat(3,1fr); gap: 1px; background: #d6cfc3; border-bottom: 1px solid var(--line); }
.summary article { background: var(--card); padding: 9px 12px; text-align: center; }
.summary strong { display: block; font-family: Georgia, serif; font-size: 22px; }
.summary span { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }

.search-row { padding: 10px 12px 7px; display: flex; gap: 8px; background: var(--paper); }
.search-box {
  flex: 1; min-width: 0; height: 44px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; display: flex; align-items: center; gap: 9px; padding: 0 12px; box-shadow: 0 3px 10px rgba(20,36,59,.05);
}
.search-box svg { width: 20px; color: var(--muted); }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--navy); font-size: 15px; }
.clear-search { border: 0; background: transparent; color: var(--muted); font-size: 24px; padding: 0 3px; }
.quick-button {
  border: 0; border-radius: 14px; padding: 0 13px; background: var(--navy); color: white; font-size: 13px; font-weight: 800;
}
.active-filters { min-height: 32px; padding: 0 12px 7px; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.active-filters:empty { min-height: 0; padding-bottom: 0; }
.active-filters::-webkit-scrollbar { display: none; }
.filter-chip { white-space: nowrap; border-radius: 999px; padding: 6px 10px; background: var(--gold-soft); color: #684d1e; font-size: 12px; font-weight: 800; }

main { min-height: 0; overflow: hidden; position: relative; }
.view { display: none; height: 100%; }
.view.active { display: block; }
.scroll-view { height: 100%; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 10px 12px 22px; }
#map { width: 100%; height: 100%; background: #d8e3e8; }
.map-tools { position: absolute; z-index: 900; right: 12px; bottom: 18px; display: grid; gap: 9px; }
.map-tool {
  width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 15px; background: var(--card);
  color: var(--navy); box-shadow: var(--shadow); display: grid; place-items: center;
}
.map-tool svg { width: 23px; }
.map-hint {
  position: absolute; z-index: 900; left: 50%; transform: translateX(-50%); bottom: 18px;
  background: rgba(20,36,59,.92); color: white; border-radius: 999px; padding: 9px 14px; font-size: 12px; font-weight: 700;
  max-width: calc(100% - 140px); text-align: center;
}

.card-list { display: grid; gap: 10px; }
.place-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 13px;
  box-shadow: 0 4px 14px rgba(20,36,59,.06);
}
.place-card.received { opacity: .9; border-color: #b8cdbf; }
.card-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.place-card h3, .popup-card h3 { margin: 0; font-family: Georgia, serif; font-size: 18px; line-height: 1.22; }
.place-card p, .popup-card p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 8px; font-size: 10px; line-height: 1; font-weight: 900; letter-spacing: .02em; }
.badge.official { background: var(--gold-soft); color: #664715; }
.badge.partner { background: #eadde5; color: #6c3654; }
.badge.unofficial { background: #dcebf3; color: #275f80; }
.badge.received { background: #dceadf; color: #285c41; }
.badge.expired { background: #f2dddd; color: #813b3b; }
.badge.upcoming, .badge.limited { background: #e8e6f3; color: #514b82; }
.card-actions, .popup-actions { margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.card-actions.three { grid-template-columns: 1fr 1fr 1fr; }
.primary-button, .secondary-button, .danger-button, .action-button {
  min-height: 42px; border-radius: 13px; padding: 9px 12px; font-weight: 850; border: 0; text-align: center;
}
.primary-button, .action-button.primary { background: var(--navy); color: white; }
.secondary-button, .action-button.secondary { background: #ede8de; color: var(--navy); }
.danger-button { background: #f1dddd; color: var(--red); }
.action-button.success { background: #dceadf; color: #24583d; }
.distance { white-space: nowrap; font-size: 12px; color: var(--green); font-weight: 850; }
.note { margin-top: 9px !important; padding: 9px 10px; border-left: 3px solid var(--gold); background: #f6efe0; color: #665537 !important; border-radius: 0 10px 10px 0; }
.empty-state { background: var(--card); border: 1px dashed #bdb5a9; border-radius: 20px; padding: 28px 18px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--navy); font-family: Georgia, serif; font-size: 20px; margin-bottom: 5px; }

.popup-card .popup-title-row { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.popup-card .popup-actions { grid-template-columns: 1fr 1fr; }
.popup-card .popup-actions.single { grid-template-columns: 1fr; }
.popup-card .distance { margin-top: 7px; display: block; }

.archive-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.archive-head h2, .data-tools h3, .about-card h3 { margin: 0; font-family: Georgia, serif; }
.archive-head p, .data-tools p, .about-card p { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 5px 0 0; }
.data-tools, .about-card { margin-top: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.tool-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-top: 12px; }
.file-button { display: grid; place-items: center; cursor: pointer; }
.file-button input { display: none; }
.about-card a { display: inline-block; margin-top: 10px; font-weight: 800; color: var(--navy); }

.bottom-nav {
  position: relative; flex: 0 0 auto;
  height: calc(68px + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  display: grid; grid-template-columns: repeat(4,1fr); background: rgba(255,253,248,.96);
  border-top: 1px solid var(--line); box-shadow: 0 -8px 28px rgba(20,36,59,.09); z-index: 900;
}
.nav-button { border: 0; background: transparent; color: var(--muted); display: grid; place-content: center; justify-items: center; gap: 3px; font-size: 11px; font-weight: 800; }
.nav-button svg { width: 23px; height: 23px; }
.nav-button.active { color: var(--navy); }
.nav-button.active svg { stroke-width: 2.3; }

.filters-dialog { width: 100%; max-width: none; margin: auto 0 0; padding: 0; border: 0; background: transparent; }
.filters-dialog::backdrop { background: rgba(7,18,31,.54); backdrop-filter: blur(2px); }
.filters-sheet {
  background: var(--paper); border-radius: 24px 24px 0 0; padding: 10px 16px calc(18px + var(--safe-bottom));
  max-height: 86dvh; overflow-y: auto; box-shadow: 0 -20px 60px rgba(10,25,42,.25);
}
.sheet-handle { width: 44px; height: 5px; background: #bbb3a7; border-radius: 999px; margin: 0 auto 12px; }
.sheet-title { display: flex; justify-content: space-between; align-items: center; }
.sheet-title .eyebrow { color: var(--muted); }
fieldset { border: 0; padding: 0; margin: 20px 0 0; }
legend { font-weight: 900; margin-bottom: 8px; }
.segmented { display: grid; grid-template-columns: repeat(3,1fr); background: #e7e0d5; border-radius: 14px; padding: 3px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: grid; place-items: center; min-height: 40px; padding: 7px 4px; border-radius: 11px; font-size: 12px; font-weight: 850; text-align: center; }
.segmented input:checked + span { background: var(--card); box-shadow: 0 3px 9px rgba(20,36,59,.1); color: var(--navy); }
select { width: 100%; height: 46px; border: 1px solid var(--line); border-radius: 13px; background: var(--card); color: var(--navy); padding: 0 12px; }
.toggle-row { margin-top: 18px; display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 15px; }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row small { color: var(--muted); margin-top: 3px; line-height: 1.25; }
.toggle-row input { width: 22px; height: 22px; accent-color: var(--navy); flex: 0 0 auto; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1.5fr; gap: 9px; margin-top: 20px; }

.toast {
  position: fixed; z-index: 2000; left: 50%; bottom: calc(82px + var(--safe-bottom)); transform: translateX(-50%);
  background: rgba(20,36,59,.96); color: white; padding: 11px 15px; border-radius: 999px; font-size: 13px; font-weight: 800;
  box-shadow: var(--shadow); max-width: calc(100% - 28px); text-align: center;
}
.hidden { display: none !important; }

.user-location-dot {
  width: 18px; height: 18px; background: #2a83cf; border: 3px solid white; border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(42,131,207,.22);
}
.marker-label {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  color: white; font-size: 14px; font-weight: 900; border: 3px solid white; box-shadow: 0 4px 12px rgba(20,36,59,.32);
}
.marker-label.official { background: var(--gold); color: var(--navy); }
.marker-label.partner { background: var(--plum); }
.marker-label.unofficial { background: var(--blue); }
.marker-label.received { background: #7f8b84; }
.custom-div-icon { background: transparent; border: 0; }

@media (min-width: 760px) {
  body { background: #d9d5cd; }
  #app { max-width: 540px; margin: 0 auto; background: var(--paper); box-shadow: 0 0 40px rgba(20,36,59,.18); }
  .filters-dialog { max-width: 540px; left: 50%; transform: translateX(-50%); }
}


.header-actions { display: flex; align-items: center; gap: 8px; }
.sync-button.syncing svg { animation: sync-spin 1s linear infinite; }
@keyframes sync-spin { to { transform: rotate(360deg); } }
.sync-dot {
  position: absolute; right: 3px; bottom: 3px; width: 10px; height: 10px;
  border-radius: 50%; border: 2px solid var(--navy);
}
.sync-dot.synced { background: #64b77d; }
.sync-dot.syncing { background: #e3b14f; }
.sync-dot.local { background: #9aa4af; }
.sync-dot.error { background: #d06060; }

#map { position: relative; }
.map-fallback {
  position: absolute; inset: 0; z-index: 800; display: grid; place-content: center;
  gap: 7px; padding: 28px; text-align: center; background: linear-gradient(150deg,#dce7ed,#f6f1e8);
}
.map-fallback strong { font-family: Georgia, serif; font-size: 22px; }
.map-fallback span { color: var(--muted); font-size: 14px; line-height: 1.45; }
.ymaps-2-1-79-map { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif !important; }
.ymaps-2-1-79-balloon__content { padding: 0 !important; margin-right: 0 !important; background: var(--card) !important; }
.ymaps-2-1-79-balloon__layout { border-radius: 18px !important; overflow: hidden; }
.ymaps-2-1-79-balloon__close-button { z-index: 2; }
.popup-card { padding: 16px; max-width: 310px; }

.sync-meta { margin-top: 8px; font-size: 12px; color: var(--muted); }
.form-error { margin-top: 8px; color: var(--red); font-size: 13px; font-weight: 800; }
.pin-dialog { border: 0; padding: 0; background: transparent; width: min(92vw, 420px); }
.pin-dialog::backdrop { background: rgba(7,18,31,.58); backdrop-filter: blur(3px); }
.pin-card { background: var(--paper); border-radius: 22px; padding: 20px; box-shadow: var(--shadow); }
.pin-card h2 { margin: 4px 0 8px; font-family: Georgia, serif; }
.pin-card p { margin: 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.pin-card input {
  width: 100%; height: 48px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--card); color: var(--navy); padding: 0 14px; font-size: 18px; letter-spacing: .08em;
}

@media (min-width: 760px) {
  .bottom-nav { width: 100%; }
}


/* Ачивки v3 */
.achievements-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  margin-bottom: 14px;
}
.achievements-head .eyebrow { color: var(--muted); }
.achievements-head h2 { margin: 2px 0 0; font-family: Georgia, serif; font-size: 27px; }
.achievements-head p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.achievement-counter {
  flex: 0 0 auto; min-width: 68px; padding: 10px 9px; border-radius: 18px;
  background: linear-gradient(145deg, #fff8e9, #f0dfbd); border: 1px solid #e0c68f;
  display: grid; justify-items: center; box-shadow: 0 5px 15px rgba(196,147,63,.13);
}
.achievement-counter strong { font-family: Georgia, serif; font-size: 24px; }
.achievement-counter span { color: #765820; font-size: 11px; font-weight: 800; }
.achievement-grid { display: grid; gap: 10px; }
.achievement-card {
  display: grid; grid-template-columns: 58px minmax(0,1fr); gap: 12px; align-items: center;
  padding: 13px; border-radius: 19px; border: 1px solid var(--line); background: var(--card);
  box-shadow: 0 4px 14px rgba(20,36,59,.06); position: relative; overflow: hidden;
}
.achievement-card.unlocked {
  border-color: #dfc27e;
  background: radial-gradient(circle at 100% 0, rgba(240,223,189,.72), transparent 43%), var(--card);
}
.achievement-card.locked { filter: saturate(.72); }
.achievement-card.locked .achievement-emoji { opacity: .56; filter: grayscale(.45); }
.achievement-emoji {
  width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center;
  font-size: 31px; background: #f1ece2; box-shadow: inset 0 0 0 1px rgba(20,36,59,.05);
}
.achievement-card.unlocked .achievement-emoji { background: #fff0c9; transform: rotate(-2deg); }
.achievement-title-row { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.achievement-title-row h3 { margin: 0; font-family: Georgia, serif; font-size: 17px; line-height: 1.15; }
.achievement-title-row > span {
  white-space: nowrap; padding: 4px 7px; border-radius: 999px; background: #ebe6dc;
  color: var(--muted); font-size: 10px; font-weight: 900;
}
.achievement-card.unlocked .achievement-title-row > span { background: #dceadf; color: #285c41; }
.achievement-body p { margin: 5px 0 8px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.achievement-body small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.achievement-progress { height: 7px; border-radius: 999px; background: #e6e0d6; overflow: hidden; }
.achievement-progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), #e9bd67); }
.achievement-card.locked .achievement-progress span { background: #98a8b4; }
.version-card { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.version-card span, .version-card small { color: var(--muted); font-size: 12px; }
.version-card strong { font-family: Georgia, serif; font-size: 20px; }
.version-card small { grid-column: 1 / -1; }
.achievement-celebration {
  position: fixed; z-index: 2400; left: 50%; top: calc(18px + env(safe-area-inset-top, 0px));
  transform: translateX(-50%); width: min(420px, calc(100% - 24px));
  display: grid; grid-template-columns: 56px minmax(0,1fr); gap: 12px; align-items: center;
  padding: 13px 15px; border-radius: 20px; color: var(--navy);
  background: linear-gradient(145deg, #fffaf0, #f0dfbd); border: 1px solid #dcb969;
  box-shadow: 0 18px 44px rgba(20,36,59,.24); animation: achievement-pop .38s ease-out;
}
.celebration-emoji { width: 56px; height: 56px; display: grid; place-items: center; font-size: 35px; background: rgba(255,255,255,.68); border-radius: 17px; }
.achievement-celebration small, .achievement-celebration strong, .achievement-celebration span { display: block; }
.achievement-celebration small { color: #765820; font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .12em; }
.achievement-celebration strong { margin-top: 2px; font-family: Georgia, serif; font-size: 19px; }
.achievement-celebration span { margin-top: 3px; color: #665537; font-size: 12px; line-height: 1.3; }
@keyframes achievement-pop {
  from { opacity: 0; transform: translate(-50%, -18px) scale(.94); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}


/* Диалоги подтверждения v3.1 */
.confirm-card { text-align: center; }
.confirm-card .sheet-actions { grid-template-columns: 1.2fr 1fr; }
.dialog-emoji {
  width: 58px; height: 58px; margin: 0 auto 10px; border-radius: 20px;
  display: grid; place-items: center; background: #fff0c9; font-size: 30px;
  box-shadow: inset 0 0 0 1px rgba(196,147,63,.24);
}
#adminResetDialog .danger-button, #restoreDialog .danger-button {
  background: #b24f4f; color: white;
}


/* Админка дат v3.2 */
.admin-dialog {
  width: min(760px, calc(100% - 20px));
  max-width: 760px;
  height: min(88dvh, 820px);
  max-height: 88dvh;
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: var(--paper, #fffdf8);
  color: inherit;
  box-shadow: 0 26px 80px rgba(50, 35, 21, .28);
}
.admin-dialog::backdrop { background: rgba(43, 32, 22, .48); backdrop-filter: blur(3px); }
.admin-panel-shell { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.admin-panel-head {
  display: flex; justify-content: space-between; gap: 16px; align-items: flex-start;
  padding: 20px 20px 14px; border-bottom: 1px solid rgba(111, 86, 52, .14);
}
.admin-panel-head h2 { margin: 2px 0 5px; }
.admin-panel-head p { margin: 0; color: var(--muted, #746b5e); font-size: 13px; }
.admin-close { flex: 0 0 auto; font-size: 28px; }
.admin-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 10px 14px 0; gap: 8px; }
.admin-tabs button {
  border: 0; border-radius: 14px; padding: 11px; background: rgba(117, 92, 57, .08);
  color: inherit; font: inherit; font-weight: 750; cursor: pointer;
}
.admin-tabs button.active { background: #ead8ae; box-shadow: inset 0 0 0 1px rgba(156, 112, 41, .22); }
.admin-tabs span { opacity: .7; margin-left: 4px; }
.admin-tab-panel { display: none; min-height: 0; flex: 1; overflow: hidden; padding: 12px 14px 14px; }
.admin-tab-panel.active { display: flex; flex-direction: column; }
.admin-search { display: grid; gap: 5px; font-size: 12px; font-weight: 700; color: var(--muted, #746b5e); }
.admin-search input {
  width: 100%; border: 1px solid rgba(111, 86, 52, .22); background: white;
  border-radius: 13px; padding: 11px 12px; font: inherit; color: inherit;
}
.admin-help { margin: 8px 2px 10px; color: var(--muted, #746b5e); font-size: 12px; }
.admin-date-list { overflow-y: auto; display: grid; gap: 9px; padding: 1px 2px 20px; overscroll-behavior: contain; }
.admin-date-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 12px; border-radius: 16px; background: white;
  border: 1px solid rgba(111, 86, 52, .14); box-shadow: 0 3px 10px rgba(64, 45, 24, .05);
}
.admin-date-main { min-width: 0; display: grid; gap: 3px; }
.admin-date-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-date-main small { color: var(--muted, #746b5e); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-date-main.with-emoji { display: flex; align-items: center; gap: 10px; }
.admin-date-main.with-emoji > span:last-child { min-width: 0; display: grid; gap: 3px; }
.admin-row-emoji { flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 13px; background: #fff1c9; font-size: 23px; }
.admin-date-controls { display: flex; gap: 7px; align-items: center; }
.admin-date-controls input[type="date"] {
  min-height: 39px; border: 1px solid rgba(111, 86, 52, .22); border-radius: 11px;
  background: #fffdf8; padding: 7px 8px; font: inherit; color: inherit;
}
.compact-button { min-height: 39px; padding: 8px 11px; white-space: nowrap; }

@media (max-width: 620px) {
  .admin-dialog { width: 100%; height: 94dvh; max-height: 94dvh; margin: auto 0 0; border-radius: 24px 24px 0 0; }
  .admin-panel-head { padding: 17px 15px 12px; }
  .admin-date-row { grid-template-columns: 1fr; gap: 9px; }
  .admin-date-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .admin-date-controls input[type="date"] { width: 100%; }
}
