/* ДНП «Комфорт» — дизайн-система: тёплый светлый фон, глубокий хвойный зелёный, золото как редкий акцент.
   Принцип: цвет — только для смысла (проблема, успех, выбранное); всё остальное — оттенки нейтрального. */
:root {
  --bg: #f5f3ee; --surface: #ffffff; --surface-2: #faf9f6; --surface-3: #f1eee7; --ink: #18201d; --ink-2: #3d4541; --muted: #7a817c; --faint: #a7ada9;
  --line: #e9e5dc; --line-2: #f0ede6;
  --accent: #1f4d3a; --accent-2: #2a6249; --accent-soft: #e8f0eb; --accent-ink: #ffffff;
  --gold: #a8843f; --gold-soft: #f6eedd;
  --ok: #2f7a55; --ok-soft: #e5f2ea; --warn: #b07216; --warn-soft: #fbf1df; --bad: #b8433a; --bad-soft: #fae7e4; --info: #376aa3; --info-soft: #e7eef8;
  --side: #13291f; --side-2: #1a3529; --side-ink: #dfe8e3; --side-muted: #86a093; --side-line: rgba(255, 255, 255, .07);
  --shadow-sm: 0 1px 2px rgba(24, 32, 29, .05);
  --shadow: 0 1px 2px rgba(24, 32, 29, .04), 0 2px 8px rgba(24, 32, 29, .04);
  --shadow-lg: 0 12px 48px rgba(24, 32, 29, .18);
  --r: 16px; --r-sm: 11px;
  --font: "Manrope", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1412; --surface: #161d1a; --surface-2: #1a221f; --surface-3: #202925; --ink: #e8eeea; --ink-2: #c4cdc8; --muted: #8a958f; --faint: #5f6a64;
    --line: #26302c; --line-2: #1f2825;
    --accent: #6bbf95; --accent-2: #86cfa9; --accent-soft: #1b3127; --accent-ink: #0b1510;
    --gold: #d4b273; --gold-soft: #2c2518;
    --ok: #67bd8f; --ok-soft: #1a3026; --warn: #e3a54c; --warn-soft: #31261a; --bad: #e57d72; --bad-soft: #36201d; --info: #84aedf; --info-soft: #1b2939;
    --side: #0a100d; --side-2: #121b17; --side-ink: #d3ddd8; --side-muted: #758a80;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px rgba(0, 0, 0, .2); --shadow-lg: 0 12px 48px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
* { box-sizing: border-box }
html, body { margin: 0 }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 0 }
a { color: var(--accent); text-decoration: none } a:hover { text-decoration: underline }
h1, h2, h3 { margin: 0; font-weight: 750; letter-spacing: -.015em; line-height: 1.2 }
h1 { font-size: 28px } h2 { font-size: 18px } h3 { font-size: 15px }
.i { flex: none; vertical-align: -3px }
.muted { color: var(--muted) } .faint { color: var(--faint) } .small { font-size: 12.5px } .nowrap { white-space: nowrap } .right { text-align: right } .num { font-variant-numeric: tabular-nums }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap } .grow { flex: 1; min-width: 0 } .stack > * + * { margin-top: 12px }
.eyebrow { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); font-weight: 750 }

/* кнопки и поля */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 650; font-size: 14px; padding: 0 15px; border-radius: var(--r-sm); cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; white-space: nowrap; text-decoration: none; box-shadow: var(--shadow-sm) }
.btn:hover { border-color: color-mix(in srgb, var(--ink) 22%, var(--line)); text-decoration: none } .btn:active { transform: translateY(1px) }
.btn:focus-visible, .chip:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink) } .btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2) }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none } .btn.ghost:hover { background: var(--surface-3) }
.btn.danger { color: var(--bad) } .btn.danger:hover { border-color: var(--bad) }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px } .btn.lg { height: 48px; padding: 0 22px; font-size: 15.5px; border-radius: 13px }
.btn.icon { width: 38px; padding: 0 } .btn.icon.sm { width: 32px }
.btn[disabled] { opacity: .45; pointer-events: none }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 12px; height: 40px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s }
textarea { min-height: 88px; padding: 10px 12px; height: auto; resize: vertical }
select[size] { height: auto; padding: 6px }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft) }
input::placeholder, textarea::placeholder { color: var(--faint) }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--accent); padding: 0; flex: none }
label.f { display: block } label.f > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 650 }
label.chk { display: inline-flex; gap: 9px; align-items: center; cursor: pointer; font-weight: 550 }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px } .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr } }

/* карточки, статусы, таблицы */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 22px }
.card.flat { box-shadow: none } .card.pad0 { padding: 0 }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px } .card-h h2 { flex: 1 }
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--surface-3); color: var(--ink-2); white-space: nowrap }
.badge.ok { background: var(--ok-soft); color: var(--ok) } .badge.warn { background: var(--warn-soft); color: var(--warn) } .badge.bad { background: var(--bad-soft); color: var(--bad) }
.badge.info { background: var(--info-soft); color: var(--info) } .badge.gold { background: var(--gold-soft); color: var(--gold) } .badge.accent { background: var(--accent-soft); color: var(--accent) }
.st { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 13.5px; color: var(--ink-2) } .st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none }
.st.ok::before { background: var(--ok) } .st.warn::before { background: var(--warn) } .st.bad::before { background: var(--bad) } .st.info::before { background: var(--info) } .st.accent::before { background: var(--accent) } .st.gold::before { background: var(--gold) }
.st.bad { color: var(--bad); font-weight: 650 }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: currentColor }
table.t { width: 100%; border-collapse: separate; border-spacing: 0 }
table.t th { text-align: left; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 11px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface-2); z-index: 1; user-select: none; white-space: nowrap }
table.t th.sort { cursor: pointer } table.t th.sort:hover { color: var(--ink) }
table.t td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle }
table.t tr.click { cursor: pointer } table.t tr.click:hover td { background: var(--surface-2) }
table.t tr:last-child td { border-bottom: 0 }
.empty { padding: 44px 20px; text-align: center; color: var(--muted) }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 10px 16px } .kv > :nth-child(odd) { color: var(--muted) }
@media (max-width: 640px) { .kv { grid-template-columns: 1fr; gap: 2px } .kv > :nth-child(even) { margin-bottom: 8px } }
.tile-no { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 14.5px; flex: none; font-variant-numeric: tabular-nums }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold); font-weight: 750; flex: none; font-size: 13.5px; letter-spacing: .02em }
.avatar.sm { width: 28px; height: 28px; font-size: 11px }
.avs { display: flex } .avs .avatar { border: 2px solid var(--surface) } .avs .avatar + .avatar { margin-left: -8px }
.plate { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-weight: 700; letter-spacing: .05em; border: 1.5px solid var(--ink-2); border-radius: 5px; padding: 1px 7px; background: var(--surface); font-size: 13px; white-space: nowrap }
.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; display: flex } .progress i { display: block; height: 100%; border-radius: 99px }

/* уведомления и окна */
#toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px) }
.toast { background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 650; animation: tin .2s ease-out }
.toast.err { background: var(--bad); color: #fff }
@keyframes tin { from { opacity: 0; transform: translateY(8px) } }
.overlay { position: fixed; inset: 0; background: rgba(12, 20, 16, .42); backdrop-filter: blur(2px); z-index: 50; display: flex; justify-content: flex-end; animation: fade .15s }
@keyframes fade { from { opacity: 0 } }
.drawer { width: min(640px, 100vw); height: 100%; background: var(--bg); box-shadow: var(--shadow-lg); overflow-y: auto; animation: slide .22s cubic-bezier(.2, .8, .2, 1); display: flex; flex-direction: column }
@keyframes slide { from { transform: translateX(48px); opacity: 0 } }
.drawer > header { position: sticky; top: 0; z-index: 2; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); padding: 22px 26px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start }
.drawer > .body { padding: 22px 26px 48px }
.overlay.center { justify-content: center; align-items: center; padding: 16px }
.modal { width: min(500px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 26px; animation: tin .2s }
.modal.wide { width: min(720px, 100%) }
.x { border: 0; background: transparent; color: var(--muted); cursor: pointer; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; font-size: 22px; line-height: 1 } .x:hover { background: var(--surface-3); color: var(--ink) }
.section-title { display: flex; align-items: center; gap: 10px; margin: 28px 0 10px } .section-title h3 { flex: 1 }
.list-item { display: flex; gap: 12px; align-items: center; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px }
.list-item + .list-item { margin-top: 8px }
.seg { display: inline-flex; gap: 2px; background: var(--surface-3); padding: 3px; border-radius: 11px }
.seg .btn { border-color: transparent; background: transparent; box-shadow: none; height: 32px } .seg .btn.on { background: var(--surface); box-shadow: var(--shadow) }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; margin: 48px auto }
@keyframes spin { to { transform: rotate(360deg) } }

/* нижняя панель ввода показаний и сканер QR — общие для кабинета жителя и приложения контролёра */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(10, 18, 14, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s }
.sheet > div { background: var(--bg); width: 100%; max-width: 640px; max-height: 94vh; overflow-y: auto; border-radius: 24px 24px 0 0; padding: 10px 18px calc(22px + env(safe-area-inset-bottom)); animation: up .22s cubic-bezier(.2, .8, .2, 1) }
@keyframes up { from { transform: translateY(40px); opacity: 0 } }
.grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 14px }
.zone { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-top: 10px }
.zone .h { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; color: var(--muted); font-weight: 650 }
.zone input { height: 60px; font-size: 30px; font-weight: 800; text-align: right; letter-spacing: .02em; margin-top: 8px; font-variant-numeric: tabular-nums; border-width: 2px }
.zone .d { font-size: 13.5px; margin-top: 6px; text-align: right; min-height: 20px; font-variant-numeric: tabular-nums; color: var(--muted) }
.warnbox { background: var(--warn-soft); color: var(--warn); border-radius: 14px; padding: 12px 14px; margin-top: 12px; font-weight: 650; font-size: 14px }
.st-h { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 750; margin: 18px 4px 8px; display: flex; justify-content: space-between }
.cam { position: fixed; inset: 0; background: #000; z-index: 60; display: flex; flex-direction: column }
.cam video { flex: 1; object-fit: cover; width: 100%; height: 100% }
.cam .frame { position: absolute; top: 50%; left: 50%; width: 64vw; max-width: 300px; aspect-ratio: 1; transform: translate(-50%, -60%); border: 3px solid #d8bb83; border-radius: 24px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45) }
.cam .bot { position: absolute; bottom: calc(26px + env(safe-area-inset-bottom)); left: 16px; right: 16px; text-align: center; color: #fff }
.cam .bot p { margin: 0 0 14px; font-weight: 650 } .cam .bot .btn { background: rgba(255, 255, 255, .15); color: #fff; border-color: rgba(255, 255, 255, .25) }

/* карта посёлка */
:root { --map-bg: #ece8dd; --map-grid: rgba(24, 32, 29, .045); --map-road: #ddd6c6; --map-green: #d3e3cb; --map-water: #c8dde8; --map-common: #e3ddce }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --map-bg: #19211e; --map-grid: rgba(255, 255, 255, .035); --map-road: #2a3430; --map-green: #1d3628; --map-water: #1b2f3d; --map-common: #252d29 } }
.mapwrap { display: flex; flex-direction: column; height: 100%; min-height: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow) }
.maptools { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; background: var(--surface) }
.maptools .mapsearch { width: 230px; height: 36px } .maptools .maplayer { width: auto; height: 36px }
.mapstage { position: relative; flex: 1; min-height: 0 }
.mapsvg { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; user-select: none; background: var(--map-bg) }
.mapsvg.drawing { cursor: crosshair }
.mapsvg .plot polygon { fill-opacity: .3; stroke-opacity: .85; transition: fill-opacity .12s }
.mapsvg .plot:hover polygon { fill-opacity: .55; cursor: pointer }
.mapsvg .plot.hl polygon { fill-opacity: .75; stroke: var(--ink) !important }
.mapsvg .plot.sel polygon, .mapsvg .area.sel { stroke: var(--info) !important; stroke-dasharray: 6 4; fill-opacity: .6 }
.mapsvg .plot text { text-anchor: middle; dominant-baseline: central; font-weight: 750; fill: var(--ink); pointer-events: none; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round }
.mapsvg .arealabel { text-anchor: middle; dominant-baseline: central; fill: var(--muted); font-weight: 650; pointer-events: none; letter-spacing: .06em }
.mapsvg .obj circle { fill: var(--surface); stroke: var(--gold) } .mapsvg .obj text { text-anchor: middle; dominant-baseline: central; pointer-events: none }
.mapsvg .obj .objlabel { fill: var(--ink-2); font-weight: 650; paint-order: stroke; stroke: var(--surface); stroke-width: 3px }
.mapsvg .obj.sel circle { stroke: var(--info); stroke-width: 3 }
.mapsvg .vtx { fill: #fff; stroke: var(--info); cursor: move } .mapsvg .draft { fill: none; stroke: var(--info) }
.maphint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-size: 13px; font-weight: 650; max-width: 90%; text-align: center; box-shadow: var(--shadow-lg) }
.mapzoom { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 4px } .mapzoom .btn { width: 34px; height: 34px; padding: 0; font-size: 16px }
.maplegend { position: absolute; left: 12px; bottom: 12px; background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 13px; padding: 10px 14px; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; box-shadow: var(--shadow) }
.maplegend span { display: flex; gap: 8px; align-items: center } .maplegend i { width: 12px; height: 12px; border-radius: 4px; opacity: .75 }
@media (max-width: 640px) { .maptools .mapsearch { width: 100% } .maplegend { font-size: 11.5px; padding: 8px 10px } }
