/* Phone layout of the admin panel (22.11). Loaded after app.css; everything here applies only to narrow screens.
   Tables become cards "label — value" (labels come from mobile.js), rows of filters and buttons wrap, node and
   device cards stack, long values break instead of pushing the page wider. */
@media (max-width:700px){
  html,body{overflow-x:hidden}
  #content{min-width:0}
  #content b,#content code,#content td,#content dd,#content small,#content .muted{overflow-wrap:anywhere}

  /* Tables → cards, one card per row. */
  table.m-cards{min-width:0!important;width:100%!important;table-layout:auto!important;border:0}
  table.m-cards thead,table.m-cards tr.m-head{display:none}
  table.m-cards,table.m-cards tbody,table.m-cards tr{display:block;width:100%}
  table.m-cards tr{border:1px solid #1d3550;border-radius:10px;margin:0 0 10px;padding:8px 10px;background:#0a1626}
  table.m-cards tr:last-child{margin-bottom:0}
  /* The label sits in the left 38 %, the value flows as normal text to its right (several parts stay together). */
  table.m-cards td,table.m-cards th{display:block;position:relative;min-height:22px;width:auto!important;border:0!important;
    padding:5px 0 5px calc(38% + 10px)!important;text-align:left!important;white-space:normal!important}
  table.m-cards td::before,table.m-cards th::before{content:attr(data-label);position:absolute;left:0;top:6px;width:38%;
    color:#8ea3c4;font-size:12px;font-weight:600;line-height:1.3;overflow-wrap:anywhere}
  table.m-cards td.m-nolabel,table.m-cards th.m-nolabel{padding-left:0!important}
  table.m-cards td.m-nolabel::before,table.m-cards th.m-nolabel::before{display:none}
  table.m-cards td>*{max-width:100%}
  table.m-cards td:empty{display:none}
  table.m-cards td button,table.m-cards td .button{width:auto;max-width:100%}
  table.m-cards input,table.m-cards select{width:100%;min-width:0}
  /* Tables of controls and the tariff matrix: the label above the value. */
  table.m-cards.m-stack td,table.m-cards.m-stack th{padding:24px 0 6px!important}
  table.m-cards.m-stack td::before,table.m-cards.m-stack th::before{top:4px;width:auto}
  table.m-cards.m-stack td.m-nolabel,table.m-cards.m-stack th.m-nolabel{padding-top:6px!important}
  .table-wrap{border:0;overflow-x:auto}
  .table-wrap.plan-matrix{overflow:visible}

  /* Rows of filters, tabs and toolbars wrap instead of running off the screen. */
  .device-filter,.stats-tabs,.user-views{flex-wrap:wrap}
  .device-filter button{flex:0 1 auto;min-width:0}
  .toolbar{flex-wrap:wrap}
  .toolbar>*{min-width:0;max-width:100%}
  .toolbar input,.toolbar select{min-width:0!important;flex:1 1 100%}
  .toolbar label{display:flex;align-items:center;gap:8px;min-width:0;flex:1 1 100%}
  .toolbar label input[type=checkbox]{flex:0 0 auto;width:auto}

  /* VPN node list: name on top, the load figures in a row, then the state chips over the whole width. */
  .node-list-card{grid-template-columns:repeat(3,minmax(0,1fr)) 20px!important;gap:8px 10px;min-height:0}
  .node-list-card .node-identity{grid-column:1/4;grid-row:1;min-width:0}
  .node-list-card>.chevron{grid-column:4;grid-row:1;align-self:center}
  .node-list-card .node-kpi{display:block!important;grid-row:2;min-width:0}
  .node-list-card .node-kpi.traffic-kpi{display:none!important}
  .node-list-card>div:not([class]){display:none}
  .node-list-card .sops-card-line{grid-column:1/-1;grid-row:3;display:flex;flex-wrap:wrap;gap:4px}
  .node-list-card .sops-chip{margin:0;white-space:nowrap;max-width:100%;overflow:hidden;text-overflow:ellipsis}

  /* Node detail: its section tabs in two rows of three. */
  .node-tabs{grid-template-columns:repeat(3,minmax(0,1fr))!important;overflow:visible}
  .node-tabs button{white-space:normal;line-height:1.25;min-width:0}

  /* Devices in the user card: each line "label" over "value", buttons full width. */
  .admin-device-card dl{grid-template-columns:minmax(0,1fr)!important;gap:2px}
  .admin-device-card dt{margin-top:6px;font-size:12px}
  .admin-device-card dd button{width:100%;white-space:normal}
  .admin-device-card header{flex-wrap:wrap}
  .admin-device-grid{grid-template-columns:minmax(0,1fr)!important}

  /* Key–value blocks elsewhere keep their two columns but may break long values. */
  #content dl dd{min-width:0}
  #content pre{white-space:pre-wrap;overflow-wrap:anywhere}
}
