:root{
  --bg:#0A0E14;
  --page:#05070B;
  --surface:#131924;
  --surface-2:#1B2330;
  --hairline:#242D3B;
  --alert:#E13B3B;
  --alert-dim:#4A1B1F;
  --clear:#34D399;
  --clear-dim:#153327;
  --amber:#F5A524;
  --amber-dim:#42300F;
  --unknown:#8A93A6;
  --text:#EDEFF2;
  --text-muted:#9AA3B5;
  --text-faint:#6B7487;
  --tab-h:64px;
  --safe-t:env(safe-area-inset-top,0px);
  --safe-b:env(safe-area-inset-bottom,0px);
  color-scheme:dark;
}
*{box-sizing:border-box;margin:0;padding:0}
[hidden]{display:none!important}
html,body{height:100%}
body{
  background:radial-gradient(ellipse 900px 500px at 50% -10%,#0F1420 0%,var(--page) 55%) fixed;
  font-family:'Inter',system-ui,sans-serif;
  color:var(--text);
  -webkit-font-smoothing:antialiased;
  -webkit-text-size-adjust:100%;
  overscroll-behavior-y:none;
}
a{color:var(--clear);text-decoration:none}
a:hover{text-decoration:underline}
button,input,select{font:inherit;color:inherit}
:focus-visible{outline:2px solid var(--clear);outline-offset:2px}

/* ---------- кнопки ---------- */
.btn{
  display:block;width:100%;padding:13px;border-radius:12px;border:1px solid var(--hairline);
  background:transparent;font-weight:600;font-size:14px;cursor:pointer;
  transition:filter .2s,border-color .2s,color .2s,background .2s;
}
.btn.primary{background:var(--clear);border-color:var(--clear);color:#08130D;font-weight:700}
.btn.primary:hover{filter:brightness(1.08)}
.btn.primary:disabled{opacity:.6;cursor:wait}
.btn.ghost:hover{background:var(--surface-2)}
.btn.small{width:auto;padding:8px 14px;font-size:13px;border-radius:10px;flex-shrink:0}
.btn.out{color:var(--text-muted);margin-bottom:10px}
.btn.out:hover{border-color:var(--alert);color:var(--alert)}
.btn.mute{width:auto;margin:14px auto 0;padding:9px 18px;border-color:var(--alert);color:var(--alert)}

/* ---------- вхід ---------- */
.view{min-height:100%}
#view-auth{display:flex;align-items:center;justify-content:center;padding:calc(28px + var(--safe-t)) 20px calc(28px + var(--safe-b))}
.auth{width:100%;max-width:380px;text-align:center}
.auth-logo{
  width:60px;height:60px;margin:0 auto 14px;border-radius:18px;
  background:radial-gradient(circle at 35% 30%,var(--surface-2),var(--surface));
  border:1.5px solid var(--hairline);display:flex;align-items:center;justify-content:center;
}
.auth-logo svg{width:28px;height:28px;stroke:var(--clear)}
.auth-title{font-family:'Space Grotesk',sans-serif;font-weight:700;font-size:26px}
.auth-sub{font-size:14px;color:var(--text-muted);margin:6px auto 24px;max-width:300px;line-height:1.45}
.seg{display:flex;background:var(--surface);border:1px solid var(--hairline);border-radius:12px;padding:3px;margin-bottom:20px}
.seg button{flex:1;padding:9px;border:0;background:transparent;color:var(--text-faint);font-size:13px;font-weight:600;border-radius:9px;cursor:pointer;transition:background .2s,color .2s}
.seg button.active{background:var(--surface-2);color:var(--text)}
.auth-form{display:none;flex-direction:column;text-align:left}
.auth-form.active{display:flex}
.field{display:block;margin-bottom:12px}
.field span{display:block;font-size:12px;color:var(--text-muted);margin-bottom:5px}
.field input{
  width:100%;padding:13px;border-radius:11px;border:1px solid var(--hairline);background:var(--surface);
  font-size:16px; /* 16px — щоб iOS не збільшував сторінку при фокусі */
  outline:none;transition:border-color .2s;
}
.field input:focus{border-color:var(--clear)}
.field input::placeholder{color:var(--text-faint)}
.field.invalid input{border-color:var(--alert)}
.form-error{min-height:18px;font-size:13px;color:var(--alert);margin:-2px 0 10px}
.divider{display:flex;align-items:center;gap:10px;margin:14px 0;color:var(--text-faint);font-size:12px}
.divider::before,.divider::after{content:'';flex:1;height:1px;background:var(--hairline)}
.hint{font-size:12.5px;color:var(--text-faint);text-align:center;margin-top:12px}
.auth-foot{font-size:12px;color:var(--text-faint);margin-top:26px;line-height:1.5}

/* ---------- оболонка ---------- */
.shell{
  display:flex;flex-direction:column;min-height:100%;
  max-width:1080px;margin:0 auto;
  padding-top:var(--safe-t);
}
.topbar{
  display:flex;align-items:center;justify-content:space-between;gap:16px;
  padding:14px 18px 10px;
}
.brand{display:flex;align-items:center;gap:12px;min-width:0}
.brand-mark{
  width:38px;height:38px;border-radius:12px;flex-shrink:0;display:flex;align-items:center;justify-content:center;
  background:radial-gradient(circle at 35% 30%,var(--surface-2),var(--surface));border:1.5px solid var(--hairline);
  transition:border-color .4s;
}
.brand-mark svg{width:19px;height:19px;stroke:var(--unknown);transition:stroke .4s}
.state-alert .brand-mark{border-color:var(--alert)} .state-alert .brand-mark svg{stroke:var(--alert)}
.state-clear .brand-mark svg{stroke:var(--clear)}
.state-oblast .brand-mark svg{stroke:var(--amber)}
.brand-city{font-family:'Space Grotesk',sans-serif;font-weight:600;font-size:20px;line-height:1.15;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.brand-sub{font-size:12.5px;color:var(--text-faint);margin-top:1px}

/* вкладки: знизу на телефоні, зверху на комп'ютері */
.tabs{
  position:fixed;left:0;right:0;bottom:0;z-index:500;
  display:flex;justify-content:space-around;
  padding:8px 10px calc(10px + var(--safe-b));
  background:rgba(14,19,29,.86);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);
  border-top:1px solid var(--hairline);
}
.tab{
  flex:1;display:flex;flex-direction:column;align-items:center;gap:4px;padding:6px 4px;
  background:none;border:0;border-radius:10px;font-size:11px;color:var(--text-faint);cursor:pointer;
}
.tab svg{width:21px;height:21px}
.tab.active{color:var(--text)}
.tab.active svg{stroke:var(--clear)}

.pages{flex:1;padding-bottom:calc(var(--tab-h) + var(--safe-b) + 28px)}
.page{display:none}
.page.active{display:block}

.attrib{
  text-align:center;font-size:12px;color:var(--text-faint);
  padding:0 18px calc(var(--tab-h) + var(--safe-b) + 20px);margin-top:-8px;
}
.attrib .sep{margin:0 4px}

/* ---------- герой-статус ---------- */
.hero{display:flex;flex-direction:column;align-items:center;text-align:center;padding:18px 20px 12px}
.ring-wrap{position:relative;width:184px;height:184px;display:flex;align-items:center;justify-content:center;margin-bottom:18px}
.pulse{position:absolute;inset:0;border-radius:50%;border:1.5px solid var(--alert);opacity:0}
.state-alert .pulse{animation:pulse 2.2s ease-out infinite}
.pulse:nth-child(2){animation-delay:.7s}
.pulse:nth-child(3){animation-delay:1.4s}
@keyframes pulse{0%{transform:scale(.62);opacity:.55}100%{transform:scale(1.35);opacity:0}}
@media (prefers-reduced-motion:reduce){.pulse{animation:none!important}}
.badge{
  position:relative;width:136px;height:136px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  background:radial-gradient(circle at 35% 30%,var(--surface-2),var(--surface));
  border:1.5px solid var(--hairline);transition:border-color .4s,box-shadow .4s;
}
.badge svg{width:54px;height:54px;stroke:var(--unknown)}
.state-alert .badge{border-color:var(--alert);box-shadow:0 0 0 1px var(--alert-dim),0 0 38px -6px var(--alert)}
.state-alert .badge svg{stroke:var(--alert)}
.state-oblast .badge{border-color:var(--amber);box-shadow:0 0 0 1px var(--amber-dim),0 0 34px -8px var(--amber)}
.state-oblast .badge svg{stroke:var(--amber)}
.state-clear .badge{border-color:var(--clear);box-shadow:0 0 0 1px var(--clear-dim),0 0 34px -8px var(--clear)}
.state-clear .badge svg{stroke:var(--clear)}

.state-label{font-family:'Space Grotesk',sans-serif;font-weight:700;font-size:24px;letter-spacing:.005em;margin-bottom:6px}
.state-alert .state-label{color:var(--alert)}
.state-oblast .state-label{color:var(--amber)}
.state-clear .state-label{color:var(--clear)}
.state-unknown .state-label{color:var(--text-muted)}
.state-detail{font-size:14px;color:var(--text-muted);max-width:320px;line-height:1.45}
.timer{font-family:'JetBrains Mono',monospace;font-size:15px;color:var(--text-muted);margin-top:8px}
.timer b{color:var(--text);font-weight:600}

/* ---------- блоки ---------- */
.block{padding:18px 18px 0}
.block-title{font-family:'Space Grotesk',sans-serif;font-size:16px;font-weight:600;margin-bottom:10px;display:flex;align-items:center;gap:8px}
.count{font-family:'JetBrains Mono',monospace;font-size:12px;color:var(--text-muted);background:var(--surface-2);padding:2px 8px;border-radius:8px;font-weight:500}
.empty{
  padding:16px;border:1px dashed var(--hairline);border-radius:14px;
  color:var(--text-faint);font-size:13.5px;line-height:1.5;
}

.threat-list{display:flex;flex-direction:column;gap:10px}
.threat{
  display:grid;grid-template-columns:auto 1fr auto;gap:12px;align-items:center;
  padding:12px 14px;background:var(--surface);border:1px solid var(--hairline);border-radius:14px;
  border-left:3px solid var(--c,var(--unknown));
}
.threat.stale{opacity:.55}
.threat.advisory{border-left-style:dashed}
.t-icon{
  width:38px;height:38px;border-radius:11px;display:flex;align-items:center;justify-content:center;
  background:color-mix(in srgb,var(--c,var(--unknown)) 16%,transparent);
}
.t-icon svg{width:20px;height:20px;stroke:var(--c,var(--unknown));fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.t-main{min-width:0}
.t-title{font-weight:600;font-size:14.5px}
.t-place{font-size:13px;color:var(--text-muted);margin-top:1px;overflow:hidden;text-overflow:ellipsis}
.t-meta{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px}
.chip{font-size:11.5px;padding:2px 8px;border-radius:7px;background:var(--surface-2);color:var(--text-muted)}
.chip.hi{color:var(--clear)} .chip.mid{color:var(--amber)} .chip.low{color:var(--text-faint)}
.t-side{text-align:right;font-family:'JetBrains Mono',monospace}
.t-dist{font-size:16px;font-weight:600}
.t-dist small{font-size:11px;color:var(--text-faint);font-weight:500}
.t-time{font-size:11.5px;color:var(--text-faint);margin-top:2px}

.history{background:var(--surface);border:1px solid var(--hairline);border-radius:14px;padding:2px 14px}
.hist-day{font-size:12px;color:var(--text-faint);padding:12px 0 4px}
.hist-item{display:flex;align-items:center;gap:12px;padding:10px 0;border-bottom:1px solid var(--hairline)}
.hist-item:last-child{border-bottom:0}
.hist-dot{width:8px;height:8px;border-radius:50%;background:var(--alert);flex-shrink:0}
.hist-dot.live{animation:blink 1.4s ease-in-out infinite}
@keyframes blink{50%{opacity:.25}}
@media (prefers-reduced-motion:reduce){.hist-dot.live{animation:none}}
.hist-main{flex:1;min-width:0}
.hist-time{font-family:'JetBrains Mono',monospace;font-size:13.5px}
.hist-name{font-size:12px;color:var(--text-faint);margin-top:1px}
.hist-dur{font-family:'JetBrains Mono',monospace;font-size:12px;color:var(--text-muted);background:var(--surface-2);padding:3px 8px;border-radius:8px}

/* ---------- карта ---------- */
.map-wrap{position:relative;height:calc(100dvh - 150px - var(--tab-h) - var(--safe-b) - var(--safe-t));min-height:380px;margin:4px 12px 0;border-radius:18px;overflow:hidden;border:1px solid var(--hairline)}
#map{position:absolute;inset:0;background:#0b1018}
.leaflet-container{font-family:'Inter',sans-serif;background:#0b1018}
.leaflet-control-attribution{background:rgba(10,14,20,.8)!important;color:var(--text-faint)!important;font-size:10px!important}
.leaflet-control-attribution a{color:var(--text-muted)!important}
.leaflet-bar a{background:var(--surface)!important;color:var(--text)!important;border-color:var(--hairline)!important}
.mk{position:relative;width:38px;height:38px}
.mk b{position:absolute;left:50%;top:50%;width:14px;height:14px;margin:-7px 0 0 -7px;border-radius:50%;background:var(--c);box-shadow:0 0 0 3px color-mix(in srgb,var(--c) 30%,transparent),0 0 14px var(--c)}
.mk i{position:absolute;inset:0}
.mk i::before{content:'';position:absolute;left:50%;top:1px;margin-left:-6px;border:6px solid transparent;border-bottom:10px solid var(--c);border-top:0}
.mk.stale{opacity:.5}
.mk.advisory b{background:transparent;border:2px dashed var(--c);box-shadow:none}
.home-pin{width:18px;height:18px;border-radius:50%;background:#fff;border:4px solid var(--clear);box-shadow:0 0 0 4px rgba(52,211,153,.25)}
.legend{
  position:absolute;left:10px;bottom:10px;z-index:400;display:flex;flex-wrap:wrap;gap:6px 12px;max-width:calc(100% - 20px);
  background:rgba(10,14,20,.82);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);
  border:1px solid var(--hairline);border-radius:12px;padding:8px 11px;font-size:11.5px;color:var(--text-muted);
}
.legend span{display:inline-flex;align-items:center;gap:6px}
.legend i{width:9px;height:9px;border-radius:50%;background:var(--c)}
.leaflet-popup-content-wrapper,.leaflet-popup-tip{background:var(--surface);color:var(--text);border:1px solid var(--hairline)}
.pop-title{font-weight:600;font-size:14px;margin-bottom:2px}
.pop-line{font-size:12.5px;color:var(--text-muted);line-height:1.45}

/* ---------- повідомлення ---------- */
.messages{display:flex;flex-direction:column;gap:8px}
.msg{padding:11px 14px;background:var(--surface);border:1px solid var(--hairline);border-radius:14px}
.msg-top{display:flex;justify-content:space-between;gap:10px;font-size:11.5px;color:var(--text-faint);margin-bottom:4px}
.msg-text{font-size:13.5px;line-height:1.5;white-space:pre-wrap;overflow-wrap:anywhere}

/* ---------- профіль ---------- */
.profile-top{display:flex;flex-direction:column;align-items:center;text-align:center;padding:26px 20px 6px}
.avatar{
  width:72px;height:72px;border-radius:50%;margin-bottom:12px;display:flex;align-items:center;justify-content:center;
  background:linear-gradient(135deg,var(--clear),var(--amber));
  font-family:'Space Grotesk',sans-serif;font-weight:700;font-size:23px;color:#0A130E;
}
.profile-name{font-family:'Space Grotesk',sans-serif;font-weight:600;font-size:18px}
.profile-sub{font-size:13px;color:var(--text-faint);margin-top:3px}
.card{background:var(--surface);border:1px solid var(--hairline);border-radius:16px}
.row{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:14px 16px;border-bottom:1px solid var(--hairline)}
.row:last-child{border-bottom:0}
.row-text{display:flex;flex-direction:column;gap:2px;min-width:0}
.row-text b{font-size:14.5px;font-weight:600}
.row-text small{font-size:12px;color:var(--text-faint);line-height:1.4}
.row select,.row-input{
  max-width:46%;padding:9px 10px;border-radius:10px;border:1px solid var(--hairline);background:var(--surface-2);
  font-size:14px;outline:none;
}
.row-input{width:46%}
.row select:focus,.row-input:focus{border-color:var(--clear)}
.row-save{justify-content:flex-end}
.save-note{font-size:12.5px;color:var(--text-faint);margin-right:auto}
.save-note.ok{color:var(--clear)}
.note{font-size:12.5px;color:var(--text-faint);line-height:1.5;margin-top:10px}
.credit{font-size:12px;color:var(--text-faint);line-height:1.5;padding:22px 18px 0;text-align:center}

.switch{
  width:48px;height:28px;border-radius:20px;background:var(--surface-2);border:1px solid var(--hairline);
  position:relative;cursor:pointer;flex-shrink:0;transition:background .25s,border-color .25s;
}
.switch::after{content:'';position:absolute;top:2px;left:2px;width:22px;height:22px;border-radius:50%;background:var(--text-faint);transition:transform .25s,background .25s}
.switch[aria-checked="true"]{background:var(--clear-dim);border-color:var(--clear)}
.switch[aria-checked="true"]::after{transform:translateX(20px);background:var(--clear)}

.toast{
  position:fixed;left:50%;top:calc(14px + var(--safe-t));z-index:1000;
  transform:translate(-50%,-160%);max-width:min(92vw,420px);
  padding:11px 16px;border-radius:14px;background:rgba(27,35,48,.96);border:1px solid var(--hairline);
  font-size:13.5px;box-shadow:0 12px 30px -10px rgba(0,0,0,.7);
  transition:transform .4s cubic-bezier(.22,.9,.25,1);
}
.toast.show{transform:translate(-50%,0)}
.toast.alert{border-color:var(--alert)}

/* ---------- комп'ютер ---------- */
@media (min-width:880px){
  .tabs{
    position:static;background:none;border:0;backdrop-filter:none;padding:0;gap:4px;
    justify-content:flex-end;flex:0 0 auto;
  }
  .tab{flex:none;flex-direction:row;gap:8px;padding:9px 14px;font-size:14px;font-weight:500}
  .tab.active{background:var(--surface-2)}
  .topbar{padding:22px 24px 12px}
  .pages{padding-bottom:40px}
  .attrib{padding-bottom:24px}
  .page.active#page-status,.page.active#page-feed{
    display:grid;grid-template-columns:1fr 1fr;align-items:start;column-gap:8px;padding:0 6px;
  }
  .page.active#page-status .hero{grid-column:1;grid-row:1 / span 2;position:sticky;top:12px;padding-top:36px}
  .page.active#page-status .block{grid-column:2}
  .page.active#page-feed .block{grid-column:auto}
  .map-wrap{height:calc(100dvh - 200px);margin:4px 24px 0}
  .block{padding:18px 18px 0}
  #page-profile{max-width:560px;margin:0 auto}
}
