/* Модуль ситуационной осведомлённости — веб-версия. Палитра — как в настольной (ui_widgets.DARK_QSS). */
:root {
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #212120; --surface-3: #262625;
  --line: #2c2c2a; --line-2: #383835; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --accent: #3987e5; --critical: #d03b3b; --serious: #ec835a; --warning: #fab219; --good: #0ca30c;
  --amber: #c4841d;
  --left-w: 300px; --right-w: 380px; --nav-h: 54px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
:root { color-scheme: dark; }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--page); color: var(--ink);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden;
  -webkit-text-size-adjust: 100%; }
button, select, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#app { position: fixed; left: 0; right: 0; top: 0; bottom: 0; display: flex; }
.panel { background: var(--surface); display: flex; flex-direction: column; min-height: 0; z-index: 5; }
#left { width: var(--left-w); border-right: 1px solid var(--line); flex: none; }
#right { width: var(--right-w); border-left: 1px solid var(--line); flex: none; }
#mapwrap { position: relative; flex: 1; min-width: 0; background: var(--page); }
#cesiumContainer { position: absolute; left: 0; top: 0; right: 0; bottom: 0; }
.cesium-widget-credits, .cesium-viewer-bottom { display: none !important; }
#loading { position: absolute; left: 0; top: 0; right: 0; bottom: 0; z-index: 3; background: var(--page);
  display: flex; align-items: center; justify-content: center; color: var(--muted); text-align: center; padding: 20px; }

.pane-scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px; flex: 1; min-height: 0; }
h3 { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600;
  margin: 14px 0 6px; display: flex; justify-content: space-between; align-items: baseline; }
h3:first-child { margin-top: 0; }
h3 .val { color: var(--ink); font-size: 12px; font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 11px; padding: 4px 12px 8px; }
#left .hint { padding: 2px 0 0; min-height: 0; }

input[type=range] { width: 100%; accent-color: var(--accent); margin: 0; height: 24px; }
select, textarea, input[type=password], input[type=text] { width: 100%; background: var(--surface-3); border: 1px solid var(--line-2);
  border-radius: 7px; padding: 7px 8px; outline: none; }
select:focus, textarea:focus, input:focus { border-color: var(--accent); }
textarea { resize: vertical; margin-top: 6px; }
.chk { display: flex; align-items: flex-start; gap: 8px; color: var(--ink-2); font-size: 12px; padding: 4px 0; cursor: pointer;
  -webkit-user-select: none; user-select: none; }
.chk input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex: none; }
.chk.inline { display: inline-flex; padding: 2px 12px 4px; }
.row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--ink-2); }
.row select { flex: 1; }

.btn { background: var(--surface-3); border: 1px solid var(--line-2); border-radius: 7px; padding: 7px 12px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { color: #666; border-color: var(--line); cursor: default; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn.small { padding: 4px 9px; font-size: 11px; }
.btn.primary { background: #2d5c8a; border-color: var(--accent); font-weight: 600; min-height: 40px; }
.btn.ghost { background: transparent; color: var(--muted); margin-top: 14px; }

.seg { display: flex; gap: 6px; }
.seg button { flex: 1; background: var(--surface-3); border: 1px solid var(--line-2); border-radius: 7px; padding: 6px 4px; cursor: pointer; }
.seg button.on { background: rgba(57,135,229,.28); border-color: var(--accent); }

.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; background: var(--surface-2); }
.tabs button { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted);
  padding: 10px 4px; cursor: pointer; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs.small { background: none; }
.tabs.small button { padding: 6px 4px; font-size: 12px; }

.pane { display: none; flex-direction: column; flex: 1; min-height: 0; }
.pane.on { display: flex; }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px;
  color: var(--ink-2); font-size: 12px; flex: none; }

.list { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; min-height: 0; }
.list.compact { flex: none; max-height: 240px; margin-top: 6px; }
.item { padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; display: block; width: 100%;
  text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0; color: var(--ink-2); }
.item:hover, .item:focus { background: #252524; outline: none; }
.item.static { cursor: default; }
.item .top { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; font-size: 11px; color: var(--muted); }
.item .risk { font-weight: 700; padding: 0 6px; border-radius: 4px; color: #0d0d0d; font-size: 11px; flex: none; }
.item .many { color: var(--accent); font-weight: 600; }
.item .time { margin-left: auto; flex: none; font-variant-numeric: tabular-nums; }
.item .ttl { color: var(--ink-2); overflow-wrap: anywhere; }
.item.unseen .ttl { color: var(--ink); font-weight: 600; }
.item.unseen .top::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.item.now .ttl { font-weight: 600; }
.empty { color: var(--muted); padding: 14px 12px; }

/* карточка события */
#detail { position: absolute; left: 12px; bottom: 34px; width: min(460px, calc(100% - 24px)); max-height: 46%;
  overflow-y: auto; -webkit-overflow-scrolling: touch; background: rgba(26,26,25,.97); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 12px 14px; z-index: 4; box-shadow: 0 8px 28px rgba(0,0,0,.5); }
#detail-close, #modal-close { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 8px; }
#detail-close { position: sticky; float: right; top: 0; margin: -6px -8px 0 6px; }
#detail h4 { margin: 0 0 8px; padding-left: 8px; border-left: 3px solid var(--good); font-size: 14px; overflow-wrap: anywhere; }
#detail .meta { color: var(--muted); font-size: 11px; margin: 0 0 6px; }
#detail .meta b { color: var(--ink-2); font-weight: 600; }
#detail .meta span { margin-right: 10px; }
#detail .sum { background: #252524; border-left: 2px solid var(--accent); padding: 6px 8px; margin: 6px 0; }
#detail .txt { color: var(--ink-2); white-space: pre-line; overflow-wrap: anywhere; margin: 6px 0; }
a { color: #6aa9f0; }

#statusbar { position: absolute; left: 0; right: 0; bottom: 0; height: 24px; padding: 0 10px; z-index: 2;
  background: rgba(22,22,21,.9); border-top: 1px solid var(--line); color: var(--muted); font-size: 11px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; white-space: nowrap; overflow: hidden; }
#status-msg { overflow: hidden; text-overflow: ellipsis; }

/* баннер тревоги */
#banner { position: fixed; top: calc(8px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 30;
  width: min(760px, calc(100% - 24px)); background: rgba(208,59,59,.95); border-radius: 8px; display: flex; align-items: stretch;
  box-shadow: 0 6px 22px rgba(0,0,0,.5); }
#banner.amber { background: rgba(196,132,29,.96); }
#banner-text { flex: 1; background: none; border: 0; color: #fff; font-weight: 600; text-align: left; padding: 9px 12px; cursor: pointer; }
#banner-close { background: none; border: 0; color: #fff; padding: 0 12px; cursor: pointer; font-size: 15px; }

/* окно списка */
#modal { position: fixed; left: 0; top: 0; right: 0; bottom: 0; background: rgba(0,0,0,.55); z-index: 40;
  display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal-box { background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; width: min(480px, 100%);
  max-height: min(70vh, 560px); display: flex; flex-direction: column; overflow: hidden; }
#modal-title { overflow-wrap: anywhere; }

/* ответ ИИ */
.prose { color: var(--ink-2); overflow-wrap: anywhere; margin-top: 10px; }
.prose h3, .prose h4, .prose h5 { color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 14px; margin: 14px 0 6px; display: block; }
.prose h4, .prose h5 { font-size: 13px; }
.prose p { margin: 6px 0; }
.prose ul, .prose ol { margin: 6px 0; padding-left: 20px; }
.prose table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; }
.prose td, .prose th { border: 1px solid var(--line-2); padding: 4px 6px; text-align: left; vertical-align: top; }
.prose .err { color: var(--critical); }
#ai-progress { margin-top: 10px; color: var(--muted); font-size: 12px; }
#ai-progress .bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin-bottom: 6px; position: relative; }
#ai-progress .bar::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 35%; background: var(--accent);
  border-radius: 2px; animation: slide 1.4s ease-in-out infinite alternate; }
@keyframes slide { from { left: 0; } to { left: 65%; } }

/* нижняя панель телефона — на широком экране её нет */
#nav { display: none; }
.badge { background: var(--accent); color: #fff; border-radius: 9px; font-size: 10px; padding: 0 5px; margin-left: 4px; }

/* ---------- узкий экран: карта на весь экран, панели — листами поверх ---------- */
@media (max-width: 900px) {
  html, body { font-size: 14px; }
  #app { bottom: calc(var(--nav-h) + var(--safe-b)); }
  #left, #right { position: absolute; left: 0; top: 0; right: 0; bottom: 0; width: auto; border: 0; display: none;
    padding-top: var(--safe-t); }
  body[data-view="filters"] #left { display: flex; }
  body[data-view="feed"] #right, body[data-view="signals"] #right,
  body[data-view="passes"] #right, body[data-view="ai"] #right { display: flex; }
  #right-tabs { display: none; }
  #nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    display: flex; background: #161615; border-top: 1px solid var(--line); z-index: 20; }
  #nav button { flex: 1; background: none; border: 0; color: var(--muted); font-size: 12px; cursor: pointer; padding: 0 2px;
    border-top: 2px solid transparent; }
  #nav button.on { color: var(--ink); border-top-color: var(--accent); }
  #detail { left: 8px; right: 8px; width: auto; bottom: 30px; max-height: 55%; }
  #status-collect { display: none; }
  /* поле ввода мельче 16px Safari на iPhone при касании увеличивает страницу */
  select, textarea, input[type=password], input[type=text] { font-size: 16px; }
  .item { padding: 11px 12px; }
  .list.compact { max-height: none; }
  .btn { min-height: 38px; }
  .btn.small { min-height: 30px; }
  .chk { padding: 7px 0; }
  .chk input { width: 18px; height: 18px; }
}

/* ---------- страница входа ---------- */
body.login { overflow: auto; display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 20px; }
.login-box { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; padding: 22px; }
.login-box h1 { font-size: 16px; margin: 0 0 16px; font-weight: 600; }
.login-box input { font-size: 16px; }
.login-box .err { color: var(--critical); min-height: 18px; margin-top: 8px; font-size: 12px; }

/* ---------- аэродром: метеосводка и схема ВПП ---------- */
.adr-meteo { display: flex; gap: 12px; align-items: flex-start; margin: 8px 0; }
.adr-meteo svg { flex: none; width: 150px; height: 150px; background: #151514; border: 1px solid var(--line); border-radius: 8px; }
.adr-meteo .facts { flex: 1; min-width: 0; color: var(--ink-2); font-size: 12px; }
.adr-meteo .facts div { margin-bottom: 3px; }
.adr-meteo .facts b { color: var(--muted); font-weight: 600; }
.cat { display: inline-block; padding: 0 7px; border-radius: 4px; color: #0d0d0d; font-weight: 700; font-size: 11px; }
table.rwy { border-collapse: collapse; width: 100%; font-size: 12px; margin: 6px 0; font-variant-numeric: tabular-nums; }
table.rwy th, table.rwy td { border-bottom: 1px solid var(--line); padding: 3px 6px; text-align: left; }
table.rwy th { color: var(--muted); font-weight: 600; font-size: 11px; }
table.rwy tr.work td:first-child { color: var(--good); font-weight: 700; }
.raw { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; color: var(--muted); overflow-wrap: anywhere; margin: 6px 0; }
.warn { color: var(--warning); }
.bad { color: var(--critical); }
.okc { color: var(--good); }
@media (max-width: 420px) { .adr-meteo { flex-direction: column; } }

/* ---------- учётная запись и пользователи ---------- */
.login-box input { margin-bottom: 8px; }
body.account { overflow: auto; height: auto; min-height: 100%; }
.acc-wrap { max-width: 900px; margin: 0 auto; padding: 16px 12px 40px; }
.acc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.acc-head #who { flex: 1; color: var(--ink-2); overflow-wrap: anywhere; }
.acc-head a.btn { text-decoration: none; color: var(--ink); }
.acc-note { background: rgba(196,132,29,.2); border: 1px solid var(--amber); border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }
.card { background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.card h2 { font-size: 15px; margin: 0 0 10px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.card p { color: var(--ink-2); margin: 6px 0; }
.card form input, .card form select { margin-bottom: 8px; max-width: 360px; display: block; }
.card .inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card .inline-form input, .card .inline-form select { width: auto; flex: 1 1 150px; margin: 0; max-width: none; }
.hint0 { color: var(--muted) !important; font-size: 12px; }
.msg { min-height: 18px; margin-top: 8px; font-size: 12px; color: var(--good); }
.msg.err { color: var(--critical); }
.tbl-scroll { overflow-x: auto; }
.tbl-scroll.tall { max-height: 420px; overflow-y: auto; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 12px; }
table.tbl th, table.tbl td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: middle; white-space: nowrap; }
table.tbl th { color: var(--muted); font-weight: 600; font-size: 11px; position: sticky; top: 0; background: var(--surface); }
table.tbl td.wrap { white-space: normal; overflow-wrap: anywhere; min-width: 130px; }
table.tbl select { width: auto; padding: 3px 6px; }
table.tbl .btn { padding: 3px 8px; font-size: 11px; min-height: 0; margin-right: 4px; }
table.tbl tr.off td { color: var(--muted); }
#user-line { color: var(--muted); font-size: 12px; margin-top: 14px; }
#user-line a { color: var(--ink-2); }
@media (max-width: 900px) { .card form input, .card form select { font-size: 16px; } table.tbl select { font-size: 14px; } }
