:root {
  --bg: var(--tg-theme-bg-color, #0d0f13);
  --surface: var(--tg-theme-secondary-bg-color, #171a20);
  --surface-strong: color-mix(in srgb, var(--surface) 84%, var(--text) 16%);
  --text: var(--tg-theme-text-color, #f4f6f8);
  --hint: var(--tg-theme-hint-color, #9299a6);
  --link: var(--tg-theme-link-color, #5aa7ff);
  --button: var(--tg-theme-button-color, #3488e8);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --accent: var(--tg-theme-accent-text-color, #67a8ff);
  --separator: color-mix(in srgb, var(--hint) 22%, transparent);
  --good: #48c78e;
  --warn: #f0b457;
  --bad: #ef6a6a;
  --unknown: #9299a6;
  --shadow: 0 10px 32px rgba(0, 0, 0, .12);
  --radius-xl: 24px;
  --radius-lg: 19px;
  --radius-md: 14px;
  --page-x: 16px;
  --nav-h: 76px;
  --safe-top: max(env(safe-area-inset-top), var(--tg-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px));
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: contain;
}
button { font: inherit; color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

.app-shell { min-height: 100vh; padding-top: var(--safe-top); }
.topbar {
  min-height: 66px;
  padding: 10px var(--page-x) 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.brand-wrap { display: flex; align-items: center; min-width: 0; gap: 11px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 19px;
  color: var(--button-text); background: linear-gradient(145deg, var(--button), var(--accent));
  box-shadow: 0 8px 24px color-mix(in srgb, var(--button) 28%, transparent);
}
.brand { font-size: 17px; font-weight: 760; letter-spacing: -.01em; }
.top-hint { margin-top: 2px; color: var(--hint); font-size: 12.5px; line-height: 1.2; }
.icon-button {
  width: 46px; height: 46px; border: 0; border-radius: 15px;
  background: var(--surface); color: var(--text); font-size: 25px;
  display: grid; place-items: center; cursor: pointer;
}
.icon-button:active { transform: scale(.97); background: var(--surface-strong); }

.content {
  padding: 8px var(--page-x) calc(var(--nav-h) + var(--safe-bottom) + 26px);
  max-width: 680px;
  margin: 0 auto;
}
.section { margin-top: 18px; }
.section:first-child { margin-top: 2px; }
.section-heading {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  margin: 0 2px 10px;
}
.section-title { margin: 0; font-size: 18px; line-height: 1.25; font-weight: 760; letter-spacing: -.015em; }
.section-note { color: var(--hint); font-size: 13px; }

.card {
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.hero {
  position: relative; overflow: hidden;
  padding: 22px 20px 20px;
  border-radius: var(--radius-xl);
}
.hero::after {
  content: "";
  position: absolute; right: -44px; top: -50px; width: 150px; height: 150px;
  border-radius: 50%; opacity: .12; background: currentColor; filter: blur(2px);
  pointer-events: none;
}
.hero.status-OK { color: var(--good); }
.hero.status-WARNING { color: var(--warn); }
.hero.status-CRITICAL { color: var(--bad); }
.hero.status-UNKNOWN { color: var(--unknown); }
.hero-kicker { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 720; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 5px color-mix(in srgb, currentColor 12%, transparent); }
.hero-title { margin: 13px 0 5px; color: var(--text); font-size: clamp(28px, 8vw, 38px); line-height: 1.02; font-weight: 820; letter-spacing: -.035em; }
.hero-message { color: var(--text); font-size: 15.5px; line-height: 1.45; max-width: 88%; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 7px 13px; margin-top: 15px; color: var(--hint); font-size: 12.5px; }

.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.metric-card {
  min-height: 138px; padding: 15px; border: 1px solid var(--separator); border-radius: var(--radius-lg);
  background: var(--surface); text-align: left; cursor: pointer; position: relative; overflow: hidden;
}
.metric-card:active { transform: scale(.985); background: var(--surface-strong); }
.metric-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.metric-name { color: var(--hint); font-size: 13px; font-weight: 650; }
.metric-arrow { color: var(--hint); font-size: 17px; }
.metric-value { margin-top: 14px; font-size: 31px; line-height: 1; font-weight: 820; letter-spacing: -.035em; }
.metric-state { margin-top: 8px; display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 690; }
.metric-state .mini-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.metric-state.status-OK { color: var(--good); }
.metric-state.status-WARNING { color: var(--warn); }
.metric-state.status-CRITICAL { color: var(--bad); }
.metric-state.status-UNKNOWN { color: var(--unknown); }
.metric-trend { margin-top: 6px; color: var(--hint); font-size: 12px; line-height: 1.35; }

.info-card { padding: 16px; }
.info-row { display: flex; align-items: flex-start; gap: 12px; }
.info-icon {
  width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center;
  border-radius: 13px; background: color-mix(in srgb, var(--button) 13%, var(--surface));
  color: var(--accent); font-size: 19px;
}
.info-main { min-width: 0; flex: 1; }
.info-title { font-weight: 730; line-height: 1.25; }
.info-detail { margin-top: 4px; color: var(--hint); line-height: 1.4; font-size: 13.5px; }
.info-value { font-size: 14px; font-weight: 750; white-space: nowrap; }
.dual-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.summary-card { padding: 15px; min-height: 112px; cursor: pointer; }
.summary-card:active { transform: scale(.987); }
.summary-label { color: var(--hint); font-size: 12.5px; }
.summary-value { margin-top: 9px; font-size: 21px; font-weight: 790; line-height: 1.15; }
.summary-detail { margin-top: 7px; color: var(--hint); font-size: 12.5px; line-height: 1.35; }

.bottom-nav {
  position: fixed;
  z-index: 50;
  left: 0; right: 0; bottom: 0;
  min-height: calc(var(--nav-h) + var(--safe-bottom));
  padding: 7px 8px calc(7px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--bg) 93%, transparent);
  border-top: 1px solid var(--separator);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.nav-item {
  min-height: 58px; min-width: 0; border: 0; background: transparent; color: var(--hint);
  border-radius: 15px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 10.5px; font-weight: 650; cursor: pointer;
}
.nav-icon { height: 22px; min-width: 27px; display: grid; place-items: center; font-size: 20px; line-height: 1; }
.nav-item.active { color: var(--accent); background: color-mix(in srgb, var(--button) 10%, transparent); }
.nav-item:active { transform: scale(.97); }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 5px 2px 16px; }
.page-eyebrow { color: var(--hint); font-size: 12.5px; font-weight: 650; }
.page-title { margin: 4px 0 0; font-size: 28px; font-weight: 820; letter-spacing: -.03em; line-height: 1.05; }
.page-subtitle { margin-top: 7px; max-width: 520px; color: var(--hint); font-size: 13.5px; line-height: 1.45; }
.back-button {
  min-width: 46px; min-height: 46px; padding: 0 13px; border: 1px solid var(--separator);
  border-radius: 15px; background: var(--surface); color: var(--text); font-size: 21px; cursor: pointer;
}

.segmented {
  display: flex; gap: 5px; overflow-x: auto; padding: 4px;
  background: var(--surface); border: 1px solid var(--separator); border-radius: 15px;
  scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented button {
  min-height: 40px; padding: 0 13px; border: 0; border-radius: 11px;
  background: transparent; color: var(--hint); font-size: 13px; font-weight: 690; white-space: nowrap;
}
.segmented button.active { background: var(--button); color: var(--button-text); }

.chart-card { padding: 16px; }
.chart-wrap { height: 210px; margin-top: 9px; position: relative; color: var(--accent); }
.chart-svg { width: 100%; height: 100%; overflow: visible; }
.chart-grid { stroke: var(--separator); stroke-width: 1; }
.chart-line { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart-area { fill: color-mix(in srgb, currentColor 12%, transparent); }
.chart-label { fill: var(--hint); font-size: 10px; }
.chart-empty { height: 190px; display: grid; place-items: center; text-align: center; color: var(--hint); line-height: 1.45; padding: 20px; }
.stat-grid { margin-top: 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { padding: 11px 10px; border-radius: 13px; background: color-mix(in srgb, var(--surface) 76%, var(--text) 3%); }
.stat-label { color: var(--hint); font-size: 11.5px; }
.stat-value { margin-top: 4px; font-size: 17px; font-weight: 760; }

.list { display: grid; gap: 8px; }
.list-item { padding: 14px 15px; }
.list-row { display: flex; gap: 11px; align-items: flex-start; }
.list-status { margin-top: 5px; width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; background: var(--unknown); }
.list-status.ok { background: var(--good); }
.list-status.warning { background: var(--warn); }
.list-status.bad { background: var(--bad); }
.list-main { min-width: 0; flex: 1; }
.list-title { font-weight: 710; line-height: 1.3; }
.list-detail { margin-top: 4px; color: var(--hint); font-size: 12.8px; line-height: 1.4; overflow-wrap: anywhere; }
.list-time { color: var(--hint); font-size: 11.5px; white-space: nowrap; }

.security-hero { padding: 18px; }
.security-hero.status-OK { border-color: color-mix(in srgb, var(--good) 25%, var(--separator)); }
.security-hero.status-WARNING { border-color: color-mix(in srgb, var(--warn) 38%, var(--separator)); }
.security-title { font-size: 23px; font-weight: 810; letter-spacing: -.02em; }
.security-message { margin-top: 5px; color: var(--hint); font-size: 13.5px; line-height: 1.4; }
.security-numbers { margin-top: 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.security-number { padding: 10px; background: color-mix(in srgb, var(--surface) 78%, var(--text) 3%); border-radius: 12px; }
.security-number strong { display: block; font-size: 18px; }
.security-number span { display: block; margin-top: 3px; color: var(--hint); font-size: 10.5px; line-height: 1.2; }

.process-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 9px; align-items: center; }
.process-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 690; }
.process-metric { color: var(--hint); font-size: 12px; text-align: right; }

.notice { padding: 15px; border-radius: var(--radius-md); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 24%, var(--separator)); color: var(--text); line-height: 1.42; font-size: 13px; }
.error-card { padding: 22px 18px; text-align: center; }
.error-icon { font-size: 32px; }
.error-title { margin-top: 10px; font-size: 19px; font-weight: 780; }
.error-text { margin: 7px auto 16px; max-width: 360px; color: var(--hint); line-height: 1.45; font-size: 13.5px; }
.primary-button {
  min-height: 48px; border: 0; border-radius: 14px; padding: 0 18px;
  background: var(--button); color: var(--button-text); font-weight: 730; cursor: pointer;
}

.loading-card { padding: 22px; }
.skeleton { border-radius: 9px; background: color-mix(in srgb, var(--hint) 15%, transparent); animation: pulse 1.3s ease-in-out infinite alternate; }
.skeleton-title { width: 58%; height: 28px; }
.skeleton-line { height: 14px; width: 88%; margin-top: 15px; }
.skeleton-line.short { width: 63%; }

@keyframes pulse { from { opacity: .45; } to { opacity: .9; } }

@media (min-width: 560px) {
  :root { --page-x: 22px; }
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .metric-card { min-height: 145px; }
}

@media (max-width: 355px) {
  :root { --page-x: 12px; }
  .metric-card { min-height: 130px; padding: 13px; }
  .metric-value { font-size: 27px; }
  .nav-item { font-size: 9.5px; }
  .security-numbers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
