/* Цвета берутся из темы Telegram (светлая/тёмная и цвета пользователя). Запасные — для браузера. */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #111114);
  --hint: var(--tg-theme-hint-color, #6b6b70);
  --sub: var(--tg-theme-subtitle-text-color, var(--tg-theme-hint-color, #3c3c43));
  --link: var(--tg-theme-link-color, #1c6db3);
  --accent: var(--tg-theme-accent-text-color, var(--tg-theme-link-color, #1c6db3));
  --head: var(--tg-theme-section-header-text-color, var(--tg-theme-hint-color, #6b6b70));
  --sep: var(--tg-theme-section-separator-color, rgba(128, 128, 140, 0.22));
  --bar: var(--tg-theme-bottom-bar-bg-color, var(--tg-theme-bg-color, #f9f9fb));
  --danger: var(--tg-theme-destructive-text-color, #b3261e);
  --ok: #1e7b45; --ok-bg: rgba(30, 123, 69, 0.12);
  --warn: #8f5400; --warn-bg: rgba(230, 140, 0, 0.16);
  --fail: var(--danger); --fail-bg: rgba(220, 50, 40, 0.12);
  --mute-bg: rgba(128, 128, 140, 0.14);
  --you: #1c5a94; --you-bg: rgba(36, 129, 204, 0.14);
  --bot: #563a9a; --bot-bg: rgba(120, 80, 200, 0.14);
  --safe-bottom: max(var(--tg-safe-area-inset-bottom, 0px), env(safe-area-inset-bottom, 0px));
}
html[data-scheme="dark"] {
  --ok: #4cc27a; --ok-bg: rgba(76, 194, 122, 0.16);
  --warn: #f0b04a; --warn-bg: rgba(240, 176, 74, 0.16);
  --fail-bg: rgba(255, 90, 80, 0.16);
  --you: #7db8f0; --you-bg: rgba(90, 160, 230, 0.18);
  --bot: #b9a3ef; --bot-bg: rgba(170, 140, 240, 0.18);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
.app { display: flex; flex-direction: column; height: var(--tg-viewport-stable-height, 100vh); max-width: 720px; margin: 0 auto; }
.screen { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 16px 28px; display: flex; flex-direction: column; gap: 22px; outline: none; }
.loading, .empty { margin: 40px 0; text-align: center; color: var(--hint); }
.banners:empty { display: none; }
.banners { padding: 10px 16px 0; display: flex; flex-direction: column; gap: 8px; }

.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 0 4px; }
.top h1 { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 700; letter-spacing: -0.4px; }
.top p { margin: 2px 0 0; font-size: 14px; color: var(--hint); }
.icon-btn { flex: 0 0 auto; width: 44px; height: 44px; border: 0; border-radius: 22px; background: var(--card); color: var(--link); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

section { display: flex; flex-direction: column; gap: 10px; }
.sec-title { display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px; }
.sec-title h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.2px; }
.sec-title .count { color: var(--hint); font-weight: 500; }
.sec-note { margin: -4px 4px 0; font-size: 13px; color: var(--hint); }

.card { background: var(--card); border-radius: 14px; padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 7px; }
.card h3 { margin: 0; font-size: 16px; line-height: 1.3; font-weight: 600; }
.card p { margin: 0; font-size: 14px; line-height: 1.4; color: var(--sub); }
.meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.meta .since { margin-left: auto; font-size: 12px; color: var(--hint); white-space: nowrap; }
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--mute-bg); color: var(--sub); font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip.you { background: var(--you-bg); color: var(--you); }
.chip.bot { background: var(--bot-bg); color: var(--bot); }
.chip.check { background: var(--warn-bg); color: var(--warn); }
.chip.dev { background: var(--you-bg); color: var(--you); }
.chip.due { background: var(--fail-bg); color: var(--fail); }
.sched { display: flex; align-items: center; gap: 6px; color: var(--ok) !important; }
.sched svg { width: 16px; height: 16px; flex: 0 0 auto; }
.chat-link { display: flex; align-items: center; gap: 6px; min-height: 36px; margin-top: 2px; padding: 0; border: 0; background: none; text-align: left; font-size: 14px; font-weight: 500; color: var(--link); cursor: pointer; }
.chat-link svg { width: 16px; height: 16px; flex: 0 0 auto; }

.tiles { display: flex; gap: 10px; }
.tile { flex: 1 1 0; min-width: 0; background: var(--card); border: 0; border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 6px; text-align: left; cursor: pointer; }
.tile .row { display: flex; align-items: center; gap: 8px; }
.tile .label { font-size: 13px; color: var(--hint); font-weight: 500; }
.tile .value { font-size: 18px; font-weight: 700; }
.tile .note { font-size: 12px; line-height: 1.35; color: var(--hint); }
.badge { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.badge svg { width: 18px; height: 18px; }
.st-ok { color: var(--ok); } .bg-ok { background: var(--ok-bg); }
.st-warn { color: var(--warn); } .bg-warn { background: var(--warn-bg); }
.st-fail { color: var(--fail); } .bg-fail { background: var(--fail-bg); }
.st-mute { color: var(--hint); } .bg-mute { background: var(--mute-bg); }

.alert { display: flex; gap: 12px; align-items: flex-start; border: 0; border-radius: 14px; padding: 12px 14px; text-align: left; width: 100%; cursor: pointer; }
.alert.fail { background: var(--fail-bg); } .alert.warn { background: var(--warn-bg); }
.alert svg { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 1px; }
.alert .body { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.alert .t { font-size: 15px; font-weight: 600; }
.alert .d { font-size: 13px; color: var(--sub); }

.more { display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 48px; border: 0; border-radius: 14px; background: var(--card); font-size: 15px; font-weight: 600; color: var(--link); cursor: pointer; }
.more svg { width: 18px; height: 18px; }

.list { background: var(--card); border-radius: 14px; overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; width: 100%; border: 0; background: none; text-align: left; }
.item + .item { border-top: 1px solid var(--sep); }
.item .dot { flex: 0 0 26px; height: 26px; border-radius: 13px; display: flex; align-items: center; justify-content: center; }
.item .dot svg { width: 15px; height: 15px; }
.item .txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item .name { font-size: 14px; line-height: 1.35; }
.item .sub { font-size: 12px; color: var(--hint); }
.item .st { flex: 0 0 auto; font-size: 12px; font-weight: 600; }
.date { flex: 0 0 52px; text-align: center; display: flex; flex-direction: column; line-height: 1.1; }
.date b { font-size: 20px; color: var(--fail); } .date span { font-size: 12px; color: var(--hint); }
button.item { cursor: pointer; color: inherit; }
.chev { width: 18px; height: 18px; flex: 0 0 auto; color: var(--hint); }

.summary { background: var(--card); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.summary .head { display: flex; align-items: center; gap: 12px; }
.summary .big { width: 44px; height: 44px; border-radius: 22px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.summary .big svg { width: 26px; height: 26px; }
.summary .h { font-size: 20px; font-weight: 700; }
.summary .s { font-size: 13px; color: var(--hint); }
.counters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.counter { border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.counter b { font-size: 22px; } .counter span { font-size: 12px; color: var(--sub); }

.toolbar { display: flex; align-items: flex-end; justify-content: space-between; padding: 0 4px; }
.switch { display: flex; align-items: center; gap: 8px; min-height: 44px; border: 0; background: none; padding: 0; font-size: 15px; cursor: pointer; }
.switch .track { position: relative; width: 51px; height: 31px; border-radius: 16px; background: var(--mute-bg); transition: background 0.2s; }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 14px; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); transition: left 0.2s; }
.switch[aria-pressed="true"] .track { background: var(--tg-theme-button-color, #1e7b45); }
.switch[aria-pressed="true"] .knob { left: 22px; }
.segs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; padding: 2px; border-radius: 10px; background: var(--mute-bg); }
.seg { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 48px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; }
.seg[aria-selected="true"] { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.seg b { font-size: 13px; line-height: 1.2; } .seg span { font-size: 12px; color: var(--hint); }

.tabbar { flex: 0 0 auto; display: flex; padding: 6px 8px calc(6px + var(--safe-bottom)); background: var(--bar); border-top: 1px solid var(--sep); }
.tab { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; border: 0; background: none; color: var(--hint); font-size: 11px; font-weight: 500; cursor: pointer; }
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--link); }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.2; }
.denied { margin: 48px 8px; text-align: center; display: flex; flex-direction: column; gap: 8px; }
.denied h1 { margin: 0; font-size: 22px; } .denied p { margin: 0; color: var(--hint); }
