/* FiberWatch — общий стиль. Светлая и тёмная тема по системе. */
:root {
  --bg: #f3f5f9; --panel: #ffffff; --panel-2: #f8fafc; --ink: #0f172a; --ink-2: #334155; --mute: #64748b;
  --line: #e2e8f0; --line-2: #cbd5e1;
  --acc: #0891b2; --acc-ink: #ffffff; --acc-soft: #ecfeff; --acc-line: #a5f3fc;
  --ok: #059669; --ok-soft: #ecfdf5; --warn: #d97706; --warn-soft: #fffbeb; --bad: #dc2626; --bad-soft: #fef2f2;
  --side: #0b1220; --side-ink: #cbd5e1; --side-mute: #64748b; --side-hover: #111b2e; --side-act: #13233d;
  --radius: 14px; --shadow: 0 1px 2px rgb(15 23 42 / .04), 0 4px 16px rgb(15 23 42 / .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070b14; --panel: #0f1625; --panel-2: #0c1320; --ink: #e2e8f0; --ink-2: #cbd5e1; --mute: #8291a7;
    --line: #1c2638; --line-2: #2a3850;
    --acc: #22d3ee; --acc-ink: #04121a; --acc-soft: #082f3a; --acc-line: #155e75;
    --ok: #34d399; --ok-soft: #052e22; --warn: #fbbf24; --warn-soft: #2e2005; --bad: #f87171; --bad-soft: #2f0d0d;
    --side: #050810; --side-hover: #0c1322; --side-act: #10203a;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box }
html, body { margin: 0 }
body { font: 14.5px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink);
       -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
a { color: var(--acc); text-decoration: none } a:hover { text-decoration: underline }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round }

/* ---------- каркас: боковое меню + контент ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 18px 12px;
        position: sticky; top: 0; height: 100vh }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: #fff; text-decoration: none }
.brand:hover { text-decoration: none }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
               background: linear-gradient(135deg, #06b6d4, #2563eb); box-shadow: 0 0 0 1px rgb(255 255 255 / .08), 0 6px 18px rgb(6 182 212 / .35) }
.brand .logo svg { width: 20px; height: 20px; stroke: #fff }
.brand b { font-size: 16px; letter-spacing: .2px } .brand small { display: block; color: var(--side-mute); font-size: 11.5px; margin-top: -2px }
.nav { display: flex; flex-direction: column; gap: 2px }
.nav .group { color: var(--side-mute); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 16px 12px 6px }
.nav a, .nav span.soon { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: var(--side-ink); font-weight: 500 }
.nav a:hover { background: var(--side-hover); text-decoration: none; color: #fff }
.nav a.on { background: var(--side-act); color: #fff; box-shadow: inset 2px 0 0 #22d3ee }
.nav a.on svg { color: #22d3ee }
.nav span.soon { color: var(--side-mute); cursor: default }
.nav span.soon em { margin-left: auto; font-style: normal; font-size: 10.5px; border: 1px solid #1e293b; border-radius: 6px; padding: 0 6px }
.me { margin-top: auto; border-top: 1px solid #172033; padding: 14px 6px 0; display: flex; align-items: center; gap: 10px }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px;
          background: #13233d; color: #67e8f9; flex: none }
.me .who { min-width: 0; flex: 1 } .me .who a { color: #fff; font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.me .who small { color: var(--side-mute); font-size: 11.5px }
.me form button { background: none; border: 0; color: var(--side-mute); padding: 6px; border-radius: 8px; cursor: pointer; display: grid }
.me form button:hover { color: #fff; background: var(--side-hover) }

main { padding: 28px 36px 64px; max-width: 1240px; width: 100%; min-width: 0 }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap }
h1 { font-size: 24px; line-height: 1.2; margin: 0; letter-spacing: -.01em }
.sub { color: var(--mute); margin-top: 4px; max-width: 720px }
h2 { font-size: 15px; margin: 0; letter-spacing: -.005em }

/* ---------- карточки ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); min-width: 0 }
.card-h { display: flex; align-items: center; gap: 12px; margin-bottom: 14px }
.card-h .ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--acc-soft); color: var(--acc); flex: none }
.card-h .ico svg { width: 20px; height: 20px }
.card-h .t { flex: 1; min-width: 0 } .card-h .t small { color: var(--mute); display: block }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px }
.grid2 > .card { margin-bottom: 0 }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 18px; align-items: start }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow) }
.kpi .l { color: var(--mute); font-size: 12.5px; display: flex; align-items: center; gap: 7px }
.kpi .l svg { width: 15px; height: 15px }
.kpi .v { font-size: 28px; font-weight: 650; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums }
.kpi .v.empty { color: var(--line-2) }
.kpi .h { color: var(--mute); font-size: 12px }

/* бейджи */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 999px;
         border: 1px solid var(--line); color: var(--mute); background: var(--panel-2); white-space: nowrap }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor }
.badge.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent }
.badge.bad { color: var(--bad); background: var(--bad-soft); border-color: transparent }
.badge.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent }
.badge.acc { color: var(--acc); background: var(--acc-soft); border-color: transparent }
.badge.plain::before { display: none }

/* ---------- шаги запуска ---------- */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s }
.steps li { display: flex; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); align-items: flex-start }
.steps li:first-child { border-top: 0; padding-top: 4px }
.steps .dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 12px; font-weight: 600;
              border: 1.5px solid var(--line-2); color: var(--mute) }
.steps li.done .dot { background: var(--ok); border-color: var(--ok); color: #fff }
.steps li.done .dot svg { width: 14px; height: 14px; stroke-width: 2.6 }
.steps li.next .dot { border-color: var(--acc); color: var(--acc); box-shadow: 0 0 0 4px var(--acc-soft) }
.steps .tx { flex: 1; min-width: 0 } .steps .tx b { font-weight: 600 } .steps .tx small { color: var(--mute); display: block }
.steps li.done .tx b { color: var(--mute); text-decoration: line-through; text-decoration-color: var(--line-2) }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 2px 0 14px }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, #06b6d4, #2563eb); border-radius: 99px }

/* ---------- карта ---------- */
.map-card { padding: 0; overflow: hidden }
.map-card .card-h { padding: 18px 20px 0 }
#map { height: 380px; border-top: 1px solid var(--line); margin-top: 14px; background: var(--panel-2) }
.map-wrap { position: relative }
.map-empty { position: absolute; inset: auto 16px 16px 16px; z-index: 500; background: var(--panel); border: 1px solid var(--line);
             border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; box-shadow: 0 8px 24px rgb(15 23 42 / .12) }
.map-empty svg { color: var(--acc) }
.leaflet-container { font: inherit }

/* ---------- журнал ---------- */
.feed { list-style: none; margin: 0; padding: 0 }
.feed li { display: grid; grid-template-columns: 18px 1fr; gap: 12px; padding: 0 0 14px; position: relative }
.feed li::before { content: ""; position: absolute; left: 8px; top: 18px; bottom: 0; width: 1.5px; background: var(--line) }
.feed li:last-child::before { display: none }
.feed .pt { width: 18px; height: 18px; border-radius: 50%; background: var(--acc-soft); border: 1.5px solid var(--acc-line); margin-top: 2px }
.feed .m { color: var(--ink-2) } .feed .m small { display: block; color: var(--mute); font-size: 12px }

/* ---------- таблицы ---------- */
.tbl { width: 100%; border-collapse: collapse }
.tbl th { text-align: left; color: var(--mute); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 0 12px 10px }
.tbl td { padding: 14px 12px; border-top: 1px solid var(--line); vertical-align: middle }
.scroll-x { overflow-x: auto }
.person { display: flex; align-items: center; gap: 12px } .person .avatar { background: var(--acc-soft); color: var(--acc) }
.person b { display: block } .person small { color: var(--mute) }

/* ---------- формы ---------- */
label.f { display: block; font-weight: 500; font-size: 13px; color: var(--ink-2); margin-bottom: 14px }
label.f > span { display: block; margin-bottom: 6px }
input, select, button, textarea { font: inherit }
input[type=text], input[type=password], input:not([type]), select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink);
  transition: border-color .15s, box-shadow .15s }
input:focus, select:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft) }
input::placeholder { color: var(--mute); opacity: .8 }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px }
.pw { position: relative } .pw input { padding-right: 42px }
.pw button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--mute); padding: 6px; cursor: pointer; display: grid }
.pw button:hover { color: var(--ink) }
.hint { color: var(--mute); font-size: 12.5px; margin-top: 6px }
.hint a { font-weight: 500 }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center }
.inline-form { display: grid; grid-template-columns: 1fr 1.3fr 1fr auto; gap: 10px }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--acc);
       background: var(--acc); color: var(--acc-ink); font-weight: 600; cursor: pointer; white-space: nowrap; transition: filter .15s, background .15s }
.btn:hover { filter: brightness(1.08); text-decoration: none }
.btn svg { width: 16px; height: 16px }
.btn.ghost { background: var(--panel); color: var(--ink); border-color: var(--line-2); font-weight: 500 }
.btn.ghost:hover { background: var(--panel-2); filter: none }
.btn.danger { background: transparent; color: var(--bad); border-color: transparent; font-weight: 500; padding: 8px 10px }
.btn.danger:hover { background: var(--bad-soft); filter: none }
.btn.sm { padding: 7px 12px; font-size: 13px }
.btn.block { width: 100% }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 6px }

/* ---------- уведомления ---------- */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; border: 1px solid; font-weight: 500 }
.flash.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent }
.flash.err { background: var(--bad-soft); color: var(--bad); border-color: transparent }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--acc-soft); color: var(--ink-2); border: 1px solid var(--acc-line); margin-bottom: 18px }
.callout svg { color: var(--acc); margin-top: 2px }
.ok { color: var(--ok) } .err { color: var(--bad) } small { color: var(--mute) }
.muted { color: var(--mute) }

/* ---------- вход ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr }
.auth-art { background: radial-gradient(1200px 600px at 10% 10%, #0e2a47 0%, #070d1a 55%, #04070e 100%); color: #e2e8f0; padding: 44px;
            display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden }
.auth-art svg.fibers { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .9 }
.auth-art .brand { position: relative; padding: 0 } .auth-art .pitch { position: relative; max-width: 460px }
.auth-art h2 { font-size: 30px; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 12px; color: #fff }
.auth-art p { color: #94a3b8; margin: 0 }
.auth-art ul { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; color: #cbd5e1 }
.auth-art li { display: flex; gap: 10px; align-items: center } .auth-art li svg { color: #22d3ee }
.auth-form { display: grid; place-items: center; padding: 32px 20px; background: var(--panel) }
.auth-form .box { width: 100%; max-width: 380px }
.auth-form h1 { margin-bottom: 6px }
.auth-form .sub { margin-bottom: 26px }

/* ---------- мобильная вёрстка ---------- */
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) } .grid-main { grid-template-columns: 1fr } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr }
  .side { position: sticky; z-index: 1000; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; gap: 8px; overflow-x: auto }
  .brand { padding: 0 6px 0 0 } .brand small { display: none }
  .nav { flex-direction: row; gap: 2px } .nav .group, .nav span.soon { display: none }
  .nav a { padding: 8px 10px; white-space: nowrap } .nav a span { display: none } .nav a.on { box-shadow: inset 0 -2px 0 #22d3ee }
  .me { margin: 0 0 0 auto; border: 0; padding: 0 } .me .who { display: none }
  main { padding: 20px 16px 48px }
  .grid2 { grid-template-columns: 1fr } .inline-form { grid-template-columns: 1fr }
  .auth { grid-template-columns: 1fr } .auth-art { display: none }
  #map { height: 300px }
}
@media (max-width: 480px) { .kpis { grid-template-columns: 1fr 1fr; gap: 10px } .kpi .v { font-size: 22px } .card { padding: 16px } }

/* Подложка OSM: приглушаем, чтобы точки порывов читались; в тёмной теме — инверсия. */
.tiles-light { filter: grayscale(.85) contrast(.95) brightness(1.04) }
.tiles-dark { filter: invert(1) hue-rotate(180deg) grayscale(.9) brightness(.85) contrast(.9) }

/* карточка аварии */
.tbl.kv td { padding: 9px 4px; } .tbl.kv tr:first-child td { border-top: 0 } .tbl.kv td:first-child { width: 150px; white-space: nowrap }
.chat { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px }
.chat li { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; max-width: 640px }
.chat .who { font-weight: 600; font-size: 13px; margin-bottom: 4px } .chat .who small { font-weight: 400; margin-left: 6px }
.chat .txt { white-space: pre-wrap; word-wrap: break-word; color: var(--ink-2) }
.chat img { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; margin: 4px 0 6px }
.chat .badge { margin: 2px 0 6px }
textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); resize: vertical }
textarea:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft) }
.kpi .v small { font-size: 14px; font-weight: 500; color: var(--mute) }
.leaflet-popup-content a { font-weight: 600 }
