/* Operator-first phone UX, inspired by supplied v19/mobile.css.
 * IMPORTANT: No selectors affecting existing elements outside the <=700px
 * query. Tablet/desktop layout, dashboard filters and navigation stay intact. */
.mobile-operator-nav,
#mobileDashboardFiltersToggle { display:none; }

@media (max-width:700px) {
  #appView .content {
    min-width:0;
    padding:10px 12px calc(104px + env(safe-area-inset-bottom, 0px));
  }
  #appView .content-shell { min-width:0; }
  #appView .topbar {
    position:relative;
    z-index:5;
    padding:calc(12px + env(safe-area-inset-top, 0px)) 12px 10px;
    margin-bottom:3px;
    gap:7px;
    min-width:0;
  }
  #appView .topbar-left { width:100%; flex-direction:row; align-items:center; gap:10px; }
  #appView #pageTitle { font-size:clamp(18px,5vw,23px); line-height:1.2; margin:0; }
  #appView #pageSubtitle { display:none; }
  #appView .mobile-menu { flex:none; width:44px; min-width:44px; height:44px; }
  #appView .topbar-actions {
    display:flex;
    width:100%;
    min-width:0;
    flex-wrap:wrap;
    justify-content:flex-start;
    align-items:stretch;
    gap:6px;
  }
  #appView .topbar-actions > * { min-width:0; }
  #appView .topbar-actions #attentionHeader {
    order:-5;
    flex:1 1 100%;
    max-width:none;
    justify-content:space-between;
    min-height:42px;
    padding:7px 12px;
    text-align:left;
  }
  #appView .topbar-actions .duty-topbar-summary {
    order:-4;
    flex:1 1 calc(50% - 6px);
    width:auto;
    max-width:none;
    min-height:42px;
  }
  #appView .topbar-actions .duty-topbar-summary strong {
    max-width:100%;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }
  #appView .topbar-actions #dutyNextActionHeader {
    order:-3;
    flex:1 1 100%;
    max-width:none;
    min-height:46px;
    padding:7px 11px;
    white-space:normal;
  }
  #appView .topbar-actions #dutyNextActionHeader strong,
  #appView .topbar-actions #dutyNextActionHeader small {
    max-width:100%; white-space:normal; overflow-wrap:anywhere;
  }
  #appView .topbar-actions #dutyInboxHeader,
  #appView .topbar-actions #serviceModeGlobalIndicator {
    order:-2;
    min-height:40px;
  }
  #appView .topbar-actions #profileButton,
  #appView .topbar-actions #logoutButton,
  #appView .topbar-actions #notificationButton { min-height:40px; }
  #appView .topbar-actions .master-selector-wrap:not(.hidden) {
    width:100%; flex:1 1 100%;
  }

  #appView .mobile-operator-nav {
    display:flex;
    position:fixed;
    left:env(safe-area-inset-left, 0px);
    right:env(safe-area-inset-right, 0px);
    bottom:0;
    z-index:25;
    gap:2px;
    padding:7px 7px calc(8px + env(safe-area-inset-bottom, 0px));
    min-height:74px;
    background:rgba(8,23,39,.97);
    border-top:1px solid rgba(116,180,235,.25);
    box-shadow:0 -5px 30px rgba(0,0,0,.35);
    backdrop-filter:blur(16px);
  }
  #appView .mobile-operator-nav > button {
    display:flex;
    position:relative;
    flex:1 1 0;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:4px;
    width:0;
    min-width:0;
    min-height:53px;
    padding:5px 2px;
    border:0;
    border-radius:10px;
    background:transparent;
    color:#acc0d3;
    box-shadow:none;
    font-size:10px;
    font-weight:750;
    line-height:1.2;
    white-space:normal;
    cursor:pointer;
    -webkit-tap-highlight-color:transparent;
  }
  #appView .mobile-operator-nav > button[hidden] { display:none; }
  #appView .mobile-operator-nav > button.active {
    background:rgba(54,124,163,.23);
    color:#a8ecfa;
  }
  #appView .mobile-operator-nav > button:focus-visible {
    outline:2px solid #9fe3ff; outline-offset:-2px;
  }
  #appView .mobile-operator-nav svg { width:22px; height:22px; flex-shrink:0; }
  #appView .mobile-operator-label {
    display:block; max-width:100%; overflow:hidden; text-overflow:ellipsis;
    white-space:nowrap;
  }
  #appView .mobile-operator-count {
    position:absolute;
    top:0px;
    left:calc(50% + 8px);
    min-width:17px;
    max-width:33px;
    padding:2px 4px;
    border-radius:10px;
    border:1px solid #071a29;
    background:#d94859;
    color:#fff;
    font-size:9px;
    line-height:1.1;
    font-variant-numeric:tabular-nums;
  }
  #appView .mobile-operator-count[hidden] { display:none; }
  body.mobile-menu-open #appView .mobile-operator-nav {
    opacity:0; pointer-events:none;
  }

  #page-dashboard #mobileDashboardFiltersToggle {
    display:flex;
    width:100%;
    min-height:44px;
    align-items:center;
    justify-content:space-between;
    margin:5px 0 12px;
    padding:9px 13px;
    background:#10253b;
    border:1px solid rgba(116,180,235,.24);
    border-radius:10px;
    color:#dbeefd;
    font-weight:750;
    font-size:13px;
    cursor:pointer;
  }
  #page-dashboard #spatialClassicView.mobile-operator-enhanced:not(.mobile-dashboard-filters-open) > .dashboard-filter-bar {
    display:none;
  }
  #page-dashboard #spatialClassicView.mobile-dashboard-filters-open > .dashboard-filter-bar {
    display:grid;
    grid-template-columns:minmax(0,1fr);
    width:100%;
    margin-bottom:16px;
  }
  #page-dashboard .dashboard-charts { grid-template-columns:minmax(0,1fr); }
  #page-dashboard .dashboard-charts > * { min-width:0; max-width:100%; }

  #page-tasks .tasks-category-tabs {
    max-width:100%;
    overflow-x:auto;
    flex-wrap:nowrap;
    overscroll-behavior-inline:contain;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:thin;
  }
  #page-tasks .tasks-category-tabs .subtab {
    flex:0 0 auto;
    white-space:nowrap;
    min-height:44px;
  }
  #page-tasks .task-page-head { align-items:stretch; }
  #page-tasks .task-page-head > button { min-height:44px; }
  #page-tasks .task-table-wrap,
  #page-tasks #operationalIncidentsPanel .table-wrap {
    max-width:100%;
    overflow-x:visible;
  }
  #page-tasks .task-table,
  #page-tasks .task-table tbody,
  #page-tasks #operationalIncidentsPanel table,
  #page-tasks #operationalIncidentsPanel tbody {
    display:block;
    width:100%;
    min-width:0;
  }
  #page-tasks .task-table thead,
  #page-tasks #operationalIncidentsPanel thead { display:none; }
  #page-tasks .task-table tbody tr,
  #page-tasks #operationalIncidentsPanel tbody tr {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    width:100%;
    gap:9px 12px;
    padding:13px;
    margin:0 0 11px;
    border:1px solid rgba(116,180,235,.23);
    border-radius:13px;
    background:rgba(12,31,49,.85);
  }
  #page-tasks .task-table td,
  #page-tasks #operationalIncidentsPanel td {
    display:block;
    width:auto!important;
    min-width:0;
    padding:0;
    border:0;
    white-space:normal;
    overflow-wrap:anywhere;
    font-size:12px;
  }
  #page-tasks .task-table td::before,
  #page-tasks #operationalIncidentsPanel td::before {
    display:block;
    margin:0 0 4px;
    color:#98b5cb;
    font-size:10px;
    font-weight:700;
    line-height:1.4;
  }
  #page-tasks .task-table td:first-child,
  #page-tasks .task-table td:last-child,
  #page-tasks #operationalIncidentsPanel td:first-child,
  #page-tasks #operationalIncidentsPanel td:last-child,
  #page-tasks .task-table td[colspan],
  #page-tasks #operationalIncidentsPanel td[colspan] { grid-column:1/-1; }
  #page-tasks .task-table td:nth-child(1)::before { content:"Задача"; }
  #page-tasks .task-table td:nth-child(2)::before { content:"Коментарі"; }
  #page-tasks .task-table td:nth-child(3)::before { content:"Статус"; }
  #page-tasks .task-table td:nth-child(4)::before { content:"Автор"; }
  #page-tasks .task-table td:nth-child(5)::before { content:"Відповідальний"; }
  #page-tasks .task-table td:nth-child(6)::before { content:"Відпрацював"; }
  #page-tasks .task-table td:nth-child(7)::before { content:"Остання дія"; }
  #page-tasks .task-table td:nth-child(8)::before { content:"Створено"; }
  #page-tasks .task-table td:nth-child(9)::before { content:"Дії"; }
  #page-tasks #operationalIncidentsPanel td:nth-child(1)::before { content:"Інцидент"; }
  #page-tasks #operationalIncidentsPanel td:nth-child(2)::before { content:"Розташування"; }
  #page-tasks #operationalIncidentsPanel td:nth-child(3)::before { content:"Рівень"; }
  #page-tasks #operationalIncidentsPanel td:nth-child(4)::before { content:"Стан"; }
  #page-tasks #operationalIncidentsPanel td:nth-child(5)::before { content:"Відкрито"; }
  #page-tasks #operationalIncidentsPanel td:nth-child(6)::before { content:"Дії"; }
  #page-tasks .task-table td button,
  #page-tasks #operationalIncidentsPanel td button { min-height:42px; }
  #page-tasks .incident-registry-controls { width:100%; max-width:100%; }
  #page-tasks .incident-registry-controls > label { min-width:0; max-width:100%; }
  #page-duty .duty-shift-action-grid { grid-template-columns:minmax(0,1fr); }
  #page-duty .duty-shift-action button,
  #page-duty .duty-section-tabs button { min-height:44px; }
  #page-duty .duty-section-tabs {
    display:flex;
    width:100%;
    max-width:100%;
    overflow-x:auto;
    flex-wrap:nowrap;
    -webkit-overflow-scrolling:touch;
  }
  #page-duty .duty-section-tabs button { flex:0 0 auto; }

  /* Spatial > Objects: mobile cards, never an oversized 740px table.
     This entire group is guarded by [data-current-view="objects"] and
     the surrounding <=700px media query; no Classic/desktop overrides. */
  #spatialViewerView[data-current-view="objects"] {
    min-width:0;
    max-width:100%;
  }
  #spatialViewerView[data-current-view="objects"] .spatial-workspace-navigation {
    display:flex;
    width:100%;
    max-width:100%;
    min-width:0;
    flex-wrap:nowrap;
    overflow-x:auto;
    overflow-y:hidden;
    gap:5px;
    overscroll-behavior-x:contain;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:thin;
    scroll-padding-inline:8px;
  }
  #spatialViewerView[data-current-view="objects"] .spatial-workspace-navigation button {
    flex:0 0 auto;
    min-height:44px;
    font-size:12px;
    padding:9px 12px;
    white-space:nowrap;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog,
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-workspace-head,
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-toolbar {
    width:100%;
    min-width:0;
    max-width:100%;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-workspace-head {
    display:grid;
    grid-template-columns:minmax(0,1fr);
    gap:12px;
    margin:8px 0 12px;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-workspace-head h2 {
    min-width:0;
    flex-wrap:wrap;
    font-size:17px;
    overflow-wrap:anywhere;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-metrics {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    width:100%;
    max-width:100%;
    min-width:0;
    gap:5px;
    padding:4px;
    overflow:visible;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-metrics button {
    display:flex;
    min-height:44px;
    min-width:0;
    max-width:100%;
    padding:9px 6px;
    font-size:12px;
    line-height:1.3;
    white-space:normal;
    overflow-wrap:anywhere;
    text-align:center;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-toolbar {
    display:grid;
    grid-template-columns:minmax(0,1fr);
    align-items:stretch;
    gap:9px;
    margin:12px 0 14px;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-catalog-search,
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-catalog-select {
    display:block;
    flex:none;
    width:100%;
    min-width:0;
    max-width:100%;
    min-height:46px;
    padding:10px 12px;
    font-size:16px;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-table-wrap {
    width:100%;
    max-width:100%;
    min-width:0;
    padding:0;
    border:0;
    background:transparent;
    overflow:visible;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-table,
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-table tbody {
    display:block;
    width:100%;
    max-width:100%;
    min-width:0;
    border:0;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-table thead {
    position:absolute;
    width:1px;
    height:1px;
    margin:-1px;
    padding:0;
    overflow:hidden;
    clip-path:inset(50%);
    white-space:nowrap;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-table tbody tr {
    display:grid;
    width:100%;
    min-width:0;
    max-width:100%;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:12px 10px;
    padding:15px;
    margin-bottom:12px;
    border:1px solid #304964;
    border-radius:13px;
    background:#0e2032;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-table tbody tr[data-band="ALARM"] {
    border-inline-start:4px solid #ff838b;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-table tbody tr[data-band="WARNING"] {
    border-inline-start:4px solid #f0be70;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-table tbody tr > td {
    display:block;
    min-width:0;
    max-width:100%;
    width:auto;
    padding:0;
    border:0;
    font-size:12px;
    line-height:1.5;
    overflow-wrap:anywhere;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-table tbody tr > td::before {
    content:attr(data-mobile-label);
    display:block;
    margin:0 0 5px;
    color:#91abc3;
    font-size:11px;
    font-weight:700;
    line-height:1.4;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-table tbody tr > td:first-child,
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-table tbody tr > td:nth-child(2),
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-table tbody tr > td:last-child,
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-table tbody tr > td[colspan] {
    grid-column:1/-1;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-table tbody tr > td[colspan]::before {
    content:none;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-object-name strong {
    font-size:16px;
    line-height:1.4;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-object-name small,
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-table td small {
    font-size:11px;
    line-height:1.5;
    margin-top:4px;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-multi-readings {
    display:grid;
    grid-template-columns:repeat(auto-fit,minmax(min(100%,146px),1fr));
    gap:8px;
    width:100%;
    max-width:100%;
    min-width:0;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-multi-readings .spatial-v19-separator {
    display:none;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-multi-readings .spatial-v19-value {
    display:flex;
    flex-direction:column;
    align-items:flex-start;
    justify-content:center;
    gap:3px;
    min-width:0;
    max-width:100%;
    padding:10px 12px;
    border:1px solid #34526b;
    border-radius:9px;
    background:#102a3d;
    white-space:normal;
    font-size:19px;
    line-height:1.3;
    font-variant-numeric:tabular-nums;
    overflow-wrap:anywhere;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-multi-readings .spatial-v19-value::before {
    content:attr(data-sensor-label);
    display:block;
    width:100%;
    min-width:0;
    color:#b3c6d9;
    font-size:11px;
    font-weight:650;
    line-height:1.4;
    overflow-wrap:anywhere;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-multi-readings .spatial-v19-value[data-band="ALARM"] {
    border-color:#925061;
    background:#322334;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-multi-readings .spatial-v19-value[data-band="WARNING"],
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-multi-readings .spatial-v19-value[data-band="DELAYED"] {
    border-color:#947540;
    background:#342b22;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-multi-readings .spatial-v19-value[data-band="OFFLINE"] {
    border-color:#8b5c6b;
    background:#342731;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-limit {
    font-size:12px;
    line-height:1.5;
    white-space:normal;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-badge {
    max-width:100%;
    padding:7px 9px;
    font-size:11px;
    line-height:1.4;
    white-space:normal;
    overflow-wrap:anywhere;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-row-actions {
    display:flex;
    align-items:center;
    flex-wrap:wrap;
    gap:8px;
    width:100%;
    min-width:0;
    max-width:100%;
    text-align:left;
    white-space:normal;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-row-actions:empty {
    display:none;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-row-actions::before {
    flex:1 0 100%;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-row-actions button {
    min-height:44px;
    font-size:12px;
    margin:0;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-row-actions .spatial-v19-small-graph {
    width:44px;
    height:44px;
    min-width:44px;
    max-width:44px;
    flex:0 0 44px;
    font-size:20px;
    line-height:1;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-row-actions button:not(.spatial-v19-small-graph) {
    flex:1 1 135px;
    padding:11px 12px;
    white-space:normal;
  }
}

@media (max-width:360px) {
  #appView .mobile-operator-label {font-size:9px;letter-spacing:-.03em;}
  #appView .mobile-operator-nav {padding-inline:3px;}
  #appView .mobile-operator-nav > button {padding-inline:1px;}
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-table tbody tr {
    grid-template-columns:minmax(0,1fr);
    padding:12px;
  }
  #spatialViewerView[data-current-view="objects"] #spatialCatalog .spatial-v19-multi-readings {
    grid-template-columns:minmax(0,1fr);
  }
}
