/* Toponexa phone app. The same family as the desktop app (dark, the same blue), but its own look: large type, rounded cards,
   one thing per screen, a tab bar for the thumb. Nothing here is shared with css/style.css. */
:root {
  --bg: #070b14; --card: #101828; --card-2: #16213a; --line: #1f2c44; --text: #e8eef8; --muted: #8b9cb5;
  --accent: #38bdf8; --accent-ink: #04202e; --ok: #22c55e; --bad: #fb7185; --warn: #fbbf24; --calm: #94a3b8; --violet: #a78bfa;
  --r: 18px; --tab-h: 62px; --top-h: 58px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; overscroll-behavior-y: contain; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---- sign-in, two-step, the screens before the app ---- */
.center-screen { min-height: 100%; display: grid; place-items: center; padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b)); }
.boot-mark { width: 84px; height: 84px; border-radius: 50%; display: block; margin: 0 auto 22px; }
.spinner { width: 28px; height: 28px; margin: 0 auto; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.auth-card { width: 100%; max-width: 380px; display: grid; gap: 12px; text-align: center; }
.auth-mark { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 4px; }
.auth-card h1 { margin: 0; font-size: 26px; letter-spacing: 0.2px; }
.auth-card p { margin: 0; }
.auth-card label { display: grid; gap: 6px; text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; }
input { width: 100%; height: 52px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 17px; outline: none; }
input:focus { border-color: var(--accent); }
.code-input { text-align: center; letter-spacing: 0.5em; font-size: 26px; font-weight: 700; }
.captcha:empty { display: none; }
.form-error { color: var(--bad); font-size: 14px; text-align: left; }
.auth-links { font-size: 14px; color: var(--muted); }
.auth-links a, .muted a { color: var(--accent); font-weight: 600; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-weight: 700; font-size: 16px; cursor: pointer; }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: 0.6; }
.btn:active { transform: scale(0.98); }
.btn svg { width: 20px; height: 20px; flex: none; }

/* ---- the app frame: top bar, the page, the tab bar ---- */
.app { height: 100%; display: flex; flex-direction: column; }
.top { flex: none; height: calc(var(--top-h) + var(--safe-t)); padding: var(--safe-t) 12px 0 14px; display: flex; align-items: center; gap: 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-mark { width: 34px; height: 34px; border-radius: 50%; flex: none; }
.top-text { flex: 1 1 auto; min-width: 0; }
.top-title { font-size: 18px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-sub:empty { display: none; }
.icon-btn { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--text); }
.icon-btn:active { background: var(--card); }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn.spinning svg { animation: spin 0.8s linear infinite; }
.notice { flex: none; padding: 8px 16px; font-size: 13px; background: #3b2a06; color: #fde68a; border-bottom: 1px solid #5a4410; }
.notice.demo { background: #14263f; color: #bae6fd; border-color: #1d3a5f; }
main { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 14px 22px; outline: none; }
main.flush { padding: 0; overflow: hidden; }
.tabs { flex: none; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); display: grid; grid-template-columns: repeat(5, 1fr); background: #0b111d; border-top: 1px solid var(--line); }
.tabs a { position: relative; display: grid; place-items: center; align-content: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--muted); }
.tabs a.on { color: var(--accent); }
.tab-ico svg { width: 24px; height: 24px; display: block; }
.tab-dot { position: absolute; top: 9px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: var(--bad); border: 2px solid #0b111d; }

/* ---- pieces ---- */
h2.sec { margin: 22px 4px 8px; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 800; display: flex; align-items: center; justify-content: space-between; }
h2.sec:first-child { margin-top: 4px; }
h2.sec .count { color: var(--text); background: var(--card-2); border-radius: 999px; padding: 1px 9px; font-size: 12px; letter-spacing: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.stack { display: grid; gap: 10px; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--calm); }
.t-online { --c: var(--ok); } .t-offline { --c: var(--bad); } .t-slow { --c: var(--warn); } .t-maintenance { --c: var(--violet); } .t-unknown, .t-none { --c: var(--calm); }
.dot[class*="t-"] { background: var(--c); }
.dot.t-offline { box-shadow: 0 0 0 4px rgba(251, 113, 133, 0.18); }

/* Home: the answer first */
.hero { display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: 22px; border: 1px solid var(--line); background: var(--card); }
.hero.good { border-color: #14532d; background: #0b1f17; } .hero.bad { border-color: #7f1d2e; background: #23101a; } .hero.warn { border-color: #6b4f0b; background: #211a0a; }
.ring { position: relative; width: 84px; height: 84px; flex: none; }
.ring svg { width: 84px; height: 84px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring .track { stroke: rgba(255, 255, 255, 0.09); }
.ring .value { stroke: var(--ok); stroke-linecap: round; transition: stroke-dashoffset 0.5s ease; }
.hero.bad .ring .value { stroke: var(--bad); } .hero.warn .ring .value { stroke: var(--warn); } .hero.empty .ring .value { stroke: var(--calm); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 19px; font-weight: 800; }
.hero h1 { margin: 0 0 4px; font-size: 22px; line-height: 1.2; }
.hero p { margin: 0; color: #c7d2e3; font-size: 14.5px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.tile { display: grid; gap: 2px; padding: 12px 10px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); text-align: center; }
.tile b { font-size: 24px; line-height: 1.1; color: var(--c, var(--text)); }
.tile span { font-size: 12px; color: var(--muted); font-weight: 700; }
.tile:active { background: var(--card-2); }
.tile.zero b { color: var(--muted); }

.outage { display: block; padding: 14px 16px; border-radius: var(--r); background: #1d0f18; border: 1px solid #5b1f30; }
.outage-head { display: flex; align-items: center; gap: 12px; }
.outage-head strong { flex: 1 1 auto; min-width: 0; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outage-time { color: #fecdd3; font-size: 13px; font-weight: 700; white-space: nowrap; }
.outage-sub { margin: 4px 0 0 24px; color: var(--muted); font-size: 13px; }
.outage-behind { margin: 8px 0 0 24px; padding: 8px 10px; border-radius: 12px; background: rgba(251, 113, 133, 0.08); font-size: 13.5px; color: #fecdd3; }

.agent { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); }
.agent.stopped, .agent.none { background: #211a0a; border-color: #6b4f0b; }
.agent svg { width: 26px; height: 26px; flex: none; color: var(--ok); }
.agent.stopped svg, .agent.none svg { color: var(--warn); }
.agent strong { display: block; font-size: 15px; }
.agent span { display: block; font-size: 13px; color: var(--muted); }
.updated { margin: 16px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

/* a device in a list */
.row { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.row:active { background: var(--card-2); }
.row-text { flex: 1 1 auto; min-width: 0; }
.row-text strong { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-text span { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-end { flex: none; text-align: right; font-size: 13px; font-weight: 700; color: var(--c, var(--muted)); max-width: 40%; }
.row-end svg { width: 18px; height: 18px; color: var(--muted); vertical-align: middle; }
.row-text .pin-mark { display: inline; color: var(--warn); font-size: inherit; }

/* Devices: search and filters stay at the top */
.finder { position: sticky; top: -14px; z-index: 2; margin: -14px -14px 10px; padding: 14px 14px 10px; background: var(--bg); }
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 15px; width: 22px; height: 22px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 46px; }
.chips { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.chip b { color: var(--text); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.on b { color: var(--accent-ink); }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty svg { width: 46px; height: 46px; color: var(--line); margin-bottom: 10px; }
.empty strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

/* one device */
.banner { padding: 18px; border-radius: 22px; background: var(--card); border: 1px solid var(--line); }
.banner .state { display: flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 800; color: var(--c, var(--text)); }
.banner p { margin: 6px 0 0; color: #c7d2e3; font-size: 15px; }
.banner a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.updated a { color: var(--accent); font-weight: 700; }
.banner.t-offline { background: #23101a; border-color: #7f1d2e; } .banner.t-online { background: #0b1f17; border-color: #14532d; } .banner.t-slow { background: #211a0a; border-color: #6b4f0b; }
.strip { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; height: 34px; margin-top: 4px; }
.strip i { border-radius: 3px; background: #1c273b; }
.strip i.up { background: var(--ok); } .strip i.down { background: var(--bad); }
.strip-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 5px; }
.facts { display: grid; }
.fact { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 2px; border-top: 1px solid var(--line); font-size: 15px; }
.fact:first-child { border-top: 0; padding-top: 2px; }
.fact:last-child { padding-bottom: 2px; }
.fact span { color: var(--muted); flex: none; }
.fact b { font-weight: 600; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.fact a { color: var(--accent); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions .btn { min-height: 56px; }
.actions .wide { grid-column: 1 / -1; }
.note { white-space: pre-wrap; overflow-wrap: anywhere; color: #c7d2e3; font-size: 14.5px; }

/* Alerts */
.alert { display: flex; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.alert-ico { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: rgba(148, 163, 184, 0.14); color: var(--calm); }
.alert-ico svg { width: 19px; height: 19px; }
.alert.down .alert-ico { background: rgba(251, 113, 133, 0.16); color: var(--bad); }
.alert.up .alert-ico { background: rgba(34, 197, 94, 0.16); color: var(--ok); }
.alert.warn .alert-ico { background: rgba(251, 191, 36, 0.16); color: var(--warn); }
.alert-text { flex: 1 1 auto; min-width: 0; font-size: 15px; overflow-wrap: anywhere; }
.alert-time { flex: none; font-size: 12px; color: var(--muted); padding-top: 2px; }
.tip { display: grid; gap: 10px; padding: 14px 16px; border-radius: var(--r); background: #0c1b2e; border: 1px solid #1d3a5f; font-size: 14px; color: #c7ddf5; }
.tip strong { color: var(--text); font-size: 15px; }

/* Map */
#map { position: absolute; inset: 0; background: #0b1220; }
.map-wrap { position: relative; height: 100%; }
#map .leaflet-tile { filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.9) saturate(0.6); }
.leaflet-container { background: #0b1220; font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--card); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.leaflet-popup-content { margin: 12px 14px; font-size: 14px; }
.leaflet-popup-content strong { display: block; font-size: 16px; }
.leaflet-popup-content a { display: inline-block; margin-top: 8px; color: var(--accent); font-weight: 700; }
.leaflet-control-attribution { background: rgba(7, 11, 20, 0.7) !important; color: var(--muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-bar a { background: var(--card) !important; color: var(--text) !important; border-color: var(--line) !important; }
.map-legend { position: absolute; left: 10px; top: 10px; z-index: 500; display: flex; gap: 10px; padding: 8px 12px; border-radius: 999px; background: rgba(16, 24, 40, 0.92); border: 1px solid var(--line); font-size: 12px; font-weight: 700; }
.map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.map-me { position: absolute; right: 12px; bottom: 26px; z-index: 500; width: 52px; min-height: 52px; padding: 0; border-radius: 50%; background: rgba(16, 24, 40, 0.94); }
.map-me svg { width: 24px; height: 24px; }
.map-legend i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }

/* More */
.me { display: flex; align-items: center; gap: 14px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 22px; flex: none; }
.me strong { display: block; font-size: 17px; overflow-wrap: anywhere; }
.me span { display: block; color: var(--muted); font-size: 13.5px; }
.menu { display: grid; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); overflow: hidden; }
.menu > * { display: flex; align-items: center; gap: 14px; min-height: 60px; padding: 10px 16px; border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; width: 100%; cursor: pointer; }
.menu > *:first-child { border-top: 0; }
.menu > *:active { background: var(--card-2); }
.menu svg { width: 22px; height: 22px; flex: none; color: var(--muted); }
.menu div { flex: 1 1 auto; min-width: 0; }
.menu strong { display: block; font-size: 16px; font-weight: 600; }
.menu span { display: block; font-size: 13px; color: var(--muted); }
.menu .danger strong, .menu .danger svg { color: var(--bad); }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 14px); transform: translate(-50%, 20px); padding: 11px 18px; border-radius: 999px; background: #e8eef8; color: #0b1220; font-weight: 700; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; max-width: calc(100% - 32px); z-index: 2000; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.skeleton { border-radius: 8px; background: #1c273b; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

/* a tablet or a desktop window: keep the phone's width, centred, instead of stretching */
@media (min-width: 720px) {
  body { display: grid; justify-items: center; background: #04070d; }
  .app, .center-screen { width: 480px; max-width: 100%; }
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--bg); }
}
/* a very narrow screen: the ring goes above the sentence instead of squeezing it */
@media (max-width: 340px) {
  .hero { flex-direction: column; text-align: center; gap: 10px; }
  .tabs a { font-size: 10px; }
  .actions { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
