:root {
  --bg: #f4f6fb; --card: #ffffff; --text: #1f2937; --muted: #6b7280;
  --primary: #2563eb; --primary-dark: #1e40af; --green: #16a34a; --red: #dc2626;
  --orange: #ea580c; --yellow: #ca8a04; --border: #e5e7eb; --radius: 14px;
  --shadow: 0 4px 18px rgba(31, 41, 55, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
.hidden { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; background: #fff; color: var(--text);
  padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); }
.skip-link:focus { top: 12px; }
main { flex: 1; width: 100%; max-width: 1150px; margin: 0 auto; padding: 24px 16px; }

.topbar {
  display: flex; align-items: center; gap: 24px; padding: 12px 24px;
  background: var(--card); box-shadow: var(--shadow); position: sticky; top: 0; z-index: 10;
}
.logo { font-weight: 700; font-size: 20px; color: var(--text); }
.topnav { display: flex; gap: 16px; flex: 1; }
.topnav a { color: var(--muted); font-weight: 500; }
.topnav a:hover { color: var(--primary); }
.user-box { display: flex; align-items: center; gap: 10px; font-size: 14px; }

.btn {
  border: none; border-radius: 10px; padding: 10px 18px; font-size: 15px; cursor: pointer;
  background: var(--primary); color: #fff; font-weight: 600; transition: .15s;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #e0e7ff; color: var(--primary-dark); }
.btn.danger { background: var(--red); }
.btn.green { background: var(--green); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, a:focus-visible, button:focus-visible { outline: 3px solid #60a5fa; outline-offset: 2px; }
input, textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 15px; font-family: inherit; background: #fff;
}
input:focus, textarea:focus, select:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
label { font-size: 14px; font-weight: 600; display: block; margin: 10px 0 4px; }
.check { display: flex; align-items: flex-start; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: auto; margin: 4px 0 0; flex: 0 0 auto; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.house-actions { display: contents; }
.house-actions > .sos-btn { grid-column: 2; grid-row: 1; justify-self: end; }
.house-actions > #sos-push-control { grid-column: 1 / -1; grid-row: 2; min-width: 0; }
.push-control { justify-content: flex-start; max-width: none; text-align: left; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card h3 { margin-top: 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.muted { color: var(--muted); font-size: 14px; }
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: #e0e7ff; color: var(--primary-dark);
}
.badge.green { background: #dcfce7; color: var(--green); }
.badge.red { background: #fee2e2; color: var(--red); }
.badge.orange { background: #ffedd5; color: var(--orange); }
.badge.yellow { background: #fef9c3; color: var(--yellow); }

.hero {
  text-align: center; padding: 56px 20px; border-radius: 22px; color: #fff; margin-bottom: 24px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}
.hero h1 { font-size: 40px; margin: 0 0 10px; }
.hero p { font-size: 18px; opacity: .92; margin: 0 0 24px; }
.search { position: relative; max-width: 560px; margin: 0 auto; }
.search input { padding: 16px 18px; font-size: 17px; border-radius: 14px; border: none; }
.suggest {
  position: absolute; top: 100%; left: 0; right: 0; background: #fff; color: var(--text);
  border-radius: 12px; box-shadow: var(--shadow); margin-top: 6px; text-align: left; overflow: hidden; z-index: 5;
}
.suggest > * { display: block; width: 100%; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--border);
  background: #fff; color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.suggest > *:hover, .suggest > *:focus-visible { background: #eff6ff; outline: 2px solid var(--primary); outline-offset: -2px; }
.feature { text-align: center; }
.feature .ico { font-size: 36px; }


.house-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px 20px; }
.house-summary { grid-column: 1; grid-row: 1; min-width: 0; }
.house-head h2 { margin: 0; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0; }
.tab {
  padding: 8px 14px; border-radius: 10px; cursor: pointer; background: #fff; border: 1px solid var(--border);
  font-weight: 500; font-size: 14px;
}
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.locked {
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; padding: 12px 16px; border-radius: 12px;
  margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
}

.chat { height: 420px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 8px; background: #f9fafb; border-radius: 12px; }
.msg { max-width: 75%; padding: 10px 14px; border-radius: 14px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.msg.me { align-self: flex-end; background: #dbeafe; }
.msg .who { font-size: 12px; font-weight: 700; color: var(--primary-dark); }
.msg .time { font-size: 11px; color: var(--muted); text-align: right; }

.item { border-bottom: 1px solid var(--border); padding: 12px 0; }
.item:last-child { border-bottom: none; }
.stars { color: #f59e0b; letter-spacing: 2px; }
.bar { height: 8px; background: #e5e7eb; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); }
.poll-opt { margin: 8px 0; cursor: pointer; }
.poll-opt:hover .bar > span { background: var(--primary-dark); }

.building { display: flex; gap: 14px; flex-wrap: wrap; }
.entrance { background: #f9fafb; border-radius: 12px; padding: 10px; min-width: 150px; }
.floor { display: flex; align-items: center; gap: 6px; padding: 4px; border-radius: 8px; margin: 3px 0; font-size: 13px; min-height: 28px; }
.floor .n { width: 22px; color: var(--muted); }
.floor .issue { font-size: 16px; cursor: help; }

.sos-btn {
  background: var(--red); color: #fff; border: none; border-radius: 99px; padding: 10px 18px;
  font-weight: 700; cursor: pointer; animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.5); } 50% { box-shadow: 0 0 0 10px rgba(220,38,38,0); } }
.alert-sos { background: #fee2e2; border: 2px solid var(--red); color: #7f1d1d; border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; }

.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 18px; padding: 24px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin-top: 0; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff;
  padding: 12px 20px; border-radius: 12px; z-index: 60; box-shadow: var(--shadow);
}
.verify-opt { display: block; width: 100%; border: 2px solid var(--border); border-radius: 12px; padding: 12px;
  margin: 8px 0; cursor: pointer; background: #fff; color: var(--text); text-align: left; font: inherit; }
.verify-opt .muted { display: block; }
.verify-opt:hover, .verify-opt.sel { border-color: var(--primary); background: #eff6ff; }

.footer { text-align: center; padding: 20px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); background: #fff; }
.footer p { margin: 2px 0; }

/* ===== Серверная версия: дополнительные элементы ===== */
.hero-hint { font-size: 14px !important; margin: 16px 0 0 !important; opacity: .85; }
.hero-hint a { color: #fff; text-decoration: underline; }
.hint { font-size: 13px; color: var(--muted); background: #f9fafb; border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.check input { width: auto; margin-top: 4px; }
.grid2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; text-align: center; }
.stat b { display: block; font-size: 26px; }
.stat span { color: var(--muted); font-size: 13px; }

.bell { position: relative; background: none; border: none; font-size: 20px; cursor: pointer; padding: 4px; }
.bell i { position: absolute; top: -4px; right: -6px; background: var(--red); color: #fff; font-style: normal;
  font-size: 11px; border-radius: 99px; padding: 0 6px; font-weight: 700; }
.me-link { color: var(--text); }
.notif.new { background: #eff6ff; border-radius: 8px; padding-left: 10px; padding-right: 10px; }

.msg.sys { align-self: center; background: #ecfdf5; color: #065f46; font-size: 13px; text-align: center; max-width: 90%; }
.msg .del { float: right; background: none; border: none; cursor: pointer; color: var(--muted); font-size: 12px; }

.rate-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.rate-row > span:first-child { width: 120px; font-size: 14px; }
.star-pick { font-size: 26px; color: #d1d5db; cursor: pointer; user-select: none; letter-spacing: 2px; }
.star-pick i { font-style: normal; }
.star-pick .on { color: #f59e0b; }

.house-grid { display: grid; gap: 4px; max-width: 520px; }
.house-grid .cell { height: 30px; border-radius: 6px; background: #e0f2fe; display: flex; align-items: center;
  justify-content: center; font-size: 15px; cursor: pointer; transition: .15s; }
.house-grid .cell:hover { outline: 2px solid var(--primary); }
.house-grid .cell.bad { background: #fecaca; }
.floor-n { font-size: 12px; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.item.done { opacity: .6; }

.item.event { display: flex; gap: 14px; align-items: flex-start; }
.date-box { min-width: 56px; text-align: center; background: #eff6ff; border-radius: 10px; padding: 6px; }
.date-box b { display: block; font-size: 22px; color: var(--primary-dark); line-height: 1.1; }
.date-box span { font-size: 12px; color: var(--muted); }

.top-row { padding: 10px; border-radius: 10px; }
.top-row.me { background: #fef9c3; }
.place { width: 32px; font-size: 20px; text-align: center; }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.tbl th { background: #f9fafb; }
code { background: #f3f4f6; padding: 2px 6px; border-radius: 6px; font-size: 14px; }

.map { height: 520px; border-radius: 12px; overflow: hidden; background: #eef2f7; position: relative; }
.map iframe { width: 100%; height: 100%; border: 0; display: block; }
.map-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.map-consent { min-height: 100%; padding: 24px; display: grid; place-items: center; text-align: center; }
.map-consent > div { max-width: 560px; }
.map-consent .btn { margin: 6px; }
.map-provider-link { position: absolute; right: 14px; bottom: 14px; z-index: 2; display: flex; flex-direction: column;
  gap: 2px; padding: 10px 14px; border-radius: 10px; color: #111827; background: rgba(255,255,255,.96);
  box-shadow: 0 3px 14px rgba(15,23,42,.2); }
.map-provider-link span { color: var(--primary-dark); font-size: 13px; }
.map-list { margin-top: 16px; }
.map-list .item { display: flex; align-items: center; gap: 12px; }
.map-list .item > span { flex: 1; }
.item.mod { display: flex; gap: 16px; align-items: flex-start; }
.item.mod img { width: 140px; height: 100px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after { content: ''; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px;
  border: 2px solid #fff; border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.footer-links { margin: 8px 0; }
.link-button { border: 0; padding: 0; color: var(--primary); background: none; font: inherit; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.legal-warning { max-width: 1150px; padding: 14px 18px; margin: 0 auto 16px; border: 2px solid var(--red);
  border-radius: 12px; color: #7f1d1d; background: #fef2f2; }
.legal-doc { max-width: 900px; margin-left: auto; margin-right: auto; }
.legal-doc h1 { line-height: 1.2; }
.legal-doc h2 { margin-top: 28px; font-size: 21px; }
.legal-doc li { margin-bottom: 6px; }
.legal-doc hr { margin: 28px 0; border: 0; border-top: 1px solid var(--border); }
.legal-details { display: grid; grid-template-columns: minmax(180px, 280px) 1fr; gap: 8px 16px;
  padding: 16px; border-radius: 10px; background: #f8fafc; }
.legal-details dt { color: var(--muted); font-weight: 600; }
.legal-details dd { margin: 0; overflow-wrap: anywhere; }
.legal-nav { max-width: 900px; display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0 auto 20px; }
.legal-table-wrap { overflow-x: auto; }
.cookie-banner { position: fixed; z-index: 90; left: 18px; right: 18px; bottom: 18px; display: flex;
  align-items: center; justify-content: space-between; gap: 20px; max-width: 1050px; margin: auto; padding: 18px;
  border: 1px solid #cbd5e1; border-radius: 14px; background: #fff; box-shadow: 0 12px 42px rgba(15,23,42,.28); }
.cookie-banner p { margin: 4px 0 0; }

@media (max-width: 700px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  .topbar { width: auto; max-width: 100vw; flex-wrap: wrap; gap: 10px; padding: 10px 14px; overflow: hidden; }
  .logo { min-width: 0; }
  .topnav { order: 3; width: 100%; min-width: 0; overflow-x: auto; padding-bottom: 4px; }
  .topnav a { white-space: nowrap; }
  .user-box { flex: 0 0 100%; min-width: 0; margin-left: 0; flex-wrap: wrap; justify-content: flex-start; }
  main { width: calc(100% - 30px); max-width: calc(100% - 30px); min-width: 0; padding: 16px 10px; }
  .hero, .stats, .grid, .grid2 { width: calc(100% - 60px); max-width: none; }
  .hero-hint { font-size: 13px !important; padding-left: 4px; padding-right: 4px; }
  .hero p, .hero a { overflow-wrap: anywhere; }
  .card { padding: 16px; }
  .hero h1 { font-size: 28px; }
  .hero { padding: 36px 12px; }
  input, textarea, select { font-size: 16px; }
  .msg { max-width: 90%; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .map { height: 380px; }
  .tbl { display: block; overflow-x: auto; }
  .item.mod { flex-direction: column; }
  .item.mod img { width: 100%; height: auto; max-height: 320px; }
  .map-list .item { align-items: flex-start; flex-direction: column; }
  .legal-details { grid-template-columns: 1fr; gap: 2px; }
  .legal-details dd { margin-bottom: 8px; }
  .cookie-banner { left: 8px; right: 8px; bottom: 8px; align-items: stretch; flex-direction: column; }
  .house-head { grid-template-columns: 1fr; }
  .house-summary { grid-column: 1; grid-row: 1; }
  .house-actions > .sos-btn { grid-column: 1; grid-row: 2; justify-self: start; }
  .house-actions > #sos-push-control { grid-column: 1; grid-row: 3; }
  .push-control { justify-content: flex-start; max-width: none; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important;
    animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (max-width: 500px) {
  .hero, .stats, .grid, .grid2 { width: 100%; max-width: 360px; }
}
