:root{font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color-scheme:light;--bg:#f5f7fb;--surface:#fff;--text:#17243b;--muted:#6e7c91;--line:#e5eaf2;--accent:#3769e8;--accent-soft:#edf2ff;--green:#208261;--green-soft:#eaf8f1;--red:#c74857;--red-soft:#fff0f1;--amber:#aa751b;--shadow:0 5px 24px #20345a06;--app-viewport-height:100dvh;--app-viewport-top:0px;--app-keyboard-inset:0px;--app-safe-top:env(safe-area-inset-top,0px);--app-safe-bottom:env(safe-area-inset-bottom,0px);--app-safe-left:env(safe-area-inset-left,0px);--app-safe-right:env(safe-area-inset-right,0px);background:var(--bg);color:var(--text);font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased}

*{box-sizing:border-box}
html{min-width:0;scroll-padding-top:16px}
body{margin:0;min-width:0;min-height:var(--app-viewport-height);overflow-wrap:break-word}
button,input,textarea{font:inherit}
button{cursor:pointer;color:inherit}
button:disabled{cursor:wait;opacity:.5}
button,input,textarea{-webkit-tap-highlight-color:transparent}
button:focus-visible,input:focus-visible,textarea:focus-visible{outline:3px solid var(--accent);outline-offset:3px}
input,textarea{min-width:0}
button{touch-action:manipulation}
button,textarea,input{border-radius:12px}
a{color:var(--accent)}
[hidden]{display:none!important}
h1,h2,h3,p{margin:0}
h1{font-size:24px;letter-spacing:-.8px;font-weight:730}
h2{font-size:19px;letter-spacing:-.4px}
h3{font-size:15px;line-height:1.4}
.muted{color:var(--muted)}
.small{font-size:12px;line-height:1.6}
.icon-library{position:absolute;width:0;height:0;overflow:hidden}
.icon{width:21px;height:21px;flex:none;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.app-shell{width:100%;max-width:1440px;min-height:var(--app-viewport-height);margin:0 auto;padding:calc(24px + var(--app-safe-top)) calc(32px + var(--app-safe-right)) calc(24px + var(--app-safe-bottom) + var(--app-keyboard-inset)) calc(32px + var(--app-safe-left))}
.header-actions{display:flex;gap:8px;flex:none}
.app-header{display:flex;justify-content:space-between;align-items:center;gap:20px;margin-bottom:35px}
.brand{min-width:0;display:flex;gap:13px;align-items:center}
.brand-mark,.gate-mark{background:var(--accent);color:white;display:grid;place-items:center;width:48px;height:48px;border-radius:15px}
.brand-mark .icon{width:28px;height:28px}
.eyebrow{font-size:10px;font-weight:750;letter-spacing:1.5px;color:var(--muted);margin-bottom:5px}
.icon-button{border:0;display:grid;place-items:center;background:var(--surface);width:44px;height:44px;flex:none;color:var(--muted)}
.icon-button:hover{color:var(--accent);background:var(--accent-soft)}
.bordered{border:1px solid var(--line)}
.card{border:1px solid var(--line);background:var(--surface);border-radius:17px;box-shadow:var(--shadow)}
.overview-heading,.section-heading{display:flex;justify-content:space-between;gap:14px;align-items:center}
.overview-heading{margin-bottom:19px}
.overview-heading p{margin-top:5px;font-size:13px}
.live-label{display:flex;align-items:center;gap:7px;font-size:11px;color:var(--muted);white-space:nowrap}
.live-dot{width:6px;height:6px;border-radius:100%;background:var(--green)}
.summary-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:13px;margin-bottom:32px}
.summary-card{text-align:left;padding:19px;display:flex;flex-direction:column;gap:13px;transition:border-color .15s,transform .15s}
.summary-card:hover{border-color:var(--accent);transform:translateY(-1px)}
.summary-card>span:first-child{display:flex;gap:7px;align-items:center;color:var(--muted);font-size:12px;font-weight:550}
.summary-card strong{font-size:34px;font-weight:650;line-height:1;letter-spacing:-1.2px;font-variant-numeric:tabular-nums}
.summary-foot{font-size:11px;color:var(--muted)}
.tone-online strong{color:var(--green)}
.tone-offline strong{color:var(--red)}
.status-dot{display:inline-block;width:7px;height:7px;border-radius:100%;background:var(--muted);flex:none}
.status-dot.online{background:var(--green)}
.status-dot.offline{background:var(--red)}
.status-dot.unknown{background:#9ca9bc}
.section-heading{margin-bottom:17px}
.heading-actions{display:flex;gap:8px;flex-wrap:wrap}
.button{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:44px;padding:11px 17px;font-size:13px;font-weight:650;border:1px solid transparent;line-height:1.4}
.primary{background:var(--accent);color:white}
.primary:hover{filter:brightness(.96)}
.secondary{background:var(--surface);border-color:var(--line)}
.secondary:hover{background:var(--accent-soft);border-color:var(--accent)}
.compact{padding:9px 13px;min-height:44px}
.compact .icon{width:17px;height:17px}
.full-width{width:100%}
.search-toolbar{display:flex;gap:10px;position:sticky;top:var(--app-safe-top);z-index:3;background:var(--bg);padding:6px 0}
.search-field{display:flex;align-items:center;gap:11px;background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:0 14px;flex:1;min-width:0;color:var(--muted)}
.search-field:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}
.search-field input{width:100%;border:0;background:none;color:var(--text);padding:13px 0;font-size:16px;outline:none}
.search-field input:focus-visible{outline:none}
.search-field kbd{border:1px solid var(--line);padding:1px 6px;font:12px inherit;border-radius:4px}
.filter-toolbar{display:flex;gap:10px;flex-wrap:wrap;justify-content:space-between;align-items:center;margin-top:14px}
.filter-chips{display:flex;flex-wrap:wrap;gap:5px;padding:2px;min-width:0}
.chip{border:1px solid transparent;background:none;padding:8px 12px;border-radius:9px;min-height:44px;white-space:nowrap;font-size:12px;color:var(--muted);font-weight:550}
.chip:hover{background:var(--surface)}
.chip.active,.chip[aria-pressed=true]{background:var(--accent-soft);color:var(--accent);border-color:color-mix(in srgb,var(--accent) 14%,transparent)}
.subscription-chip{display:inline-flex;gap:6px;align-items:center;flex:none}
.subscription-chip .icon{width:15px;height:15px}
.list-meta{display:flex;flex-wrap:wrap;justify-content:space-between;gap:8px;margin:22px 1px 10px;font-size:11px;color:var(--muted)}
.device-list{display:grid;grid-template-columns:minmax(0,1fr);gap:10px}
.device-card{display:grid;grid-template-columns:40px minmax(0,1fr) auto 17px;gap:14px;align-items:center;padding:17px 18px;text-align:left;width:100%;border:1px solid var(--line);background:var(--surface);border-radius:13px;transition:border-color .15s,background .15s}
.device-card:hover{border-color:color-mix(in srgb,var(--accent) 45%,var(--line));background:color-mix(in srgb,var(--accent-soft) 24%,var(--surface))}
.device-avatar{display:grid;place-items:center;background:var(--bg);color:var(--muted);height:40px;width:40px;border-radius:11px}
.device-avatar.online{background:var(--green-soft);color:var(--green)}
.device-avatar.offline{background:var(--red-soft);color:var(--red)}
.device-copy{min-width:0}
.device-name-line{display:flex;gap:8px;align-items:center;min-width:0}
.device-name{font-size:15px;font-weight:650;letter-spacing:-.2px;line-height:1.45;overflow-wrap:anywhere;min-width:0}
.subscription-indicator{color:var(--accent);width:13px;height:13px}
.device-description{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;font-size:12px;line-height:1.5;color:var(--muted);margin-top:5px;white-space:normal;overflow:hidden;overflow-wrap:anywhere}
.device-side{display:flex;min-width:0;align-items:flex-end;flex-direction:column;gap:6px}
.device-time{font-size:10px;color:var(--muted);white-space:nowrap}
.device-card>.icon{width:15px;height:15px;color:var(--muted)}
.status-badge{display:inline-flex;align-items:center;gap:6px;font-size:11px;font-weight:600;white-space:nowrap;border-radius:6px;padding:5px 8px;background:var(--bg);color:var(--muted)}
.status-badge.online{color:var(--green);background:var(--green-soft)}
.status-badge.offline{color:var(--red);background:var(--red-soft)}
.app-footer{display:flex;flex-wrap:wrap;justify-content:space-between;gap:14px;color:var(--muted);font-size:10px;margin-top:25px}
.empty-state{padding:40px 22px;text-align:center;color:var(--muted)}
.empty-state>.icon{width:35px;height:35px;margin-bottom:14px;opacity:.6}
.empty-state h3{color:var(--text);margin-bottom:7px;font-size:16px}
.empty-state p{font-size:13px;line-height:1.6;max-width:340px;margin:0 auto}
.empty-state .button{margin-top:20px}
.gate{max-width:470px;margin:65px auto;text-align:center;padding:35px 25px}
.gate-mark{margin:0 auto 20px;width:60px;height:60px;border-radius:19px}
.gate-mark .icon{width:32px;height:32px}
.gate p{color:var(--muted);font-size:14px;line-height:1.7;margin-top:12px}
.gate .button{margin-top:22px}
.notice{overflow-wrap:anywhere;flex-wrap:wrap;border:1px solid var(--line);border-radius:12px;padding:13px 15px;font-size:13px;line-height:1.6;margin-bottom:18px;display:flex;justify-content:space-between;align-items:center;gap:15px}
.notice.error{background:var(--red-soft);color:var(--red);border-color:color-mix(in srgb,var(--red) 20%,transparent)}
.text-button{border:0;padding:4px;background:none;color:inherit;font-size:12px;font-weight:700;white-space:nowrap}
.sheet{position:fixed;inset:auto max(16px,var(--app-safe-right)) auto max(16px,var(--app-safe-left));top:calc(var(--app-viewport-top) + var(--app-safe-top) + (var(--app-viewport-height) - var(--app-safe-top) - var(--app-safe-bottom))/2);transform:translateY(-50%);margin:0 auto;padding:0;border:1px solid var(--line);border-radius:22px;background:var(--surface);color:var(--text);width:min(800px,calc(100% - 32px - var(--app-safe-left) - var(--app-safe-right)));max-height:calc(var(--app-viewport-height) - var(--app-safe-top) - var(--app-safe-bottom) - 32px);overflow:hidden;overflow:clip;box-shadow:0 25px 100px #0003}
.sheet[open]{display:flex;flex-direction:column}
.sheet::backdrop{background:#0d183866;backdrop-filter:blur(4px)}
.small-sheet{width:min(560px,calc(100% - 32px - var(--app-safe-left) - var(--app-safe-right)))}
.sheet-header{display:flex;flex:none;min-width:0;justify-content:space-between;gap:15px;align-items:center;padding:23px 24px;border-bottom:1px solid var(--line);background:var(--surface);z-index:2}
.sheet-header>div{min-width:0}
.sheet-header h2{font-size:22px;overflow-wrap:anywhere}
.sheet-header .icon-button{background:var(--bg)}
.sheet-body{padding:24px;min-height:0;min-width:0;overflow-y:auto;overscroll-behavior-y:contain;-webkit-overflow-scrolling:touch;scroll-padding:20px 0 90px;flex:1 1 auto}
.detail-status-line{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:10px;font-size:11px;margin-bottom:17px}
.detail-description{font-size:15px;line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere}
.target-text{font-family:ui-monospace,SFMono-Regular,monospace;color:var(--muted);font-size:11px;margin-top:7px;overflow-wrap:anywhere}
.metric-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,1.4fr);gap:8px;margin:23px 0}
.metric{background:var(--bg);border-radius:12px;padding:14px 12px;display:flex;flex-direction:column;gap:11px}
.metric span{font-size:10px;color:var(--muted);line-height:1.5;min-height:28px}
.metric strong{font-size:23px;font-weight:650;letter-spacing:-.5px;font-variant-numeric:tabular-nums}
.history-section{margin:26px 0}
.history-section .section-heading{margin-bottom:13px;flex-wrap:wrap}
.history-chart{width:100%;height:68px;background:var(--bg);border-radius:10px;padding:8px 6px;overflow:hidden}
.history-chart svg{width:100%;height:100%;display:block}
.history-legend{display:flex;gap:14px;flex-wrap:wrap;font-size:10px;color:var(--muted);margin:10px 0}
.history-legend span{display:flex;gap:5px;align-items:center}
.setting-row{display:flex;min-width:0;justify-content:space-between;align-items:center;gap:20px;padding:20px 0;border-top:1px solid var(--line)}
.setting-row p,.setting-help{font-size:12px;line-height:1.6;color:var(--muted);display:block;margin-top:5px}
.setting-row>span>strong{font-size:14px;font-weight:600}
.setting-row .button{font-size:12px;padding:10px 12px;flex:none}
.admin-section{border-top:1px solid var(--line);padding-top:24px;margin-top:4px}
.admin-section .eyebrow{margin-bottom:18px}
.form-label{display:block;font-size:12px;font-weight:650;margin-bottom:8px}
textarea,input[type=text]{background:var(--bg);border:1px solid var(--line);color:var(--text);width:100%;padding:12px;font-size:16px;line-height:1.5;scroll-margin:16px 0 90px}
textarea{resize:vertical;min-height:104px;max-height:320px;overflow-wrap:anywhere}
.edit-actions{display:flex;gap:10px;flex-wrap:wrap;margin:13px 0 0;padding:12px 0 0;background:var(--surface);position:sticky;bottom:-24px;z-index:1}
.edit-actions .button{font-size:12px}
.form-actions{position:sticky;bottom:-24px;padding:14px 0 0;background:var(--surface);z-index:1}
.form-stack{display:flex;flex-direction:column;gap:22px}
.form-stack .small{margin-top:8px}
.feedback{font-size:12px;line-height:1.6;min-height:0;color:var(--green);margin:12px 0}
.feedback:empty{margin:0}
.feedback.error{color:var(--red)}
.switch{appearance:none;-webkit-appearance:none;width:43px;height:26px;min-width:43px;border-radius:20px;background:var(--line);position:relative;cursor:pointer;transition:background .2s}
.switch:before{content:"";position:absolute;background:#fff;width:20px;height:20px;border-radius:50%;left:3px;top:3px;box-shadow:0 1px 3px #0002;transition:transform .2s}
.switch:checked{background:var(--accent)}
.switch:checked:before{transform:translateX(17px)}
.select-all{display:flex;align-items:center;gap:10px;font-size:13px;padding:18px 0 12px}
.select-all .muted{margin-left:auto;font-size:11px}
input[type=checkbox]:not(.switch){width:18px;height:18px;accent-color:var(--accent);flex:none}
.discovery-list{display:grid;gap:8px}
.discovery-item{display:flex;align-items:center;gap:12px;padding:13px;border:1px solid var(--line);border-radius:12px;cursor:pointer}
.discovery-item .discovery-copy{min-width:0;flex:1}
.discovery-item strong{font-size:14px;overflow-wrap:anywhere}
.discovery-item p{font-size:10px;color:var(--muted);margin-top:5px;overflow-wrap:anywhere}
.loading-state{text-align:center;color:var(--muted);padding:45px 10px;font-size:13px}
.skeleton{height:79px;border-radius:13px;border:1px solid var(--line);background:linear-gradient(100deg,var(--surface) 30%,var(--bg) 50%,var(--surface) 70%);background-size:200%;animation:shimmer 1.7s infinite}
.toast{position:fixed;top:calc(var(--app-viewport-top) + var(--app-viewport-height) - var(--app-safe-bottom) - 20px);left:50%;transform:translate(-50%,-100%);max-width:calc(100% - 32px);width:max-content;padding:13px 20px;border-radius:13px;background:var(--text);color:var(--surface);font-size:13px;box-shadow:0 8px 30px #0002;z-index:10;text-align:center}
.spinning .icon{animation:spin 1s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}
}
@keyframes shimmer{to{background-position:-200% 0}
}

:root[data-theme=dark]{color-scheme:dark;--bg:#121923;--surface:#1a2431;--text:#e8edf5;--muted:#94a3b9;--line:#2b384a;--accent:#729aff;--accent-soft:#253650;--green:#6bd1a9;--green-soft:#1d3933;--red:#fa8f9a;--red-soft:#3e2934;--amber:#e6b661;--shadow:none}
:root[data-theme=dark] .primary{color:#101e36}

@media(prefers-color-scheme:dark){:root:not([data-theme=light]){color-scheme:dark;--bg:#121923;--surface:#1a2431;--text:#e8edf5;--muted:#94a3b9;--line:#2b384a;--accent:#729aff;--accent-soft:#253650;--green:#6bd1a9;--green-soft:#1d3933;--red:#fa8f9a;--red-soft:#3e2934;--amber:#e6b661;--shadow:none}
}


/* Use the space available in expanded desktop Telegram windows. */
@media(min-width:1000px){
  .device-list{grid-template-columns:repeat(2,minmax(0,1fr));align-items:stretch}
  .device-card{height:100%;min-height:92px}
  .app-header{margin-bottom:30px}
  .summary-card{padding:22px 24px}
  .devices-section>.section-heading h2{font-size:21px}
}

/* A mobile sheet has one scrolling body; its header stays above the keyboard. */
@media(max-width:680px){
  .app-shell{padding:calc(16px + var(--app-safe-top)) calc(16px + var(--app-safe-right)) calc(24px + var(--app-safe-bottom) + var(--app-keyboard-inset)) calc(16px + var(--app-safe-left))}
  .app-header{gap:10px;margin-bottom:24px}
  .header-actions{gap:6px}
  h1{font-size:23px}
  .brand{gap:10px}
  .brand-mark{width:42px;height:42px;border-radius:13px;flex:none}
  .overview-heading{align-items:flex-start}
  .overview-heading h2{font-size:17px}
  .overview-heading p{font-size:12px}
  .live-label{font-size:0;gap:0;padding-top:8px}
  .live-dot{width:7px;height:7px}
  .summary-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-bottom:24px}
  .summary-card{padding:15px 16px;gap:10px}
  .summary-card strong{font-size:31px}
  .summary-card>span:first-child{font-size:12px}
  .summary-foot{font-size:11px;line-height:1.4}
  .devices-section>.section-heading{flex-wrap:wrap;gap:12px}
  .devices-section>.section-heading h2{font-size:18px}
  .heading-actions{gap:6px}
  .compact{padding:9px 11px;font-size:12px;border-radius:10px}
  .compact .icon{width:17px;height:17px}
  .filter-toolbar{align-items:flex-start;gap:4px;margin-top:8px}
  .filter-chips{width:100%;margin-left:-2px;gap:4px}
  .chip{padding:8px 10px;font-size:12px}
  .subscription-chip{padding-left:10px}
  .search-field kbd{display:none}
  .list-meta{font-size:11px;margin-top:13px}
  .device-card{grid-template-columns:34px minmax(0,1fr) auto;gap:10px;padding:14px 12px}
  .device-avatar{width:34px;height:37px;border-radius:9px}
  .device-avatar .icon{width:18px;height:18px}
  .device-card>.icon{display:none}
  .device-name{font-size:15px}
  .device-description{font-size:12px}
  .status-badge{font-size:11px;padding:5px 7px}
  .device-time{font-size:10px}
  .app-footer{font-size:10px;flex-direction:column;gap:5px;line-height:1.5}
  .sheet,.small-sheet{inset-inline:max(8px,var(--app-safe-left)) max(8px,var(--app-safe-right));width:calc(100% - 16px - var(--app-safe-left) - var(--app-safe-right));max-width:none;max-height:calc(var(--app-viewport-height) - var(--app-safe-top) - var(--app-safe-bottom) - 16px);border-radius:20px}
  .sheet-header{padding:16px;gap:12px}
  .sheet-header h2{font-size:20px}
  .sheet-body{padding:18px 16px;scroll-padding:16px 0 82px}
  .metric-grid{gap:7px}
  .metric{padding:13px 10px}
  .metric strong{font-size:22px}
  .metric span{font-size:10px}
  .setting-row{gap:12px;flex-wrap:wrap}
  .setting-row>div{flex:1 1 150px}
  label.setting-row{flex-wrap:nowrap}
  label.setting-row>span{min-width:0}
  .setting-row h3{font-size:14px}
  .setting-row p{font-size:12px}
  .detail-status-line{font-size:11px}
  .detail-description{font-size:15px}
  .form-actions,.edit-actions{bottom:-18px;padding-top:12px}
  .form-stack{gap:18px}
  .edit-actions .button{width:100%;font-size:13px}
  .gate{margin:32px auto;padding:28px 20px}
}
@media(max-width:380px){
  .app-shell{padding-inline:calc(12px + var(--app-safe-left)) calc(12px + var(--app-safe-right))}
  .brand{gap:8px}
  .brand-mark{width:36px;height:36px}
  .brand-mark .icon{width:24px;height:24px}
  .brand h1{font-size:21px}
  .brand .eyebrow{font-size:9px;letter-spacing:1px}
  .header-actions{gap:4px}
  .device-card{grid-template-columns:34px minmax(0,1fr);row-gap:9px}
  .device-side{grid-column:2;align-items:center;justify-content:space-between;flex-direction:row;gap:8px}
  .metric-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .metric:last-child{grid-column:1/-1;flex-direction:row;align-items:center;justify-content:space-between}
  .metric:last-child span{min-height:0;max-width:150px}
}
:root[data-keyboard-open=true] .sheet-header{padding-block:10px}
:root[data-keyboard-open=true] .sheet-header .eyebrow{display:none}
:root[data-keyboard-open=true] .sheet-body{scroll-padding-top:12px}
:root[data-keyboard-open=true] textarea{min-height:80px;max-height:min(240px,max(80px,calc(var(--app-viewport-height) - 180px)))}
@media(max-height:500px){
  .sheet-header{padding-block:10px}
  .sheet-header .eyebrow{display:none}
  .sheet-header h2{font-size:18px}
}
@media(prefers-reduced-motion:reduce){*,*:before{animation:none!important;transition:none!important}}
