*{box-sizing:border-box}body{margin:0;background:#f5f7fa;color:#20262e;font:14px "Segoe UI",Arial,sans-serif}.page{max-width:1180px;margin:auto;padding:28px}.top{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:18px}h1{font-size:30px;margin:0 0 5px}.subtitle,.cap{color:#69727e}.status-card,.card{background:#fff;border:1px solid #dce1e8}.status-card{min-width:430px;padding:13px 15px;display:flex;align-items:center;gap:12px}.status-card strong{margin-left:auto;color:#2563eb}.dot{width:12px;height:12px;border-radius:50%;background:#dc2626}.dot.on{background:#16a34a}.good,.ok,.in{color:#16a34a}.bad{color:#dc2626}.connection{padding:16px;display:flex;gap:12px;align-items:end;margin-bottom:14px}.connection>div{flex:1}label{display:block;color:#69727e;font-size:13px;margin-bottom:6px}input,select,textarea{width:100%;border:1px solid #dce1e8;background:#f9fafc;padding:10px;border-radius:4px;font:inherit;color:#20262e}textarea{min-height:110px;resize:vertical}.composer{padding:18px;margin-bottom:16px}.field{margin-bottom:13px}.send-row{display:flex;align-items:center;gap:18px;color:#69727e}.primary,.secondary,.danger{border:1px solid #dce1e8;border-radius:4px;padding:10px 16px;font-weight:600;cursor:pointer}.primary{background:#2563eb;color:#fff;border-color:#2563eb;min-width:260px}.primary:disabled{opacity:.6}.secondary{background:#fff;color:#69727e}.danger{background:#fff2f2;color:#dc2626;border-color:#fecaca}.counter{text-align:right;color:#69727e;font-size:12px;margin-top:4px}.history-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:9px}.history-head h2{font-size:17px;margin:0}.history-head button{margin-left:8px}.table-wrap{overflow:auto;min-height:260px}table{width:100%;border-collapse:collapse}th{text-align:left;background:#eef2f7;padding:12px 10px;font-size:13px}td{padding:11px 10px;border-top:1px solid #e8ebef;vertical-align:top}td.msg{white-space:pre-wrap;min-width:300px}.out{color:#2563eb}.empty{text-align:center;color:#69727e;padding:50px}@media(max-width:850px){.top{display:block}.status-card{min-width:0;margin-top:15px}.connection{display:block}.connection>div{margin-bottom:10px}.send-row{display:block}.primary{width:100%;margin-bottom:10px}.history-head{display:block}.history-head div{margin-top:10px}.history-head button{margin:0 5px 5px 0}}

.button-link{display:inline-block;text-decoration:none;box-sizing:border-box;}

.adb-menu{margin-bottom:14px}.adb-menu>summary{cursor:pointer;list-style:none;background:#fff;border:1px solid #dce1e8;padding:12px 16px;font-weight:600;color:#69727e;border-radius:4px}.adb-menu>summary::-webkit-details-marker{display:none}.adb-menu>summary:before{content:'▸';display:inline-block;margin-right:8px}.adb-menu[open]>summary:before{content:'▾'}.adb-menu[open]>summary{border-radius:4px 4px 0 0}.adb-menu .connection{border-top:0;border-radius:0 0 4px 4px}.diagnostic-box{padding:12px 16px;margin-top:10px}.diagnostic-box pre{white-space:pre-wrap;word-break:break-word;max-height:280px;overflow:auto;background:#f5f7fa;padding:8px}.history-source-warning{background:#fff7ed;border:1px solid #fed7aa;color:#9a3412;padding:10px 14px;border-radius:4px;margin-bottom:14px}

.history-row{cursor:pointer}.history-row:hover{background:#f7f9fc}.modal{display:none;position:fixed;inset:0;background:rgba(15,23,42,.55);z-index:9999;padding:30px;overflow:auto}.modal.show{display:flex;align-items:center;justify-content:center}.modal-dialog{width:min(760px,100%);max-height:90vh;overflow:auto;background:#fff;border-radius:8px;box-shadow:0 20px 60px rgba(0,0,0,.25);border:1px solid #dce1e8}.modal-head{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid #e8ebef}.modal-head h3{margin:0;font-size:19px}.modal-close{border:0;background:transparent;font-size:28px;line-height:1;cursor:pointer;color:#69727e;padding:2px 8px}.modal-body{padding:20px}.modal-grid{display:grid;grid-template-columns:160px 1fr;gap:12px 18px}.modal-label{color:#69727e;font-size:13px}.modal-value{word-break:break-word}.modal-text{margin-top:18px;border:1px solid #e8ebef;background:#f9fafc;border-radius:5px;padding:14px;white-space:pre-wrap;word-break:break-word;min-height:80px}.modal-footer{padding:12px 20px;border-top:1px solid #e8ebef;text-align:right}.modal-open{overflow:hidden}@media(max-width:600px){.modal{padding:10px}.modal-grid{grid-template-columns:1fr;gap:5px 0}.modal-label{margin-top:8px}}

/* FIX: reliable modal rendering in older browsers/OpenServer */
#messageModal{display:none !important;position:fixed !important;top:0 !important;left:0 !important;right:0 !important;bottom:0 !important;width:100% !important;height:100% !important;background:rgba(15,23,42,.60) !important;z-index:2147483647 !important;padding:30px !important;overflow:auto !important;align-items:center !important;justify-content:center !important;}
#messageModal.modal-show{display:flex !important;}
#messageModal .modal-dialog{display:block !important;position:relative !important;width:760px !important;max-width:100% !important;max-height:90vh !important;overflow:auto !important;background:#fff !important;color:#20262e !important;border:1px solid #dce1e8 !important;border-radius:8px !important;box-shadow:0 20px 60px rgba(0,0,0,.30) !important;}
#messageModal .modal-head{display:flex !important;align-items:center !important;justify-content:space-between !important;padding:16px 20px !important;border-bottom:1px solid #e8ebef !important;}
#messageModal .modal-body{display:block !important;padding:20px !important;}
#messageModal .modal-footer{display:block !important;padding:12px 20px !important;border-top:1px solid #e8ebef !important;text-align:right !important;}
#messageModal .modal-grid{display:grid !important;grid-template-columns:160px 1fr !important;gap:12px 18px !important;}
#messageModal .modal-text{display:block !important;margin-top:18px !important;border:1px solid #e8ebef !important;background:#f9fafc !important;border-radius:5px !important;padding:14px !important;white-space:pre-wrap !important;word-break:break-word !important;min-height:80px !important;}
#messageModal .modal-close{display:block !important;border:0 !important;background:transparent !important;font-size:28px !important;line-height:1 !important;cursor:pointer !important;color:#69727e !important;padding:2px 8px !important;}
@media(max-width:600px){#messageModal{padding:10px !important;}#messageModal .modal-grid{grid-template-columns:1fr !important;gap:5px 0 !important;}}

.history-source-info{font-size:12px;color:#777;margin:4px 0 8px;max-width:900px;word-break:break-all}


/* iPhone / mobile optimization */
html{width:100%;min-width:0;-webkit-text-size-adjust:100%;text-size-adjust:100%}
body{width:100%;min-width:0;overflow-x:hidden;-webkit-tap-highlight-color:transparent}
button,input,select,textarea{touch-action:manipulation}



/* Desktop top row: wide modem status card on the left, MTS packages on the right. */
@media (min-width: 701px) {
  .top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 282px;
    grid-template-areas: "left right" "mail mail" "diagnostics diagnostics";
    align-items: start;
    column-gap: 24px;
    row-gap: 14px;
  }
  .top-left {
    grid-area: left;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 100%;
  }
  .top-left .brand-block { display: none; }
  .top-left .status-card {
    width: 100%;
    min-width: 0;
    min-height: 75px;
    padding: 13px 15px;
    border-radius: 8px;
  }
  .top-right {
    grid-area: right;
    width: 282px;
    min-width: 0;
  }
  .mts-package-widget { width: 100%; min-width: 0; }
  .mass-mailing-top { grid-area: mail; justify-self: end; }
  .adb-menu { grid-area: diagnostics; width: 100%; min-width: 0; }
  .status-card .modem-radio { max-width: 230px; flex-shrink: 0; }
}

@media (max-width: 700px){
  body{font-size:15px;background:#f5f7fa}
  .page{width:100%;max-width:none;margin:0;padding:12px 10px calc(22px + env(safe-area-inset-bottom));}
  .top{display:block;margin-bottom:12px}
  h1{font-size:24px;line-height:1.2;margin-bottom:4px}
  .subtitle{font-size:13px;line-height:1.35}
  .status-card{width:100%;min-width:0;margin-top:10px;padding:12px;border-radius:8px}
  .status-card strong{font-size:13px}

  .adb-menu{margin-bottom:10px}
  .adb-menu>summary{padding:13px 14px;min-height:46px;display:flex;align-items:center}
  .connection{padding:12px;margin-bottom:10px}
  .connection .secondary,.connection .button-link{width:100%;text-align:center;margin-top:8px;min-height:44px;display:flex;align-items:center;justify-content:center}

  .card{border-radius:8px}
  .composer{padding:14px;margin-bottom:12px}
  input,select,textarea{font-size:16px;min-height:46px;padding:12px;border-radius:7px}
  textarea{min-height:130px}
  .counter{font-size:12px;margin-top:6px}
  .send-row{display:block}
  .send-row .primary{width:100%;min-width:0;min-height:48px;margin:0 0 8px;font-size:15px}
  .send-row>span{display:block;font-size:12px;line-height:1.4}

  .history-head{display:block;margin-bottom:10px}
  .history-head h2{font-size:18px;margin-bottom:9px}
  .history-head>div{display:grid;grid-template-columns:1fr;gap:7px}
  .history-head button{width:100%;margin:0;min-height:44px}

  /* Mobile history becomes readable message cards instead of a squeezed desktop table. */
  .table-wrap{overflow:visible;min-height:0;background:transparent;border:0}
  table,thead,tbody,tr,td{display:block;width:100%}
  thead{display:none}
  .history-row{background:#fff;border:1px solid #dce1e8;border-radius:8px;margin-bottom:9px;padding:11px 12px;box-shadow:0 1px 2px rgba(0,0,0,.03)}
  .history-row:hover{background:#fff}
  .history-row td{padding:0;border:0;min-width:0}
  .history-row td:before{display:block;color:#69727e;font-size:11px;margin-bottom:2px;text-transform:uppercase;letter-spacing:.02em}
  .history-row td:nth-child(1){font-weight:600;color:#20262e;margin-bottom:7px}
  .history-row td:nth-child(1):before{content:'Время'}
  .history-row td:nth-child(2){margin-bottom:6px;font-weight:600}
  .history-row td:nth-child(2):before{content:'Направление'}
  .history-row td:nth-child(3){margin-bottom:7px;word-break:break-word}
  .history-row td:nth-child(3):before{content:'Номер / отправитель'}
  .history-row td:nth-child(4){padding:10px;background:#f9fafc;border-radius:6px;line-height:1.45;margin-bottom:7px;word-break:break-word}
  .history-row td:nth-child(4):before{content:'Текст сообщения'}
  .history-row td:nth-child(5){font-size:13px;font-weight:600}
  .history-row td:nth-child(5):before{content:'Статус'}
  .empty{padding:35px 15px;background:#fff;border:1px solid #dce1e8;border-radius:8px}

  .history-source-warning{font-size:13px;line-height:1.4}

  #messageModal{padding:max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)) !important;align-items:flex-end !important}
  #messageModal .modal-dialog{width:100% !important;max-width:none !important;max-height:calc(100vh - 16px) !important;border-radius:12px !important;margin:0 !important}
  #messageModal .modal-head{padding:14px 16px !important;min-height:54px !important}
  #messageModal .modal-body{padding:16px !important}
  #messageModal .modal-grid{grid-template-columns:1fr !important;gap:4px 0 !important}
  #messageModal .modal-label{margin-top:9px !important}
  #messageModal .modal-value{font-size:16px !important;line-height:1.4 !important}
  #messageModal .modal-text{font-size:16px !important;line-height:1.45 !important}
  #messageModal .modal-footer{padding:10px 16px calc(10px + env(safe-area-inset-bottom)) !important}
  #messageModal .modal-footer button{width:100%;min-height:44px}
}

@media (max-width: 380px){
  .page{padding-left:8px;padding-right:8px}
  h1{font-size:22px}
  .history-row{padding:10px}
}


/* Telegram forwarding settings inside ADB diagnostics */
.telegram-settings{margin-top:12px}.telegram-settings h3{margin:0 0 8px;font-size:1.05rem}.telegram-settings .hint{font-size:.9rem;color:#64748b;margin:6px 0 12px}.telegram-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.telegram-grid>div{min-width:0}.telegram-grid label{display:block;margin-bottom:5px;font-weight:600}.telegram-grid input{width:100%;box-sizing:border-box}.telegram-check{display:flex;align-items:center;gap:8px;margin:12px 0}.telegram-check input{width:auto}.telegram-actions{display:flex;gap:10px;flex-wrap:wrap}.telegram-actions button{min-height:40px}@media(max-width:600px){.telegram-grid{grid-template-columns:1fr}.telegram-actions button{width:100%}}

/* Windows Telegram service integration */
.telegram-service-url { grid-column: 1 / -1; }
.telegram-service-url small { display:block; opacity:.8; margin-top:5px; }

.proxy6-check{margin-top:10px;padding:12px 16px}.proxy6-check h3{margin:0 0 8px;font-size:1.05rem}.proxy6-check .hint{font-size:.9rem;color:#64748b;margin:6px 0 12px}.proxy6-row{display:grid;grid-template-columns:minmax(0,1fr) auto auto auto;align-items:end;gap:10px}.proxy6-row label{display:block;margin-bottom:5px;font-weight:600}.proxy6-row input{width:100%;box-sizing:border-box}.proxy6-row button{min-height:40px}@media(max-width:650px){.proxy6-row{grid-template-columns:1fr}.proxy6-row button{width:100%}}


/* Сотовый сигнал и тип сети в карточке состояния ST-906 */
.status-card .modem-radio{margin-left:auto;display:flex;align-items:center;gap:10px;min-width:150px;max-width:230px}
.status-card .radio-labels{display:flex;flex-direction:column;gap:3px;min-width:0}
.status-card .radio-labels strong{margin:0;color:#20262e;font-size:13px;line-height:1.2;overflow-wrap:anywhere}
.status-card .radio-labels span{color:#69727e;font-size:12px;font-weight:600}
.signal-bars{height:25px;display:flex;align-items:flex-end;gap:3px;flex-shrink:0}
.signal-bars i{display:block;width:4px;border-radius:2px 2px 0 0;background:#cbd5e1;height:5px}
.signal-bars i:nth-child(2){height:9px}.signal-bars i:nth-child(3){height:14px}.signal-bars i:nth-child(4){height:19px}.signal-bars i:nth-child(5){height:24px}
.signal-bars i.lit{background:#16a34a}.signal-bars.unknown i{background:#cbd5e1}.signal-bars.strength-1 i.lit{background:#dc2626}.signal-bars.strength-2 i.lit{background:#f97316}.signal-bars.strength-3 i.lit{background:#eab308}.signal-bars.strength-4 i.lit{background:#84cc16}.signal-bars.strength-5 i.lit{background:#16a34a}
@media(max-width:850px){.status-card .modem-radio{margin-left:auto;min-width:0;max-width:55%}.status-card .radio-labels strong{font-size:12px}}

.signal-bars.no-network{height:25px;width:25px;align-items:center;justify-content:center;gap:0;color:#dc2626;font-size:32px;font-weight:700;line-height:22px}.signal-bars.no-network .no-network-mark{display:block;color:#dc2626}

/* Desktop: compact modem-status card like the supplied reference screenshot. */
@media (min-width: 701px) {
  .top .top-left .status-card {
    width: 300px !important;
    min-width: 300px !important;
    max-width: 300px !important;
    padding: 18px 12px !important;
    grid-template-columns: 12px minmax(0, 1fr) auto !important;
    column-gap: 8px !important;
  }
  .top .top-left .status-card .modem-radio {
    gap: 5px !important;
    max-width: 100px !important;
  }
  .top .top-left .status-card .signal-bars {
    gap: 2px;
  }
  .top .top-left .status-card .signal-bars i {
    width: 3px;
  }
}
@media (max-width: 700px) {
  .top .top-left .status-card {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
}
