:root {
  --forest: #253126; --forest-2: #344538; --moss: #758164; --lime: #d9e5a2;
  --paper: #f6f3ea; --ink: #20251f; --muted: #697066; --amber: #dfa34a; --danger: #c95e49;
  --shadow: 0 12px 38px rgba(20, 29, 22, .22); --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body, #app { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { color: var(--ink); background: var(--forest); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 17px; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; }
button { color: inherit; }
#map { position: absolute; inset: 0; z-index: 0; background: #d7dacb; }
.leaflet-control-attribution { font-size: 11px; background: rgba(255,255,255,.82) !important; max-width: 76vw; }
.leaflet-tooltip { font-size: 15px; }
.leaflet-control-zoom { display: none; }
.topbar { position: absolute; z-index: 500; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: calc(12px + var(--safe-top)) 15px 10px; pointer-events: none; background: linear-gradient(rgba(20,30,23,.34), transparent); }
.brand { display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 9px; color: white; background: rgba(37,49,38,.94); box-shadow: 0 5px 18px rgba(15,23,17,.22); border: 1px solid rgba(255,255,255,.12); border-radius: 14px; font-size: 17px; font-weight: 750; letter-spacing: -.02em; }
.brand svg { width: 25px; height: 25px; fill: none; stroke: var(--lime); stroke-width: 2.3; }
.status-chip { pointer-events: auto; display: flex; align-items: center; gap: 7px; height: 44px; border: 1px solid rgba(255,255,255,.5); border-radius: 999px; padding: 0 15px; background: rgba(250,249,244,.95); box-shadow: 0 5px 18px rgba(15,23,17,.18); font-size: 15px; font-weight: 750; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #879085; box-shadow: 0 0 0 3px rgba(135,144,133,.15); }
.status-chip.online .status-dot { background: #4e9b65; box-shadow: 0 0 0 3px rgba(78,155,101,.18); animation: pulse 2s infinite; }
.status-chip.stale .status-dot { background: var(--amber); box-shadow: 0 0 0 3px rgba(223,163,74,.2); }
.status-chip.offline .status-dot { background: #8b918b; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(78,155,101,0); } }
.summary-card { position: absolute; z-index: 450; top: calc(86px + var(--safe-top)); left: 15px; right: 15px; display: grid; grid-template-columns: 1.08fr 1px 1fr; gap: 14px; padding: 15px; border: 1px solid rgba(255,255,255,.74); border-radius: 17px; background: rgba(250,249,244,.94); backdrop-filter: blur(12px); box-shadow: var(--shadow); }
.summary-card section { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.summary-card strong { font-size: 23px; line-height: 1.2; letter-spacing: -.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-card .last-seen strong { font-size: 18px; line-height: 27px; }
.eyebrow { color: var(--moss); font-size: 13px; line-height: 1.3; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.muted { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#distance-note { white-space: normal; line-height: 1.3; }
.divider { width: 1px; background: #d9d9cf; }
.map-actions { position: absolute; z-index: 450; right: 15px; bottom: calc(99px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 9px; }
.round-button { display: grid; place-items: center; width: 46px; height: 46px; padding: 0; border: 1px solid rgba(255,255,255,.72); border-radius: 14px; background: rgba(250,249,244,.96); box-shadow: 0 6px 20px rgba(24,35,27,.22); }
.round-button:active { transform: scale(.95); }
.round-button svg { width: 22px; height: 22px; fill: var(--forest-2); }
.bottom-nav { position: absolute; z-index: 500; left: 15px; right: 15px; bottom: calc(11px + var(--safe-bottom)); height: 72px; display: grid; grid-template-columns: repeat(4,1fr); padding: 6px; background: rgba(37,49,38,.96); border: 1px solid rgba(255,255,255,.12); border-radius: 20px; box-shadow: var(--shadow); }
.nav-button { border: 0; border-radius: 15px; background: transparent; color: #b9c1b5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 14px; font-weight: 700; }
.nav-button svg { width: 22px; height: 22px; fill: currentColor; }
.nav-button.active { color: var(--lime); background: rgba(255,255,255,.08); }
.nav-icon { font-size: 20px; line-height: 20px; }
.history-view { position: absolute; inset: 0; z-index: 700; pointer-events: none; }
.history-toolbar, .history-timeline { pointer-events: auto; position: absolute; left: 15px; right: 15px; border: 1px solid rgba(255,255,255,.74); background: rgba(250,249,244,.96); backdrop-filter: blur(12px); box-shadow: var(--shadow); }
.history-toolbar { top: calc(12px + var(--safe-top)); padding: 12px; border-radius: 18px; }
.history-view-header { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.history-heading { min-width: 0; flex: 1; }
.history-heading h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-view-header h2 { font-size: 24px; }
.history-back { display: flex; flex: 0 0 auto; align-items: center; gap: 3px; min-height: 50px; padding: 0 14px 0 9px; color: white; border: 0; border-radius: 12px; background: var(--forest); font-size: 16px; font-weight: 800; }
.history-back svg { width: 24px; height: 24px; fill: currentColor; }
.history-toolbar-toggle { display: flex; flex: 0 0 auto; align-items: center; justify-content: center; gap: 2px; min-width: 50px; min-height: 50px; padding: 0 10px; color: var(--forest-2); border: 1px solid #d4d5ca; border-radius: 12px; background: #fff; font-size: 15px; font-weight: 800; }
.history-toolbar-toggle svg { width: 25px; height: 25px; fill: currentColor; transition: transform .2s ease; }
.history-toolbar.collapsed { right: auto; width: auto; min-width: 246px; }
.history-toolbar.collapsed .history-view-header { margin-bottom: 0; }
.history-toolbar.collapsed .history-heading, .history-toolbar.collapsed .history-controls { display: none; }
.history-toolbar.collapsed .history-toolbar-toggle { margin-left: auto; padding: 0 14px; }
.history-toolbar.collapsed .history-toolbar-toggle svg { transform: rotate(180deg); }
.history-toolbar .preset-row { margin-bottom: 0; }
.history-toolbar .custom-range { padding: 10px 2px 0; border: 0; }
.history-toolbar .custom-range[open] { margin-top: 8px; border-top: 1px solid #dcded3; }
.history-timeline { bottom: calc(14px + var(--safe-bottom)); padding: 15px 16px 13px; border-radius: 18px; }
.history-timeline .empty-state { padding: 8px; }
.history-timeline .scrubber { padding: 0; }
.history-hint { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.4; }
.history-timeline .scrubber input[type=range] { height: 7px; margin: 20px 0 11px; }
.history-stats-panel { margin: 0 0 11px; border-radius: 11px; background: #e9eadf; }
.history-stats-panel summary { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; min-height: 50px; padding: 8px 11px; cursor: pointer; list-style: none; }
.history-stats-panel summary::-webkit-details-marker { display: none; }
.history-stats-panel summary > span:first-child { color: var(--muted); font-size: 14px; font-weight: 750; }
.history-stats-panel summary > strong { font-size: 20px; }
.stats-more { padding: 6px 8px; color: var(--forest-2); border-radius: 8px; background: #fff; font-size: 13px; font-weight: 800; }
.history-stats-panel[open] .stats-more::after { content: 'Скрий'; }
.history-stats-panel[open] .stats-more { font-size: 0; }
.history-stats-panel[open] .stats-more::after { font-size: 13px; }
.history-stats { display: grid !important; grid-template-columns: repeat(3,1fr); gap: 7px; padding: 0 7px 7px; }
.history-stats div { min-width: 0; padding: 8px 7px; border-radius: 10px; background: #e9eadf; }
.history-stats span { display: block; min-height: 30px; color: var(--muted); font-size: 12px; line-height: 1.2; font-weight: 750; }
.history-stats strong { display: block; margin-top: 2px; font-size: 17px; white-space: nowrap; }
#app.history-mode .topbar, #app.history-mode .summary-card, #app.history-mode .map-actions, #app.history-mode .bottom-nav, #app.history-mode .permission-card { display: none; }
.sheet { position: absolute; z-index: 900; left: 0; right: 0; bottom: 0; max-height: min(72vh, 570px); padding: 9px 20px calc(24px + var(--safe-bottom)); overflow: auto; border-radius: 25px 25px 0 0; background: var(--paper); box-shadow: 0 -12px 50px rgba(15,24,17,.3); transform: translateY(105%); transition: transform .28s cubic-bezier(.22,.9,.35,1); }
.sheet.open { transform: translateY(0); }
.sheet-handle { display: block; width: 42px; height: 5px; margin: 0 auto 13px; border: 0; border-radius: 99px; background: #c9cbc1; }
.sheet-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
h2 { margin: 3px 0 0; font-family: Georgia, serif; font-size: 25px; font-weight: 600; letter-spacing: -.025em; }
.close-button { width: 37px; height: 37px; border: 0; border-radius: 50%; background: #e8e8df; font-size: 26px; line-height: 1; }
.sheet-backdrop { position: absolute; inset: 0; z-index: 850; background: rgba(20,29,22,.28); backdrop-filter: blur(2px); }
.preset-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-bottom: 13px; }
.preset-row button { height: 52px; border: 1px solid #d4d5ca; border-radius: 12px; background: transparent; font-weight: 750; font-size: 16px; }
.preset-row button.selected { color: white; border-color: var(--forest); background: var(--forest); }
.custom-range { padding: 3px 0 14px; border-bottom: 1px solid #dcded3; }
.custom-range summary { display: flex; align-items: center; min-height: 44px; color: var(--forest-2); cursor: pointer; font-size: 16px; font-weight: 750; }
.date-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 10px; margin: 12px 0 10px; }
.date-grid input { width: 100%; max-width: 100%; }
label { color: var(--muted); display: flex; flex-direction: column; gap: 7px; font-size: 15px; font-weight: 700; }
input { width: 100%; min-width: 0; height: 54px; padding: 0 14px; color: var(--ink); border: 1px solid #cfd2c6; border-radius: 11px; background: #fff; font-size: 16px; outline: none; }
input[type=datetime-local]::-webkit-calendar-picker-indicator { width: 24px; height: 24px; padding: 8px; margin-right: -4px; cursor: pointer; }
input:focus { border-color: var(--moss); box-shadow: 0 0 0 3px rgba(117,129,100,.15); }
.primary-button { width: 100%; min-height: 52px; border: 0; border-radius: 12px; color: white; background: var(--forest); font-size: 16px; font-weight: 800; }
.text-button { border: 0; padding: 11px; color: var(--forest-2); background: transparent; font-size: 16px; font-weight: 750; }
.secondary-button, .danger-button { width: 100%; min-height: 52px; border: 1px solid #cfd2c6; border-radius: 12px; background: #fff; font-size: 16px; font-weight: 800; }
.danger-button { color: #9d3f32; border-color: #deb7af; background: #fff8f6; }
.button-stack { display: grid; gap: 9px; }
.zone-sheet { max-height: min(86vh, 740px); }
.zone-status { display: grid; grid-template-columns: 13px 1fr; align-items: start; gap: 10px; padding: 13px; border-radius: 13px; background: #e9eadf; }
.zone-status .status-dot { margin-top: 6px; }
.zone-status.on .status-dot { background: #4e9b65; box-shadow: 0 0 0 3px rgba(78,155,101,.18); }
.zone-status.outside { background: #fff0eb; }
.zone-status.outside .status-dot { background: var(--danger); }
.zone-status strong { font-size: 18px; }
.zone-status p, .notification-card p { margin: 3px 0 0; color: var(--muted); font-size: 15px; line-height: 1.35; }
.section-help { margin: 12px 0; color: var(--muted); font-size: 15px; line-height: 1.45; }
.zone-fieldset { margin: 0 0 12px; padding: 0; border: 0; }
.zone-fieldset legend { margin-bottom: 8px; color: var(--forest-2); font-size: 15px; font-weight: 800; }
.radius-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; }
.radius-row button { min-height: 48px; border: 1px solid #d4d5ca; border-radius: 11px; background: #fff; font-size: 15px; font-weight: 800; }
.radius-row button.selected { color: #fff; border-color: var(--forest); background: var(--forest); }
.zone-center-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; padding: 13px; border-radius: 12px; background: #e9eadf; }
.zone-center-card span { color: var(--muted); font-size: 14px; font-weight: 750; }
.zone-center-card strong { text-align: right; font-size: 15px; }
.notification-card { margin-top: 17px; padding-top: 15px; border-top: 1px solid #d4d5ca; }
.notification-card > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.notification-card > div:first-child strong { font-size: 18px; }
.notification-card > div:first-child p { text-align: right; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.map-pick-banner { position: absolute; z-index: 1100; top: calc(75px + var(--safe-top)); left: 15px; right: 15px; display: grid; gap: 5px; padding: 14px; color: #fff; border-radius: 14px; background: rgba(37,49,38,.96); box-shadow: var(--shadow); font-size: 16px; font-weight: 750; text-align: center; }
.map-pick-banner > span { color: #d9dfd5; font-size: 14px; font-weight: 600; }
.map-pick-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.map-pick-banner button { min-height: 42px; padding: 8px 12px; color: var(--forest); border: 0; border-radius: 9px; background: #fff; font-size: 15px; font-weight: 800; }
.map-pick-banner button.confirm { background: var(--lime); }
.empty-state { padding: 24px 12px 8px; color: var(--muted); text-align: center; font-size: 16px; }
.scrubber { padding: 17px 0 0; }
.scrubber > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.scrubber strong { font-size: 17px; }
.scrubber input[type=range] { appearance: none; height: 4px; margin: 22px 0 10px; padding: 0; border: 0; border-radius: 9px; background: #c8ccbd; box-shadow: none; }
.scrubber input[type=range]::-webkit-slider-thumb { appearance: none; width: 27px; height: 27px; border: 4px solid var(--paper); border-radius: 50%; background: var(--amber); box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.range-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 10px; }
.detail-grid div { padding: 13px; border-radius: 12px; background: #e9eadf; }
.detail-grid dt { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .07em; font-weight: 800; }
.detail-grid dd { margin: 4px 0 0; font-size: 18px; font-weight: 750; }
.permission-card { position: absolute; z-index: 1000; left: 15px; right: 15px; bottom: calc(96px + var(--safe-bottom)); display: grid; grid-template-columns: 46px 1fr; gap: 8px 12px; padding: 17px; border-radius: 19px; background: var(--paper); box-shadow: var(--shadow); }
.permission-card .permission-icon { grid-row: span 1; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: #e3e8d3; }
.permission-icon svg { width: 23px; fill: var(--forest-2); }
.permission-card strong { font-family: Georgia, serif; font-size: 22px; }
.permission-card p { margin: 4px 0 7px; color: var(--muted); font-size: 16px; line-height: 1.45; }
.permission-card .primary-button, .permission-card .text-button { grid-column: 1/-1; }
.permission-card .text-button { padding: 5px; font-size: 15px; }
.login-screen { position: absolute; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 22px; overflow: auto; background: radial-gradient(circle at 70% 15%, #495d47 0, transparent 35%), linear-gradient(150deg,#1c2a20,#304032); }
.login-card { width: min(100%, 390px); padding: 29px; border: 1px solid rgba(255,255,255,.45); border-radius: 23px; background: var(--paper); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-mark { width: 48px; height: 48px; margin-bottom: 19px; fill: none; stroke: var(--forest); stroke-width: 2.5; }
.login-card h1 { margin: 4px 0 8px; font: 600 33px/1.05 Georgia,serif; letter-spacing: -.035em; }
.login-card > p { margin: 0 0 21px; color: var(--muted); font-size: 16px; line-height: 1.45; }
.login-card label { margin: 11px 0; }
.login-card .primary-button { margin-top: 5px; }
.form-error { min-height: 18px; margin: 2px 0 !important; color: var(--danger) !important; font-size: 14px !important; }
.toast { position: absolute; z-index: 2500; left: 50%; bottom: calc(99px + var(--safe-bottom)); max-width: calc(100% - 36px); transform: translateX(-50%); padding: 12px 16px; color: white; background: rgba(31,39,32,.94); border-radius: 10px; box-shadow: var(--shadow); font-size: 15px; text-align: center; }
.tracker-pin, .user-pin, .history-pin { background: transparent; border: 0; }
.tracker-pin-inner { position: relative; display: grid; place-items: center; width: 46px; height: 46px; color: var(--forest); border: 4px solid white; border-radius: 50% 50% 50% 10%; transform: rotate(-45deg); background: var(--amber); box-shadow: 0 4px 13px rgba(31,38,31,.35); }
.dog-image { display: block; width: 36px; height: 36px; object-fit: contain; transform: rotate(45deg); filter: drop-shadow(0 1px 1px rgba(255,255,255,.55)); }
.user-pin-inner { display: grid; place-items: center; width: 30px; height: 30px; color: white; border: 3px solid white; border-radius: 50%; background: #397cc0; box-shadow: 0 0 0 10px rgba(57,124,192,.16), 0 3px 10px rgba(22,51,80,.32); }
.user-pin-inner svg { width: 20px; height: 20px; fill: currentColor; }
.history-pin-inner { width: 18px; height: 18px; border: 3px solid white; border-radius: 50%; background: var(--amber); box-shadow: 0 2px 8px rgba(0,0,0,.3); }
@media (min-width: 700px) {
  .summary-card { right: auto; width: 430px; }
  .bottom-nav { left: 50%; right: auto; width: 390px; transform: translateX(-50%); }
  .sheet { left: 50%; right: auto; width: 480px; transform: translate(-50%,105%); border-radius: 25px 25px 0 0; }
  .sheet.open { transform: translate(-50%,0); }
  .permission-card { left: 50%; right: auto; width: 430px; transform: translateX(-50%); }
  .history-toolbar, .history-timeline { left: 50%; right: auto; width: 470px; transform: translateX(-50%); }
  .history-toolbar.collapsed { width: 246px; }
}
@media (max-width: 480px) {
  .history-toolbar:not(.collapsed) .history-toolbar-toggle span { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
