:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f3f6);
  --text: var(--tg-theme-text-color, #141a26);
  --hint: var(--tg-theme-hint-color, #8a93a6);
  --accent: var(--tg-theme-button-color, #2a6bf2);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #2a6bf2);
  --card: var(--tg-theme-section-bg-color, var(--bg));
  --ok: #22a55b; --bad: #e0483e;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg2); color: var(--text); font: 15px/1.45 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(74px + env(safe-area-inset-bottom, 0px)); }
.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 6px; }
.brand { font-weight: 800; font-size: 19px; letter-spacing: -.01em; }
.logo { margin-right: 4px; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 99px; background: var(--card); color: var(--hint); }
.pill.ok { color: var(--ok); } .pill.bad { color: var(--bad); }
main { padding: 6px 12px; display: block; }
.tab { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.card.accent { outline: 2px solid var(--accent); }
.hero .big { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.hero-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.hero-traffic { display: flex; flex-direction: column; align-items: flex-end; font-size: 12px; white-space: nowrap; }
.hero-traffic b { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.title { font-weight: 700; font-size: 16px; }
h2 { margin: 6px 4px 0; font-size: 22px; }
.title-row { display: flex; justify-content: space-between; align-items: baseline; padding-right: 4px; }
.muted { color: var(--hint); } .small { font-size: 13px; padding: 0 4px; }
.bar { height: 6px; background: var(--bg2); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .4s; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > button { flex: 1 1 0; }
button { font: inherit; font-weight: 600; border: 0; border-radius: 12px; padding: 12px 14px; background: var(--accent); color: var(--accent-text); cursor: pointer; }
button.ghost { background: var(--bg2); color: var(--link); }
button.link { background: none; color: var(--link); padding: 6px 0; text-align: left; }
button.wide { width: 100%; }
button:disabled { opacity: .5; }
.nodes { display: flex; flex-direction: column; gap: 6px; }
.node { display: flex; justify-content: space-between; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; background: var(--ok); }
.dot.bad { background: var(--bad); }
.device { background: var(--card); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.device .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.device .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.device .actions button { padding: 8px 10px; font-size: 13px; }
.off { color: var(--bad); font-size: 12px; }
.seg { display: flex; background: var(--card); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; background: none; color: var(--text); padding: 10px 6px; }
.seg button.on { background: var(--accent); color: var(--accent-text); }
.opt { display: flex; justify-content: space-between; align-items: center; background: var(--card); border-radius: 16px; padding: 14px 16px; margin-top: 10px; gap: 10px; }
.opt .price { font-weight: 800; font-size: 18px; white-space: nowrap; }
.opt .save { font-size: 12px; color: var(--ok); font-weight: 700; }
.guide details { border-top: 1px solid var(--bg2); padding: 8px 0; }
.guide summary { font-weight: 600; cursor: pointer; }
.guide ol { margin: 6px 0 0; padding-left: 20px; }
.pay { display: flex; justify-content: space-between; padding: 4px 0; color: var(--text); }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -1px 0 rgba(127,127,127,.15); }
.tabs button { flex: 1; background: none; color: var(--hint); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; padding: 6px 2px; }
.tabs button span { font-size: 20px; }
.tabs button.on { color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: rgba(20,26,38,.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; }
[hidden] { display: none !important; }
input, textarea, select { font: inherit; color: var(--text); background: var(--bg2); border: 0; border-radius: 12px; padding: 11px 12px; width: 100%; min-width: 0; }
.row > input { flex: 2 1 0; }
textarea { resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid2 label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--hint); }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--card); border-radius: 14px; padding: 12px; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--hint); }
.urow { border-top: 1px solid var(--bg2); padding-top: 10px; margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.urow .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.urow .actions button { padding: 8px 10px; font-size: 13px; }
.gift { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--bg2); }
.gift code { font-size: 13px; }
.traffic { font-size: 12px; color: var(--hint); }

/* Hover and press feedback for everything clickable */
button, .guide summary { transition: filter .15s, background-color .15s, color .15s, box-shadow .15s, transform .08s; -webkit-tap-highlight-color: transparent; }
@media (hover: hover) {
  button:not(:disabled):hover { filter: brightness(1.12); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent); }
  button.ghost:not(:disabled):hover, button.link:not(:disabled):hover, .seg button:not(.on):not(:disabled):hover {
    filter: none; background: color-mix(in srgb, var(--accent) 16%, var(--bg2)); }
  .tabs button:not(.on):hover { filter: none; box-shadow: none; color: var(--text); background: color-mix(in srgb, var(--accent) 10%, transparent); }
  .guide summary:hover { color: var(--accent); }
}
button:not(:disabled):active { transform: scale(.97); filter: brightness(.9); }
button:focus-visible, .guide summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
